From 521daf6f0ac4fa6a2fbfb5d523c0c743342dca2b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 4 Jan 2007 13:43:45 +0000 Subject: Huge trailing whitespace cleanup. Let's keep the tree pure from here on, mmmkay? git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1418 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/alsa-util.c | 28 ++++---- src/modules/alsa-util.h | 6 +- src/modules/dbus-util.c | 6 +- src/modules/dbus-util.h | 6 +- src/modules/module-alsa-sink.c | 54 +++++++------- src/modules/module-alsa-source.c | 58 +++++++-------- src/modules/module-cli.c | 14 ++-- src/modules/module-combine.c | 70 +++++++++--------- src/modules/module-detect.c | 36 +++++----- src/modules/module-esound-compat-spawnfd.c | 6 +- src/modules/module-esound-compat-spawnpid.c | 6 +- src/modules/module-esound-sink.c | 58 +++++++-------- src/modules/module-hal-detect.c | 12 ++-- src/modules/module-jack-sink.c | 70 +++++++++--------- src/modules/module-jack-source.c | 70 +++++++++--------- src/modules/module-lirc.c | 42 +++++------ src/modules/module-match.c | 26 +++---- src/modules/module-mmkbd-evdev.c | 26 +++---- src/modules/module-native-protocol-fd.c | 10 +-- src/modules/module-null-sink.c | 24 +++---- src/modules/module-oss-mmap.c | 86 +++++++++++----------- src/modules/module-oss.c | 70 +++++++++--------- src/modules/module-pipe-sink.c | 36 +++++----- src/modules/module-pipe-source.c | 30 ++++---- src/modules/module-protocol-stub.c | 36 +++++----- src/modules/module-rescue-streams.c | 22 +++--- src/modules/module-sine.c | 18 ++--- src/modules/module-solaris.c | 36 +++++----- src/modules/module-tunnel.c | 86 +++++++++++----------- src/modules/module-volume-restore.c | 64 ++++++++--------- src/modules/module-waveout.c | 22 +++--- src/modules/module-x11-bell.c | 18 ++--- src/modules/module-x11-publish.c | 26 +++---- src/modules/module-zeroconf-publish.c | 108 ++++++++++++++-------------- src/modules/oss-util.c | 44 ++++++------ src/modules/oss-util.h | 6 +- 36 files changed, 668 insertions(+), 668 deletions(-) (limited to 'src/modules') diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c index d8b6c5cc..8023d3ad 100644 --- a/src/modules/alsa-util.c +++ b/src/modules/alsa-util.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -270,7 +270,7 @@ static int set_format(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_s }; int i, ret; - + assert(pcm_handle); assert(f); @@ -290,12 +290,12 @@ static int set_format(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_s if ((ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format_trans[*f])) >= 0) return ret; - + try_auto: for (i = 0; try_order[i] != PA_SAMPLE_INVALID; i++) { *f = try_order[i]; - + if ((ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format_trans[*f])) >= 0) return ret; } @@ -312,14 +312,14 @@ int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, pa_sample_spec *ss, uint32_t *p unsigned int c = ss->channels; pa_sample_format_t f = ss->format; snd_pcm_hw_params_t *hwparams; - + assert(pcm_handle); assert(ss); assert(periods); assert(period_size); buffer_size = *periods * *period_size; - + if ((ret = snd_pcm_hw_params_malloc(&hwparams)) < 0 || (ret = snd_pcm_hw_params_any(pcm_handle, hwparams)) < 0 || (ret = snd_pcm_hw_params_set_rate_resample(pcm_handle, hwparams, 0)) < 0 || @@ -359,25 +359,25 @@ int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, pa_sample_spec *ss, uint32_t *p pa_log_warn("device doesn't support sample format %s, changed to %s.", pa_sample_format_to_string(ss->format), pa_sample_format_to_string(f)); ss->format = f; } - + if ((ret = snd_pcm_prepare(pcm_handle)) < 0) goto finish; if ((ret = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size)) < 0 || (ret = snd_pcm_hw_params_get_period_size(hwparams, period_size, NULL)) < 0) goto finish; - + assert(buffer_size > 0); assert(*period_size > 0); *periods = buffer_size / *period_size; assert(*periods > 0); - + ret = 0; - + finish: if (hwparams) snd_pcm_hw_params_free(hwparams); - + return ret; } @@ -419,7 +419,7 @@ snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const if (fallback) { snd_mixer_selem_id_set_name(sid, fallback); - + if (!(elem = snd_mixer_find_selem(mixer, sid))) pa_log_warn("Cannot find fallback mixer control \"%s\".", snd_mixer_selem_id_get_name(sid)); } diff --git a/src/modules/alsa-util.h b/src/modules/alsa-util.h index 215844b4..675856c6 100644 --- a/src/modules/alsa-util.h +++ b/src/modules/alsa-util.h @@ -5,17 +5,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/src/modules/dbus-util.c b/src/modules/dbus-util.c index 165ccff6..ee9062d1 100644 --- a/src/modules/dbus-util.c +++ b/src/modules/dbus-util.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/src/modules/dbus-util.h b/src/modules/dbus-util.h index 7a9871a4..73501c29 100644 --- a/src/modules/dbus-util.h +++ b/src/modules/dbus-util.h @@ -5,17 +5,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c index 6ff9a6e4..2fea5891 100644 --- a/src/modules/module-alsa-sink.c +++ b/src/modules/module-alsa-sink.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -95,13 +95,13 @@ static void update_usage(struct userdata *u) { static void clear_up(struct userdata *u) { assert(u); - + if (u->sink) { pa_sink_disconnect(u->sink); pa_sink_unref(u->sink); u->sink = NULL; } - + if (u->pcm_fdl) pa_alsa_fdlist_free(u->pcm_fdl); if (u->mixer_fdl) @@ -113,7 +113,7 @@ static void clear_up(struct userdata *u) { snd_mixer_close(u->mixer_handle); u->mixer_handle = NULL; } - + if (u->pcm_handle) { snd_pcm_drop(u->pcm_handle); snd_pcm_close(u->pcm_handle); @@ -126,7 +126,7 @@ static int xrun_recovery(struct userdata *u) { assert(u); pa_log_info("*** ALSA-XRUN (playback) ***"); - + if ((ret = snd_pcm_prepare(u->pcm_handle)) < 0) { pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret)); @@ -142,11 +142,11 @@ static void do_write(struct userdata *u) { assert(u); update_usage(u); - + for (;;) { pa_memchunk *memchunk = NULL; snd_pcm_sframes_t frames; - + if (u->memchunk.memblock) memchunk = &u->memchunk; else { @@ -155,7 +155,7 @@ static void do_write(struct userdata *u) { else memchunk = &u->memchunk; } - + assert(memchunk->memblock && memchunk->memblock->data && memchunk->length && memchunk->memblock->length && (memchunk->length % u->frame_size) == 0); if ((frames = snd_pcm_writei(u->pcm_handle, (uint8_t*) memchunk->memblock->data + memchunk->index, memchunk->length / u->frame_size)) < 0) { @@ -165,7 +165,7 @@ static void do_write(struct userdata *u) { if (frames == -EPIPE) { if (xrun_recovery(u) < 0) return; - + continue; } @@ -187,7 +187,7 @@ static void do_write(struct userdata *u) { memchunk->index = memchunk->length = 0; } } - + break; } } @@ -229,7 +229,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) { struct userdata *u = s->userdata; snd_pcm_sframes_t frames; int err; - + assert(s && u && u->sink); if ((err = snd_pcm_delay(u->pcm_handle, &frames)) < 0) { @@ -292,14 +292,14 @@ static int sink_set_hw_volume_cb(pa_sink *s) { for (i = 0; i < s->hw_volume.channels; i++) { long alsa_vol; - + assert(snd_mixer_selem_has_playback_channel(u->mixer_elem, i)); vol = s->hw_volume.values[i]; if (vol > PA_VOLUME_NORM) vol = PA_VOLUME_NORM; - + alsa_vol = (long) roundf(((float) vol * (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min; if ((err = snd_mixer_selem_set_playback_volume(u->mixer_elem, i, alsa_vol)) < 0) @@ -367,7 +367,7 @@ int pa__init(pa_core *c, pa_module*m) { const char *name; char *name_buf = NULL; int namereg_fail; - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments"); goto fail; @@ -380,7 +380,7 @@ int pa__init(pa_core *c, pa_module*m) { } frame_size = pa_frame_size(&ss); - + /* Fix latency to 100ms */ periods = 8; fragsize = pa_bytes_per_second(&ss)/128; @@ -390,11 +390,11 @@ int pa__init(pa_core *c, pa_module*m) { goto fail; } period_size = fragsize/frame_size; - + u = pa_xnew0(struct userdata, 1); m->userdata = u; u->module = m; - + snd_config_update_free_global(); if ((err = snd_pcm_open(&u->pcm_handle, dev = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) { pa_log("Error opening PCM device %s: %s", dev, snd_strerror(err)); @@ -415,7 +415,7 @@ int pa__init(pa_core *c, pa_module*m) { if (ss.channels != map.channels) /* Seems ALSA didn't like the channel number, so let's fix the channel map */ pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_ALSA); - + if ((err = snd_mixer_open(&u->mixer_handle, 0)) < 0) { pa_log("Error opening mixer: %s", snd_strerror(err)); goto fail; @@ -486,7 +486,7 @@ int pa__init(pa_core *c, pa_module*m) { snd_mixer_elem_set_callback_private(u->mixer_elem, u); } else u->mixer_fdl = NULL; - + u->frame_size = frame_size; u->fragment_size = period_size * frame_size; @@ -499,7 +499,7 @@ int pa__init(pa_core *c, pa_module*m) { u->memchunk.memblock = NULL; u->memchunk.index = u->memchunk.length = 0; - + ret = 0; /* Get initial mixer settings */ @@ -507,21 +507,21 @@ int pa__init(pa_core *c, pa_module*m) { u->sink->get_hw_volume(u->sink); if (u->sink->get_hw_mute) u->sink->get_hw_mute(u->sink); - + finish: pa_xfree(name_buf); - + if (ma) pa_modargs_free(ma); if (pcm_info) snd_pcm_info_free(pcm_info); - + return ret; fail: - + if (u) pa__done(c, m); @@ -541,7 +541,7 @@ void pa__done(pa_core *c, pa_module*m) { pa_memblock_unref(u->memchunk.memblock); if (u->silence.memblock) pa_memblock_unref(u->silence.memblock); - + pa_xfree(u); } diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c index aa0666f1..596998d1 100644 --- a/src/modules/module-alsa-source.c +++ b/src/modules/module-alsa-source.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -96,13 +96,13 @@ static void update_usage(struct userdata *u) { static void clear_up(struct userdata *u) { assert(u); - + if (u->source) { pa_source_disconnect(u->source); pa_source_unref(u->source); u->source = NULL; } - + if (u->pcm_fdl) pa_alsa_fdlist_free(u->pcm_fdl); if (u->mixer_fdl) @@ -114,7 +114,7 @@ static void clear_up(struct userdata *u) { snd_mixer_close(u->mixer_handle); u->mixer_handle = NULL; } - + if (u->pcm_handle) { snd_pcm_drop(u->pcm_handle); snd_pcm_close(u->pcm_handle); @@ -127,7 +127,7 @@ static int xrun_recovery(struct userdata *u) { assert(u); pa_log_info("*** ALSA-XRUN (capture) ***"); - + if ((ret = snd_pcm_prepare(u->pcm_handle)) < 0) { pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret)); @@ -144,17 +144,17 @@ static void do_read(struct userdata *u) { assert(u); update_usage(u); - + for (;;) { pa_memchunk post_memchunk; snd_pcm_sframes_t frames; size_t l; - + if (!u->memchunk.memblock) { u->memchunk.memblock = pa_memblock_new(u->source->core->mempool, u->memchunk.length = u->fragment_size); u->memchunk.index = 0; } - + assert(u->memchunk.memblock); assert(u->memchunk.length); assert(u->memchunk.memblock->data); @@ -164,11 +164,11 @@ static void do_read(struct userdata *u) { if ((frames = snd_pcm_readi(u->pcm_handle, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length / u->frame_size)) < 0) { if (frames == -EAGAIN) return; - + if (frames == -EPIPE) { if (xrun_recovery(u) < 0) return; - + continue; } @@ -180,7 +180,7 @@ static void do_read(struct userdata *u) { } l = frames * u->frame_size; - + post_memchunk = u->memchunk; post_memchunk.length = l; @@ -188,13 +188,13 @@ static void do_read(struct userdata *u) { u->memchunk.index += l; u->memchunk.length -= l; - + if (u->memchunk.length == 0) { pa_memblock_unref(u->memchunk.memblock); u->memchunk.memblock = NULL; u->memchunk.index = u->memchunk.length = 0; } - + break; } } @@ -223,7 +223,7 @@ static int mixer_callback(snd_mixer_elem_t *elem, unsigned int mask) { u->source->get_hw_volume(u->source); if (u->source->get_hw_mute) u->source->get_hw_mute(u->source); - + pa_subscription_post(u->source->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, u->source->index); @@ -256,14 +256,14 @@ static int source_get_hw_volume_cb(pa_source *s) { for (i = 0;i < s->hw_volume.channels;i++) { long set_vol; - + assert(snd_mixer_selem_has_capture_channel(u->mixer_elem, i)); - + if ((err = snd_mixer_selem_get_capture_volume(u->mixer_elem, i, &vol)) < 0) goto fail; set_vol = (long) roundf(((float) s->hw_volume.values[i] * (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min; - + /* Try to avoid superfluous volume changes */ if (set_vol != vol) s->hw_volume.values[i] = (pa_volume_t) roundf(((float) (vol - u->hw_volume_min) * PA_VOLUME_NORM) / (u->hw_volume_max - u->hw_volume_min)); @@ -361,7 +361,7 @@ int pa__init(pa_core *c, pa_module*m) { const char *name; char *name_buf = NULL; int namereg_fail; - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments"); goto fail; @@ -378,17 +378,17 @@ int pa__init(pa_core *c, pa_module*m) { /* Fix latency to 100ms */ periods = 12; fragsize = pa_bytes_per_second(&ss)/128; - + if (pa_modargs_get_value_u32(ma, "fragments", &periods) < 0 || pa_modargs_get_value_u32(ma, "fragment_size", &fragsize) < 0) { pa_log("failed to parse buffer metrics"); goto fail; } period_size = fragsize/frame_size; - + u = pa_xnew0(struct userdata, 1); m->userdata = u; u->module = m; - + snd_config_update_free_global(); if ((err = snd_pcm_open(&u->pcm_handle, dev = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)) < 0) { pa_log("Error opening PCM device %s: %s", dev, snd_strerror(err)); @@ -427,7 +427,7 @@ int pa__init(pa_core *c, pa_module*m) { name = name_buf = pa_sprintf_malloc("alsa_input.%s", dev); namereg_fail = 0; } - + if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map))) { pa_log("Failed to create source object"); goto fail; @@ -490,7 +490,7 @@ int pa__init(pa_core *c, pa_module*m) { u->memchunk.index = u->memchunk.length = 0; snd_pcm_start(u->pcm_handle); - + ret = 0; /* Get initial mixer settings */ @@ -507,11 +507,11 @@ finish: if (pcm_info) snd_pcm_info_free(pcm_info); - + return ret; fail: - + if (u) pa__done(c, m); @@ -526,10 +526,10 @@ void pa__done(pa_core *c, pa_module*m) { return; clear_up(u); - + if (u->memchunk.memblock) pa_memblock_unref(u->memchunk.memblock); - + pa_xfree(u); } diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index d5374838..b5c27299 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -48,7 +48,7 @@ static const char* const valid_modargs[] = { static void eof_and_unload_cb(pa_cli*c, void *userdata) { pa_module *m = userdata; - + assert(c); assert(m); @@ -68,7 +68,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_iochannel *io; pa_modargs *ma; int exit_on_eof = 0; - + assert(c); assert(m); @@ -81,7 +81,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse module arguments."); goto fail; } - + if (pa_modargs_get_value_boolean(ma, "exit_on_eof", &exit_on_eof) < 0) { pa_log("exit_on_eof= expects boolean argument."); goto fail; @@ -102,7 +102,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m); pa_modargs_free(ma); - + return 0; fail: diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c index f3bb3fd3..6bc958aa 100644 --- a/src/modules/module-combine.c +++ b/src/modules/module-combine.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -91,7 +91,7 @@ struct userdata { struct output *master; pa_time_event *time_event; uint32_t adjust_time; - + PA_LLIST_HEAD(struct output, outputs); }; @@ -110,9 +110,9 @@ static void adjust_rates(struct userdata *u) { for (o = u->outputs; o; o = o->next) { uint32_t sink_latency = o->sink_input->sink ? pa_sink_get_latency(o->sink_input->sink) : 0; - + o->total_latency = sink_latency + pa_sink_input_get_latency(o->sink_input); - + if (sink_latency > max_sink_latency) max_sink_latency = sink_latency; @@ -123,14 +123,14 @@ static void adjust_rates(struct userdata *u) { assert(min_total_latency != (pa_usec_t) -1); target_latency = max_sink_latency > min_total_latency ? max_sink_latency : min_total_latency; - + pa_log_info("[%s] target latency is %0.0f usec.", u->sink->name, (float) target_latency); base_rate = u->sink->sample_spec.rate; for (o = u->outputs; o; o = o->next) { - uint32_t r = base_rate; - + uint32_t r = base_rate; + if (o->total_latency < target_latency) r -= (uint32_t) (((((double) target_latency - o->total_latency))/u->adjust_time)*r/ 1000000); else if (o->total_latency > target_latency) @@ -151,7 +151,7 @@ static void request_memblock(struct userdata *u) { assert(u && u->sink); update_usage(u); - + if (pa_sink_render(u->sink, RENDER_SIZE, &chunk) < 0) return; @@ -179,10 +179,10 @@ static int sink_input_peek_cb(pa_sink_input *i, pa_memchunk *chunk) { if (pa_memblockq_peek(o->memblockq, chunk) >= 0) return 0; - + /* Try harder */ request_memblock(o->userdata); - + return pa_memblockq_peek(o->memblockq, chunk); } @@ -204,7 +204,7 @@ static void sink_input_kill_cb(pa_sink_input *i) { static pa_usec_t sink_input_get_latency_cb(pa_sink_input *i) { struct output *o = i->userdata; assert(i && o && o->sink_input); - + return pa_bytes_to_usec(pa_memblockq_get_length(o->memblockq), &i->sample_spec); } @@ -220,11 +220,11 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) { static void sink_notify(pa_sink *s) { struct userdata *u; struct output *o; - + assert(s); u = s->userdata; assert(u); - + for (o = u->outputs; o; o = o->next) pa_sink_notify(o->sink_input->sink); } @@ -233,12 +233,12 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample struct output *o = NULL; char t[256]; pa_sink_input_new_data data; - + assert(u && sink && u->sink); - + o = pa_xmalloc(sizeof(struct output)); o->userdata = u; - + o->counter = 0; o->memblockq = pa_memblockq_new( 0, @@ -258,7 +258,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample pa_sink_input_new_data_set_sample_spec(&data, &u->sink->sample_spec); pa_sink_input_new_data_set_channel_map(&data, &u->sink->channel_map); data.module = u->module; - + if (!(o->sink_input = pa_sink_input_new(u->core, &data, PA_SINK_INPUT_VARIABLE_RATE))) goto fail; @@ -267,7 +267,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample o->sink_input->drop = sink_input_drop_cb; o->sink_input->kill = sink_input_kill_cb; o->sink_input->userdata = o; - + PA_LLIST_PREPEND(struct output, u->outputs, o); u->n_outputs++; return o; @@ -282,7 +282,7 @@ fail: if (o->memblockq) pa_memblockq_free(o->memblockq); - + pa_xfree(o); } @@ -302,17 +302,17 @@ static void output_free(struct output *o) { static void clear_up(struct userdata *u) { struct output *o; assert(u); - + if (u->time_event) { u->core->mainloop->time_free(u->time_event); u->time_event = NULL; } - + while ((o = u->outputs)) output_free(o); u->master = NULL; - + if (u->sink) { pa_sink_disconnect(u->sink); pa_sink_unref(u->sink); @@ -331,7 +331,7 @@ int pa__init(pa_core *c, pa_module*m) { int resample_method = -1; pa_sample_spec ss; pa_channel_map map; - + assert(c && m); if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { @@ -345,7 +345,7 @@ int pa__init(pa_core *c, pa_module*m) { goto fail; } } - + u = pa_xnew(struct userdata, 1); m->userdata = u; u->sink = NULL; @@ -361,7 +361,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse adjust_time value"); goto fail; } - + if (!(master_name = pa_modargs_get_value(ma, "master", NULL)) || !(slaves = pa_modargs_get_value(ma, "slaves", NULL))) { pa_log("no master or slave sinks specified"); goto fail; @@ -392,7 +392,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("channel map and sample specification don't match."); goto fail; } - + if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) { pa_log("failed to create sink"); goto fail; @@ -403,16 +403,16 @@ int pa__init(pa_core *c, pa_module*m) { u->sink->get_latency = sink_get_latency_cb; u->sink->notify = sink_notify; u->sink->userdata = u; - + if (!(u->master = output_new(u, master_sink, resample_method))) { pa_log("failed to create master sink input on sink '%s'.", u->sink->name); goto fail; } - + split_state = NULL; while ((n = pa_split(slaves, ",", &split_state))) { pa_sink *slave_sink; - + if (!(slave_sink = pa_namereg_get(c, n, PA_NAMEREG_SINK, 1))) { pa_log("invalid slave sink '%s'", n); goto fail; @@ -425,7 +425,7 @@ int pa__init(pa_core *c, pa_module*m) { goto fail; } } - + if (u->n_outputs <= 1) pa_log_warn("WARNING: no slave sinks specified."); @@ -434,13 +434,13 @@ int pa__init(pa_core *c, pa_module*m) { tv.tv_sec += u->adjust_time; u->time_event = c->mainloop->time_new(c->mainloop, &tv, time_callback, u); } - + pa_modargs_free(ma); - return 0; + return 0; fail: pa_xfree(n); - + if (ma) pa_modargs_free(ma); diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 84ccd14c..3057f70d 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -58,7 +58,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (errno != ENOENT) pa_log_error("open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno)); - + return -1; } @@ -66,7 +66,7 @@ static int detect_alsa(pa_core *c, int just_one) { char line[64], args[64]; unsigned device, subdevice; int is_sink; - + if (!fgets(line, sizeof(line), f)) break; @@ -81,7 +81,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (just_one && is_sink && n_sink >= 1) continue; - + if (just_one && !is_sink && n_source >= 1) continue; @@ -105,7 +105,7 @@ static int detect_alsa(pa_core *c, int just_one) { } fclose(f); - + return n; } #endif @@ -114,7 +114,7 @@ static int detect_alsa(pa_core *c, int just_one) { static int detect_oss(pa_core *c, int just_one) { FILE *f; int n = 0, b = 0; - + if (!(f = fopen("/dev/sndstat", "r")) && !(f = fopen("/proc/sndstat", "r")) && !(f = fopen("/proc/asound/oss/sndstat", "r"))) { @@ -128,7 +128,7 @@ static int detect_oss(pa_core *c, int just_one) { while (!feof(f)) { char line[64], args[64]; unsigned device; - + if (!fgets(line, sizeof(line), f)) break; @@ -141,20 +141,20 @@ static int detect_oss(pa_core *c, int just_one) { if (line[0] == 0) break; - + if (sscanf(line, "%u: ", &device) == 1) { if (device == 0) snprintf(args, sizeof(args), "device=/dev/dsp"); else snprintf(args, sizeof(args), "device=/dev/dsp%u", device); - + if (!pa_module_load(c, "module-oss", args)) continue; - + } else if (sscanf(line, "pcm%u: ", &device) == 1) { /* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */ snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device); - + if (!pa_module_load(c, "module-oss", args)) continue; } @@ -219,7 +219,7 @@ int pa__init(pa_core *c, pa_module*m) { "just-one", NULL }; - + assert(c); assert(m); @@ -227,14 +227,14 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("Failed to parse module arguments"); goto fail; } - + if (pa_modargs_get_value_boolean(ma, "just-one", &just_one) < 0) { pa_log("just_one= expects a boolean argument."); goto fail; } #if HAVE_ALSA - if ((n = detect_alsa(c, just_one)) <= 0) + if ((n = detect_alsa(c, just_one)) <= 0) #endif #if HAVE_OSS if ((n = detect_oss(c, just_one)) <= 0) @@ -251,7 +251,7 @@ int pa__init(pa_core *c, pa_module*m) { } pa_log_info("loaded %i modules.", n); - + /* We were successful and can unload ourselves now. */ pa_module_unload_request(m); @@ -262,7 +262,7 @@ int pa__init(pa_core *c, pa_module*m) { fail: if (ma) pa_modargs_free(ma); - + return -1; } diff --git a/src/modules/module-esound-compat-spawnfd.c b/src/modules/module-esound-compat-spawnfd.c index 263e81f9..fbb6bd6d 100644 --- a/src/modules/module-esound-compat-spawnfd.c +++ b/src/modules/module-esound-compat-spawnfd.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/src/modules/module-esound-compat-spawnpid.c b/src/modules/module-esound-compat-spawnpid.c index 7a662c2d..a7196313 100644 --- a/src/modules/module-esound-compat-spawnpid.c +++ b/src/modules/module-esound-compat-spawnpid.c @@ -1,17 +1,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c index 6d4a8489..62600682 100644 --- a/src/modules/module-esound-sink.c +++ b/src/modules/module-esound-sink.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -69,7 +69,7 @@ struct userdata { void *write_data; size_t write_length, write_index; - + void *read_data; size_t read_length, read_index; @@ -135,7 +135,7 @@ static int do_write(struct userdata *u) { u->write_index += r; assert(u->write_index <= u->write_length); - + if (u->write_index == u->write_length) { free(u->write_data); u->write_data = NULL; @@ -143,13 +143,13 @@ static int do_write(struct userdata *u) { } } else if (u->state == STATE_RUNNING) { pa_module_set_used(u->module, pa_sink_used_by(u->sink)); - + if (!u->memchunk.length) if (pa_sink_render(u->sink, 8192, &u->memchunk) < 0) return 0; assert(u->memchunk.memblock && u->memchunk.length); - + if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) { pa_log("write() failed: %s", pa_cstrerror(errno)); return -1; @@ -157,13 +157,13 @@ static int do_write(struct userdata *u) { u->memchunk.index += r; u->memchunk.length -= r; - + if (u->memchunk.length <= 0) { pa_memblock_unref(u->memchunk.memblock); u->memchunk.memblock = NULL; } } - + return 0; } @@ -191,7 +191,7 @@ static int handle_response(struct userdata *u) { assert(u->read_length >= sizeof(int32_t)); u->read_index = 0; u->read_length = sizeof(int32_t); - + break; case STATE_LATENCY: { @@ -220,10 +220,10 @@ static int handle_response(struct userdata *u) { pa_xfree(u->read_data); u->read_data = NULL; u->read_index = u->read_length = 0; - + break; } - + default: abort(); } @@ -233,18 +233,18 @@ static int handle_response(struct userdata *u) { static int do_read(struct userdata *u) { assert(u); - + if (!pa_iochannel_is_readable(u->io)) return 0; - + if (u->state == STATE_AUTH || u->state == STATE_LATENCY) { ssize_t r; - + if (!u->read_data) return 0; - + assert(u->read_index < u->read_length); - + if ((r = pa_iochannel_read(u->io, (uint8_t*) u->read_data + u->read_index, u->read_length - u->read_index)) <= 0) { pa_log("read() failed: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); cancel(u); @@ -265,7 +265,7 @@ static void do_work(struct userdata *u) { assert(u); u->core->mainloop->defer_enable(u->defer_event, 0); - + if (do_read(u) < 0 || do_write(u) < 0) cancel(u); } @@ -304,13 +304,13 @@ static void on_connection(PA_GCC_UNUSED pa_socket_client *c, pa_iochannel*io, vo pa_socket_client_unref(u->client); u->client = NULL; - + if (!io) { pa_log("connection failed: %s", pa_cstrerror(errno)); cancel(u); return; } - + u->io = io; pa_iochannel_set_callback(u->io, io_callback, u); } @@ -321,9 +321,9 @@ int pa__init(pa_core *c, pa_module*m) { pa_sample_spec ss; pa_modargs *ma = NULL; char *t; - + assert(c && m); - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments"); goto fail; @@ -340,7 +340,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("esound sample type support is limited to mono/stereo and U8 or S16NE sample data"); goto fail; } - + u = pa_xmalloc0(sizeof(struct userdata)); u->core = c; u->module = m; @@ -378,7 +378,7 @@ int pa__init(pa_core *c, pa_module*m) { /* Reserve space for the response */ u->read_data = pa_xmalloc(u->read_length = sizeof(int32_t)); - + u->sink->notify = notify_cb; u->sink->get_latency = get_latency_cb; u->sink->userdata = u; @@ -392,15 +392,15 @@ int pa__init(pa_core *c, pa_module*m) { u->defer_event = c->mainloop->defer_new(c->mainloop, defer_callback, u); c->mainloop->defer_enable(u->defer_event, 0); - + pa_modargs_free(ma); - + return 0; fail: if (ma) pa_modargs_free(ma); - + pa__done(c, m); return -1; @@ -415,13 +415,13 @@ void pa__done(pa_core *c, pa_module*m) { u->module = NULL; cancel(u); - + if (u->memchunk.memblock) pa_memblock_unref(u->memchunk.memblock); if (u->client) pa_socket_client_unref(u->client); - + pa_xfree(u->read_data); pa_xfree(u->write_data); diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c index 8232cd38..eb275ff0 100644 --- a/src/modules/module-hal-detect.c +++ b/src/modules/module-hal-detect.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -58,7 +58,7 @@ typedef enum { #endif #ifdef HAVE_OSS CAP_OSS, -#endif +#endif CAP_MAX } capability_t; @@ -181,7 +181,7 @@ static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi, module_name = "module-alsa-source"; snprintf(args, sizeof(args), "device=hw:%u source_name=alsa_input.%s", card, strip_udi(udi)); } - + return pa_module_load(u->core, module_name, args); } @@ -198,7 +198,7 @@ static dbus_bool_t hal_device_is_oss_pcm(LibHalContext *ctx, const char *udi, type = libhal_device_get_property_string(ctx, udi, "oss.type", error); if (!type || dbus_error_is_set(error)) return FALSE; - + if (!strcmp(type, "pcm")) { char *e; diff --git a/src/modules/module-jack-sink.c b/src/modules/module-jack-sink.c index 47f77bab..6175536c 100644 --- a/src/modules/module-jack-sink.c +++ b/src/modules/module-jack-sink.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -75,7 +75,7 @@ struct userdata { pthread_mutex_t mutex; pthread_cond_t cond; - + void * buffer[PA_CHANNELS_MAX]; jack_nframes_t frames_requested; int quit_requested; @@ -100,7 +100,7 @@ static const char* const valid_modargs[] = { static void stop_sink(struct userdata *u) { assert (u); - + jack_client_close(u->client); u->client = NULL; u->core->mainloop->io_free(u->io_event); @@ -114,7 +114,7 @@ static void stop_sink(struct userdata *u) { static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_flags_t flags, void *userdata) { struct userdata *u = userdata; char x; - + assert(m); assert(e); assert(flags == PA_IO_EVENT_INPUT); @@ -122,39 +122,39 @@ static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_ assert(u->pipe_fds[0] == fd); pa_read(fd, &x, 1, &u->pipe_fd_type); - + if (u->quit_requested) { stop_sink(u); u->quit_requested = 0; return; } - + pthread_mutex_lock(&u->mutex); if (u->frames_requested > 0) { unsigned fs; jack_nframes_t frame_idx; pa_memchunk chunk; - + fs = pa_frame_size(&u->sink->sample_spec); pa_sink_render_full(u->sink, u->frames_requested * fs, &chunk); for (frame_idx = 0; frame_idx < u->frames_requested; frame_idx ++) { unsigned c; - + for (c = 0; c < u->channels; c++) { float *s = ((float*) ((uint8_t*) chunk.memblock->data + chunk.index)) + (frame_idx * u->channels) + c; float *d = ((float*) u->buffer[c]) + frame_idx; - + *d = *s; } } - + pa_memblock_unref(chunk.memblock); u->frames_requested = 0; - + pthread_cond_signal(&u->cond); } @@ -183,36 +183,36 @@ static int jack_process(jack_nframes_t nframes, void *arg) { if (jack_transport_query(u->client, NULL) == JackTransportRolling) { unsigned c; - + pthread_mutex_lock(&u->mutex); - + u->frames_requested = nframes; - + for (c = 0; c < u->channels; c++) { u->buffer[c] = jack_port_get_buffer(u->port[c], nframes); assert(u->buffer[c]); } - + request_render(u); - + pthread_cond_wait(&u->cond, &u->mutex); u->frames_in_buffer = nframes; u->timestamp = jack_get_current_transport_frame(u->client); - + pthread_mutex_unlock(&u->mutex); } - + return 0; } static pa_usec_t sink_get_latency_cb(pa_sink *s) { struct userdata *u; jack_nframes_t n, l, d; - + assert(s); u = s->userdata; - + if (jack_transport_query(u->client, NULL) != JackTransportRolling) return 0; @@ -226,7 +226,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) { if (d >= l) return 0; - + return pa_bytes_to_usec((l - d) * pa_frame_size(&s->sample_spec), &s->sample_spec); } @@ -246,12 +246,12 @@ int pa__init(pa_core *c, pa_module*m) { unsigned i; const char **ports = NULL, **p; char *t; - + assert(c); assert(m); jack_set_error_function(jack_error_func); - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments."); goto fail; @@ -261,7 +261,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse connect= argument."); goto fail; } - + server_name = pa_modargs_get_value(ma, "server_name", NULL); client_name = pa_modargs_get_value(ma, "client_name", "PulseAudio"); @@ -274,28 +274,28 @@ int pa__init(pa_core *c, pa_module*m) { pthread_mutex_init(&u->mutex, NULL); pthread_cond_init(&u->cond, NULL); - + if (pipe(u->pipe_fds) < 0) { pa_log("pipe() failed: %s", pa_cstrerror(errno)); goto fail; } pa_make_nonblock_fd(u->pipe_fds[1]); - + if (!(u->client = jack_client_open(client_name, server_name ? JackServerName : JackNullOption, &status, server_name))) { pa_log("jack_client_open() failed."); goto fail; } ports = jack_get_ports(u->client, NULL, NULL, JackPortIsPhysical|JackPortIsInput); - + channels = 0; for (p = ports; *p; p++) channels++; if (!channels) channels = c->default_sample_spec.channels; - + if (pa_modargs_get_value_u32(ma, "channels", &channels) < 0 || channels <= 0 || channels >= PA_CHANNELS_MAX) { pa_log("failed to parse channels= argument."); goto fail; @@ -306,7 +306,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse channel_map= argument."); goto fail; } - + pa_log_info("Successfully connected as '%s'", jack_get_client_name(u->client)); ss.channels = u->channels = channels; @@ -350,7 +350,7 @@ int pa__init(pa_core *c, pa_module*m) { } pa_log_info("connecting %s to %s", jack_port_name(u->port[i]), *p); - + if (jack_connect(u->client, jack_port_name(u->port[i]), *p)) { pa_log("failed to connect %s to %s, leaving unconnected.", jack_port_name(u->port[i]), *p); break; @@ -360,10 +360,10 @@ int pa__init(pa_core *c, pa_module*m) { } u->io_event = c->mainloop->io_new(c->mainloop, u->pipe_fds[0], PA_IO_EVENT_INPUT, io_event_cb, u); - + free(ports); pa_modargs_free(ma); - + return 0; fail: @@ -371,7 +371,7 @@ fail: pa_modargs_free(ma); free(ports); - + pa__done(c, m); return -1; diff --git a/src/modules/module-jack-source.c b/src/modules/module-jack-source.c index 62a99108..8d891ce6 100644 --- a/src/modules/module-jack-source.c +++ b/src/modules/module-jack-source.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -75,7 +75,7 @@ struct userdata { pthread_mutex_t mutex; pthread_cond_t cond; - + void * buffer[PA_CHANNELS_MAX]; jack_nframes_t frames_posted; int quit_requested; @@ -100,7 +100,7 @@ static const char* const valid_modargs[] = { static void stop_source(struct userdata *u) { assert (u); - + jack_client_close(u->client); u->client = NULL; u->core->mainloop->io_free(u->io_event); @@ -114,39 +114,39 @@ static void stop_source(struct userdata *u) { static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_flags_t flags, void *userdata) { struct userdata *u = userdata; char x; - + assert(m); assert(flags == PA_IO_EVENT_INPUT); assert(u); assert(u->pipe_fds[0] == fd); pa_read(fd, &x, 1, &u->pipe_fd_type); - + if (u->quit_requested) { stop_source(u); u->quit_requested = 0; return; } - + pthread_mutex_lock(&u->mutex); if (u->frames_posted > 0) { unsigned fs; jack_nframes_t frame_idx; pa_memchunk chunk; - + fs = pa_frame_size(&u->source->sample_spec); chunk.memblock = pa_memblock_new(u->core->mempool, chunk.length = u->frames_posted * fs); chunk.index = 0; - + for (frame_idx = 0; frame_idx < u->frames_posted; frame_idx ++) { unsigned c; - + for (c = 0; c < u->channels; c++) { float *s = ((float*) u->buffer[c]) + frame_idx; float *d = ((float*) ((uint8_t*) chunk.memblock->data + chunk.index)) + (frame_idx * u->channels) + c; - + *d = *s; } } @@ -155,7 +155,7 @@ static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_ pa_memblock_unref(chunk.memblock); u->frames_posted = 0; - + pthread_cond_signal(&u->cond); } @@ -184,36 +184,36 @@ static int jack_process(jack_nframes_t nframes, void *arg) { if (jack_transport_query(u->client, NULL) == JackTransportRolling) { unsigned c; - + pthread_mutex_lock(&u->mutex); - + u->frames_posted = nframes; - + for (c = 0; c < u->channels; c++) { u->buffer[c] = jack_port_get_buffer(u->port[c], nframes); assert(u->buffer[c]); } - + request_post(u); - + pthread_cond_wait(&u->cond, &u->mutex); u->frames_in_buffer = nframes; u->timestamp = jack_get_current_transport_frame(u->client); - + pthread_mutex_unlock(&u->mutex); } - + return 0; } static pa_usec_t source_get_latency_cb(pa_source *s) { struct userdata *u; jack_nframes_t n, l, d; - + assert(s); u = s->userdata; - + if (jack_transport_query(u->client, NULL) != JackTransportRolling) return 0; @@ -224,7 +224,7 @@ static pa_usec_t source_get_latency_cb(pa_source *s) { d = n - u->timestamp; l = jack_port_get_total_latency(u->client, u->port[0]); - + return pa_bytes_to_usec((l + d) * pa_frame_size(&s->sample_spec), &s->sample_spec); } @@ -244,12 +244,12 @@ int pa__init(pa_core *c, pa_module*m) { unsigned i; const char **ports = NULL, **p; char *t; - + assert(c); assert(m); jack_set_error_function(jack_error_func); - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments."); goto fail; @@ -259,7 +259,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse connect= argument."); goto fail; } - + server_name = pa_modargs_get_value(ma, "server_name", NULL); client_name = pa_modargs_get_value(ma, "client_name", "PulseAudio"); @@ -272,28 +272,28 @@ int pa__init(pa_core *c, pa_module*m) { pthread_mutex_init(&u->mutex, NULL); pthread_cond_init(&u->cond, NULL); - + if (pipe(u->pipe_fds) < 0) { pa_log("pipe() failed: %s", pa_cstrerror(errno)); goto fail; } pa_make_nonblock_fd(u->pipe_fds[1]); - + if (!(u->client = jack_client_open(client_name, server_name ? JackServerName : JackNullOption, &status, server_name))) { pa_log("jack_client_open() failed."); goto fail; } ports = jack_get_ports(u->client, NULL, NULL, JackPortIsPhysical|JackPortIsOutput); - + channels = 0; for (p = ports; *p; p++) channels++; if (!channels) channels = c->default_sample_spec.channels; - + if (pa_modargs_get_value_u32(ma, "channels", &channels) < 0 || channels <= 0 || channels >= PA_CHANNELS_MAX) { pa_log("failed to parse channels= argument."); goto fail; @@ -304,7 +304,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse channel_map= argument."); goto fail; } - + pa_log_info("Successfully connected as '%s'", jack_get_client_name(u->client)); ss.channels = u->channels = channels; @@ -348,7 +348,7 @@ int pa__init(pa_core *c, pa_module*m) { } pa_log_info("connecting %s to %s", jack_port_name(u->port[i]), *p); - + if (jack_connect(u->client, *p, jack_port_name(u->port[i]))) { pa_log("failed to connect %s to %s, leaving unconnected.", jack_port_name(u->port[i]), *p); break; @@ -358,10 +358,10 @@ int pa__init(pa_core *c, pa_module*m) { } u->io_event = c->mainloop->io_new(c->mainloop, u->pipe_fds[0], PA_IO_EVENT_INPUT, io_event_cb, u); - + free(ports); pa_modargs_free(ma); - + return 0; fail: @@ -369,7 +369,7 @@ fail: pa_modargs_free(ma); free(ports); - + pa__done(c, m); return -1; diff --git a/src/modules/module-lirc.c b/src/modules/module-lirc.c index 18b2ddf1..f32667ee 100644 --- a/src/modules/module-lirc.c +++ b/src/modules/module-lirc.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -73,20 +73,20 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC pa_log("lost connection to LIRC daemon."); goto fail; } - + if (events & PA_IO_EVENT_INPUT) { char *c; - + if (lirc_nextcode(&code) != 0 || !code) { pa_log("lirc_nextcode() failed."); goto fail; } - + c = pa_xstrdup(code); c[strcspn(c, "\n\r")] = 0; pa_log_debug("raw IR code '%s'", c); pa_xfree(c); - + while (lirc_code2char(u->config, code, &name) == 0 && name) { enum { INVALID, @@ -96,9 +96,9 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC RESET, MUTE_TOGGLE } volchange = INVALID; - + pa_log_info("translated IR code '%s'", name); - + if (strcasecmp(name, "volume-up") == 0) volchange = UP; else if (strcasecmp(name, "volume-down") == 0) @@ -109,12 +109,12 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC volchange = MUTE_TOGGLE; else if (strcasecmp(name, "reset") == 0) volchange = RESET; - + if (volchange == INVALID) pa_log_warn("recieved unknown IR code '%s'", name); else { pa_sink *s; - + if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1))) pa_log("failed to get sink '%s'", u->sink_name); else { @@ -134,7 +134,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv); break; - + case DOWN: for (i = 0; i < cv.channels; i++) { if (cv.values[i] >= DELTA) @@ -142,18 +142,18 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC else cv.values[i] = PA_VOLUME_MUTED; } - + pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv); break; - + case MUTE: pa_sink_set_mute(s, PA_MIXER_HARDWARE, 0); break; - + case RESET: pa_sink_set_mute(s, PA_MIXER_HARDWARE, 1); break; - + case MUTE_TOGGLE: pa_sink_set_mute(s, PA_MIXER_HARDWARE, !pa_sink_get_mute(s, PA_MIXER_HARDWARE)); @@ -170,7 +170,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC pa_xfree(code); return; - + fail: u->module->core->mainloop->io_free(u->io); u->io = NULL; @@ -179,7 +179,7 @@ fail: free(code); } - + int pa__init(pa_core *c, pa_module*m) { pa_modargs *ma = NULL; struct userdata *u; @@ -189,7 +189,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("module-lirc may no be loaded twice."); return -1; } - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("Failed to parse module arguments"); goto fail; @@ -212,13 +212,13 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("lirc_readconfig() failed."); goto fail; } - + u->io = c->mainloop->io_new(c->mainloop, u->lirc_fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u); lirc_in_use = 1; pa_modargs_free(ma); - + return 0; fail: diff --git a/src/modules/module-match.c b/src/modules/module-match.c index eb5de64e..d0e82ba3 100644 --- a/src/modules/module-match.c +++ b/src/modules/module-match.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -88,7 +88,7 @@ static int load_rules(struct userdata *u, const char *filename) { } pa_lock_fd(fileno(f), 1); - + while (!feof(f)) { char *d, *v; pa_volume_t volume; @@ -96,12 +96,12 @@ static int load_rules(struct userdata *u, const char *filename) { regex_t regex; char ln[256]; struct rule *rule; - + if (!fgets(ln, sizeof(ln), f)) break; n++; - + pa_strip_nl(ln); if (ln[0] == '#' || !*ln ) @@ -110,7 +110,7 @@ static int load_rules(struct userdata *u, const char *filename) { d = ln+strcspn(ln, WHITESPACE); v = d+strspn(d, WHITESPACE); - + if (!*v) { pa_log(__FILE__ ": [%s:%u] failed to parse line - too few words", filename, n); goto finish; @@ -124,7 +124,7 @@ static int load_rules(struct userdata *u, const char *filename) { volume = (pa_volume_t) k; - + if (regcomp(®ex, ln, REG_EXTENDED|REG_NOSUB) != 0) { pa_log("[%s:%u] invalid regular expression", filename, n); goto finish; @@ -140,12 +140,12 @@ static int load_rules(struct userdata *u, const char *filename) { else u->rules = rule; end = rule; - + *d = 0; } ret = 0; - + finish: if (f) { pa_lock_fd(fileno(f), 0); @@ -172,7 +172,7 @@ static void callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, v if (!si->name) return; - + for (r = u->rules; r; r = r->next) { if (!regexec(&r->regex, si->name, 0, NULL, 0)) { pa_cvolume cv; @@ -197,7 +197,7 @@ int pa__init(pa_core *c, pa_module*m) { u->rules = NULL; u->subscription = NULL; m->userdata = u; - + if (load_rules(u, pa_modargs_get_value(ma, "table", NULL)) < 0) goto fail; @@ -224,7 +224,7 @@ void pa__done(pa_core *c, pa_module*m) { if (u->subscription) pa_subscription_free(u->subscription); - + for (r = u->rules; r; r = n) { n = r->next; diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c index 37234d92..baf688f1 100644 --- a/src/modules/module-mmkbd-evdev.c +++ b/src/modules/module-mmkbd-evdev.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -85,7 +85,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC pa_log("lost connection to evdev device."); goto fail; } - + if (events & PA_IO_EVENT_INPUT) { struct input_event ev; @@ -107,15 +107,15 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC if (volchange != INVALID) { pa_sink *s; - + if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1))) pa_log("failed to get sink '%s'", u->sink_name); else { int i; pa_cvolume cv = *pa_sink_get_volume(s, PA_MIXER_HARDWARE); - + #define DELTA (PA_VOLUME_NORM/20) - + switch (volchange) { case UP: for (i = 0; i < cv.channels; i++) { @@ -127,7 +127,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv); break; - + case DOWN: for (i = 0; i < cv.channels; i++) { if (cv.values[i] >= DELTA) @@ -135,10 +135,10 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC else cv.values[i] = PA_VOLUME_MUTED; } - + pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv); break; - + case MUTE_TOGGLE: pa_sink_set_mute(s, PA_MIXER_HARDWARE, !pa_sink_get_mute(s, PA_MIXER_HARDWARE)); @@ -153,7 +153,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC } return; - + fail: u->module->core->mainloop->io_free(u->io); u->io = NULL; @@ -162,7 +162,7 @@ fail: } #define test_bit(bit, array) (array[bit/8] & (1<<(bit%8))) - + int pa__init(pa_core *c, pa_module*m) { pa_modargs *ma = NULL; struct userdata *u; @@ -226,7 +226,7 @@ int pa__init(pa_core *c, pa_module*m) { u->io = c->mainloop->io_new(c->mainloop, u->fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u); pa_modargs_free(ma); - + return 0; fail: diff --git a/src/modules/module-native-protocol-fd.c b/src/modules/module-native-protocol-fd.c index dd3b4abe..907aab27 100644 --- a/src/modules/module-native-protocol-fd.c +++ b/src/modules/module-native-protocol-fd.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -61,7 +61,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("invalid file descriptor."); goto finish; } - + io = pa_iochannel_new(c->mainloop, fd, fd); if (!(m->userdata = pa_protocol_native_new_iochannel(c, io, m, ma))) { @@ -74,7 +74,7 @@ int pa__init(pa_core *c, pa_module*m) { finish: if (ma) pa_modargs_free(ma); - + return r; } diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c index 50e58853..fc9107a3 100644 --- a/src/modules/module-null-sink.c +++ b/src/modules/module-null-sink.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -115,10 +115,10 @@ int pa__init(pa_core *c, pa_module*m) { pa_sample_spec ss; pa_channel_map map; pa_modargs *ma = NULL; - + assert(c); assert(m); - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments."); goto fail; @@ -129,12 +129,12 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("invalid sample format specification or channel map."); goto fail; } - + u = pa_xnew0(struct userdata, 1); u->core = c; u->module = m; m->userdata = u; - + if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) { pa_log("failed to create sink."); goto fail; @@ -147,19 +147,19 @@ int pa__init(pa_core *c, pa_module*m) { u->n_bytes = 0; pa_gettimeofday(&u->start_time); - + u->time_event = c->mainloop->time_new(c->mainloop, &u->start_time, time_callback, u); u->block_size = pa_bytes_per_second(&ss) / 10; - + pa_modargs_free(ma); - + return 0; fail: if (ma) pa_modargs_free(ma); - + pa__done(c, m); return -1; @@ -171,7 +171,7 @@ void pa__done(pa_core *c, pa_module*m) { if (!(u = m->userdata)) return; - + pa_sink_disconnect(u->sink); pa_sink_unref(u->sink); diff --git a/src/modules/module-oss-mmap.c b/src/modules/module-oss-mmap.c index 5ab08287..7bf6cbbd 100644 --- a/src/modules/module-oss-mmap.c +++ b/src/modules/module-oss-mmap.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -113,7 +113,7 @@ static const char* const valid_modargs[] = { #define DEFAULT_FRAGSIZE 1024 static void update_usage(struct userdata *u) { - pa_module_set_used(u->module, + pa_module_set_used(u->module, (u->sink ? pa_sink_used_by(u->sink) : 0) + (u->source ? pa_source_used_by(u->source) : 0)); } @@ -126,7 +126,7 @@ static void clear_up(struct userdata *u) { pa_sink_unref(u->sink); u->sink = NULL; } - + if (u->source) { pa_source_disconnect(u->source); pa_source_unref(u->source); @@ -137,12 +137,12 @@ static void clear_up(struct userdata *u) { munmap(u->in_mmap, u->in_mmap_length); u->in_mmap = NULL; } - + if (u->out_mmap && u->out_mmap != MAP_FAILED) { munmap(u->out_mmap, u->out_mmap_length); u->out_mmap = NULL; } - + if (u->io_event) { u->core->mainloop->io_free(u->io_event); u->io_event = NULL; @@ -156,13 +156,13 @@ static void clear_up(struct userdata *u) { static void out_fill_memblocks(struct userdata *u, unsigned n) { assert(u && u->out_memblocks); - + while (n > 0) { pa_memchunk chunk; - + if (u->out_memblocks[u->out_current]) pa_memblock_unref_fixed(u->out_memblocks[u->out_current]); - + chunk.memblock = u->out_memblocks[u->out_current] = pa_memblock_new_fixed( u->core->mempool, @@ -172,13 +172,13 @@ static void out_fill_memblocks(struct userdata *u, unsigned n) { assert(chunk.memblock); chunk.length = chunk.memblock->length; chunk.index = 0; - + pa_sink_render_into_full(u->sink, &chunk); - + u->out_current++; while (u->out_current >= u->out_fragments) u->out_current -= u->out_fragments; - + n--; } } @@ -188,7 +188,7 @@ static void do_write(struct userdata *u) { assert(u && u->sink); update_usage(u); - + if (ioctl(u->fd, SNDCTL_DSP_GETOPTR, &info) < 0) { pa_log("SNDCTL_DSP_GETOPTR: %s", pa_cstrerror(errno)); @@ -199,31 +199,31 @@ static void do_write(struct userdata *u) { info.blocks += u->out_blocks_saved; u->out_blocks_saved = 0; - + if (!info.blocks) return; - + out_fill_memblocks(u, info.blocks); } static void in_post_memblocks(struct userdata *u, unsigned n) { assert(u && u->in_memblocks); - + while (n > 0) { pa_memchunk chunk; - + if (!u->in_memblocks[u->in_current]) { chunk.memblock = u->in_memblocks[u->in_current] = pa_memblock_new_fixed(u->core->mempool, (uint8_t*) u->in_mmap+u->in_fragment_size*u->in_current, u->in_fragment_size, 1); chunk.length = chunk.memblock->length; chunk.index = 0; - + pa_source_post(u->source, &chunk); } u->in_current++; while (u->in_current >= u->in_fragments) u->in_current -= u->in_fragments; - + n--; } } @@ -234,7 +234,7 @@ static void in_clear_memblocks(struct userdata*u, unsigned n) { if (n > u->in_fragments) n = u->in_fragments; - + while (n > 0) { if (u->in_memblocks[i]) { pa_memblock_unref_fixed(u->in_memblocks[i]); @@ -254,7 +254,7 @@ static void do_read(struct userdata *u) { assert(u && u->source); update_usage(u); - + if (ioctl(u->fd, SNDCTL_DSP_GETIPTR, &info) < 0) { pa_log("SNDCTL_DSP_GETIPTR: %s", pa_cstrerror(errno)); @@ -265,10 +265,10 @@ static void do_read(struct userdata *u) { info.blocks += u->in_blocks_saved; u->in_blocks_saved = 0; - + if (!info.blocks) return; - + in_post_memblocks(u, info.blocks); in_clear_memblocks(u, u->in_fragments/2); } @@ -311,7 +311,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) { n = bpos - info.ptr; /* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->out_fragment_size, u->out_fragments); */ - + return pa_bytes_to_usec(n, &s->sample_spec); } @@ -337,7 +337,7 @@ static pa_usec_t source_get_latency_cb(pa_source *s) { n = (u->in_fragments * u->in_fragment_size) - bpos + info.ptr; /* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->in_fragment_size, u->in_fragments); */ - + return pa_bytes_to_usec(n, &s->sample_spec); } @@ -416,7 +416,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse module arguments."); goto fail; } - + if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) { pa_log("record= and playback= expect numeric arguments."); goto fail; @@ -460,7 +460,7 @@ int pa__init(pa_core *c, pa_module*m) { if (nfrags >= 2 && frag_size >= 1) if (pa_oss_set_fragments(u->fd, nfrags, frag_size) < 0) goto fail; - + if (pa_oss_auto_format(u->fd, &u->sample_spec) < 0) goto fail; @@ -491,7 +491,7 @@ int pa__init(pa_core *c, pa_module*m) { if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &u->sample_spec, &map))) goto fail; - + u->source->userdata = u; u->source->get_latency = source_get_latency_cb; u->source->get_hw_volume = source_get_hw_volume; @@ -504,22 +504,22 @@ int pa__init(pa_core *c, pa_module*m) { hwdesc[0] ? ")" : "")); pa_xfree(t); u->source->is_hardware = 1; - + u->in_memblocks = pa_xnew0(pa_memblock*, u->in_fragments); - + enable_bits |= PCM_ENABLE_INPUT; } } pa_xfree(name_buf); name_buf = NULL; - + if (mode != O_RDONLY) { if (ioctl(u->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) { pa_log("SNDCTL_DSP_GETOSPACE: %s", pa_cstrerror(errno)); goto fail; } - + pa_log_info("output -- %u fragments of size %u.", info.fragstotal, info.fragsize); u->out_mmap_length = (u->out_fragment_size = info.fragsize) * (u->out_fragments = info.fragstotal); @@ -540,7 +540,7 @@ int pa__init(pa_core *c, pa_module*m) { name = name_buf = pa_sprintf_malloc("oss_output.%s", pa_path_get_filename(p)); namereg_fail = 0; } - + if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &u->sample_spec, &map))) goto fail; @@ -555,28 +555,28 @@ int pa__init(pa_core *c, pa_module*m) { hwdesc[0] ? hwdesc : "", hwdesc[0] ? ")" : "")); pa_xfree(t); - + u->sink->is_hardware = 1; u->out_memblocks = pa_xmalloc0(sizeof(struct memblock *)*u->out_fragments); - + enable_bits |= PCM_ENABLE_OUTPUT; } } pa_xfree(name_buf); name_buf = NULL; - + zero = 0; if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &zero) < 0) { pa_log("SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno)); goto fail; } - + if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) < 0) { pa_log("SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno)); goto fail; } - + assert(u->source || u->sink); u->io_event = c->mainloop->io_new(c->mainloop, u->fd, (u->source ? PA_IO_EVENT_INPUT : 0) | (u->sink ? PA_IO_EVENT_OUTPUT : 0), io_callback, u); @@ -589,7 +589,7 @@ int pa__init(pa_core *c, pa_module*m) { source_get_hw_volume(u->source); if (u->sink) sink_get_hw_volume(u->sink); - + return 0; fail: @@ -599,13 +599,13 @@ fail: pa_modargs_free(ma); pa_xfree(name_buf); - + return -1; } void pa__done(pa_core *c, pa_module*m) { struct userdata *u; - + assert(c); assert(m); @@ -629,6 +629,6 @@ void pa__done(pa_core *c, pa_module*m) { pa_memblock_unref_fixed(u->in_memblocks[i]); pa_xfree(u->in_memblocks); } - + pa_xfree(u); } diff --git a/src/modules/module-oss.c b/src/modules/module-oss.c index b71581d9..b8ced86f 100644 --- a/src/modules/module-oss.c +++ b/src/modules/module-oss.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -100,20 +100,20 @@ static const char* const valid_modargs[] = { #define DEFAULT_DEVICE "/dev/dsp" static void update_usage(struct userdata *u) { - pa_module_set_used(u->module, + pa_module_set_used(u->module, (u->sink ? pa_sink_used_by(u->sink) : 0) + (u->source ? pa_source_used_by(u->source) : 0)); } static void clear_up(struct userdata *u) { assert(u); - + if (u->sink) { pa_sink_disconnect(u->sink); pa_sink_unref(u->sink); u->sink = NULL; } - + if (u->source) { pa_source_disconnect(u->source); pa_source_unref(u->source); @@ -131,7 +131,7 @@ static void do_write(struct userdata *u) { ssize_t r; size_t l; int loop = 0; - + assert(u); if (!u->sink || !pa_iochannel_is_writable(u->io)) @@ -140,10 +140,10 @@ static void do_write(struct userdata *u) { update_usage(u); l = u->out_fragment_size; - + if (u->use_getospace) { audio_buf_info info; - + if (ioctl(u->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) u->use_getospace = 0; else { @@ -156,15 +156,15 @@ static void do_write(struct userdata *u) { do { memchunk = &u->memchunk; - + if (!memchunk->length) if (pa_sink_render(u->sink, l, memchunk) < 0) memchunk = &u->silence; - + assert(memchunk->memblock); assert(memchunk->memblock->data); assert(memchunk->length); - + if ((r = pa_iochannel_write(u->io, (uint8_t*) memchunk->memblock->data + memchunk->index, memchunk->length)) < 0) { pa_log("write() failed: %s", pa_cstrerror(errno)); @@ -172,13 +172,13 @@ static void do_write(struct userdata *u) { pa_module_unload_request(u->module); break; } - + if (memchunk == &u->silence) assert(r % u->sample_size == 0); else { u->memchunk.index += r; u->memchunk.length -= r; - + if (u->memchunk.length <= 0) { pa_memblock_unref(u->memchunk.memblock); u->memchunk.memblock = NULL; @@ -195,7 +195,7 @@ static void do_read(struct userdata *u) { size_t l; int loop = 0; assert(u); - + if (!u->source || !pa_iochannel_is_readable(u->io) || !pa_idxset_size(u->source->outputs)) return; @@ -205,7 +205,7 @@ static void do_read(struct userdata *u) { if (u->use_getispace) { audio_buf_info info; - + if (ioctl(u->fd, SNDCTL_DSP_GETISPACE, &info) < 0) u->use_getispace = 0; else { @@ -215,7 +215,7 @@ static void do_read(struct userdata *u) { } } } - + do { memchunk.memblock = pa_memblock_new(u->core->mempool, l); assert(memchunk.memblock); @@ -228,11 +228,11 @@ static void do_read(struct userdata *u) { } break; } - + assert(r <= (ssize_t) memchunk.memblock->length); memchunk.length = memchunk.memblock->length = r; memchunk.index = 0; - + pa_source_post(u->source, &memchunk); pa_memblock_unref(memchunk.memblock); @@ -280,12 +280,12 @@ static pa_usec_t source_get_latency_cb(pa_source *s) { if (!u->use_getispace) return 0; - + if (ioctl(u->fd, SNDCTL_DSP_GETISPACE, &info) < 0) { u->use_getispace = 0; return 0; } - + if (info.bytes <= 0) return 0; @@ -355,7 +355,7 @@ int pa__init(pa_core *c, pa_module*m) { const char *name; char *name_buf = NULL; int namereg_fail; - + assert(c); assert(m); @@ -363,7 +363,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse module arguments."); goto fail; } - + if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) { pa_log("record= and playback= expect numeric argument."); goto fail; @@ -381,11 +381,11 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse sample specification or channel map"); goto fail; } - + /* Fix latency to 100ms */ nfrags = 12; frag_size = pa_bytes_per_second(&ss)/128; - + if (pa_modargs_get_value_s32(ma, "fragments", &nfrags) < 0 || pa_modargs_get_value_s32(ma, "fragment_size", &frag_size) < 0) { pa_log("failed to parse fragments arguments"); goto fail; @@ -398,12 +398,12 @@ int pa__init(pa_core *c, pa_module*m) { pa_log_info("hardware name is '%s'.", hwdesc); else hwdesc[0] = 0; - + pa_log_info("device opened in %s mode.", mode == O_WRONLY ? "O_WRONLY" : (mode == O_RDONLY ? "O_RDONLY" : "O_RDWR")); if (nfrags >= 2 && frag_size >= 1) - if (pa_oss_set_fragments(fd, nfrags, frag_size) < 0) - goto fail; + if (pa_oss_set_fragments(fd, nfrags, frag_size) < 0) + goto fail; if (pa_oss_auto_format(fd, &ss) < 0) goto fail; @@ -418,7 +418,7 @@ int pa__init(pa_core *c, pa_module*m) { u = pa_xmalloc(sizeof(struct userdata)); u->core = c; u->use_getospace = u->use_getispace = 0; - + if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) >= 0) { pa_log_info("input -- %u fragments of size %u.", info.fragstotal, info.fragsize); in_frag_size = info.fragsize; @@ -438,7 +438,7 @@ int pa__init(pa_core *c, pa_module*m) { name = name_buf = pa_sprintf_malloc("oss_input.%s", pa_path_get_filename(p)); namereg_fail = 0; } - + if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map))) goto fail; @@ -468,7 +468,7 @@ int pa__init(pa_core *c, pa_module*m) { name = name_buf = pa_sprintf_malloc("oss_output.%s", pa_path_get_filename(p)); namereg_fail = 0; } - + if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &ss, &map))) goto fail; @@ -489,7 +489,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_xfree(name_buf); name_buf = NULL; - + assert(u->source || u->sink); u->io = pa_iochannel_new(c->mainloop, u->source ? fd : -1, u->sink ? fd : -1); @@ -539,13 +539,13 @@ fail: pa_modargs_free(ma); pa_xfree(name_buf); - + return -1; } void pa__done(pa_core *c, pa_module*m) { struct userdata *u; - + assert(c); assert(m); @@ -553,7 +553,7 @@ void pa__done(pa_core *c, pa_module*m) { return; clear_up(u); - + if (u->memchunk.memblock) pa_memblock_unref(u->memchunk.memblock); if (u->silence.memblock) diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c index 4aee849b..72400313 100644 --- a/src/modules/module-pipe-sink.c +++ b/src/modules/module-pipe-sink.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -63,7 +63,7 @@ struct userdata { pa_core *core; char *filename; - + pa_sink *sink; pa_iochannel *io; pa_defer_event *defer_event; @@ -87,18 +87,18 @@ static void do_write(struct userdata *u) { assert(u); u->core->mainloop->defer_enable(u->defer_event, 0); - + if (!pa_iochannel_is_writable(u->io)) return; pa_module_set_used(u->module, pa_sink_used_by(u->sink)); - + if (!u->memchunk.length) if (pa_sink_render(u->sink, PIPE_BUF, &u->memchunk) < 0) return; assert(u->memchunk.memblock && u->memchunk.length); - + if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) { pa_log("write(): %s", pa_cstrerror(errno)); return; @@ -106,7 +106,7 @@ static void do_write(struct userdata *u) { u->memchunk.index += r; u->memchunk.length -= r; - + if (u->memchunk.length <= 0) { pa_memblock_unref(u->memchunk.memblock); u->memchunk.memblock = NULL; @@ -149,9 +149,9 @@ int pa__init(pa_core *c, pa_module*m) { pa_channel_map map; pa_modargs *ma = NULL; char *t; - + assert(c && m); - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments"); goto fail; @@ -162,7 +162,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("invalid sample format specification"); goto fail; } - + mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777); if ((fd = open(p, O_RDWR)) < 0) { @@ -171,7 +171,7 @@ int pa__init(pa_core *c, pa_module*m) { } pa_fd_set_cloexec(fd, 1); - + if (fstat(fd, &st) < 0) { pa_log("fstat('%s'): %s", p, pa_cstrerror(errno)); goto fail; @@ -187,7 +187,7 @@ int pa__init(pa_core *c, pa_module*m) { u->core = c; u->module = m; m->userdata = u; - + if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) { pa_log("failed to create sink."); goto fail; @@ -211,13 +211,13 @@ int pa__init(pa_core *c, pa_module*m) { c->mainloop->defer_enable(u->defer_event, 0); pa_modargs_free(ma); - + return 0; fail: if (ma) pa_modargs_free(ma); - + if (fd >= 0) close(fd); @@ -232,10 +232,10 @@ void pa__done(pa_core *c, pa_module*m) { if (!(u = m->userdata)) return; - + if (u->memchunk.memblock) pa_memblock_unref(u->memchunk.memblock); - + pa_sink_disconnect(u->sink); pa_sink_unref(u->sink); pa_iochannel_free(u->io); @@ -244,6 +244,6 @@ void pa__done(pa_core *c, pa_module*m) { assert(u->filename); unlink(u->filename); pa_xfree(u->filename); - + pa_xfree(u); } diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c index c251f7ac..f53f6a63 100644 --- a/src/modules/module-pipe-source.c +++ b/src/modules/module-pipe-source.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -63,7 +63,7 @@ struct userdata { pa_core *core; char *filename; - + pa_source *source; pa_iochannel *io; pa_module *module; @@ -127,9 +127,9 @@ int pa__init(pa_core *c, pa_module*m) { pa_channel_map map; pa_modargs *ma = NULL; char *t; - + assert(c && m); - + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("failed to parse module arguments"); goto fail; @@ -140,7 +140,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("invalid sample format specification or channel map"); goto fail; } - + mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777); if ((fd = open(p, O_RDWR)) < 0) { @@ -149,7 +149,7 @@ int pa__init(pa_core *c, pa_module*m) { } pa_fd_set_cloexec(fd, 1); - + if (fstat(fd, &st) < 0) { pa_log("fstat('%s'): %s", p, pa_cstrerror(errno)); goto fail; @@ -164,7 +164,7 @@ int pa__init(pa_core *c, pa_module*m) { u->filename = pa_xstrdup(p); u->core = c; - + if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map))) { pa_log("failed to create source."); goto fail; @@ -180,18 +180,18 @@ int pa__init(pa_core *c, pa_module*m) { u->chunk.memblock = NULL; u->chunk.index = u->chunk.length = 0; - + u->module = m; m->userdata = u; pa_modargs_free(ma); - + return 0; fail: if (ma) pa_modargs_free(ma); - + if (fd >= 0) close(fd); @@ -206,10 +206,10 @@ void pa__done(pa_core *c, pa_module*m) { if (!(u = m->userdata)) return; - + if (u->chunk.memblock) pa_memblock_unref(u->chunk.memblock); - + pa_source_disconnect(u->source); pa_source_unref(u->source); pa_iochannel_free(u->io); @@ -217,6 +217,6 @@ void pa__done(pa_core *c, pa_module*m) { assert(u->filename); unlink(u->filename); pa_xfree(u->filename); - + pa_xfree(u); } diff --git a/src/modules/module-protocol-stub.c b/src/modules/module-protocol-stub.c index df58958a..93fb2a36 100644 --- a/src/modules/module-protocol-stub.c +++ b/src/modules/module-protocol-stub.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -85,13 +85,13 @@ "record= " SOCKET_USAGE) #elif defined(USE_PROTOCOL_CLI) - #include + #include #define protocol_new pa_protocol_cli_new #define protocol_free pa_protocol_cli_free #define TCPWRAP_SERVICE "pulseaudio-cli" #define IPV4_PORT 4712 #define UNIX_SOCKET "cli" - #define MODULE_ARGUMENTS + #define MODULE_ARGUMENTS #ifdef USE_TCP_SOCKETS #include "module-cli-protocol-tcp-symdef.h" #else @@ -106,7 +106,7 @@ #define TCPWRAP_SERVICE "pulseaudio-http" #define IPV4_PORT 4714 #define UNIX_SOCKET "http" - #define MODULE_ARGUMENTS + #define MODULE_ARGUMENTS #ifdef USE_TCP_SOCKETS #include "module-http-protocol-tcp-symdef.h" #else @@ -129,16 +129,16 @@ #endif #if defined(HAVE_CREDS) && !defined(USE_TCP_SOCKETS) - #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-group", "auth-group-enable", + #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-group", "auth-group-enable", #define AUTH_USAGE "auth-group= auth-group-enable= " #elif defined(USE_TCP_SOCKETS) - #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl", + #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl", #define AUTH_USAGE "auth-ip-acl= " #else #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON #define AUTH_USAGE #endif - + PA_MODULE_DESCRIPTION("Native protocol "SOCKET_DESCRIPTION) PA_MODULE_USAGE("auth-anonymous= " "cookie= " @@ -160,7 +160,7 @@ #endif #if defined(USE_TCP_SOCKETS) - #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl", + #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl", #define AUTH_USAGE "auth-ip-acl= " #else #define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON @@ -175,7 +175,7 @@ AUTH_USAGE SOCKET_USAGE) #else - #error "Broken build system" + #error "Broken build system" #endif PA_MODULE_AUTHOR("Lennart Poettering") @@ -266,21 +266,21 @@ int pa__init(pa_core *c, pa_module*m) { /* This socket doesn't reside in our own runtime dir but in * /tmp/.esd/, hence we have to create the dir first */ - + if (pa_make_secure_parent_dir(u->socket_path, c->is_system_instance ? 0755 : 0700, (uid_t)-1, (gid_t)-1) < 0) { pa_log("Failed to create socket directory: %s\n", pa_cstrerror(errno)); goto fail; } #endif - + if ((r = pa_unix_socket_remove_stale(tmp)) < 0) { pa_log("Failed to remove stale UNIX socket '%s': %s", tmp, pa_cstrerror(errno)); goto fail; } - + if (r) pa_log("Removed stale UNIX socket '%s'.", tmp); - + if (!(s = pa_socket_server_new_unix(c->mainloop, tmp))) goto fail; @@ -332,7 +332,7 @@ fail: void pa__done(pa_core *c, pa_module*m) { struct userdata *u; - + assert(c); assert(m); @@ -354,8 +354,8 @@ void pa__done(pa_core *c, pa_module*m) { pa_xfree(p); } #endif - - + + pa_xfree(u->socket_path); #endif diff --git a/src/modules/module-rescue-streams.c b/src/modules/module-rescue-streams.c index 7aa205bd..2eea4f61 100644 --- a/src/modules/module-rescue-streams.c +++ b/src/modules/module-rescue-streams.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -49,7 +49,7 @@ struct userdata { static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* userdata) { pa_sink_input *i; pa_sink *target; - + assert(c); assert(sink); @@ -57,7 +57,7 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user pa_log_debug("No sink inputs to move away."); return PA_HOOK_OK; } - + if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SINK, 0))) { pa_log_info("No evacuation sink found."); return PA_HOOK_OK; @@ -74,14 +74,14 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index, i->name, target->name); } - + return PA_HOOK_OK; } static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void* userdata) { pa_source_output *o; pa_source *target; - + assert(c); assert(source); @@ -89,7 +89,7 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void pa_log_debug("No source outputs to move away."); return PA_HOOK_OK; } - + if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SOURCE, 0))) { pa_log_info("No evacuation source found."); return PA_HOOK_OK; @@ -106,14 +106,14 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index, o->name, target->name); } - + return PA_HOOK_OK; } int pa__init(pa_core *c, pa_module*m) { pa_modargs *ma = NULL; struct userdata *u; - + assert(c); assert(m); @@ -132,7 +132,7 @@ int pa__init(pa_core *c, pa_module*m) { void pa__done(pa_core *c, pa_module*m) { struct userdata *u; - + assert(c); assert(m); diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c index fa29ba16..871b702d 100644 --- a/src/modules/module-sine.c +++ b/src/modules/module-sine.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -96,7 +96,7 @@ static void calc_sine(float *f, size_t l, float freq) { size_t i; l /= sizeof(float); - + for (i = 0; i < l; i++) f[i] = (float) sin((double) i/l*M_PI*2*freq)/2; } @@ -115,7 +115,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("Failed to parse module arguments"); goto fail; } - + m->userdata = u = pa_xmalloc(sizeof(struct userdata)); u->core = c; u->module = m; @@ -138,7 +138,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("Invalid frequency specification"); goto fail; } - + u->memblock = pa_memblock_new(c->mempool, pa_bytes_per_second(&ss)); calc_sine(u->memblock->data, u->memblock->length, frequency); @@ -160,10 +160,10 @@ int pa__init(pa_core *c, pa_module*m) { u->sink_input->userdata = u; u->peek_index = 0; - + pa_modargs_free(ma); return 0; - + fail: if (ma) pa_modargs_free(ma); @@ -183,7 +183,7 @@ void pa__done(pa_core *c, pa_module*m) { pa_sink_input_disconnect(u->sink_input); pa_sink_input_unref(u->sink_input); } - + if (u->memblock) pa_memblock_unref(u->memblock); pa_xfree(u); diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c index 66968cb1..1454d639 100644 --- a/src/modules/module-solaris.c +++ b/src/modules/module-solaris.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -124,7 +124,7 @@ static void do_write(struct userdata *u) { int err; size_t len; ssize_t r; - + assert(u); /* We cannot check pa_iochannel_is_writable() because of our buffer hack */ @@ -163,7 +163,7 @@ static void do_write(struct userdata *u) { } u->sink_underflow = 0; - + assert(u->memchunk.memblock); assert(u->memchunk.memblock->data); assert(u->memchunk.length); @@ -181,10 +181,10 @@ static void do_write(struct userdata *u) { } assert(r % u->frame_size == 0); - + u->memchunk.index += r; u->memchunk.length -= r; - + if (u->memchunk.length <= 0) { pa_memblock_unref(u->memchunk.memblock); u->memchunk.memblock = NULL; @@ -199,7 +199,7 @@ static void do_read(struct userdata *u) { size_t l; ssize_t r; assert(u); - + if (!u->source || !pa_iochannel_is_readable(u->io)) return; @@ -221,11 +221,11 @@ static void do_read(struct userdata *u) { pa_log("read() failed: %s", pa_cstrerror(errno)); return; } - + assert(r <= (ssize_t) memchunk.memblock->length); memchunk.length = memchunk.memblock->length = r; memchunk.index = 0; - + pa_source_post(u->source, &memchunk); pa_memblock_unref(memchunk.memblock); @@ -256,7 +256,7 @@ static void timer_cb(pa_mainloop_api*a, pa_time_event *e, const struct timeval * static void sig_callback(pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata) { struct userdata *u = userdata; pa_cvolume old_vol; - + assert(u); if (u->sink) { @@ -518,7 +518,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse module arguments."); goto fail; } - + if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) { pa_log("record= and playback= expect numeric argument."); goto fail; @@ -531,7 +531,7 @@ int pa__init(pa_core *c, pa_module*m) { mode = (playback&&record) ? O_RDWR : (playback ? O_WRONLY : (record ? O_RDONLY : 0)); - buffer_size = 16384; + buffer_size = 16384; if (pa_modargs_get_value_s32(ma, "buffer_size", &buffer_size) < 0) { pa_log("failed to parse buffer size argument"); goto fail; @@ -542,7 +542,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse sample specification"); goto fail; } - + if ((fd = open(p = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), mode | O_NONBLOCK)) < 0) goto fail; @@ -642,7 +642,7 @@ fail: if (ma) pa_modargs_free(ma); - + return -1; } @@ -657,7 +657,7 @@ void pa__done(pa_core *c, pa_module*m) { c->mainloop->time_free(u->timer); ioctl(u->fd, I_SETSIG, 0); pa_signal_free(u->sig); - + if (u->memchunk.memblock) pa_memblock_unref(u->memchunk.memblock); @@ -665,12 +665,12 @@ void pa__done(pa_core *c, pa_module*m) { pa_sink_disconnect(u->sink); pa_sink_unref(u->sink); } - + if (u->source) { pa_source_disconnect(u->source); pa_source_unref(u->source); } - + pa_iochannel_free(u->io); pa_xfree(u); } diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index a110c57e..f7420a67 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -116,10 +116,10 @@ static void command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = { #ifdef TUNNEL_SINK [PA_COMMAND_REQUEST] = command_request, -#endif +#endif [PA_COMMAND_PLAYBACK_STREAM_KILLED] = command_stream_killed, [PA_COMMAND_RECORD_STREAM_KILLED] = command_stream_killed, - [PA_COMMAND_SUBSCRIBE_EVENT] = command_subscribe_event, + [PA_COMMAND_SUBSCRIBE_EVENT] = command_subscribe_event, }; struct userdata { @@ -136,7 +136,7 @@ struct userdata { char *source_name; pa_source *source; #endif - + pa_module *module; pa_core *core; @@ -146,7 +146,7 @@ struct userdata { uint32_t ctag; uint32_t device_index; uint32_t channel; - + pa_usec_t host_latency; pa_time_event *time_event; @@ -156,7 +156,7 @@ struct userdata { static void close_stuff(struct userdata *u) { assert(u); - + if (u->pstream) { pa_pstream_close(u->pstream); pa_pstream_unref(u->pstream); @@ -256,10 +256,10 @@ static void send_bytes(struct userdata *u) { while (u->requested_bytes > 0) { pa_memchunk chunk; if (pa_sink_render(u->sink, u->requested_bytes, &chunk) < 0) { - - if (u->requested_bytes >= DEFAULT_TLENGTH-DEFAULT_PREBUF) + + if (u->requested_bytes >= DEFAULT_TLENGTH-DEFAULT_PREBUF) send_prebuf_request(u); - + return; } @@ -293,7 +293,7 @@ static void command_request(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED ui die(u); return; } - + u->requested_bytes += bytes; send_bytes(u); } @@ -316,7 +316,7 @@ static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, PA_G die(u); return; } - + if (pa_tagstruct_get_usec(t, &sink_usec) < 0 || pa_tagstruct_get_usec(t, &source_usec) < 0 || pa_tagstruct_get_boolean(t, &playing) < 0 || @@ -333,14 +333,14 @@ static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, PA_G pa_gettimeofday(&now); /* FIXME! This could use some serious love. */ - + if (pa_timeval_cmp(&local, &remote) < 0 && pa_timeval_cmp(&remote, &now)) { /* local and remote seem to have synchronized clocks */ #ifdef TUNNEL_SINK transport_usec = pa_timeval_diff(&remote, &local); #else transport_usec = pa_timeval_diff(&now, &remote); -#endif +#endif } else transport_usec = pa_timeval_diff(&now, &local)/2; @@ -364,7 +364,7 @@ static void request_latency(struct userdata *u) { assert(u); t = pa_tagstruct_new(NULL, 0); -#ifdef TUNNEL_SINK +#ifdef TUNNEL_SINK pa_tagstruct_putu32(t, PA_COMMAND_GET_PLAYBACK_LATENCY); #else pa_tagstruct_putu32(t, PA_COMMAND_GET_RECORD_LATENCY); @@ -374,7 +374,7 @@ static void request_latency(struct userdata *u) { pa_gettimeofday(&now); pa_tagstruct_put_timeval(t, &now); - + pa_pstream_send_tagstruct(u->pstream, t); pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, stream_get_latency_callback, u, NULL); } @@ -496,7 +496,7 @@ static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED assert(m && e && u); request_latency(u); - + pa_gettimeofday(&ntv); ntv.tv_sec += LATENCY_INTERVAL; m->time_restart(e, &ntv); @@ -518,16 +518,16 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN if (pa_tagstruct_getu32(t, &u->channel) < 0 || pa_tagstruct_getu32(t, &u->device_index) < 0 -#ifdef TUNNEL_SINK +#ifdef TUNNEL_SINK || pa_tagstruct_getu32(t, &u->requested_bytes) < 0 -#endif +#endif ) goto parse_error; if (u->version >= 9) { #ifdef TUNNEL_SINK uint32_t maxlength, tlength, prebuf, minreq; - + if (pa_tagstruct_getu32(t, &maxlength) < 0 || pa_tagstruct_getu32(t, &tlength) < 0 || pa_tagstruct_getu32(t, &prebuf) < 0 || @@ -535,13 +535,13 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN goto parse_error; #else uint32_t maxlength, fragsize; - + if (pa_tagstruct_getu32(t, &maxlength) < 0 || - pa_tagstruct_getu32(t, &fragsize) < 0) + pa_tagstruct_getu32(t, &fragsize) < 0) goto parse_error; #endif } - + if (!pa_tagstruct_eof(t)) goto parse_error; @@ -559,7 +559,7 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN #endif return; - + parse_error: pa_log("invalid reply. (create stream)"); die(u); @@ -603,7 +603,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t pa_get_user_name(un, sizeof(un)), u->source->name); #endif - + reply = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu32(reply, PA_COMMAND_SET_CLIENT_NAME); pa_tagstruct_putu32(reply, tag = u->ctag++); @@ -612,7 +612,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t /* We ignore the server's reply here */ reply = pa_tagstruct_new(NULL, 0); -#ifdef TUNNEL_SINK +#ifdef TUNNEL_SINK pa_tagstruct_putu32(reply, PA_COMMAND_CREATE_PLAYBACK_STREAM); pa_tagstruct_putu32(reply, tag = u->ctag++); pa_tagstruct_puts(reply, name); @@ -640,7 +640,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t pa_tagstruct_put_boolean(reply, 0); pa_tagstruct_putu32(reply, DEFAULT_FRAGSIZE); #endif - + pa_pstream_send_tagstruct(u->pstream, reply); pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, create_stream_callback, u, NULL); } @@ -673,7 +673,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, PA_GCC_UN die(u); return; } - + pa_source_post(u->source, chunk); } #endif @@ -686,7 +686,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata pa_socket_client_unref(u->client); u->client = NULL; - + if (!io) { pa_log("connection failed."); pa_module_unload_request(u->module); @@ -701,7 +701,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata #ifndef TUNNEL_SINK pa_pstream_set_recieve_memblock_callback(u->pstream, pstream_memblock_callback, u); #endif - + t = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu32(t, PA_COMMAND_AUTH); pa_tagstruct_putu32(t, tag = u->ctag++); @@ -709,7 +709,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata pa_tagstruct_put_arbitrary(t, u->auth_cookie, sizeof(u->auth_cookie)); pa_pstream_send_tagstruct(u->pstream, t); pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, u, NULL); - + } #ifdef TUNNEL_SINK @@ -862,14 +862,14 @@ static int load_key(struct userdata *u, const char*fn) { assert(u); u->auth_cookie_in_property = 0; - + if (!fn && pa_authkey_prop_get(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0) { pa_log_debug("using already loaded auth cookie."); pa_authkey_prop_ref(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME); u->auth_cookie_in_property = 1; return 0; } - + if (!fn) fn = PA_NATIVE_COOKIE_FILE; @@ -877,7 +877,7 @@ static int load_key(struct userdata *u, const char*fn) { return -1; pa_log_debug("loading cookie from disk."); - + if (pa_authkey_prop_put(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0) u->auth_cookie_in_property = 1; @@ -890,7 +890,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_sample_spec ss; pa_channel_map map; char *t, *dn = NULL; - + assert(c && m); if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { @@ -919,10 +919,10 @@ int pa__init(pa_core *c, pa_module*m) { u->host_latency = 0; u->auth_cookie_in_property = 0; u->time_event = NULL; - + if (load_key(u, pa_modargs_get_value(ma, "cookie", NULL)) < 0) goto fail; - + if (!(u->server_name = pa_xstrdup(pa_modargs_get_value(ma, "server", NULL)))) { pa_log("no server specified."); goto fail; @@ -938,7 +938,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to connect to server '%s'", u->server_name); goto fail; } - + if (!u->client) goto fail; @@ -987,7 +987,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_source_set_owner(u->source, m); #endif - + pa_xfree(dn); u->time_event = NULL; @@ -995,7 +995,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_modargs_free(ma); return 0; - + fail: pa__done(c, m); @@ -1003,7 +1003,7 @@ fail: pa_modargs_free(ma); pa_xfree(dn); - + return -1; } @@ -1018,7 +1018,7 @@ void pa__done(pa_core *c, pa_module*m) { if (u->auth_cookie_in_property) pa_authkey_prop_unref(c, PA_NATIVE_COOKIE_PROPERTY_NAME); - + #ifdef TUNNEL_SINK pa_xfree(u->sink_name); #else diff --git a/src/modules/module-volume-restore.c b/src/modules/module-volume-restore.c index efa59f40..877d17c7 100644 --- a/src/modules/module-volume-restore.c +++ b/src/modules/module-volume-restore.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -82,7 +82,7 @@ static pa_cvolume* parse_volume(const char *s, pa_cvolume *v) { char *p; long k; unsigned i; - + assert(s); assert(v); @@ -92,7 +92,7 @@ static pa_cvolume* parse_volume(const char *s, pa_cvolume *v) { k = strtol(s, &p, 0); if (k <= 0 || k > PA_CHANNELS_MAX) return NULL; - + v->channels = (unsigned) k; for (i = 0; i < v->channels; i++) { @@ -105,7 +105,7 @@ static pa_cvolume* parse_volume(const char *s, pa_cvolume *v) { if (k < PA_VOLUME_MUTED) return NULL; - + v->values[i] = (pa_volume_t) k; } @@ -132,22 +132,22 @@ static int load_rules(struct userdata *u) { ret = 0; } else pa_log("failed to open file '%s': %s", u->table_file, pa_cstrerror(errno)); - + goto finish; } pa_lock_fd(fileno(f), 1); - + while (!feof(f)) { struct rule *rule; pa_cvolume v; int v_is_set; - + if (!fgets(ln, sizeof(buf_name), f)) break; n++; - + pa_strip_nl(ln); if (ln[0] == '#') @@ -181,12 +181,12 @@ static int load_rules(struct userdata *u) { v_is_set = 0; ln = buf_name; - + if (pa_hashmap_get(u->hashmap, buf_name)) { pa_log("double entry in %s:%u, ignoring", u->table_file, n); continue; } - + rule = pa_xnew(struct rule, 1); rule->name = pa_xstrdup(buf_name); if ((rule->volume_is_set = v_is_set)) @@ -203,7 +203,7 @@ static int load_rules(struct userdata *u) { } ret = 0; - + finish: if (f) { pa_lock_fd(fileno(f), 0); @@ -218,7 +218,7 @@ static int save_rules(struct userdata *u) { int ret = -1; void *state = NULL; struct rule *rule; - + f = u->table_file ? fopen(u->table_file, "w") : pa_open_config_file(NULL, DEFAULT_VOLUME_TABLE_FILE, NULL, &u->table_file, "w"); @@ -232,7 +232,7 @@ static int save_rules(struct userdata *u) { while ((rule = pa_hashmap_iterate(u->hashmap, &state, NULL))) { unsigned i; - + fprintf(f, "%s\n", rule->name); if (rule->volume_is_set) { @@ -241,14 +241,14 @@ static int save_rules(struct userdata *u) { for (i = 0; i < rule->volume.channels; i++) fprintf(f, " %u", rule->volume.values[i]); } - + fprintf(f, "\n%s\n%s\n", rule->sink ? rule->sink : "", rule->source ? rule->source : ""); } - + ret = 0; - + finish: if (f) { pa_lock_fd(fileno(f), 0); @@ -260,7 +260,7 @@ finish: static char* client_name(pa_client *c) { char *t, *e; - + if (!c->name || !c->driver) return NULL; @@ -280,11 +280,11 @@ static char* client_name(pa_client *c) { * sessions of the same application, which is something we * explicitly don't want. Besides other stuff this makes xmms * with esound work properly for us. */ - + if (*k == ')' && *(k+1) == 0) *e = 0; } - + return t; } @@ -294,7 +294,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 pa_source_output *so = NULL; struct rule *r; char *name; - + assert(c); assert(u); @@ -307,7 +307,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK_INPUT) { if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx))) return; - + if (!si->client || !(name = client_name(si->client))) return; } else { @@ -315,7 +315,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if (!(so = pa_idxset_get_by_index(c->source_outputs, idx))) return; - + if (!so->client || !(name = client_name(so->client))) return; } @@ -348,7 +348,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 u->modified = 1; } } - + } else { pa_log_info("Creating new entry for <%s>", name); @@ -366,7 +366,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 r->sink = NULL; r->source = pa_xstrdup(so->source->name); } - + pa_hashmap_put(u->hashmap, r->name, r); u->modified = 1; } @@ -419,7 +419,7 @@ static pa_hook_result_t source_output_hook_callback(pa_core *c, pa_source_output int pa__init(pa_core *c, pa_module*m) { pa_modargs *ma = NULL; struct userdata *u; - + assert(c); assert(m); @@ -433,9 +433,9 @@ int pa__init(pa_core *c, pa_module*m) { u->subscription = NULL; u->table_file = pa_xstrdup(pa_modargs_get_value(ma, "table", NULL)); u->modified = 0; - + m->userdata = u; - + if (load_rules(u) < 0) goto fail; @@ -451,7 +451,7 @@ fail: if (ma) pa_modargs_free(ma); - + return -1; } @@ -467,7 +467,7 @@ static void free_func(void *p, void *userdata) { void pa__done(pa_core *c, pa_module*m) { struct userdata* u; - + assert(c); assert(m); @@ -486,7 +486,7 @@ void pa__done(pa_core *c, pa_module*m) { if (u->modified) save_rules(u); - + pa_hashmap_free(u->hashmap, free_func, NULL); } diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c index 4043c136..e245e138 100644 --- a/src/modules/module-waveout.c +++ b/src/modules/module-waveout.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -172,7 +172,7 @@ static void do_write(struct userdata *u) pa_log_error(__FILE__ ": ERROR: Unable to write waveOut block: %d", res); } - + u->written_bytes += hdr->dwBufferLength; EnterCriticalSection(&u->crit); @@ -233,7 +233,7 @@ static void do_read(struct userdata *u) pa_log_error(__FILE__ ": ERROR: Unable to add waveIn block: %d", res); } - + free_frags--; u->cur_ihdr++; u->cur_ihdr %= u->fragments; @@ -561,7 +561,7 @@ int pa__init(pa_core *c, pa_module*m) { u->ohdrs[i].lpData = pa_xmalloc(u->fragment_size); assert(u->ohdrs); } - + u->module = m; m->userdata = u; @@ -585,7 +585,7 @@ fail: if (ma) pa_modargs_free(ma); - + return -1; } @@ -597,7 +597,7 @@ void pa__done(pa_core *c, pa_module*m) { if (!(u = m->userdata)) return; - + if (u->event) c->mainloop->time_free(u->event); @@ -608,12 +608,12 @@ void pa__done(pa_core *c, pa_module*m) { pa_sink_disconnect(u->sink); pa_sink_unref(u->sink); } - + if (u->source) { pa_source_disconnect(u->source); pa_source_unref(u->source); } - + if (u->hwi != INVALID_HANDLE_VALUE) { waveInReset(u->hwi); waveInClose(u->hwi); @@ -633,6 +633,6 @@ void pa__done(pa_core *c, pa_module*m) { pa_xfree(u->ohdrs); DeleteCriticalSection(&u->crit); - + pa_xfree(u); } diff --git a/src/modules/module-x11-bell.c b/src/modules/module-x11-bell.c index 48e95c8c..5322a71f 100644 --- a/src/modules/module-x11-bell.c +++ b/src/modules/module-x11-bell.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -107,19 +107,19 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("failed to parse module arguments"); goto fail; } - + m->userdata = u = pa_xmalloc(sizeof(struct userdata)); u->core = c; u->scache_item = pa_xstrdup(pa_modargs_get_value(ma, "sample", "x11-bell")); u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL)); u->x11_client = NULL; - if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL)))) + if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL)))) goto fail; major = XkbMajorVersion; minor = XkbMinorVersion; - + if (!XkbLibraryVersion(&major, &minor)) { pa_log("XkbLibraryVersion() failed"); goto fail; @@ -140,11 +140,11 @@ int pa__init(pa_core *c, pa_module*m) { XkbChangeEnabledControls(pa_x11_wrapper_get_display(u->x11_wrapper), XkbUseCoreKbd, XkbAudibleBellMask, 0); u->x11_client = pa_x11_client_new(u->x11_wrapper, x11_event_callback, u); - + pa_modargs_free(ma); - + return 0; - + fail: if (ma) pa_modargs_free(ma); diff --git a/src/modules/module-x11-publish.c b/src/modules/module-x11-publish.c index f2cace14..b1c17a7c 100644 --- a/src/modules/module-x11-publish.c +++ b/src/modules/module-x11-publish.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -77,14 +77,14 @@ static int load_key(struct userdata *u, const char*fn) { assert(u); u->auth_cookie_in_property = 0; - + if (!fn && pa_authkey_prop_get(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0) { pa_log_debug("using already loaded auth cookie."); pa_authkey_prop_ref(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME); u->auth_cookie_in_property = 1; return 0; } - + if (!fn) fn = PA_NATIVE_COOKIE_FILE; @@ -92,7 +92,7 @@ static int load_key(struct userdata *u, const char*fn) { return -1; pa_log_debug("loading cookie from disk."); - + if (pa_authkey_prop_put(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0) u->auth_cookie_in_property = 1; @@ -121,7 +121,7 @@ int pa__init(pa_core *c, pa_module*m) { if (load_key(u, pa_modargs_get_value(ma, "cookie", NULL)) < 0) goto fail; - if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL)))) + if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL)))) goto fail; if (!(l = pa_property_get(c, PA_NATIVE_SERVER_PROPERTY_NAME))) @@ -130,10 +130,10 @@ int pa__init(pa_core *c, pa_module*m) { s = pa_strlist_tostring(l); pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER", s); pa_xfree(s); - + if (!pa_get_fqdn(hn, sizeof(hn)) || !pa_get_user_name(un, sizeof(un))) goto fail; - + u->id = pa_sprintf_malloc("%s@%s/%u", un, hn, (unsigned) getpid()); pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", u->id); @@ -144,10 +144,10 @@ int pa__init(pa_core *c, pa_module*m) { pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SINK", t); pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_COOKIE", pa_hexstr(u->auth_cookie, sizeof(u->auth_cookie), hx, sizeof(hx))); - + pa_modargs_free(ma); return 0; - + fail: if (ma) pa_modargs_free(ma); @@ -162,7 +162,7 @@ void pa__done(pa_core *c, pa_module*m) { if (!(u = m->userdata)) return; - + if (u->x11_wrapper) { char t[256]; @@ -178,7 +178,7 @@ void pa__done(pa_core *c, pa_module*m) { XSync(pa_x11_wrapper_get_display(u->x11_wrapper), False); } } - + if (u->x11_wrapper) pa_x11_wrapper_unref(u->x11_wrapper); diff --git a/src/modules/module-zeroconf-publish.c b/src/modules/module-zeroconf-publish.c index 696d8afe..10643808 100644 --- a/src/modules/module-zeroconf-publish.c +++ b/src/modules/module-zeroconf-publish.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -153,7 +153,7 @@ static int publish_service(struct userdata *u, struct service *s) { if (!u->client || avahi_client_get_state(u->client) != AVAHI_CLIENT_S_RUNNING) return 0; - + if ((s->published == PUBLISHED_REAL && s->loaded.valid) || (s->published == PUBLISHED_AUTOLOAD && s->autoload.valid && !s->loaded.valid)) return 0; @@ -161,8 +161,8 @@ static int publish_service(struct userdata *u, struct service *s) { if (s->published != UNPUBLISHED) { avahi_entry_group_reset(s->entry_group); s->published = UNPUBLISHED; - } - + } + if (s->loaded.valid || s->autoload.valid) { pa_namereg_type_t type; @@ -172,26 +172,26 @@ static int publish_service(struct userdata *u, struct service *s) { goto finish; } } - + txt = avahi_string_list_add_pair(txt, "device", s->name); txt = txt_record_server_data(u->core, txt); - + if (s->loaded.valid) { char *description; pa_sample_spec ss; - + get_service_data(u, s, &ss, &description); - + txt = avahi_string_list_add_printf(txt, "rate=%u", ss.rate); txt = avahi_string_list_add_printf(txt, "channels=%u", ss.channels); txt = avahi_string_list_add_pair(txt, "format", pa_sample_format_to_string(ss.format)); if (description) txt = avahi_string_list_add_pair(txt, "description", description); - + type = s->loaded.type; } else if (s->autoload.valid) type = s->autoload.type; - + if (avahi_entry_group_add_service_strlst( s->entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, @@ -202,24 +202,24 @@ static int publish_service(struct userdata *u, struct service *s) { NULL, u->port, txt) < 0) { - + pa_log("avahi_entry_group_add_service_strlst(): %s", avahi_strerror(avahi_client_errno(u->client))); goto finish; } - + if (avahi_entry_group_commit(s->entry_group) < 0) { pa_log("avahi_entry_group_commit(): %s", avahi_strerror(avahi_client_errno(u->client))); goto finish; } - + if (s->loaded.valid) s->published = PUBLISHED_REAL; else if (s->autoload.valid) s->published = PUBLISHED_AUTOLOAD; } - + r = 0; - + finish: if (s->published == UNPUBLISHED) { @@ -227,7 +227,7 @@ finish: if (s->entry_group) avahi_entry_group_free(s->entry_group); - + pa_hashmap_remove(u->services, s->name); pa_xfree(s->name); pa_xfree(s->service_name); @@ -236,17 +236,17 @@ finish: if (txt) avahi_string_list_free(txt); - + return r; } static struct service *get_service(struct userdata *u, const char *name, const char *description) { struct service *s; char hn[64]; - + if ((s = pa_hashmap_get(u->services, name))) return s; - + s = pa_xnew(struct service, 1); s->userdata = u; s->entry_group = NULL; @@ -283,7 +283,7 @@ static int publish_sink(struct userdata *u, pa_sink *s) { static int publish_source(struct userdata *u, pa_source *s) { struct service *svc; int ret; - + assert(u && s); svc = get_service(u, s->name, s->description); @@ -295,7 +295,7 @@ static int publish_source(struct userdata *u, pa_source *s) { svc->loaded.index = s->index; pa_dynarray_put(u->source_dynarray, s->index, svc); - + if ((ret = publish_service(u, svc)) < 0) return ret; @@ -306,7 +306,7 @@ static int publish_source(struct userdata *u, pa_source *s) { static int publish_autoload(struct userdata *u, pa_autoload_entry *s) { struct service *svc; int ret; - + assert(u && s); svc = get_service(u, s->name, NULL); @@ -319,7 +319,7 @@ static int publish_autoload(struct userdata *u, pa_autoload_entry *s) { if ((ret = publish_service(u, svc)) < 0) return ret; - + pa_dynarray_put(u->autoload_dynarray, s->index, svc); return ret; } @@ -336,14 +336,14 @@ static int remove_sink(struct userdata *u, uint32_t idx) { svc->loaded.valid = 0; pa_dynarray_put(u->sink_dynarray, idx, NULL); - + return publish_service(u, svc); } static int remove_source(struct userdata *u, uint32_t idx) { struct service *svc; assert(u && idx != PA_INVALID_INDEX); - + if (!(svc = pa_dynarray_get(u->source_dynarray, idx))) return 0; @@ -359,7 +359,7 @@ static int remove_source(struct userdata *u, uint32_t idx) { static int remove_autoload(struct userdata *u, uint32_t idx) { struct service *svc; assert(u && idx != PA_INVALID_INDEX); - + if (!(svc = pa_dynarray_get(u->autoload_dynarray, idx))) return 0; @@ -389,14 +389,14 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if (remove_sink(u, idx) < 0) goto fail; } - + break; case PA_SUBSCRIPTION_EVENT_SOURCE: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { pa_source *source; - + if ((source = pa_idxset_get_by_index(c->sources, idx))) { if (publish_source(u, source) < 0) goto fail; @@ -405,13 +405,13 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if (remove_source(u, idx) < 0) goto fail; } - + break; case PA_SUBSCRIPTION_EVENT_AUTOLOAD: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { pa_autoload_entry *autoload; - + if ((autoload = pa_idxset_get_by_index(c->autoload_idxset, idx))) { if (publish_autoload(u, autoload) < 0) goto fail; @@ -420,7 +420,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if (remove_autoload(u, idx) < 0) goto fail; } - + break; } @@ -453,7 +453,7 @@ static void main_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState s static int publish_main_service(struct userdata *u) { AvahiStringList *txt = NULL; int r = -1; - + if (!u->main_entry_group) { if (!(u->main_entry_group = avahi_entry_group_new(u->client, main_entry_group_callback, u))) { pa_log("avahi_entry_group_new() failed: %s", avahi_strerror(avahi_client_errno(u->client))); @@ -461,7 +461,7 @@ static int publish_main_service(struct userdata *u) { } } else avahi_entry_group_reset(u->main_entry_group); - + txt = txt_record_server_data(u->core, NULL); if (avahi_entry_group_add_service_strlst( @@ -474,18 +474,18 @@ static int publish_main_service(struct userdata *u) { NULL, u->port, txt) < 0) { - + pa_log("avahi_entry_group_add_service_strlst() failed: %s", avahi_strerror(avahi_client_errno(u->client))); goto fail; } - + if (avahi_entry_group_commit(u->main_entry_group) < 0) { pa_log("avahi_entry_group_commit() failed: %s", avahi_strerror(avahi_client_errno(u->client))); goto fail; } r = 0; - + fail: avahi_string_list_free(txt); @@ -498,7 +498,7 @@ static int publish_all_services(struct userdata *u) { pa_autoload_entry *autoload; int r = -1; uint32_t idx; - + assert(u); pa_log_debug("Publishing services in Zeroconf"); @@ -518,9 +518,9 @@ static int publish_all_services(struct userdata *u) { if (publish_main_service(u) < 0) goto fail; - + r = 0; - + fail: return r; } @@ -528,7 +528,7 @@ fail: static void unpublish_all_services(struct userdata *u, int rem) { void *state = NULL; struct service *s; - + assert(u); pa_log_debug("Unpublishing services in Zeroconf"); @@ -538,7 +538,7 @@ static void unpublish_all_services(struct userdata *u, int rem) { if (rem) { avahi_entry_group_free(s->entry_group); s->entry_group = NULL; - } else + } else avahi_entry_group_reset(s->entry_group); } @@ -559,12 +559,12 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda assert(c); u->client = c; - + switch (state) { case AVAHI_CLIENT_S_RUNNING: publish_all_services(u); break; - + case AVAHI_CLIENT_S_COLLISION: unpublish_all_services(u, 0); break; @@ -578,7 +578,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) pa_log("pa_avahi_client_new() failed: %s", avahi_strerror(error)); } - + break; default: ; @@ -607,7 +607,7 @@ int pa__init(pa_core *c, pa_module*m) { u->port = (uint16_t) port; u->avahi_poll = pa_avahi_poll_new(c->mainloop); - + u->services = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func); u->sink_dynarray = pa_dynarray_new(); u->source_dynarray = pa_dynarray_new(); @@ -628,15 +628,15 @@ int pa__init(pa_core *c, pa_module*m) { } pa_modargs_free(ma); - + return 0; - + fail: pa__done(c, m); if (ma) pa_modargs_free(ma); - + return -1; } @@ -649,7 +649,7 @@ static void service_free(void *p, void *userdata) { if (s->entry_group) avahi_entry_group_free(s->entry_group); - + pa_xfree(s->service_name); pa_xfree(s->name); pa_xfree(s); @@ -674,14 +674,14 @@ void pa__done(pa_core *c, pa_module*m) { pa_dynarray_free(u->source_dynarray, NULL, NULL); if (u->autoload_dynarray) pa_dynarray_free(u->autoload_dynarray, NULL, NULL); - + if (u->main_entry_group) avahi_entry_group_free(u->main_entry_group); - + if (u->client) avahi_client_free(u->client); - + if (u->avahi_poll) pa_avahi_poll_free(u->avahi_poll); diff --git a/src/modules/oss-util.c b/src/modules/oss-util.c index 0aaf6971..d26a0e81 100644 --- a/src/modules/oss-util.c +++ b/src/modules/oss-util.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -48,14 +48,14 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) { if(!pcaps) pcaps = ∩︀ - + if (*mode == O_RDWR) { if ((fd = open(device, O_RDWR|O_NDELAY)) >= 0) { int dcaps, *tcaps; ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0); tcaps = pcaps ? pcaps : &dcaps; - + if (ioctl(fd, SNDCTL_DSP_GETCAPS, tcaps) < 0) { pa_log("SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno)); goto fail; @@ -68,7 +68,7 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) { close(fd); } - + if ((fd = open(device, (*mode = O_WRONLY)|O_NDELAY)) < 0) { if ((fd = open(device, (*mode = O_RDONLY)|O_NDELAY)) < 0) { pa_log("open('%s'): %s", device, pa_cstrerror(errno)); @@ -80,17 +80,17 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) { pa_log("open('%s'): %s", device, pa_cstrerror(errno)); goto fail; } - } + } success: *pcaps = 0; - + if (ioctl(fd, SNDCTL_DSP_GETCAPS, pcaps) < 0) { pa_log("SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno)); goto fail; } - + pa_log_debug("capabilities:%s%s%s%s%s%s%s%s%s%s%s%s%s%s", *pcaps & DSP_CAP_BATCH ? " BATCH" : "", #ifdef DSP_CAP_BIND @@ -100,7 +100,7 @@ success: #endif *pcaps & DSP_CAP_COPROC ? " COPROC" : "", *pcaps & DSP_CAP_DUPLEX ? " DUPLEX" : "", -#ifdef DSP_CAP_FREERATE +#ifdef DSP_CAP_FREERATE *pcaps & DSP_CAP_FREERATE ? " FREERATE" : "", #else "", @@ -140,7 +140,7 @@ success: *pcaps & DSP_CAP_TRIGGER ? " TRIGGER" : ""); pa_fd_set_cloexec(fd, 1); - + return fd; fail: @@ -152,7 +152,7 @@ fail: int pa_oss_auto_format(int fd, pa_sample_spec *ss) { int format, channels, speed, reqformat; pa_sample_format_t orig_format; - + static const int format_trans[PA_SAMPLE_MAX] = { [PA_SAMPLE_U8] = AFMT_U8, [PA_SAMPLE_ALAW] = AFMT_A_LAW, @@ -166,7 +166,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) { assert(fd >= 0 && ss); orig_format = ss->format; - + reqformat = format = format_trans[ss->format]; if (reqformat == AFMT_QUERY || ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != reqformat) { format = AFMT_S16_NE; @@ -190,7 +190,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) { pa_log_warn("device doesn't support sample format %s, changed to %s.", pa_sample_format_to_string(orig_format), pa_sample_format_to_string(ss->format)); - + channels = ss->channels; if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) < 0) { pa_log("SNDCTL_DSP_CHANNELS: %s", pa_cstrerror(errno)); @@ -229,14 +229,14 @@ static int simple_log2(int v) { if (!v) break; k++; } - + return k; } int pa_oss_set_fragments(int fd, int nfrags, int frag_size) { int arg; arg = ((int) nfrags << 16) | simple_log2(frag_size); - + if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) { pa_log("SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno)); return -1; @@ -252,7 +252,7 @@ static int pa_oss_get_volume(int fd, int mixer, const pa_sample_spec *ss, pa_cvo assert(fd >= 0); assert(ss); assert(volume); - + if (ioctl(fd, mixer, &vol) < 0) return -1; @@ -278,7 +278,7 @@ static int pa_oss_set_volume(int fd, int mixer, const pa_sample_spec *ss, const r = volume->values[1] > PA_VOLUME_NORM ? PA_VOLUME_NORM : volume->values[1]; vol |= ((r*100)/PA_VOLUME_NORM) << 8; } - + if (ioctl(fd, mixer, &vol) < 0) return -1; @@ -321,7 +321,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) { n = *e - '0'; else return -1; - + if (!(f = fopen("/dev/sndstat", "r")) && !(f = fopen("/proc/sndstat", "r")) && !(f = fopen("/proc/asound/oss/sndstat", "r"))) { @@ -335,7 +335,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) { while (!feof(f)) { char line[64]; int device; - + if (!fgets(line, sizeof(line), f)) break; @@ -348,7 +348,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) { if (line[0] == 0) break; - + if (sscanf(line, "%i: ", &device) != 1) continue; @@ -360,7 +360,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) { if (pa_endswith(k, " (DUPLEX)")) k[strlen(k)-9] = 0; - + pa_strlcpy(name, k, l); r = 0; break; diff --git a/src/modules/oss-util.h b/src/modules/oss-util.h index 12855f4e..6a8bf3d2 100644 --- a/src/modules/oss-util.h +++ b/src/modules/oss-util.h @@ -5,17 +5,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -- cgit