diff options
author | NNesh <mullruslan@yandex.ru> | 2017-04-25 17:02:45 +0500 |
---|---|---|
committer | NNesh <mullruslan@yandex.ru> | 2017-04-25 17:02:45 +0500 |
commit | 6cf0c62221e304a58c028358ecb4d45ad4bbf3b7 (patch) | |
tree | e5862700608c047b51162f27666666463347552b /modules/stb_vorbis | |
parent | 0edc3d72087abf4c0c6bbd14c998180de62cd00a (diff) |
Fix AudioPlayer.get_pos() always returns 0
Diffstat (limited to 'modules/stb_vorbis')
-rw-r--r-- | modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 8eb05b4324..b0870c9dc2 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -42,6 +42,7 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, (float *)p_buffer, todo * 2); todo -= mixed; + frames_mixed += mixed; if (todo) { //end of file! @@ -95,7 +96,12 @@ void AudioStreamPlaybackOGGVorbis::seek_pos(float p_time) { if (!active) return; - stb_vorbis_seek(ogg_stream, uint32_t(p_time * vorbis_stream->sample_rate)); + if (p_time >= get_length()) { + p_time = 0; + } + frames_mixed = uint32_t(vorbis_stream->sample_rate * p_time); + + stb_vorbis_seek(ogg_stream, frames_mixed); } float AudioStreamPlaybackOGGVorbis::get_length() const { |