fhub: remove duplicate code in bluetooth_hf_audio_mute API 77/282277/1 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/7.0/unified/20221110.060830 accepted/tizen/7.0/unified/hotfix/20221116.105140 accepted/tizen/unified/20221006.065308 accepted/tizen/unified/20221006.065347 tizen_7.0_m2_release
authorAyush Garg <ayush.garg@samsung.com>
Thu, 29 Sep 2022 09:12:06 +0000 (14:42 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Thu, 29 Sep 2022 09:12:06 +0000 (14:42 +0530)
Change-Id: I914d10f81e998c4f9d208ece96c3706fce3905e9
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
bt-api/bt-audio.c

index 8b2d9e5..e2b105e 100644 (file)
@@ -1291,17 +1291,22 @@ BT_EXPORT_API int bluetooth_hf_is_ibr_supported(gboolean *ibr_supported)
        return ret;
 }
 
-BT_EXPORT_API int bluetooth_hf_audio_mute_on()
+static int __bluetooth_hf_audio_mute_onoff(bool is_mute)
 {
        GVariant *reply = NULL;
        GError *err = NULL;
        int ret = BLUETOOTH_ERROR_INTERNAL;
 
        BT_CHECK_ENABLED(return);
-       BT_DBG("+");
+       BT_DBG("HF Audio Mute %s", is_mute ? "ON" : "OFF");
+
+       if (is_mute)
+               reply = __bt_hf_agent_dbus_send(BT_HF_OBJECT_PATH, BT_HF_INTERFACE,
+                                       "AudioMuteOn", &err, NULL);
+       else
+               reply = __bt_hf_agent_dbus_send(BT_HF_OBJECT_PATH, BT_HF_INTERFACE,
+                                       "AudioMuteOff", &err, NULL);
 
-       reply = __bt_hf_agent_dbus_send(BT_HF_OBJECT_PATH, BT_HF_INTERFACE,
-                      "AudioMuteOn", &err, NULL);
        if (!reply) {
                BT_ERR("Error returned in method call\n");
                if (err) {
@@ -1317,28 +1322,12 @@ BT_EXPORT_API int bluetooth_hf_audio_mute_on()
        return BLUETOOTH_ERROR_NONE;
 }
 
-BT_EXPORT_API int bluetooth_hf_audio_mute_off()
+BT_EXPORT_API int bluetooth_hf_audio_mute_on()
 {
-       GVariant *reply = NULL;
-       GError *err = NULL;
-       int ret = BLUETOOTH_ERROR_INTERNAL;
-
-       BT_CHECK_ENABLED(return);
-       BT_DBG("+");
-
-       reply = __bt_hf_agent_dbus_send(BT_HF_OBJECT_PATH, BT_HF_INTERFACE,
-                                       "AudioMuteOff", &err, NULL);
-       if (!reply) {
-               BT_ERR("Error returned in method call\n");
-               if (err) {
-                       BT_ERR("Error = %s", err->message);
-                       g_dbus_error_strip_remote_error(err);
-                       ret = _bt_get_error_value_from_message(err->message);
-                       g_clear_error(&err);
-               }
-               return ret;
-       }
+       return __bluetooth_hf_audio_mute_onoff(true);
+}
 
-       g_variant_unref(reply);
-       return BLUETOOTH_ERROR_NONE;
+BT_EXPORT_API int bluetooth_hf_audio_mute_off()
+{
+       return __bluetooth_hf_audio_mute_onoff(false);
 }