diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-04-28 14:06:12 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-04-28 14:06:12 +0000 |
| commit | b470ca97b694a70b2e0a838059c755d5506ab8c2 (patch) | |
| tree | dd21cce5fcbf4c5e617edf4fb861e0f4e1e3d1fe /src/plugins/Input | |
| parent | 86d896debe9f4a1d9465b06def8cc81c337d935a (diff) | |
| download | qmmp-b470ca97b694a70b2e0a838059c755d5506ab8c2.tar.gz qmmp-b470ca97b694a70b2e0a838059c755d5506ab8c2.tar.bz2 qmmp-b470ca97b694a70b2e0a838059c755d5506ab8c2.zip | |
sid plugin: added end of song mark
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3425 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input')
| -rw-r--r-- | src/plugins/Input/sid/decoder_sid.cpp | 16 | ||||
| -rw-r--r-- | src/plugins/Input/sid/decoder_sid.h | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/plugins/Input/sid/decoder_sid.cpp b/src/plugins/Input/sid/decoder_sid.cpp index c79b8bf70..30d694f8d 100644 --- a/src/plugins/Input/sid/decoder_sid.cpp +++ b/src/plugins/Input/sid/decoder_sid.cpp @@ -38,6 +38,8 @@ DecoderSID::DecoderSID(SidDatabase *db, const QString &url) : Decoder() m_url = url; m_player = new sidplayfp(); m_length = 0; + m_length_in_bytes = 0; + m_read_bytes = 0; } DecoderSID::~DecoderSID() @@ -47,6 +49,8 @@ DecoderSID::~DecoderSID() bool DecoderSID::initialize() { + m_length_in_bytes = 0; + m_read_bytes = 0; QString path = m_url; path.remove("sid://"); path.remove(QRegExp("#\\d+$")); @@ -137,6 +141,9 @@ bool DecoderSID::initialize() } configure(44100, 2); + m_length_in_bytes = audioParameters().sampleRate() * + audioParameters().channels() * + audioParameters().sampleSize() * m_length; qDebug("DecoderSID: initialize succes"); return true; } @@ -158,7 +165,10 @@ int DecoderSID::bitrate() qint64 DecoderSID::read(char *data, qint64 size) { - //if(m_player->time() > m_length) - // return 0; - return m_player->play((short *)data, size/2) * 2; + size = qMin(size, qMax(m_length_in_bytes - m_read_bytes, qint64(0))); + size -= size % 4; + if(size <= 0) + return 0; + m_read_bytes += size; + return m_player->play((short *)data, size/2) * 2; } diff --git a/src/plugins/Input/sid/decoder_sid.h b/src/plugins/Input/sid/decoder_sid.h index 05c70660a..69d8483cb 100644 --- a/src/plugins/Input/sid/decoder_sid.h +++ b/src/plugins/Input/sid/decoder_sid.h @@ -48,6 +48,8 @@ private: sidplayfp *m_player; SidDatabase *m_db; int m_length; + qint64 m_length_in_bytes; + qint64 m_read_bytes; }; #endif // DECODER_SID_H |
