mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-27 03:14:30 +00:00
Added a bit of seeking robustness to FlacDecoder.
This commit is contained in:
parent
e65d56ac8c
commit
2599b409a9
@ -212,12 +212,20 @@ void FlacDecoder::Destroy() {
|
||||
}
|
||||
|
||||
double FlacDecoder::SetPosition(double seconds) {
|
||||
FLAC__uint64 seekToSample = (FLAC__uint64)(this->sampleRate * seconds);
|
||||
FLAC__uint64 seekToSample = (FLAC__uint64)((double) this->sampleRate * seconds);
|
||||
|
||||
if (FLAC__stream_decoder_seek_absolute(this->decoder, seekToSample)) {
|
||||
return seconds;
|
||||
}
|
||||
|
||||
if (FLAC__stream_decoder_get_state(this->decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) {
|
||||
if (FLAC__stream_decoder_flush(this->decoder)) {
|
||||
if (FLAC__stream_decoder_seek_absolute(this->decoder, seekToSample)) {
|
||||
return seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user