diff options
| -rw-r--r-- | src/plugins/Input/mpeg/decoder_mpg123.cpp | 18 | ||||
| -rw-r--r-- | src/plugins/Input/mpeg/decoder_mpg123.h | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/plugins/Input/mpeg/decoder_mpg123.cpp b/src/plugins/Input/mpeg/decoder_mpg123.cpp index 4451ff47b..f69d05bca 100644 --- a/src/plugins/Input/mpeg/decoder_mpg123.cpp +++ b/src/plugins/Input/mpeg/decoder_mpg123.cpp @@ -67,6 +67,7 @@ DecoderMPG123::DecoderMPG123(QIODevice *i) : Decoder(i) m_frame_info.bitrate = 0; m_mpg123_encoding = MPG123_ENC_SIGNED_16; m_handle = 0; + m_resync_errors = 0; } DecoderMPG123::~DecoderMPG123() @@ -77,6 +78,7 @@ DecoderMPG123::~DecoderMPG123() bool DecoderMPG123::initialize() { + m_resync_errors = 0; if (input()->isSequential ()) //for streams only { TagExtractor extractor(input()); @@ -161,11 +163,25 @@ qint64 DecoderMPG123::read(unsigned char *data, qint64 size) { size_t done = 0; int err = mpg123_read(m_handle, data, size, &done); - if(err != MPG123_DONE && err != MPG123_OK) + if(err < 0) + { + err = mpg123_errcode(m_handle); + if(err == MPG123_RESYNC_FAIL && m_resync_errors < 10) + { + qWarning("DecoderMPG123: skipping resync error..."); + m_resync_errors++; + return done; + } + + qWarning("DecoderMPG123: decoder error: %s", mpg123_plain_strerror(err)); + return -1; + } + else if(err != MPG123_DONE && err != MPG123_OK) { qWarning("DecoderMPG123: decoder error: %s", mpg123_plain_strerror(err)); return -1; } + m_resync_errors = 0; mpg123_info(m_handle, &m_frame_info); return done; } diff --git a/src/plugins/Input/mpeg/decoder_mpg123.h b/src/plugins/Input/mpeg/decoder_mpg123.h index 54fc1e751..b16d7682a 100644 --- a/src/plugins/Input/mpeg/decoder_mpg123.h +++ b/src/plugins/Input/mpeg/decoder_mpg123.h @@ -49,6 +49,7 @@ private: qint64 m_totalTime; long m_rate; int m_mpg123_encoding; + int m_resync_errors; }; |
