From a1d057be714b8a12fb7ab1c2b9586b442d831b04 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 17 Apr 2012 18:05:05 +0200 Subject: [PATCH] optimize AudioUnit startup time --- coreapi/callbacks.c | 7 +++++-- coreapi/linphonecore.c | 8 +++++++- mediastreamer2 | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index bde6a2f40..b587ac75c 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -277,6 +277,9 @@ static void call_ringing(SalOp *h){ if (lc->sound_conf.play_sndcard!=NULL){ MSSndCard *ringcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard; if (call->localdesc->streams[0].max_rate>0) ms_snd_card_set_preferred_sample_rate(ringcard, call->localdesc->streams[0].max_rate); + /*we release sound before playing ringback tone*/ + if (call->audiostream) + audio_stream_unprepare_sound(call->audiostream); lc->ringstream=ring_start(lc->sound_conf.remote_ring,2000,ringcard); } ms_message("Remote ringing..."); @@ -285,7 +288,7 @@ static void call_ringing(SalOp *h){ linphone_call_set_state(call,LinphoneCallOutgoingRinging,"Remote ringing"); }else{ /*accept early media */ - if (call->audiostream && call->audiostream->ticker!=NULL){ + if (call->audiostream && audio_stream_started(call->audiostream)){ /*streams already started */ ms_message("Early media already started."); return; @@ -299,7 +302,7 @@ static void call_ringing(SalOp *h){ lc->ringstream=NULL; } ms_message("Doing early media..."); - linphone_core_update_streams (lc,call,md); + linphone_core_update_streams(lc,call,md); } } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index f7d78a025..9a73d0aa6 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2071,8 +2071,9 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro ms_free(contact); } - //TODO : should probably not be done here linphone_call_init_media_streams(call); + if (lc->ringstream==NULL) + audio_stream_prepare_sound(call->audiostream,lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard); if (!lc->sip_conf.sdp_200_ack){ call->media_pending=TRUE; sal_call_set_local_media_description(call->op,call->localdesc); @@ -2459,6 +2460,7 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, const char *contact=NULL; SalOp *replaced; SalMediaDescription *new_md; + bool_t was_ringing=FALSE; if (call==NULL){ //if just one call is present answer the only one ... @@ -2494,6 +2496,7 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, ring_stop(lc->ringstream); ms_message("ring stopped"); lc->ringstream=NULL; + was_ringing=TRUE; } if (call->ringing_beep){ linphone_core_stop_dtmf(lc); @@ -2515,6 +2518,9 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, if (call->audiostream==NULL) linphone_call_init_media_streams(call); + if (!was_ringing && call->audiostream->ticker==NULL){ + audio_stream_prepare_sound(call->audiostream,lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard); + } if (params){ call->params=*params; diff --git a/mediastreamer2 b/mediastreamer2 index c194c9209..bef50ee99 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit c194c9209bf6c96d419c0513f979ca1114ff3111 +Subproject commit bef50ee99700c4b6cb8c504fbec1686f3102edea