diff options
author | 2014-06-12 21:21:16 +0100 | |
---|---|---|
committer | 2014-06-12 21:21:16 +0100 | |
commit | 87c7f779bf8d789ae74497098da0b0543c348907 (patch) | |
tree | a20435934fc59893213bd405102250da4c3a01a0 /plugins | |
parent | 845d73615ddb48f968de3c2c5e6208fdbddf839a (diff) | |
parent | 9dc48204208b22b998c981da4840951db6daf731 (diff) |
Merge pull request #3 from Alexey-Yakovenko/master
Resync
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 27 | ||||
-rw-r--r-- | plugins/vorbis/vorbis.c | 35 |
2 files changed, 21 insertions, 41 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index 22b21051..e2c3e9bc 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -223,7 +223,6 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { buffer->startoffset = initpos; } - int had_invalid_frames = 0; int lastframe_valid = 0; int64_t offs = -1; // }}} @@ -241,11 +240,6 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { uint32_t hdr; uint8_t sync; // {{{ parse frame header, sync stream - // mp3 files often have some garbage in the beginning - // try to skip it if this is the case - if (!lastframe_valid && valid_frames > 5) { - had_invalid_frames = 1; - } if (!lastframe_valid && offs >= 0) { deadbeef->fseek (buffer->file, offs+1, SEEK_SET); } @@ -436,18 +430,16 @@ retry_sync: return 0; } // don't get parameters from frames coming after any bad frame - if (!had_invalid_frames) { - buffer->version = ver; - buffer->layer = layer; - buffer->bitrate = bitrate; - buffer->samplerate = samplerate; - buffer->packetlength = packetlength; - if (nchannels > buffer->channels) { - buffer->channels = nchannels; - } - buffer->bitspersample = 16; -// trace ("frame %d mpeg v%d layer %d bitrate %d samplerate %d packetlength %d channels %d\n", nframe, ver, layer, bitrate, samplerate, packetlength, nchannels); + buffer->version = ver; + buffer->layer = layer; + buffer->bitrate = bitrate; + buffer->samplerate = samplerate; + buffer->packetlength = packetlength; + if (nchannels > buffer->channels) { + buffer->channels = nchannels; } + buffer->bitspersample = 16; +// trace ("frame %d mpeg v%d layer %d bitrate %d samplerate %d packetlength %d channels %d\n", nframe, ver, layer, bitrate, samplerate, packetlength, nchannels); } // }}} @@ -615,7 +607,6 @@ retry_sync: return 0; } buffer->nframes = sz / packetlength; - printf ("buffer->nframes: %d/%d=%d\n", sz, packetlength, buffer->nframes); buffer->avg_packetlength = packetlength; buffer->avg_samplerate = samplerate; buffer->avg_samples_per_frame = samples_per_frame; diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c index 3fb6bef2..9b2d8684 100644 --- a/plugins/vorbis/vorbis.c +++ b/plugins/vorbis/vorbis.c @@ -37,7 +37,7 @@ #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) -//#define trace(...) { fprintf (stderr, __VA_ARGS__); } +// #define trace(...) { fprintf (stderr, __VA_ARGS__); } #define trace(fmt,...) #if WORDS_BIGENDIAN @@ -101,26 +101,7 @@ static const char case RG_REFERENCE_LOUDNESS: return "REPLAYGAIN_REFERENCE_LOUDNESS"; default: - return NULL; - } -} - -static const char -*gain_meta_key(const int tag_enum) -{ - switch(tag_enum) { - case DDB_REPLAYGAIN_ALBUMGAIN: - return ":REPLAYGAIN_ALBUMGAIN"; - case DDB_REPLAYGAIN_ALBUMPEAK: - return ":REPLAYGAIN_ALBUMPEAK"; - case DDB_REPLAYGAIN_TRACKGAIN: - return ":REPLAYGAIN_TRACKGAIN"; - case DDB_REPLAYGAIN_TRACKPEAK: - return ":REPLAYGAIN_TRACKPEAK"; - case RG_REFERENCE_LOUDNESS: - return ":REPLAYGAIN_REFERENCE_LOUDNESS"; - default: - return NULL; + return ""; } } @@ -181,7 +162,7 @@ update_vorbis_comments (DB_playItem_t *it, OggVorbis_File *vorbis_file, const in !replaygain_tag(it, DDB_REPLAYGAIN_TRACKGAIN, tag, value) && !replaygain_tag(it, DDB_REPLAYGAIN_TRACKPEAK, tag, value)) { if (!strcasecmp(tag, gain_tag_name(RG_REFERENCE_LOUDNESS))) - deadbeef->pl_replace_meta(it, gain_meta_key(RG_REFERENCE_LOUDNESS), value); + deadbeef->pl_replace_meta(it, ":REPLAYGAIN_REFERENCE_LOUDNESS", value); else add_meta(it, oggedit_map_tag(tag, "tag2meta"), value); } @@ -223,6 +204,14 @@ cvorbis_seek_sample (DB_fileinfo_t *_info, int sample) { trace ("vorbis: file is NULL on seek\n"); return -1; } + if (sample == 0) { + deadbeef->pl_lock (); + const char *filetype = deadbeef->pl_find_meta_raw(info->it, ":FILETYPE"); + if (filetype && strncmp(filetype, "Ogg Vorbis", 10)) { + sample = 1; // workaround libvorbis bug #1486 (ddb issue #1116) + } + deadbeef->pl_unlock (); + } sample += info->it->startsample; trace ("vorbis: seek to sample %d\n", sample); int res = ov_pcm_seek (&info->vorbis_file, sample); @@ -311,7 +300,7 @@ cvorbis_init (DB_fileinfo_t *_info, DB_playItem_t *it) { deadbeef->pl_set_meta_int(info->it, ":TRACKNUM", 0); } else { - cvorbis_seek_sample (_info, 1); // vorbisfile bug + cvorbis_seek_sample (_info, 0); } vorbis_info *vi = ov_info (&info->vorbis_file, -1); |