summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ffap/ffap.c22
-rw-r--r--plugins/ffmpeg/ffmpeg.c13
-rw-r--r--plugins/flac/flac.c92
-rw-r--r--plugins/mpgmad/mpgmad.c19
-rw-r--r--plugins/sndfile/sndfile.c10
-rw-r--r--plugins/vorbis/vorbis.c26
-rw-r--r--plugins/wavpack/wavpack.c12
7 files changed, 99 insertions, 95 deletions
diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c
index e04ca40d..d737df02 100644
--- a/plugins/ffap/ffap.c
+++ b/plugins/ffap/ffap.c
@@ -1651,13 +1651,6 @@ ffap_insert (DB_playItem_t *after, const char *fname) {
float duration = ape_ctx.totalsamples / (float)ape_ctx.samplerate;
DB_playItem_t *it = NULL;
- it = deadbeef->pl_insert_cue (after, fname, &plugin, "APE", ape_ctx.totalsamples, ape_ctx.samplerate);
- if (it) {
- deadbeef->fclose (fp);
- ape_free_ctx (&ape_ctx);
- return it;
- }
-
it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
it->fname = strdup (fname);
@@ -1675,22 +1668,27 @@ ffap_insert (DB_playItem_t *after, const char *fname) {
/*int apeerr = */deadbeef->junk_read_ape (it, fp);
deadbeef->fclose (fp);
+ ape_free_ctx (&ape_ctx);
+
+ DB_playItem_t *cue = deadbeef->pl_insert_cue (after, it, ape_ctx.totalsamples, ape_ctx.samplerate);
+ if (cue) {
+ deadbeef->pl_item_free (it);
+ return cue;
+ }
// embedded cue
const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet");
if (cuesheet) {
- DB_playItem_t *last = deadbeef->pl_insert_cue_from_buffer (after, fname, cuesheet, strlen (cuesheet), &plugin, plugin.filetypes[0], ape_ctx.totalsamples, ape_ctx.samplerate);
- if (last) {
+ cue = deadbeef->pl_insert_cue_from_buffer (after, it, cuesheet, strlen (cuesheet), ape_ctx.totalsamples, ape_ctx.samplerate);
+ if (cue) {
deadbeef->pl_item_free (it);
- ape_free_ctx (&ape_ctx);
- return last;
+ return cue;
}
}
deadbeef->pl_add_meta (it, "title", NULL);
after = deadbeef->pl_insert_item (after, it);
- ape_free_ctx (&ape_ctx);
return after;
}
diff --git a/plugins/ffmpeg/ffmpeg.c b/plugins/ffmpeg/ffmpeg.c
index fcbdff78..604d0158 100644
--- a/plugins/ffmpeg/ffmpeg.c
+++ b/plugins/ffmpeg/ffmpeg.c
@@ -432,13 +432,6 @@ ffmpeg_insert (DB_playItem_t *after, const char *fname) {
filetype = filetypes[FT_UNKNOWN];
}
- // external cuesheet
- DB_playItem_t *cue = deadbeef->pl_insert_cue (after, fname, &plugin, filetype, totalsamples, samplerate);
- if (cue) {
- // cuesheet loaded
- av_close_input_file(fctx);
- return cue;
- }
DB_playItem_t *it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
it->fname = strdup (fname);
@@ -474,6 +467,12 @@ ffmpeg_insert (DB_playItem_t *after, const char *fname) {
// free decoder
av_close_input_file(fctx);
+ // external cuesheet
+ DB_playItem_t *cue = deadbeef->pl_insert_cue (after, it, totalsamples, samplerate);
+ if (cue) {
+ deadbeef->pl_item_free (it);
+ return cue;
+ }
// now the track is ready, insert into playlist
after = deadbeef->pl_insert_item (after, it);
return after;
diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c
index 0275c40c..c397041b 100644
--- a/plugins/flac/flac.c
+++ b/plugins/flac/flac.c
@@ -350,6 +350,7 @@ cflac_init_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
+#if 0
static void
cflac_init_cue_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) {
if (cflac_init_stop_decoding) {
@@ -364,22 +365,8 @@ cflac_init_cue_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC_
//cb->duration = metadata->data.stream_info.total_samples / (float)metadata->data.stream_info.sample_rate;
cb->totalsamples = metadata->data.stream_info.total_samples;
}
- else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
- trace ("flac: cflac_init_cue_metadata_callback: got FLAC__METADATA_TYPE_VORBIS_COMMENT\n");
- const FLAC__StreamMetadata_VorbisComment *vc = &metadata->data.vorbis_comment;
- for (int i = 0; i < vc->num_comments; i++) {
- const FLAC__StreamMetadata_VorbisComment_Entry *c = &vc->comments[i];
- if (c->length > 0) {
- char s[c->length+1];
- s[c->length] = 0;
- memcpy (s, c->entry, c->length);
- if (!strncasecmp (s, "cuesheet=", 9)) {
- cb->last = deadbeef->pl_insert_cue_from_buffer (cb->after, cb->fname, s+9, c->length-9, &plugin, "FLAC", cb->totalsamples, cb->samplerate);
- }
- }
- }
- }
}
+#endif
static void
cflac_init_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) {
@@ -391,6 +378,9 @@ cflac_init_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__Str
DB_playItem_t *it = cb->it;
//it->tracknum = 0;
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
+ cb->samplerate = metadata->data.stream_info.sample_rate;
+ cb->channels = metadata->data.stream_info.channels;
+ cb->totalsamples = metadata->data.stream_info.total_samples;
deadbeef->pl_set_item_duration (it, metadata->data.stream_info.total_samples / (float)metadata->data.stream_info.sample_rate);
}
else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
@@ -424,6 +414,10 @@ cflac_init_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__Str
else if (!strncasecmp (s, "COMMENT=", 8)) {
deadbeef->pl_add_meta (it, "comment", s + 8);
}
+ if (!strncasecmp (s, "CUESHEET=", 9)) {
+ deadbeef->pl_add_meta (it, "cuesheet", s + 9);
+// cb->last = deadbeef->pl_insert_cue_from_buffer (cb->after, cb->fname, s+9, c->length-9, &plugin, "FLAC", cb->totalsamples, cb->samplerate);
+ }
else if (!strncasecmp (s, "replaygain_album_gain=", 22)) {
it->replaygain_album_gain = atof (s + 22);
}
@@ -444,14 +438,7 @@ cflac_init_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__Str
if (!title_added) {
deadbeef->pl_add_meta (it, "title", NULL);
}
-
-// pl_add_meta (it, "artist", performer);
-// pl_add_meta (it, "album", albumtitle);
-// pl_add_meta (it, "track", track);
-// pl_add_meta (it, "title", title);
}
-// int *psr = (int *)client_data;
-// *psr = metadata->data.stream_info.sample_rate;
}
static DB_playItem_t *
@@ -484,15 +471,17 @@ cflac_insert (DB_playItem_t *after, const char *fname) {
}
deadbeef->fseek (cb.file, -4, SEEK_CUR);
cflac_init_stop_decoding = 0;
- //try embedded cue, and calculate duration
+
+ // open decoder for metadata reading
FLAC__StreamDecoderInitStatus status;
decoder = FLAC__stream_decoder_new();
if (!decoder) {
trace ("flac: failed to create decoder\n");
goto cflac_insert_fail;
}
- FLAC__stream_decoder_set_md5_checking(decoder, 0);
+#if 0
+ FLAC__stream_decoder_set_md5_checking(decoder, 0);
// try embedded cue
FLAC__stream_decoder_set_metadata_respond_all (decoder);
status = FLAC__stream_decoder_init_stream (decoder, flac_read_cb, flac_seek_cb, flac_tell_cb, flac_lenght_cb, flac_eof_cb, cflac_init_write_callback, cflac_init_cue_metadata_callback, cflac_init_error_callback, &cb);
@@ -507,35 +496,11 @@ cflac_insert (DB_playItem_t *after, const char *fname) {
FLAC__stream_decoder_delete(decoder);
decoder = NULL;
- if (cb.last != after) {
- trace ("flac: loaded embedded cuesheet\n");
- // that means embedded cue is loaded
- if (cb.file) {
- deadbeef->fclose (cb.file);
- }
- return cb.last;
- }
+#endif
- // try external cue
- DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, fname, &plugin, "FLAC", cb.totalsamples, cb.samplerate);
- if (cue_after) {
- if (cb.file) {
- deadbeef->fclose (cb.file);
- }
- trace ("flac: loaded external cuesheet\n");
- return cue_after;
- }
- decoder = FLAC__stream_decoder_new();
- if (!decoder) {
- if (cb.file) {
- deadbeef->fclose (cb.file);
- }
- goto cflac_insert_fail;
- }
+ // read all metadata
FLAC__stream_decoder_set_md5_checking(decoder, 0);
- // try single FLAC file without cue
FLAC__stream_decoder_set_metadata_respond_all (decoder);
- int samplerate = -1;
it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
it->fname = strdup (fname);
@@ -559,6 +524,33 @@ cflac_insert (DB_playItem_t *after, const char *fname) {
FLAC__stream_decoder_delete(decoder);
decoder = NULL;
it->filetype = "FLAC";
+
+ // try embedded cue
+ const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet");
+ if (cuesheet) {
+ DB_playItem_t *last = deadbeef->pl_insert_cue_from_buffer (after, it, cuesheet, strlen (cuesheet), cb.totalsamples, cb.samplerate);
+ if (last) {
+ deadbeef->pl_item_free (it);
+ return last;
+ }
+ }
+
+ // try external cue
+ DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, it, cb.totalsamples, cb.samplerate);
+ if (cue_after) {
+ if (cb.file) {
+ deadbeef->fclose (cb.file);
+ }
+ trace ("flac: loaded external cuesheet\n");
+ return cue_after;
+ }
+ decoder = FLAC__stream_decoder_new();
+ if (!decoder) {
+ if (cb.file) {
+ deadbeef->fclose (cb.file);
+ }
+ goto cflac_insert_fail;
+ }
after = deadbeef->pl_insert_item (after, it);
if (cb.file) {
deadbeef->fclose (cb.file);
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index abee585b..f48202a0 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -1017,26 +1017,25 @@ cmp3_insert (DB_playItem_t *after, const char *fname) {
break;
}
}
- // FIXME! bad numsamples passed to cue
- DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, fname, &plugin, ftype, buffer.duration*buffer.samplerate, buffer.samplerate);
- if (cue_after) {
- deadbeef->fclose (fp);
- return cue_after;
- }
-
- deadbeef->rewind (fp);
-
DB_playItem_t *it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
it->fname = strdup (fname);
+ deadbeef->rewind (fp);
int apeerr = deadbeef->junk_read_ape (it, fp);
int v2err = deadbeef->junk_read_id3v2 (it, fp);
int v1err = deadbeef->junk_read_id3v1 (it, fp);
- deadbeef->fclose (fp);
deadbeef->pl_add_meta (it, "title", NULL);
deadbeef->pl_set_item_duration (it, buffer.duration);
it->filetype = ftype;
+ deadbeef->fclose (fp);
+
+ // FIXME! bad numsamples passed to cue
+ DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, it, buffer.duration*buffer.samplerate, buffer.samplerate);
+ if (cue_after) {
+ deadbeef->pl_item_free (it);
+ return cue_after;
+ }
after = deadbeef->pl_insert_item (after, it);
return after;
diff --git a/plugins/sndfile/sndfile.c b/plugins/sndfile/sndfile.c
index dfb956de..2be2759b 100644
--- a/plugins/sndfile/sndfile.c
+++ b/plugins/sndfile/sndfile.c
@@ -204,11 +204,6 @@ sndfile_insert (DB_playItem_t *after, const char *fname) {
deadbeef->fclose (sfctx.file);
float duration = (float)totalsamples / samplerate;
- DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, fname, &plugin, "sndfile", totalsamples, samplerate);
- if (cue_after) {
- return cue_after;
- }
-
DB_playItem_t *it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
it->fname = strdup (fname);
@@ -217,6 +212,11 @@ sndfile_insert (DB_playItem_t *after, const char *fname) {
trace ("sndfile: totalsamples=%d, samplerate=%d, duration=%f\n", totalsamples, samplerate, duration);
+ DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, it, totalsamples, samplerate);
+ if (cue_after) {
+ return cue_after;
+ }
+
deadbeef->pl_add_meta (it, "title", NULL);
after = deadbeef->pl_insert_item (after, it);
diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c
index 1006929f..f203f6bb 100644
--- a/plugins/vorbis/vorbis.c
+++ b/plugins/vorbis/vorbis.c
@@ -101,6 +101,9 @@ update_vorbis_comments (DB_playItem_t *it, vorbis_comment *vc) {
else if (!strncasecmp (vc->user_comments[i], "copyright=", 10)) {
deadbeef->pl_add_meta (it, "copyright", vc->user_comments[i] + 10);
}
+ else if (!strncasecmp (vc->user_comments[i], "cuesheet=", 9)) {
+ deadbeef->pl_add_meta (it, "cuesheet", vc->user_comments[i] + 9);
+ }
else if (!strncasecmp (vc->user_comments[i], "replaygain_album_gain=", 22)) {
it->replaygain_album_gain = atof (vc->user_comments[i] + 22);
}
@@ -363,11 +366,6 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) {
}
float duration = ov_time_total (&vorbis_file, -1);
int totalsamples = ov_pcm_total (&vorbis_file, -1);
- DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, fname, &plugin, "OggVorbis", totalsamples, vi->rate);
- if (cue_after) {
- ov_clear (&vorbis_file);
- return cue_after;
- }
DB_playItem_t *it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
@@ -378,7 +376,25 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) {
// metainfo
vorbis_comment *vc = ov_comment (&vorbis_file, -1);
update_vorbis_comments (it, vc);
+ int samplerate = vi->rate;
ov_clear (&vorbis_file);
+
+ DB_playItem_t *cue = deadbeef->pl_insert_cue (after, it, totalsamples, samplerate);
+ if (cue) {
+ deadbeef->pl_item_free (it);
+ return cue;
+ }
+
+ // embedded cue
+ const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet");
+ if (cuesheet) {
+ cue = deadbeef->pl_insert_cue_from_buffer (after, it, cuesheet, strlen (cuesheet), totalsamples, samplerate);
+ if (cue) {
+ deadbeef->pl_item_free (it);
+ return cue;
+ }
+ }
+
after = deadbeef->pl_insert_item (after, it);
return after;
}
diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c
index 44aec9ea..8dfddbd2 100644
--- a/plugins/wavpack/wavpack.c
+++ b/plugins/wavpack/wavpack.c
@@ -224,11 +224,6 @@ wv_insert (DB_playItem_t *after, const char *fname) {
int samplerate = WavpackGetSampleRate (ctx);
WavpackCloseFile (ctx);
float duration = (float)totalsamples / samplerate;
- DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, fname, &plugin, "wv", totalsamples, samplerate);
- if (cue_after) {
- deadbeef->fclose (fp);
- return cue_after;
- }
DB_playItem_t *it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
@@ -248,10 +243,15 @@ wv_insert (DB_playItem_t *after, const char *fname) {
}
deadbeef->fclose (fp);
+ DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, it, totalsamples, samplerate);
+ if (cue_after) {
+ return cue_after;
+ }
+
// embedded cue
const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet");
if (cuesheet) {
- DB_playItem_t *last = deadbeef->pl_insert_cue_from_buffer (after, fname, cuesheet, strlen (cuesheet), &plugin, plugin.filetypes[0], totalsamples, samplerate);
+ DB_playItem_t *last = deadbeef->pl_insert_cue_from_buffer (after, it, cuesheet, strlen (cuesheet), totalsamples, samplerate);
if (last) {
deadbeef->pl_item_free (it);
return last;