Remove audio stream from the map when using the audio-stream-stop commands to prevent crash with wrong id parameter.

This commit is contained in:
Ghislain MARY 2012-09-27 10:36:14 +02:00
parent 207f4a1211
commit 99cf5ab3d5
3 changed files with 8 additions and 0 deletions

View file

@ -14,6 +14,7 @@ void AudioStreamStopCommand::exec(Daemon *app, const char *args) {
return;
}
audio_stream_stop(stream);
app->removeAudioStream(id);
app->sendResponse(Response());
} else {
app->sendResponse(Response("Missing/Incorrect parameter(s)."));

View file

@ -319,6 +319,12 @@ AudioStream *Daemon::findAudioStream(int id) {
return NULL;
}
void Daemon::removeAudioStream(int id) {
std::map<int, AudioStream*>::iterator it = mAudioStreams.find(id);
if (it != mAudioStreams.end())
mAudioStreams.erase(it);
}
void Daemon::initCommands() {
mCommands.push_back(new RegisterCommand());
mCommands.push_back(new RegisterStatusCommand());

View file

@ -152,6 +152,7 @@ public:
LinphoneCall *findCall(int id);
LinphoneProxyConfig *findProxy(int id);
AudioStream *findAudioStream(int id);
void removeAudioStream(int id);
bool pullEvent();
int updateCallId(LinphoneCall *call);
int updateProxyId(LinphoneProxyConfig *proxy);