Audio/Music: Fix Seek method

This commit is contained in:
Jérôme Leclercq
2021-06-03 17:20:09 +02:00
parent 5bc3cd8d8c
commit f0b26efcd3
3 changed files with 13 additions and 11 deletions

View File

@@ -250,7 +250,7 @@ namespace Nz
else
{
UInt64 readSample = drwav_read_pcm_frames_s16(&m_decoder, sampleCount / m_decoder.channels, static_cast<Int16*>(buffer));
m_readSampleCount += readSample;
m_readSampleCount += readSample * m_decoder.channels;
return readSample * m_decoder.channels;
}
@@ -258,7 +258,7 @@ namespace Nz
void Seek(UInt64 offset) override
{
drwav_seek_to_pcm_frame(&m_decoder, offset);
drwav_seek_to_pcm_frame(&m_decoder, (m_mixToMono) ? offset : offset / m_decoder.channels);
m_readSampleCount = offset;
}

View File

@@ -338,8 +338,8 @@ namespace Nz
void Seek(UInt64 offset) override
{
if (m_mixToMono)
offset *= m_channelCount;
if (!m_mixToMono)
offset /= m_channelCount;
ov_pcm_seek(&m_decoder, Int64(offset));
}
@@ -347,8 +347,8 @@ namespace Nz
UInt64 Tell() override
{
UInt64 offset = UInt64(ov_pcm_tell(&m_decoder));
if (m_mixToMono)
offset /= m_channelCount;
if (!m_mixToMono)
offset *= m_channelCount;
return offset;
}