diff options
Diffstat (limited to 'src/plugins/Input/vorbis/decoder_vorbis.cpp')
| -rw-r--r-- | src/plugins/Input/vorbis/decoder_vorbis.cpp | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp index 7f77d485f..765572c91 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.cpp +++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp @@ -71,9 +71,8 @@ static long oggtell(void *src) DecoderVorbis::DecoderVorbis(const QString &url, QIODevice *i) : Decoder(i) { - inited = false; + m_inited = false; m_totalTime = 0; - m_section = 0; m_last_section = -1; m_bitrate = 0; m_url = url; @@ -88,7 +87,7 @@ DecoderVorbis::~DecoderVorbis() bool DecoderVorbis::initialize() { qDebug("DecoderVorbis: initialize"); - inited = false; + m_inited = false; m_totalTime = 0; if (!input()) { @@ -140,15 +139,15 @@ bool DecoderVorbis::initialize() qWarning("DecoderVorbis: unsupported number of channels: %d", chan); return false; } - configure(freq, chmap, Qmmp::PCM_S16LE); - inited = true; + configure(freq, chmap, Qmmp::PCM_FLOAT); + m_inited = true; return true; } qint64 DecoderVorbis::totalTime() { - if (!inited) + if (!m_inited) return 0; return m_totalTime; } @@ -161,7 +160,7 @@ int DecoderVorbis::bitrate() void DecoderVorbis::deinit() { - if (inited) + if (m_inited) ov_clear(&oggfile); len = 0; } @@ -296,23 +295,10 @@ void DecoderVorbis::seek(qint64 time) qint64 DecoderVorbis::read(unsigned char *data, qint64 maxSize) { len = -1; - while (len < 0) - len = ov_read(&oggfile, (char *)data, maxSize, 0, 2, 1, &m_section); - - if (m_section != m_last_section) - updateTags(); - m_last_section = m_section; - if(len > 0) - m_bitrate = ov_bitrate_instant(&oggfile) / 1000; - return len; -} - -qint64 DecoderVorbis::read(float *data, qint64 samples) -{ - len = -1; float **pcm = 0; + int section = 0; while (len < 0) - len = ov_read_float(&oggfile, &pcm, samples, &m_section); + len = ov_read_float(&oggfile, &pcm, maxSize/sizeof(float), §ion); if(len == 0) return 0; @@ -321,7 +307,7 @@ qint64 DecoderVorbis::read(float *data, qint64 samples) for(int i = 0; i < channels; ++i) { - float *ptr = &data[i]; + float *ptr = (float *) (data + i*sizeof(float)); for(int j = 0; j < len; ++j) { *ptr = pcm[i][j]; @@ -329,9 +315,12 @@ qint64 DecoderVorbis::read(float *data, qint64 samples) } } - if (m_section != m_last_section) + if (section != m_last_section) + { updateTags(); + m_last_section = section; + } m_bitrate = ov_bitrate_instant(&oggfile) / 1000; - return len*channels; + return len*sizeof(float)*channels; } |
