Skip to content

Commit 7e0ce45

Browse files
committed
PlayerOpenAL: some error handle
1 parent 2232a7e commit 7e0ce45

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/OpenCOVER/audio/PlayerOpenAL.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,31 @@ void PlayerOpenAL::Source::play(double start)
159159
}
160160

161161
ALuint buf = audio->buffer();
162+
if (buf == AL_NONE)
163+
{
164+
std::cerr << "Audio: OpenAL source play requested with invalid buffer for URL '" << audio->url() << "'" << std::endl;
165+
return;
166+
}
167+
162168
alSourceQueueBuffers(alSource, 1, &buf);
169+
ALenum queueError = alGetError();
170+
if (queueError != AL_NO_ERROR)
171+
{
172+
std::cerr << "Audio: alSourceQueueBuffers failed with error " << queueError << " for URL '" << audio->url() << "'" << std::endl;
173+
return;
174+
}
175+
163176
if (loop)
164177
{
165178
alSourcei(alSource, AL_LOOPING, AL_TRUE);
166179
}
167180

168181
alSourcePlay(alSource);
182+
ALenum playError = alGetError();
183+
if (playError != AL_NO_ERROR)
184+
{
185+
std::cerr << "Audio: alSourcePlay failed with error " << playError << " for URL '" << audio->url() << "'" << std::endl;
186+
}
169187
}
170188

171189
void PlayerOpenAL::Source::stop()

0 commit comments

Comments
 (0)