diff options
author | 2010-08-19 20:48:39 +0200 | |
---|---|---|
committer | 2010-08-19 20:48:39 +0200 | |
commit | e76b2e55840bc1b33694b6e2052d5e70a07bbe6a (patch) | |
tree | d75ff550e4f6502f48d1dc6863154663c4d913e2 /plugins/musepack | |
parent | 30426cd4ae4550a80acb2e9505a241b4447753bf (diff) |
added basic support for musepack chapters
Diffstat (limited to 'plugins/musepack')
-rw-r--r-- | plugins/musepack/musepack.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/plugins/musepack/musepack.c b/plugins/musepack/musepack.c index 17a72105..4333c98e 100644 --- a/plugins/musepack/musepack.c +++ b/plugins/musepack/musepack.c @@ -336,8 +336,39 @@ musepack_insert (DB_playItem_t *after, const char *fname) { int totalsamples = mpc_streaminfo_get_length_samples (&si); double dur = mpc_streaminfo_get_length (&si); - mpc_demux_exit (demux); - demux = NULL; + // chapters + int nchapters = mpc_demux_chap_nb (demux); + DB_playItem_t *prev = NULL; + if (nchapters > 1) { + int i; + for (i = 0; i < nchapters; i++) { + const mpc_chap_info *ch = mpc_demux_chap (demux, i); + DB_playItem_t *it = deadbeef->pl_item_alloc (); + it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); + it->fname = strdup (fname); + it->filetype = "MusePack"; + it->tracknum = i; + it->startsample = ch->sample; + it->endsample = totalsamples-1; + deadbeef->pl_set_item_flags (it, DDB_IS_SUBTRACK); + if (prev) { + prev->endsample = it->startsample-1; + float dur = (prev->endsample - prev->startsample) / (float)si.sample_freq; + deadbeef->pl_set_item_duration (prev, dur); + } + if (i == nchapters - 1) { + float dur = (it->endsample - it->startsample) / (float)si.sample_freq; + deadbeef->pl_set_item_duration (it, dur); + } + after = deadbeef->pl_insert_item (after, it); + prev = it; + deadbeef->pl_item_unref (it); + } + mpc_demux_exit (demux); + demux = NULL; + deadbeef->fclose (fp); + return after; + } DB_playItem_t *it = deadbeef->pl_item_alloc (); it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); @@ -348,8 +379,9 @@ musepack_insert (DB_playItem_t *after, const char *fname) { /*int apeerr = */deadbeef->junk_apev2_read (it, fp); deadbeef->fclose (fp); - // embedded cue deadbeef->pl_lock (); + + // embedded cue const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet"); DB_playItem_t *cue = NULL; if (cuesheet) { @@ -358,6 +390,8 @@ musepack_insert (DB_playItem_t *after, const char *fname) { deadbeef->pl_item_unref (it); deadbeef->pl_item_unref (cue); deadbeef->pl_unlock (); + mpc_demux_exit (demux); + demux = NULL; return cue; } } @@ -367,6 +401,9 @@ musepack_insert (DB_playItem_t *after, const char *fname) { if (cue) { deadbeef->pl_item_unref (it); deadbeef->pl_item_unref (cue); + mpc_demux_exit (demux); + demux = NULL; + return cue; } @@ -374,6 +411,9 @@ musepack_insert (DB_playItem_t *after, const char *fname) { after = deadbeef->pl_insert_item (after, it); deadbeef->pl_item_unref (it); + mpc_demux_exit (demux); + demux = NULL; + return after; } |