mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-04 21:43:34 +00:00
Audio: Rewind on play, not stop
Before, streams were rewound when they stopped, so that next time they're played they're played from the start. Instead, rewind on play instead, so that it's done when it's needed. This gets us a good point to make sure we're not rewinding raw streams too.
This commit is contained in:
parent
c6806f50e1
commit
33bee6ce44
|
@ -95,7 +95,6 @@ void lovrAudioUpdate() {
|
|||
alSourcePlay(id);
|
||||
}
|
||||
} else if (isStopped) {
|
||||
lovrAudioStreamRewind(lovrSourceGetStream(source));
|
||||
arr_splice(&state.sources, i, 1);
|
||||
lovrRelease(Source, source);
|
||||
}
|
||||
|
|
|
@ -165,6 +165,11 @@ void lovrSourcePlay(Source* source) {
|
|||
return;
|
||||
}
|
||||
|
||||
// in case we're replaying an already-used stream, make sure to rewind it if applicable
|
||||
if (!lovrAudioStreamIsRaw(source->stream)) {
|
||||
lovrAudioStreamRewind(source->stream);
|
||||
}
|
||||
|
||||
lovrSourceStream(source, source->buffers, SOURCE_BUFFERS);
|
||||
alSourcePlay(source->id);
|
||||
}
|
||||
|
@ -285,7 +290,9 @@ void lovrSourceStop(Source* source) {
|
|||
alSourcei(source->id, AL_BUFFER, AL_NONE);
|
||||
|
||||
// Rewind the decoder
|
||||
if (!lovrAudioStreamIsRaw(source->stream)) {
|
||||
lovrAudioStreamRewind(source->stream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue