[pulseaudio-discuss] [PATCH v0 08/16] bluetooth: Use helper functions to move streams
Mikel Astiz
mikel.astiz.oss at gmail.com
Fri Sep 28 08:45:32 PDT 2012
From: Mikel Astiz <mikel.astiz at bmw-carit.de>
Wrap the moving sink-input and source-outputs into two helper functions.
---
src/modules/bluetooth/module-bluetooth-device.c | 51 ++++++++++++++++---------
1 file changed, 32 insertions(+), 19 deletions(-)
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index ea31fa3..badf296 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -2188,10 +2188,39 @@ static void restore_sco_volume_callbacks(struct userdata *u) {
}
/* Run from main thread */
+static void move_all_start(struct userdata *u, pa_queue **inputs, pa_queue **outputs) {
+ *inputs = NULL;
+ *outputs = NULL;
+
+ if (u->sink)
+ *inputs = pa_sink_move_all_start(u->sink, NULL);
+
+ if (u->source)
+ *outputs = pa_source_move_all_start(u->source, NULL);
+}
+
+/* Run from main thread */
+static void move_all_end(struct userdata *u, pa_queue *inputs, pa_queue *outputs) {
+ if (inputs) {
+ if (u->sink)
+ pa_sink_move_all_finish(u->sink, inputs, FALSE);
+ else
+ pa_sink_move_all_fail(inputs);
+ }
+
+ if (outputs) {
+ if (u->source)
+ pa_source_move_all_finish(u->source, outputs, FALSE);
+ else
+ pa_source_move_all_fail(outputs);
+ }
+}
+
+/* Run from main thread */
static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
struct userdata *u;
enum profile *d;
- pa_queue *inputs = NULL, *outputs = NULL;
+ pa_queue *inputs, *outputs;
pa_assert(c);
pa_assert(new_profile);
@@ -2222,11 +2251,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
}
}
- if (u->sink)
- inputs = pa_sink_move_all_start(u->sink, NULL);
-
- if (u->source)
- outputs = pa_source_move_all_start(u->source, NULL);
+ move_all_start(u, &inputs, &outputs);
stop_thread(u);
@@ -2245,19 +2270,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
if (u->sink || u->source)
start_thread(u);
- if (inputs) {
- if (u->sink)
- pa_sink_move_all_finish(u->sink, inputs, FALSE);
- else
- pa_sink_move_all_fail(inputs);
- }
-
- if (outputs) {
- if (u->source)
- pa_source_move_all_finish(u->source, outputs, FALSE);
- else
- pa_source_move_all_fail(outputs);
- }
+ move_all_end(u, inputs, outputs);
return 0;
}
--
1.7.11.4
More information about the pulseaudio-discuss
mailing list