void alSourceStop(ALuint source) { DEBUGLOGCALL(LCF_OPENAL); AudioSource* as = audiocontext.getSource(source); if (as == nullptr) return; if ((as->state == SOURCE_INITIAL) || (as->state == SOURCE_STOPPED)) { /* Illegal operation. */ return; } as->init(); as->state = SOURCE_STOPPED; }
void alSourcei(ALuint source, ALenum param, ALint value) { DEBUGLOGCALL(LCF_OPENAL); AudioSource* as = audiocontext.getSource(source); if (as == nullptr) { ALSETERROR(AL_INVALID_NAME); return; } std::lock_guard<std::mutex> lock(audiocontext.mutex); AudioBuffer* bindab; switch(param) { case AL_LOOPING: debuglog(LCF_OPENAL, " Set looping of ", value); if (value == AL_TRUE) as->looping = true; else if (value == AL_FALSE) as->looping = false; else ALSETERROR(AL_INVALID_VALUE); break; case AL_BUFFER: /* Bind a buffer to the source */ if ((as->state == SOURCE_PLAYING) || (as->state == SOURCE_PAUSED)) { ALSETERROR(AL_INVALID_OPERATION); return; } if (value == 0) { /* Unbind buffer from source */ as->init(); as->buffer_queue.clear(); as->source = SOURCE_UNDETERMINED; as->state = SOURCE_INITIAL; debuglog(LCF_OPENAL, " Unbind buffer"); } else { bindab = audiocontext.getBuffer(value); if (bindab == nullptr) { ALSETERROR(AL_INVALID_VALUE); return; } as->init(); as->buffer_queue.clear(); as->buffer_queue.push_back(bindab); as->source = SOURCE_STATIC; as->state = SOURCE_INITIAL; debuglog(LCF_OPENAL, " Bind to buffer ", value); } break; case AL_SOURCE_RELATIVE: case AL_CONE_INNER_ANGLE: case AL_CONE_OUTER_ANGLE: debuglog(LCF_OPENAL, "Operation not supported"); break; case AL_SEC_OFFSET: case AL_SAMPLE_OFFSET: case AL_BYTE_OFFSET: alSourcef(source, param, (ALfloat)value); break; default: ALSETERROR(AL_INVALID_OPERATION); return; } }