my app deadlock on android when call SDL_LockAudioDevice (sdl2.0.8)), I did not call SDL_LockAudioDevice in callbackfunction
here is my callbackfunction(SDL_AudioCallback):
void SDLAudio::sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{
SDLAudio* sa = (SDLAudio*)opaque;
bool mute = true;
bool clean = true;
std::unordered_map<unsigned int, MediaState*>::iterator iter;
for (iter = sa->_AudioMap.begin(); iter != sa->_AudioMap.end(); iter++)
{
bool is_mute = iter->second->sdl_audio_callback(stream, len, clean);
clean = false;
if (!is_mute)
{
mute = false;
}
}
if (mute)
{
memset(stream, 0, len);
}
}
and here is my function which include SDL_LockAudioDevice
void SDLAudio::close_audio(unsigned int id)
{
SDL_LockAudioDevice(_audio_dev);
std::unordered_map<unsigned int, MediaState*>::iterator got = _AudioMap.find(id);
if (got != _AudioMap.end())
{
_AudioMap.erase(id);
}
SDL_UnlockAudioDevice(_audio_dev);
}