aboutsummaryrefslogtreecommitdiff
path: root/src/library_openal.js
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2013-03-19 17:55:00 -0400
committerEhsan Akhgari <ehsan.akhgari@gmail.com>2013-03-19 17:55:00 -0400
commit7c71bf1d0ab8feb685a256de74abcae8c6a56f68 (patch)
treec18defd26455df9ce2eccae26db5216ec1c8798a /src/library_openal.js
parent8754ddc7e358b04aefbb453f3d07fd597474a1bf (diff)
Only pause/resume in progress sources if the buffer being played back is the same as the buffer for the new source
Diffstat (limited to 'src/library_openal.js')
-rw-r--r--src/library_openal.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/library_openal.js b/src/library_openal.js
index 6bd0f6b0..271ae5ae 100644
--- a/src/library_openal.js
+++ b/src/library_openal.js
@@ -385,14 +385,18 @@ var LibraryOpenAL = {
return;
}
var offset = 0;
- if ("src" in AL.currentContext.src[source - 1]) {
- // If the source is already playing, we need to resume from beginning.
- // We do that by stopping the current source and replaying it.
- _alSourceStop(source);
- } else if (AL.currentContext.src[source - 1].paused) {
- // So now we have to resume playback, remember the offset here.
- offset = AL.currentContext.src[source - 1].pausedTime -
- AL.currentContext.src[source - 1].playTime;
+ if ("src" in AL.currentContext.src[source - 1] &&
+ AL.currentContext.src[source - 1]["src"].buffer ==
+ AL.currentContext.src[source - 1].buffer) {
+ if (AL.currentContext.src[source - 1].paused) {
+ // So now we have to resume playback, remember the offset here.
+ offset = AL.currentContext.src[source - 1].pausedTime -
+ AL.currentContext.src[source - 1].playTime;
+ } else {
+ // If the source is already playing, we need to resume from beginning.
+ // We do that by stopping the current source and replaying it.
+ _alSourceStop(source);
+ }
}
var src = AL.currentContext.ctx.createBufferSource();
src.loop = AL.currentContext.src[source - 1].loop;