Skip to content
Permalink
Browse files

Fix crash issue due to StreamPlayer being erased prior to removal fro…

…m DuplexStreamer
  • Loading branch information
bear101 committed Dec 12, 2019
1 parent 857bd09 commit 74d56f5c9c995ba94d7c05e9ef885a27f0ac6adf
Showing with 16 additions and 10 deletions.
  1. +16 −10 Library/TeamTalkLib/avstream/SoundSystemBase.h
@@ -1132,8 +1132,10 @@ namespace soundsystem {
newstreamer->duplex = true;
#endif
{
std::lock_guard<std::recursive_mutex> g1(players_lock());
m_output_streamers[player] = newstreamer;
{
std::lock_guard<std::recursive_mutex> g1(players_lock());
m_output_streamers[player] = newstreamer;
}

std::lock_guard<std::recursive_mutex> g2(streamer->players_mtx);
//store in list of duplex players which will receive output-callback
@@ -1153,18 +1155,22 @@ namespace soundsystem {
if (!streamer)
return false;

std::lock_guard<std::recursive_mutex> g1(players_lock());
m_output_streamers.erase(player);

std::lock_guard<std::recursive_mutex> g2(streamer->players_mtx);
for (size_t i=0;i<streamer->players.size();)
{
if(streamer->players[i]->player == player)
std::lock_guard<std::recursive_mutex> g2(streamer->players_mtx);
for(size_t i = 0; i<streamer->players.size();)
{
streamer->players.erase(streamer->players.begin()+i);
if(streamer->players[i]->player == player)
{
streamer->players.erase(streamer->players.begin() + i);
}
else i++;
}
else i++;
}

// player must be erased after it is removed from streamer->players
std::lock_guard<std::recursive_mutex> g1(players_lock());
m_output_streamers.erase(player);

return true;
}

0 comments on commit 74d56f5

Please sign in to comment.
You can’t perform that action at this time.