]> code.delx.au - pulseaudio/commitdiff
bluetooth: Move profile_to_string() to bluetooth-util
authorMikel Astiz <mikel.astiz@bmw-carit.de>
Fri, 14 Dec 2012 14:14:31 +0000 (15:14 +0100)
committerTanu Kaskinen <tanuk@iki.fi>
Wed, 19 Dec 2012 10:31:49 +0000 (12:31 +0200)
Move the function to the utility library where the enum is defined. At
same time avoid using the default clause in order to make sure the
compiler will complain if the enum type gets extended.

src/modules/bluetooth/bluetooth-util.c
src/modules/bluetooth/bluetooth-util.h
src/modules/bluetooth/module-bluetooth-device.c

index 28dc6d84554dedaf7312fc004264026220bf24ab..e3cfcda5a34d4740aa0323a0245160c5a018256b 100644 (file)
@@ -93,6 +93,23 @@ pa_bt_audio_state_t pa_bt_audio_state_from_string(const char* value) {
     return PA_BT_AUDIO_STATE_INVALID;
 }
 
+const char *pa_bt_profile_to_string(enum profile profile) {
+    switch(profile) {
+        case PROFILE_A2DP:
+            return "a2dp";
+        case PROFILE_A2DP_SOURCE:
+            return "a2dp_source";
+        case PROFILE_HSP:
+            return "hsp";
+        case PROFILE_HFGW:
+            return "hfgw";
+        case PROFILE_OFF:
+            pa_assert_not_reached();
+    }
+
+    pa_assert_not_reached();
+}
+
 static int profile_from_interface(const char *interface, enum profile *p) {
     pa_assert(interface);
     pa_assert(p);
index e471e0d6d2927e5025ba76f3a4fb677d2146835f..fb4a2110d062a6b0000e653d7f7a721555a1c4f1 100644 (file)
@@ -162,5 +162,6 @@ char *pa_bluetooth_cleanup_name(const char *name);
 
 pa_bool_t pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid);
 pa_bt_audio_state_t pa_bt_audio_state_from_string(const char* value);
+const char *pa_bt_profile_to_string(enum profile profile);
 
 #endif
index 547aea3f3f5a3a5f0017e21497debcf22bd4542c..f005b86827eff76fb1d63c07d9e079dd3304d162 100644 (file)
@@ -1654,21 +1654,6 @@ static void connect_ports(struct userdata *u, void *sink_or_source_new_data, pa_
     }
 }
 
-static const char *profile_to_string(enum profile profile) {
-    switch(profile) {
-        case PROFILE_A2DP:
-            return "a2dp";
-        case PROFILE_A2DP_SOURCE:
-            return "a2dp_source";
-        case PROFILE_HSP:
-            return "hsp";
-        case PROFILE_HFGW:
-            return "hfgw";
-        default:
-            pa_assert_not_reached();
-    }
-}
-
 static int sink_set_port_cb(pa_sink *s, pa_device_port *p) {
     return 0;
 }
@@ -1688,7 +1673,7 @@ static int add_sink(struct userdata *u) {
 
         u->sink = u->hsp.sco_sink;
         p = pa_proplist_new();
-        pa_proplist_sets(p, "bluetooth.protocol", profile_to_string(u->profile));
+        pa_proplist_sets(p, "bluetooth.protocol", pa_bt_profile_to_string(u->profile));
         pa_proplist_update(u->sink->proplist, PA_UPDATE_MERGE, p);
         pa_proplist_free(p);
     } else {
@@ -1699,7 +1684,7 @@ static int add_sink(struct userdata *u) {
         data.driver = __FILE__;
         data.module = u->module;
         pa_sink_new_data_set_sample_spec(&data, &u->sample_spec);
-        pa_proplist_sets(data.proplist, "bluetooth.protocol", profile_to_string(u->profile));
+        pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bt_profile_to_string(u->profile));
         if (u->profile == PROFILE_HSP)
             pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
         data.card = u->card;
@@ -1760,7 +1745,7 @@ static int add_source(struct userdata *u) {
 
     if (USE_SCO_OVER_PCM(u)) {
         u->source = u->hsp.sco_source;
-        pa_proplist_sets(u->source->proplist, "bluetooth.protocol", profile_to_string(u->profile));
+        pa_proplist_sets(u->source->proplist, "bluetooth.protocol", pa_bt_profile_to_string(u->profile));
     } else {
         pa_source_new_data data;
         pa_bool_t b;
@@ -1769,7 +1754,7 @@ static int add_source(struct userdata *u) {
         data.driver = __FILE__;
         data.module = u->module;
         pa_source_new_data_set_sample_spec(&data, &u->sample_spec);
-        pa_proplist_sets(data.proplist, "bluetooth.protocol", profile_to_string(u->profile));
+        pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bt_profile_to_string(u->profile));
         if (u->profile == PROFILE_HSP)
             pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");