From 37560e36c3c8eee03d733f26db428cfe019d8c4a Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Mon, 21 Mar 2011 14:07:51 -0500 Subject: [PATCH] Source:seek didn't work properly for streaming sources, fixed that --HG-- branch : minor --- src/modules/audio/openal/Source.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/audio/openal/Source.cpp b/src/modules/audio/openal/Source.cpp index 7c844f0f4..241c2b7c5 100644 --- a/src/modules/audio/openal/Source.cpp +++ b/src/modules/audio/openal/Source.cpp @@ -225,13 +225,24 @@ namespace openal { switch (unit) { case Source::UNIT_SAMPLES: - if (type == TYPE_STREAM) offset -= offsetSamples; - alSourcef(source, AL_SAMPLE_OFFSET, offset); + if (type == TYPE_STREAM) { + ALint buffer; + alGetSourcei(source, AL_BUFFER, &buffer); + int freq; + alGetBufferi(buffer, AL_FREQUENCY, &freq); + offset /= freq; + decoder->seek(offset); + } else { + alSourcef(source, AL_SAMPLE_OFFSET, offset); + } break; case Source::UNIT_SECONDS: default: - if (type == TYPE_STREAM) offset -= offsetSeconds; - alSourcef(source, AL_SEC_OFFSET, offset); + if (type == TYPE_STREAM) { + decoder->seek(offset); + } else { + alSourcef(source, AL_SEC_OFFSET, offset); + } break; } }