From 04218d3a86cce8e0c1f93647819b019f1bb7111a Mon Sep 17 00:00:00 2001 From: Tommi Kenakkala Date: Mon, 2 Feb 2015 14:43:06 +0200 Subject: handsfree-audio: Refactor manager init / cleanup --- src/handsfree-audio.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c index 6f69fb3f..14f65dcb 100644 --- a/src/handsfree-audio.c +++ b/src/handsfree-audio.c @@ -845,6 +845,8 @@ void ofono_handsfree_audio_ref(void) if (ref_count != 1) return; + __ofono_handsfree_audio_manager_init(); + if (!g_dbus_register_interface(ofono_dbus_get_connection(), OFONO_MANAGER_PATH, HFP_AUDIO_MANAGER_INTERFACE, @@ -873,6 +875,8 @@ void ofono_handsfree_audio_unref(void) agent_release(agent); agent_free(agent); } + + __ofono_handsfree_audio_manager_cleanup(); } int __ofono_handsfree_audio_manager_init(void) @@ -882,15 +886,11 @@ int __ofono_handsfree_audio_manager_init(void) void __ofono_handsfree_audio_manager_cleanup(void) { - if (ref_count == 0) + if (ref_count != 0) return; - ofono_error("Handsfree Audio manager not cleaned up properly," - "fixing..."); - - ref_count = 1; - ofono_handsfree_audio_unref(); - - if (sco_watch > 0) + if (sco_watch > 0) { g_source_remove(sco_watch); + sco_watch = 0; + } } -- cgit v1.2.3