[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-131-g759a9d0
Lennart Poettering
gitmailer-noreply at 0pointer.de
Mon May 25 15:02:49 PDT 2009
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from 8f23a2edb5c602064b24648088572e61e9aeb395 (commit)
- Log -----------------------------------------------------------------
759a9d0 core-util: introduce pa_disable_sigpipe()
ebce318 cli: allow easy repeating of commands with '/'
8b180b6 volume: implement pa_cvolume_{scale|max|avg}_mask()
5f2d848 map-file: add missing channel map/cvolume position functions
-----------------------------------------------------------------------
Summary of changes:
src/daemon/main.c | 4 +--
src/map-file | 6 +++
src/pulse/volume.c | 87 +++++++++++++++++++++++++++++++++++++++-----
src/pulse/volume.h | 22 +++++++++++-
src/pulsecore/cli.c | 13 +++++++
src/pulsecore/core-util.c | 21 +++++++++++
src/pulsecore/core-util.h | 2 +
src/utils/pabrowse.c | 4 ++-
8 files changed, 144 insertions(+), 15 deletions(-)
-----------------------------------------------------------------------
commit 5f2d848d8e6958f8e83d4ef5100ef9597ff75011
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 25 23:54:08 2009 +0200
map-file: add missing channel map/cvolume position functions
diff --git a/src/map-file b/src/map-file
index 98a568e..5cae6d3 100644
--- a/src/map-file
+++ b/src/map-file
@@ -15,6 +15,7 @@ pa_channel_map_can_balance;
pa_channel_map_can_fade;
pa_channel_map_compatible;
pa_channel_map_equal;
+pa_channel_map_has_position;
pa_channel_map_init;
pa_channel_map_init_auto;
pa_channel_map_init_extend;
@@ -117,6 +118,7 @@ pa_cvolume_compatible_with_channel_map;
pa_cvolume_equal;
pa_cvolume_get_balance;
pa_cvolume_get_fade;
+pa_cvolume_get_position;
pa_cvolume_init;
pa_cvolume_max;
pa_cvolume_remap;
@@ -124,6 +126,7 @@ pa_cvolume_scale;
pa_cvolume_set;
pa_cvolume_set_balance;
pa_cvolume_set_fade;
+pa_cvolume_set_position;
pa_cvolume_snprint;
pa_cvolume_valid;
pa_ext_stream_restore_delete;
commit 8b180b6368b64c53d0da03682b5bfa8c7e6e6536
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 25 23:55:44 2009 +0200
volume: implement pa_cvolume_{scale|max|avg}_mask()
diff --git a/src/map-file b/src/map-file
index 5cae6d3..c46c679 100644
--- a/src/map-file
+++ b/src/map-file
@@ -112,6 +112,7 @@ pa_context_suspend_source_by_name;
pa_context_unload_module;
pa_context_unref;
pa_cvolume_avg;
+pa_cvolume_avg_mask;
pa_cvolume_channels_equal_to;
pa_cvolume_compatible;
pa_cvolume_compatible_with_channel_map;
@@ -121,8 +122,10 @@ pa_cvolume_get_fade;
pa_cvolume_get_position;
pa_cvolume_init;
pa_cvolume_max;
+pa_cvolume_max_mask;
pa_cvolume_remap;
pa_cvolume_scale;
+pa_cvolume_scale_mask;
pa_cvolume_set;
pa_cvolume_set_balance;
pa_cvolume_set_fade;
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index e48c777..64688e0 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -80,29 +80,78 @@ pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v) {
pa_volume_t pa_cvolume_avg(const pa_cvolume *a) {
uint64_t sum = 0;
- int i;
+ unsigned c;
pa_assert(a);
pa_return_val_if_fail(pa_cvolume_valid(a), PA_VOLUME_MUTED);
- for (i = 0; i < a->channels; i++)
- sum += a->values[i];
+ for (c = 0; c < a->channels; c++)
+ sum += a->values[c];
sum /= a->channels;
return (pa_volume_t) sum;
}
+pa_volume_t pa_cvolume_avg_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) {
+ uint64_t sum = 0;
+ unsigned c, n;
+
+ pa_assert(a);
+
+ if (!cm)
+ return pa_cvolume_avg(a);
+
+ pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(a, cm), PA_VOLUME_MUTED);
+
+ for (c = n = 0; c < a->channels; c++) {
+
+ if (!(PA_CHANNEL_POSITION_MASK(cm->map[c]) & mask))
+ continue;
+
+ sum += a->values[c];
+ n ++;
+ }
+
+ if (n > 0)
+ sum /= n;
+
+ return (pa_volume_t) sum;
+}
+
pa_volume_t pa_cvolume_max(const pa_cvolume *a) {
pa_volume_t m = 0;
- int i;
+ unsigned c;
pa_assert(a);
pa_return_val_if_fail(pa_cvolume_valid(a), PA_VOLUME_MUTED);
- for (i = 0; i < a->channels; i++)
- if (a->values[i] > m)
- m = a->values[i];
+ for (c = 0; c < a->channels; c++)
+ if (a->values[c] > m)
+ m = a->values[c];
+
+ return m;
+}
+
+pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) {
+ pa_volume_t m = 0;
+ unsigned c, n;
+
+ pa_assert(a);
+
+ if (!cm)
+ return pa_cvolume_max(a);
+
+ pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(a, cm), PA_VOLUME_MUTED);
+
+ for (c = n = 0; c < a->channels; c++) {
+
+ if (!(PA_CHANNEL_POSITION_MASK(cm->map[c]) & mask))
+ continue;
+
+ if (a->values[c] > m)
+ m = a->values[c];
+ }
return m;
}
@@ -590,11 +639,29 @@ pa_cvolume* pa_cvolume_scale(pa_cvolume *v, pa_volume_t max) {
pa_return_val_if_fail(pa_cvolume_valid(v), NULL);
pa_return_val_if_fail(max != (pa_volume_t) -1, NULL);
+ t = pa_cvolume_max(v);
+
+ if (t <= PA_VOLUME_MUTED)
+ return pa_cvolume_set(v, v->channels, max);
+
for (c = 0; c < v->channels; c++)
- if (v->values[c] > t)
- t = v->values[c];
+ v->values[c] = (pa_volume_t) (((uint64_t) v->values[c] * (uint64_t) max) / (uint64_t) t);
+
+ return v;
+}
+
+pa_cvolume* pa_cvolume_scale_mask(pa_cvolume *v, pa_volume_t max, pa_channel_map *cm, pa_channel_position_mask_t mask) {
+ unsigned c;
+ pa_volume_t t = 0;
+
+ pa_assert(v);
+
+ pa_return_val_if_fail(pa_cvolume_valid(v), NULL);
+ pa_return_val_if_fail(max != (pa_volume_t) -1, NULL);
+
+ t = pa_cvolume_max_mask(v, cm, mask);
- if (t <= 0)
+ if (t <= PA_VOLUME_MUTED)
return pa_cvolume_set(v, v->channels, max);
for (c = 0; c < v->channels; c++)
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index b567778..c07fd99 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -178,9 +178,23 @@ char *pa_sw_volume_snprint_dB(char *s, size_t l, pa_volume_t v);
/** Return the average volume of all channels */
pa_volume_t pa_cvolume_avg(const pa_cvolume *a) PA_GCC_PURE;
+/** Return the average volume of all channels that are included in the
+ * specified channel map with the specified channel position mask. If
+ * cm is NULL this call is identical to pa_cvolume_avg(). If no
+ * channel is selected the returned value will be
+ * PA_VOLUME_MUTED. \since 0.9.16 */
+pa_volume_t pa_cvolume_avg_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) PA_GCC_PURE;
+
/** Return the maximum volume of all channels. \since 0.9.12 */
pa_volume_t pa_cvolume_max(const pa_cvolume *a) PA_GCC_PURE;
+/** Return the maximum volume of all channels that are included in the
+ * specified channel map with the specified channel position mask. If
+ * cm is NULL this call is identical to pa_cvolume_max(). If no
+ * channel is selected the returned value will be PA_VOLUME_MUTED.
+ * \since 0.9.16 */
+pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) PA_GCC_PURE;
+
/** Return TRUE when the passed cvolume structure is valid, FALSE otherwise */
int pa_cvolume_valid(const pa_cvolume *v) PA_GCC_PURE;
@@ -283,6 +297,12 @@ pa_cvolume* pa_cvolume_set_fade(pa_cvolume *v, const pa_channel_map *map, float
* volumes are kept. \since 0.9.15 */
pa_cvolume* pa_cvolume_scale(pa_cvolume *v, pa_volume_t max);
+/** Scale the passed pa_cvolume structure so that the maximum volume
+ * of all channels selected via cm/mask equals max. This also modifies
+ * the volume of those channels that are unmasked. The proportions
+ * between the channel volumes are kept. \since 0.9.16 */
+pa_cvolume* pa_cvolume_scale_mask(pa_cvolume *v, pa_volume_t max, pa_channel_map *cm, pa_channel_position_mask_t mask);
+
/** Set the passed volume to all channels at the specified channel
* position. Will return the updated volume struct, or NULL if there
* is no channel at the position specified. You can check if a channel
@@ -294,7 +314,7 @@ pa_cvolume* pa_cvolume_set_position(pa_cvolume *cv, const pa_channel_map *map, p
* position. Will return 0 if there is no channel at the position
* specified. You can check if a channel map includes a specific
* position by calling pa_channel_map_has_position(). \since 0.9.16 */
-pa_volume_t pa_cvolume_get_position(pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t);
+pa_volume_t pa_cvolume_get_position(pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t) PA_GCC_PURE;
PA_C_DECL_END
commit ebce3185ef8064ab42106d2fd24aba21a159905d
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 25 23:56:38 2009 +0200
cli: allow easy repeating of commands with '/'
diff --git a/src/pulsecore/cli.c b/src/pulsecore/cli.c
index a784f58..54514e7 100644
--- a/src/pulsecore/cli.c
+++ b/src/pulsecore/cli.c
@@ -59,6 +59,8 @@ struct pa_cli {
pa_bool_t fail, kill_requested;
int defer_kill;
+
+ char *last_line;
};
static void line_callback(pa_ioline *line, const char *s, void *userdata);
@@ -101,6 +103,8 @@ pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m) {
c->fail = c->kill_requested = FALSE;
c->defer_kill = 0;
+ c->last_line = NULL;
+
return c;
}
@@ -110,6 +114,7 @@ void pa_cli_free(pa_cli *c) {
pa_ioline_close(c->line);
pa_ioline_unref(c->line);
pa_client_free(c->client);
+ pa_xfree(c->last_line);
pa_xfree(c);
}
@@ -144,6 +149,14 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
return;
}
+ /* Magic command, like they had in AT Hayes Modems! Those were the good days! */
+ if (pa_streq(s, "/"))
+ s = c->last_line;
+ else if (s[0]) {
+ pa_xfree(c->last_line);
+ c->last_line = pa_xstrdup(s);
+ }
+
pa_assert_se(buf = pa_strbuf_new());
c->defer_kill++;
pa_cli_command_execute_line(c->core, s, buf, &c->fail);
commit 759a9d0cc56c074567e0048fc0a1058bc179a101
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 25 23:56:38 2009 +0200
core-util: introduce pa_disable_sigpipe()
diff --git a/src/daemon/main.c b/src/daemon/main.c
index a232451..3e50baa 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -946,9 +946,7 @@ int main(int argc, char *argv[]) {
valid_pid_file = TRUE;
}
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
-#endif
+ pa_disable_sigpipe();
if (pa_rtclock_hrtimer())
pa_log_info(_("Fresh high-resolution timers available! Bon appetit!"));
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index d4956fb..b747cd8 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2711,3 +2711,24 @@ char *pa_realpath(const char *path) {
return t;
}
+
+void pa_disable_sigpipe(void) {
+
+#ifdef SIGPIPE
+ struct sigaction sa;
+
+ pa_zero(sa);
+
+ if (sigaction(SIGPIPE, NULL, &sa) < 0) {
+ pa_log("sigaction(): %s", pa_cstrerror(errno));
+ return;
+ }
+
+ sa.sa_handler = SIG_IGN;
+
+ if (sigaction(SIGPIPE, &sa, NULL) < 0) {
+ pa_log("sigaction(): %s", pa_cstrerror(errno));
+ return;
+ }
+#endif
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 91a4c55..d073b75 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -227,4 +227,6 @@ char *pa_unescape(char *p);
char *pa_realpath(const char *path);
+void pa_disable_sigpipe(void);
+
#endif
diff --git a/src/utils/pabrowse.c b/src/utils/pabrowse.c
index 288d44a..a6487b8 100644
--- a/src/utils/pabrowse.c
+++ b/src/utils/pabrowse.c
@@ -30,6 +30,8 @@
#include <pulse/pulseaudio.h>
#include <pulse/browser.h>
+#include <pulsecore/core-util.h>
+
static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
fprintf(stderr, "Got signal, exiting\n");
m->quit(m, 0);
@@ -127,7 +129,7 @@ int main(int argc, char *argv[]) {
assert(r == 0);
pa_signal_new(SIGINT, exit_signal_callback, NULL);
pa_signal_new(SIGTERM, exit_signal_callback, NULL);
- signal(SIGPIPE, SIG_IGN);
+ pa_disable_sigpipe();
if (!(browser = pa_browser_new_full(pa_mainloop_get_api(mainloop), PA_BROWSE_FOR_SERVERS|PA_BROWSE_FOR_SINKS|PA_BROWSE_FOR_SOURCES, &s))) {
fprintf(stderr, "pa_browse_new_full(): %s\n", s);
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list