mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-23 09:40:59 +00:00
Fixed a bug introduced by recent buffer changes that broke low-level seek behavior.
This commit is contained in:
parent
050736b339
commit
9aa1a0081c
@ -48,6 +48,7 @@ Stream::Stream(unsigned int options)
|
||||
: preferedBufferSampleSize(2048)
|
||||
, options(options)
|
||||
, decoderSampleRate(0)
|
||||
, decoderChannels(0)
|
||||
, decoderSamplePosition(0)
|
||||
{
|
||||
if ((this->options & NoDSP) == 0) {
|
||||
@ -70,7 +71,9 @@ double Stream::SetPosition(double requestedSeconds) {
|
||||
|
||||
if (actualSeconds != -1) {
|
||||
double rate = (double) this->decoderSampleRate;
|
||||
this->decoderSamplePosition = (uint64)(actualSeconds * rate);
|
||||
|
||||
this->decoderSamplePosition =
|
||||
(uint64)(actualSeconds * rate) * this->decoderChannels;
|
||||
}
|
||||
|
||||
return actualSeconds;
|
||||
@ -138,8 +141,9 @@ BufferPtr Stream::GetNextBufferFromDecoder() {
|
||||
}
|
||||
|
||||
/* remember the sample rate so we can calculate the current time-position */
|
||||
if (!this->decoderSampleRate) {
|
||||
if (!this->decoderSampleRate || !this->decoderChannels) {
|
||||
this->decoderSampleRate = buffer->SampleRate();
|
||||
this->decoderChannels = buffer->Channels();
|
||||
}
|
||||
|
||||
/* offset, in samples */
|
||||
|
@ -87,6 +87,7 @@ namespace musik { namespace core { namespace audio {
|
||||
double maxCacheLength;
|
||||
unsigned int options;
|
||||
long decoderSampleRate;
|
||||
long decoderChannels;
|
||||
uint64 decoderSamplePosition;
|
||||
std::string uri;
|
||||
musik::core::io::DataStreamFactory::DataStreamPtr dataStream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user