diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index e6254e93a..ce9bfa38b 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1018,6 +1018,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const if (cstate==LinphoneCallReleased){ linphone_call_set_released(call); } + linphone_core_soundcard_hint_check(lc); } } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index bc08d68f1..c3a838aef 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -6415,11 +6415,32 @@ bool_t linphone_core_can_we_add_call(LinphoneCore *lc) static void notify_soundcard_usage(LinphoneCore *lc, bool_t used){ MSSndCard *card=lc->sound_conf.capt_sndcard; if (card && ms_snd_card_get_capabilities(card) & MS_SND_CARD_CAP_IS_SLOW){ - ms_message("Notifying soundcard that we don't need it anymore for calls."); ms_snd_card_set_usage_hint(card,used); } } +void linphone_core_soundcard_hint_check( LinphoneCore* lc){ + MSList* the_calls = lc->calls; + LinphoneCall* call = NULL; + bool_t remaining_paused = FALSE; + + /* check if the remaining calls are paused */ + while( the_calls ){ + call = the_calls->data; + if( call->state == LinphoneCallPausing || call->state == LinphoneCallPaused ){ + remaining_paused = TRUE; + break; + } + the_calls = the_calls->next; + } + + /* if no more calls or all calls are paused, we can free the soundcard */ + if ( (lc->calls==NULL || remaining_paused) && !lc->use_files){ + ms_message("Notifying soundcard that we don't need it anymore for calls."); + notify_soundcard_usage(lc,FALSE); + } +} + int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call) { if (linphone_core_can_we_add_call(lc)){ @@ -6446,7 +6467,9 @@ int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call) return -1; } lc->calls = the_calls; - if (lc->calls==NULL) notify_soundcard_usage(lc,FALSE); + + linphone_core_soundcard_hint_check(lc); + return 0; } diff --git a/coreapi/private.h b/coreapi/private.h index 3aa9b283d..a8816b04b 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -374,6 +374,8 @@ void linphone_notify_parse_presence(SalOp *op, const char *content_type, const c void linphone_notify_convert_presence_to_xml(SalOp *op, SalPresenceModel *presence, const char *contact, char **content); void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model); void linphone_proxy_config_process_authentication_failure(LinphoneCore *lc, SalOp *op); +void linphone_core_soundcard_hint_check(LinphoneCore* lc); + void linphone_subscription_answered(LinphoneCore *lc, SalOp *op); void linphone_subscription_closed(LinphoneCore *lc, SalOp *op);