gboolean SoundPlayer::checkBuffer(gpointer data) { // Cast the passed pointer onto self SoundPlayer* self = reinterpret_cast<SoundPlayer*>(data); // Check for active source and buffer if (self->_source != 0 && self->_buffer != 0) { ALint state; // Query the state of the source alGetSourcei(self->_source, AL_SOURCE_STATE, &state); if (state == AL_STOPPED) { // Erase the buffer self->clearBuffer(); // Disable the timer to stop calling this function self->_timer.disable(); return false; } } // Return true, so that the timer gets called again return true; }