aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/sid/decoder_sid.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-04-28 14:06:12 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-04-28 14:06:12 +0000
commitb470ca97b694a70b2e0a838059c755d5506ab8c2 (patch)
treedd21cce5fcbf4c5e617edf4fb861e0f4e1e3d1fe /src/plugins/Input/sid/decoder_sid.cpp
parent86d896debe9f4a1d9465b06def8cc81c337d935a (diff)
downloadqmmp-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/sid/decoder_sid.cpp')
-rw-r--r--src/plugins/Input/sid/decoder_sid.cpp16
1 files changed, 13 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;
}