diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-04-26 08:13:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 08:13:30 +0200 |
commit | cdf0fbd8e83c942b4d16d4bd05af793b2979f826 (patch) | |
tree | 4d30f250075a3348af782d6c4a972d68af1f80a7 /modules | |
parent | 95683f051ccdd073358abd9c95a3fb6d8a12ce6c (diff) | |
parent | 6cf0c62221e304a58c028358ecb4d45ad4bbf3b7 (diff) |
Merge pull request #8522 from NNesh/mus
Fix AudioPlayer bugs with OGG
Diffstat (limited to 'modules')
-rw-r--r-- | modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 227e5e61b6..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! @@ -66,8 +67,8 @@ float AudioStreamPlaybackOGGVorbis::get_stream_sampling_rate() { void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) { - seek_pos(p_from_pos); active = true; + seek_pos(p_from_pos); loops = 0; _begin_resample(); } @@ -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 { |