diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-08-11 23:16:46 -0400 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2012-08-11 23:16:46 -0400 |
commit | a78e661c67b6532319d204b6facb9b231f3c5181 (patch) | |
tree | 927637011f3b3c6a539b25c1cbb3d720b1ec61c6 | |
parent | 74659ea10be110665f41c1c5b6f830fc7cb1335d (diff) | |
download | mirror-ponymix-a78e661c67b6532319d204b6facb9b231f3c5181.tar.gz mirror-ponymix-a78e661c67b6532319d204b6facb9b231f3c5181.tar.bz2 mirror-ponymix-a78e661c67b6532319d204b6facb9b231f3c5181.zip |
use switch/case for determining mode
-rw-r--r-- | pulsemix.c | 42 |
1 files changed, 30 insertions, 12 deletions
@@ -431,10 +431,14 @@ static void get_sinks(struct pulseaudio_t *pulse, enum mode mode) { pa_operation *op; - if (mode == MODE_APP) + switch (mode) { + case MODE_APP: op = pa_context_get_sink_input_info_list(pulse->cxt, sink_input_add_cb, pulse); - else + break; + case MODE_DEVICE: + default: op = pa_context_get_sink_info_list(pulse->cxt, sink_add_cb, pulse); + } pulse_async_wait(pulse, op); pa_operation_unref(op); @@ -444,14 +448,19 @@ static void get_sink_by_name(struct pulseaudio_t *pulse, const char *name, enum { pa_operation *op; - if (mode == MODE_APP) { + switch (mode) { + case MODE_APP: + { long id; - int r = xstrtol(name, &id); - if (r < 0) + if (xstrtol(name, &id) < 0) errx(EXIT_FAILURE, "application sink not id: %s", name); op = pa_context_get_sink_input_info(pulse->cxt, (uint32_t)id, sink_input_add_cb, pulse); - } else + break; + } + case MODE_DEVICE: + default: op = pa_context_get_sink_info_by_name(pulse->cxt, name, sink_add_cb, pulse); + } pulse_async_wait(pulse, op); pa_operation_unref(op); @@ -472,10 +481,14 @@ static void get_sources(struct pulseaudio_t *pulse, enum mode mode) { pa_operation *op; - if (mode == MODE_APP) + switch (mode) { + case MODE_APP: op = pa_context_get_source_output_info_list(pulse->cxt, source_output_add_cb, pulse); - else + break; + case MODE_DEVICE: + default: op = pa_context_get_source_info_list(pulse->cxt, source_add_cb, pulse); + } pulse_async_wait(pulse, op); pa_operation_unref(op); @@ -485,14 +498,19 @@ static void get_source_by_name(struct pulseaudio_t *pulse, const char *name, enu { pa_operation *op; - if (mode == MODE_APP) { + switch (mode) { + case MODE_APP: + { long id; - int r = xstrtol(name, &id); - if (r < 0) + if (xstrtol(name, &id) < 0) errx(EXIT_FAILURE, "application source not id: %s", name); op = pa_context_get_source_output_info(pulse->cxt, (uint32_t)id, source_output_add_cb, pulse); - } else + break; + } + case MODE_DEVICE: + default: op = pa_context_get_source_info_by_name(pulse->cxt, name, source_add_cb, pulse); + } pulse_async_wait(pulse, op); pa_operation_unref(op); |