mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-04 21:43:34 +00:00
RawAudioStream: getter for isRaw
And disallow looping raw streams
This commit is contained in:
parent
4fb4f6cdd1
commit
c6806f50e1
|
@ -230,6 +230,7 @@ void lovrSourceSetFalloff(Source* source, float reference, float max, float roll
|
|||
}
|
||||
|
||||
void lovrSourceSetLooping(Source* source, bool isLooping) {
|
||||
lovrAssert(!source->stream || lovrAudioStreamIsRaw(source->stream), "Can't loop a raw stream");
|
||||
source->isLooping = isLooping;
|
||||
if (source->type == SOURCE_STATIC) {
|
||||
alSourcei(source->id, AL_LOOPING, isLooping ? AL_TRUE : AL_FALSE);
|
||||
|
|
|
@ -92,7 +92,7 @@ size_t lovrAudioStreamDecode(AudioStream* stream, int16_t* destination, size_t s
|
|||
|
||||
bool lovrAudioStreamAppendRawBlob(AudioStream* stream, struct Blob* blob)
|
||||
{
|
||||
lovrAssert(stream->decoder == NULL, "Raw PCM data can only be appended to a raw AudioStream (see constructor that takes channel count and sample rate)")
|
||||
lovrAssert(lovrAudioStreamIsRaw(stream), "Raw PCM data can only be appended to a raw AudioStream (see constructor that takes channel count and sample rate)")
|
||||
lovrRetain(blob);
|
||||
arr_push(&stream->queuedRawBuffers, blob);
|
||||
return true;
|
||||
|
@ -105,20 +105,25 @@ bool lovrAudioStreamAppendRawSound(AudioStream* stream, struct SoundData* sound)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool lovrAudioStreamIsRaw(AudioStream* stream)
|
||||
{
|
||||
return stream->decoder == NULL;
|
||||
}
|
||||
|
||||
void lovrAudioStreamRewind(AudioStream* stream) {
|
||||
lovrAssert(stream->decoder, "Can't rewind raw stream");
|
||||
lovrAssert(!lovrAudioStreamIsRaw(stream), "Can't rewind raw stream");
|
||||
stb_vorbis* decoder = (stb_vorbis*) stream->decoder;
|
||||
stb_vorbis_seek_start(decoder);
|
||||
}
|
||||
|
||||
void lovrAudioStreamSeek(AudioStream* stream, size_t sample) {
|
||||
lovrAssert(stream->decoder, "Can't seek raw stream");
|
||||
lovrAssert(!lovrAudioStreamIsRaw(stream), "Can't seek raw stream");
|
||||
stb_vorbis* decoder = (stb_vorbis*) stream->decoder;
|
||||
stb_vorbis_seek(decoder, (int) sample);
|
||||
}
|
||||
|
||||
size_t lovrAudioStreamTell(AudioStream* stream) {
|
||||
lovrAssert(stream->decoder, "No position available in raw stream");
|
||||
lovrAssert(!lovrAudioStreamIsRaw(stream), "No position available in raw stream");
|
||||
stb_vorbis* decoder = (stb_vorbis*) stream->decoder;
|
||||
return stb_vorbis_get_sample_offset(decoder);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ void lovrAudioStreamDestroy(void* ref);
|
|||
size_t lovrAudioStreamDecode(AudioStream* stream, int16_t* destination, size_t size);
|
||||
bool lovrAudioStreamAppendRawBlob(AudioStream* stream, struct Blob* blob);
|
||||
bool lovrAudioStreamAppendRawSound(AudioStream* stream, struct SoundData* sound);
|
||||
bool lovrAudioStreamIsRaw(AudioStream* stream);
|
||||
void lovrAudioStreamRewind(AudioStream* stream);
|
||||
void lovrAudioStreamSeek(AudioStream* stream, size_t sample);
|
||||
size_t lovrAudioStreamTell(AudioStream* stream);
|
||||
|
|
Loading…
Reference in a new issue