SDLオーディオを使用してサウンドを再生しています。
SDL_LockAudioはこれを伝えます:
コールバック関数からこれを呼び出さないでください。デッドロックが発生します。
しかし、SDL_PauseAudioはそれを言いません、代わりにそれは言います:
この関数は、オーディオコールバック処理を一時停止および一時停止解除します
私のミキサーコールバックは次のようになります:
void AudioPlaybackCallback( void *, core::bty::UInt8 *stream, int len )
{
// number of bytes left to play in the current sample
const int thisSampleLeft = currentSample.dataLength - currentSample.dataPos;
// number of bytes that will be sent to the audio stream
const int amountToPlay = std::min( thisSampleLeft, len );
if ( amountToPlay > 0 )
{
SDL_MixAudio( stream,
currentSample.data + currentSample.dataPos,
amountToPlay,
currentSample.volume );
// update the current sample
currentSample.dataPos += amountToPlay;
}
else
{
if ( PlayingQueue::QueueHasElements() )
{
// update the current sample
currentSample = PlayingQueue::QueuePop();
}
else
{
// since the current sample finished, and there are no more samples to
// play, pause the playback
SDL_PauseAudio( 1 );
}
}
}
PlayingQueue
std::queue
静的オブジェクトへのアクセスを提供するクラスです。特別なことは何もありません。
これは、SDLおよびalsaライブラリを更新することを決定するまでは正常に機能しました(現在、元に戻すことはできません)。それ以来、私はこれを私のログに見ています:
ALSA lib pcm.c:7316:(snd_pcm_recover)アンダーランが発生しました
SDLまたはalsaライブラリにバグがないと仮定した場合(このメッセージをグーグルで検索した後、これはおそらく間違っています)、コードを変更して修正するか、少なくともアンダーランを回避できるはずです。
だから、問題は:それ自体からのコールバックを一時停止できますか?私が見ているアンダーランを引き起こす可能性はありますか?