Commit 9c5012b1 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Ensure ptr is set to NULL after unref

parent 6faf4a4c
......@@ -4968,7 +4968,10 @@ bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *dev
LinphoneStatus linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid) {
MSSndCard *card = get_card_from_string_id(devid, MS_SND_CARD_CAP_PLAYBACK, lc->factory);
if (lc->sound_conf.ring_sndcard) ms_snd_card_unref(lc->sound_conf.ring_sndcard);
if (lc->sound_conf.ring_sndcard) {
ms_snd_card_unref(lc->sound_conf.ring_sndcard);
lc->sound_conf.ring_sndcard = NULL;
}
if (card) lc->sound_conf.ring_sndcard = ms_snd_card_ref(card);
if (card && (linphone_core_ready(lc) || !devid || strcmp(devid, ms_snd_card_get_string_id(card)) != 0))
linphone_config_set_string(lc->config, "sound", "ringer_dev_id", ms_snd_card_get_string_id(card));
......@@ -4977,7 +4980,10 @@ LinphoneStatus linphone_core_set_ringer_device(LinphoneCore *lc, const char * de
LinphoneStatus linphone_core_set_playback_device(LinphoneCore *lc, const char * devid) {
MSSndCard *card = get_card_from_string_id(devid, MS_SND_CARD_CAP_PLAYBACK, lc->factory);
if (lc->sound_conf.play_sndcard) ms_snd_card_unref(lc->sound_conf.play_sndcard);
if (lc->sound_conf.play_sndcard) {
ms_snd_card_unref(lc->sound_conf.play_sndcard);
lc->sound_conf.play_sndcard = NULL;
}
if (card) lc->sound_conf.play_sndcard = ms_snd_card_ref(card);
if (card && (linphone_core_ready(lc) || !devid || strcmp(devid, ms_snd_card_get_string_id(card)) != 0))
linphone_config_set_string(lc->config, "sound", "playback_dev_id", ms_snd_card_get_string_id(card));
......@@ -4986,7 +4992,10 @@ LinphoneStatus linphone_core_set_playback_device(LinphoneCore *lc, const char *
LinphoneStatus linphone_core_set_capture_device(LinphoneCore *lc, const char * devid) {
MSSndCard *card = get_card_from_string_id(devid, MS_SND_CARD_CAP_CAPTURE, lc->factory);
if (lc->sound_conf.capt_sndcard) ms_snd_card_unref(lc->sound_conf.capt_sndcard);
if (lc->sound_conf.capt_sndcard) {
ms_snd_card_unref(lc->sound_conf.capt_sndcard);
lc->sound_conf.capt_sndcard = NULL;
}
if (card) lc->sound_conf.capt_sndcard = ms_snd_card_ref(card);
if (card && (linphone_core_ready(lc) || !devid || strcmp(devid, ms_snd_card_get_string_id(card)) != 0))
linphone_config_set_string(lc->config, "sound", "capture_dev_id", ms_snd_card_get_string_id(card));
......@@ -4995,7 +5004,10 @@ LinphoneStatus linphone_core_set_capture_device(LinphoneCore *lc, const char * d
LinphoneStatus linphone_core_set_media_device(LinphoneCore *lc, const char * devid) {
MSSndCard *card = get_card_from_string_id(devid, MS_SND_CARD_CAP_PLAYBACK, lc->factory);
if (lc->sound_conf.media_sndcard) ms_snd_card_unref(lc->sound_conf.media_sndcard);
if (lc->sound_conf.media_sndcard) {
ms_snd_card_unref(lc->sound_conf.media_sndcard);
lc->sound_conf.media_sndcard = NULL;
}
if (card) lc->sound_conf.media_sndcard = ms_snd_card_ref(card);
if (card && (linphone_core_ready(lc) || !devid || strcmp(devid, ms_snd_card_get_string_id(card)) != 0))
linphone_config_set_string(lc->config, "sound", "media_dev_id", ms_snd_card_get_string_id(card));
......@@ -6719,10 +6731,22 @@ static void sound_config_uninit(LinphoneCore *lc)
{
sound_config_t *config=&lc->sound_conf;
ms_free((void *)config->cards);
if (config->ring_sndcard) ms_snd_card_unref(config->ring_sndcard);
if (config->media_sndcard) ms_snd_card_unref(config->media_sndcard);
if (config->capt_sndcard) ms_snd_card_unref(config->capt_sndcard);
if (config->play_sndcard) ms_snd_card_unref(config->play_sndcard);
if (config->ring_sndcard) {
ms_snd_card_unref(config->ring_sndcard);
config->ring_sndcard = NULL;
}
if (config->media_sndcard) {
ms_snd_card_unref(config->media_sndcard);
config->media_sndcard = NULL;
}
if (config->capt_sndcard) {
ms_snd_card_unref(config->capt_sndcard);
config->capt_sndcard = NULL;
}
if (config->play_sndcard) {
ms_snd_card_unref(config->play_sndcard);
config->play_sndcard = NULL;
}
linphone_config_set_string(lc->config,"sound","remote_ring",config->remote_ring);
linphone_config_set_float(lc->config,"sound","playback_gain_db",config->soft_play_lev);
......
......@@ -132,6 +132,7 @@ public:
void setCurrentOutputAudioDevice(AudioDevice * audioDevice) {
if (currentOutputAudioDevice) {
currentOutputAudioDevice->unref();
currentOutputAudioDevice = nullptr;
}
currentOutputAudioDevice = audioDevice;
if (currentOutputAudioDevice) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment