summaryrefslogtreecommitdiffstats
path: root/audio/gstavdtpsink.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/gstavdtpsink.c')
-rw-r--r--audio/gstavdtpsink.c100
1 files changed, 37 insertions, 63 deletions
diff --git a/audio/gstavdtpsink.c b/audio/gstavdtpsink.c
index 2a97b559..8c8a7465 100644
--- a/audio/gstavdtpsink.c
+++ b/audio/gstavdtpsink.c
@@ -279,9 +279,7 @@ static gboolean gst_avdtp_sink_init_sbc_pkt_conf(GstAvdtpSink *sink,
value = gst_structure_get_value(structure, "mode");
pref = g_value_get_string(value);
- if (strcmp(pref, "auto") == 0)
- cfg->channel_mode = BT_A2DP_CHANNEL_MODE_AUTO;
- else if (strcmp(pref, "mono") == 0)
+ if (strcmp(pref, "mono") == 0)
cfg->channel_mode = BT_A2DP_CHANNEL_MODE_MONO;
else if (strcmp(pref, "dual") == 0)
cfg->channel_mode = BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL;
@@ -296,9 +294,7 @@ static gboolean gst_avdtp_sink_init_sbc_pkt_conf(GstAvdtpSink *sink,
value = gst_structure_get_value(structure, "allocation");
pref = g_value_get_string(value);
- if (strcmp(pref, "auto") == 0)
- cfg->allocation_method = BT_A2DP_ALLOCATION_AUTO;
- else if (strcmp(pref, "loudness") == 0)
+ if (strcmp(pref, "loudness") == 0)
cfg->allocation_method = BT_A2DP_ALLOCATION_LOUDNESS;
else if (strcmp(pref, "snr") == 0)
cfg->allocation_method = BT_A2DP_ALLOCATION_SNR;
@@ -438,32 +434,21 @@ static GstStructure *gst_avdtp_sink_parse_sbc_caps(
/* mode */
list = g_value_init(g_new0(GValue, 1), GST_TYPE_LIST);
- if (sbc->channel_mode == BT_A2DP_CHANNEL_MODE_AUTO) {
- g_value_set_static_string(value, "joint");
+ if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_MONO) {
+ g_value_set_static_string(value, "mono");
gst_value_list_prepend_value(list, value);
+ }
+ if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO) {
g_value_set_static_string(value, "stereo");
gst_value_list_prepend_value(list, value);
- g_value_set_static_string(value, "mono");
- gst_value_list_prepend_value(list, value);
+ }
+ if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL) {
g_value_set_static_string(value, "dual");
gst_value_list_prepend_value(list, value);
- } else {
- if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_MONO) {
- g_value_set_static_string(value, "mono");
- gst_value_list_prepend_value(list, value);
- }
- if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO) {
- g_value_set_static_string(value, "stereo");
- gst_value_list_prepend_value(list, value);
- }
- if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL) {
- g_value_set_static_string(value, "dual");
- gst_value_list_prepend_value(list, value);
- }
- if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_JOINT_STEREO) {
- g_value_set_static_string(value, "joint");
- gst_value_list_prepend_value(list, value);
- }
+ }
+ if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_JOINT_STEREO) {
+ g_value_set_static_string(value, "joint");
+ gst_value_list_prepend_value(list, value);
}
g_value_unset(value);
if (list) {
@@ -519,20 +504,13 @@ static GstStructure *gst_avdtp_sink_parse_sbc_caps(
/* allocation */
g_value_init(value, G_TYPE_STRING);
list = g_value_init(g_new0(GValue,1), GST_TYPE_LIST);
- if (sbc->allocation_method == BT_A2DP_ALLOCATION_AUTO) {
+ if (sbc->allocation_method & BT_A2DP_ALLOCATION_LOUDNESS) {
g_value_set_static_string(value, "loudness");
gst_value_list_prepend_value(list, value);
+ }
+ if (sbc->allocation_method & BT_A2DP_ALLOCATION_SNR) {
g_value_set_static_string(value, "snr");
gst_value_list_prepend_value(list, value);
- } else {
- if (sbc->allocation_method & BT_A2DP_ALLOCATION_LOUDNESS) {
- g_value_set_static_string(value, "loudness");
- gst_value_list_prepend_value(list, value);
- }
- if (sbc->allocation_method & BT_A2DP_ALLOCATION_SNR) {
- g_value_set_static_string(value, "snr");
- gst_value_list_prepend_value(list, value);
- }
}
g_value_unset(value);
if (list) {
@@ -576,37 +554,33 @@ static GstStructure *gst_avdtp_sink_parse_sbc_caps(
g_value_unset(value);
/* channels */
- if (sbc->channel_mode == BT_A2DP_CHANNEL_MODE_AUTO) {
+ mono = FALSE;
+ stereo = FALSE;
+ if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
+ mono = TRUE;
+ if ((sbc->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO) ||
+ (sbc->channel_mode &
+ BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL) ||
+ (sbc->channel_mode &
+ BT_A2DP_CHANNEL_MODE_JOINT_STEREO))
+ stereo = TRUE;
+
+ if (mono && stereo) {
g_value_init(value, GST_TYPE_INT_RANGE);
gst_value_set_int_range(value, 1, 2);
} else {
- mono = FALSE;
- stereo = FALSE;
- if (sbc->channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
- mono = TRUE;
- if ((sbc->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO) ||
- (sbc->channel_mode &
- BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL) ||
- (sbc->channel_mode &
- BT_A2DP_CHANNEL_MODE_JOINT_STEREO))
- stereo = TRUE;
-
- if (mono && stereo) {
- g_value_init(value, GST_TYPE_INT_RANGE);
- gst_value_set_int_range(value, 1, 2);
- } else {
- g_value_init(value, G_TYPE_INT);
- if (mono)
- g_value_set_int(value, 1);
- else if (stereo)
- g_value_set_int(value, 2);
- else {
- GST_ERROR_OBJECT(self,
- "Unexpected number of channels");
- g_value_set_int(value, 0);
- }
+ g_value_init(value, G_TYPE_INT);
+ if (mono)
+ g_value_set_int(value, 1);
+ else if (stereo)
+ g_value_set_int(value, 2);
+ else {
+ GST_ERROR_OBJECT(self,
+ "Unexpected number of channels");
+ g_value_set_int(value, 0);
}
}
+
gst_structure_set_value(structure, "channels", value);
g_free(value);