[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v1.0-dev-42-gaefa94f
Colin Guthrie
gitmailer-noreply at 0pointer.de
Sat Jan 15 05:50:16 PST 2011
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 a37e0963efbdd9ef22561f9c1ab386ee2c09280d (commit)
- Log -----------------------------------------------------------------
aefa94f alsa-sink: Don't assume we were able to enable hw-volume or sync-volume (v1.1)
98db3df alsa-sink: Fix double use of string
3d83a0c core: Use pa_sink_get_latency_within_thread() in sync-volume code
6fd138f core: Use volume_change_safety_margin when rewinding sync-volume events
34d022c core: Change sematics of pa_flist_new_with_name() (v1.1)
-----------------------------------------------------------------------
Summary of changes:
src/modules/alsa/alsa-sink.c | 56 +++++++++++++++++++++--------------------
src/pulsecore/flist.c | 4 ++-
src/pulsecore/flist.h | 4 +-
src/pulsecore/sink.c | 33 +++++++++++++-----------
4 files changed, 52 insertions(+), 45 deletions(-)
-----------------------------------------------------------------------
commit 34d022c16e654975c771f76511ef0d89bef6bec2
Author: Jyri Sarha <jyri.sarha at nokia.com>
Date: Thu Jan 13 16:44:41 2011 +0200
core: Change sematics of pa_flist_new_with_name() (v1.1)
Name string is copied and added to flist structure. The original is
responsibility of the caller. The name is only used for debug printing.
diff --git a/src/pulsecore/flist.c b/src/pulsecore/flist.c
index 1867525..23af5dd 100644
--- a/src/pulsecore/flist.c
+++ b/src/pulsecore/flist.c
@@ -83,13 +83,14 @@ static void stack_push(pa_atomic_ptr_t *list, pa_flist_elem *new_elem) {
pa_flist *pa_flist_new_with_name(unsigned size, const char *name) {
pa_flist *l;
unsigned i;
+ pa_assert(name);
if (!size)
size = FLIST_SIZE;
l = pa_xmalloc0(sizeof(pa_flist) + sizeof(pa_flist_elem) * size);
- l->name = name;
+ l->name = pa_xstrdup(name);
l->size = size;
pa_atomic_ptr_store(&l->stored, NULL);
pa_atomic_ptr_store(&l->empty, NULL);
@@ -105,6 +106,7 @@ pa_flist *pa_flist_new(unsigned size) {
void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb) {
pa_assert(l);
+ pa_assert(l->name);
if (free_cb) {
pa_flist_elem *elem;
diff --git a/src/pulsecore/flist.h b/src/pulsecore/flist.h
index 7fb5035..915b113 100644
--- a/src/pulsecore/flist.h
+++ b/src/pulsecore/flist.h
@@ -33,8 +33,8 @@
typedef struct pa_flist pa_flist;
pa_flist * pa_flist_new(unsigned size);
-/* Freeing the name is responsibility of caller. The name is only used
- * for debug printing. */
+/* Name string is copied and added to flist structure. The original is
+ * responsibility of the caller. The name is only used for debug printing. */
pa_flist * pa_flist_new_with_name(unsigned size, const char *name);
void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb);
commit 6fd138f66998b4c62a1acea7ba55ea6c7b854b48
Author: Jyri Sarha <jyri.sarha at nokia.com>
Date: Thu Jan 13 16:44:42 2011 +0200
core: Use volume_change_safety_margin when rewinding sync-volume events
After this patch the volume changes are applied immediately after
sink rewind before processing streams and monitor source.
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 7b4e626..acaed15 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -751,8 +751,11 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
if (s->thread_info.state == PA_SINK_SUSPENDED)
return;
- if (nbytes > 0)
+ if (nbytes > 0) {
pa_log_debug("Processing rewind...");
+ if (s->flags & PA_SINK_SYNC_VOLUME)
+ pa_sink_volume_change_rewind(s, nbytes);
+ }
PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state) {
pa_sink_input_assert_ref(i);
@@ -762,8 +765,6 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
if (nbytes > 0) {
if (s->monitor_source && PA_SOURCE_IS_LINKED(s->monitor_source->thread_info.state))
pa_source_process_rewind(s->monitor_source, nbytes);
- if (s->flags & PA_SINK_SYNC_VOLUME)
- pa_sink_volume_change_rewind(s, nbytes);
}
}
@@ -3006,6 +3007,7 @@ pa_bool_t pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next) {
static void pa_sink_volume_change_rewind(pa_sink *s, size_t nbytes) {
/* All the queued volume events later than current latency are shifted to happen earlier. */
pa_sink_volume_change *c;
+ pa_volume_t prev_vol = pa_cvolume_avg(&s->thread_info.current_hw_volume);
pa_usec_t rewound = pa_bytes_to_usec(nbytes, &s->sample_spec);
pa_usec_t limit;
@@ -3013,13 +3015,21 @@ static void pa_sink_volume_change_rewind(pa_sink *s, size_t nbytes) {
if (PA_MSGOBJECT(s)->process_msg(PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_LATENCY, &limit, 0, NULL) < 0)
limit = 0;
+ pa_log_debug("latency = %lld", limit);
limit += pa_rtclock_now() + s->thread_info.volume_change_extra_delay;
PA_LLIST_FOREACH(c, s->thread_info.volume_changes) {
- if (c->at > limit) {
+ pa_usec_t modified_limit = limit;
+ if (prev_vol > pa_cvolume_avg(&c->hw_volume))
+ modified_limit -= s->thread_info.volume_change_safety_margin;
+ else
+ modified_limit += s->thread_info.volume_change_safety_margin;
+ if (c->at > modified_limit) {
c->at -= rewound;
- if (c->at < limit)
- c->at = limit;
+ if (c->at < modified_limit)
+ c->at = modified_limit;
}
+ prev_vol = pa_cvolume_avg(&c->hw_volume);
}
+ pa_sink_volume_change_apply(s, NULL);
}
commit 3d83a0cf520b92b39d5c74a1cdbc845dd6c923c9
Author: Jyri Sarha <jyri.sarha at nokia.com>
Date: Thu Jan 13 16:44:43 2011 +0200
core: Use pa_sink_get_latency_within_thread() in sync-volume code
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index acaed15..3cadbff 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2906,10 +2906,7 @@ void pa_sink_volume_change_push(pa_sink *s) {
return;
}
- /* Get the latency of the sink */
- if (PA_MSGOBJECT(s)->process_msg(PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_LATENCY, &nc->at, 0, NULL) < 0)
- nc->at = 0;
-
+ nc->at = pa_sink_get_latency_within_thread(s);
nc->at += pa_rtclock_now() + s->thread_info.volume_change_extra_delay;
if (s->thread_info.volume_changes_tail) {
@@ -3009,11 +3006,7 @@ static void pa_sink_volume_change_rewind(pa_sink *s, size_t nbytes) {
pa_sink_volume_change *c;
pa_volume_t prev_vol = pa_cvolume_avg(&s->thread_info.current_hw_volume);
pa_usec_t rewound = pa_bytes_to_usec(nbytes, &s->sample_spec);
- pa_usec_t limit;
-
- /* Get the latency of the sink */
- if (PA_MSGOBJECT(s)->process_msg(PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_LATENCY, &limit, 0, NULL) < 0)
- limit = 0;
+ pa_usec_t limit = pa_sink_get_latency_within_thread(s);
pa_log_debug("latency = %lld", limit);
limit += pa_rtclock_now() + s->thread_info.volume_change_extra_delay;
commit 98db3dffb6250f814a79498e7752f86434d89b74
Author: Jyri Sarha <jyri.sarha at nokia.com>
Date: Thu Jan 13 16:44:44 2011 +0200
alsa-sink: Fix double use of string
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 53c14b8..a8ba363 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1281,15 +1281,17 @@ static void sink_write_volume_cb(pa_sink *s) {
(pa_cvolume_max(&tmp_vol) <= (PA_VOLUME_NORM + VOLUME_ACCURACY));
if (!accurate_enough) {
- char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX];
- char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX];
+ union {
+ char db[2][PA_SW_CVOLUME_SNPRINT_DB_MAX];
+ char pcnt[2][PA_CVOLUME_SNPRINT_MAX];
+ } vol;
pa_log_debug("Written HW volume did not match with the request: %s (request) != %s",
- pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &s->thread_info.current_hw_volume),
- pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &hw_vol));
+ pa_cvolume_snprint(vol.pcnt[0], sizeof(vol.pcnt[0]), &s->thread_info.current_hw_volume),
+ pa_cvolume_snprint(vol.pcnt[1], sizeof(vol.pcnt[1]), &hw_vol));
pa_log_debug(" in dB: %s (request) != %s",
- pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &s->thread_info.current_hw_volume),
- pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &hw_vol));
+ pa_sw_cvolume_snprint_dB(vol.db[0], sizeof(vol.db[0]), &s->thread_info.current_hw_volume),
+ pa_sw_cvolume_snprint_dB(vol.db[1], sizeof(vol.db[1]), &hw_vol));
}
}
}
commit aefa94f05282bb1164be7d1812fff4c086d9d55b
Author: Jyri Sarha <jyri.sarha at nokia.com>
Date: Thu Jan 13 16:44:45 2011 +0200
alsa-sink: Don't assume we were able to enable hw-volume or sync-volume (v1.1)
This patch also disables mixer callback code if we do not have neither
HW-volume or HW-mute.
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index a8ba363..f861904 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1672,8 +1672,6 @@ fail:
}
static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_volume) {
- int (*mixer_callback)(snd_mixer_elem_t *, unsigned int);
-
pa_assert(u);
if (!u->mixer_handle)
@@ -1762,29 +1760,31 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
pa_log_info("Using hardware mute control.");
}
- if (sync_volume) {
- u->mixer_pd = pa_alsa_mixer_pdata_new();
- mixer_callback = io_mixer_callback;
-
- if (pa_alsa_set_mixer_rtpoll(u->mixer_pd, u->mixer_handle, u->rtpoll) < 0) {
- pa_log("Failed to initialize file descriptor monitoring");
- return -1;
- }
+ if (u->sink->flags & (PA_SINK_HW_VOLUME_CTRL|PA_SINK_HW_MUTE_CTRL)) {
+ int (*mixer_callback)(snd_mixer_elem_t *, unsigned int);
+ if (u->sink->flags & PA_SINK_SYNC_VOLUME) {
+ u->mixer_pd = pa_alsa_mixer_pdata_new();
+ mixer_callback = io_mixer_callback;
- } else {
- u->mixer_fdl = pa_alsa_fdlist_new();
- mixer_callback = ctl_mixer_callback;
+ if (pa_alsa_set_mixer_rtpoll(u->mixer_pd, u->mixer_handle, u->rtpoll) < 0) {
+ pa_log("Failed to initialize file descriptor monitoring");
+ return -1;
+ }
+ } else {
+ u->mixer_fdl = pa_alsa_fdlist_new();
+ mixer_callback = ctl_mixer_callback;
- if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, u->core->mainloop) < 0) {
- pa_log("Failed to initialize file descriptor monitoring");
- return -1;
+ if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, u->core->mainloop) < 0) {
+ pa_log("Failed to initialize file descriptor monitoring");
+ return -1;
+ }
}
- }
- if (u->mixer_path_set)
- pa_alsa_path_set_set_callback(u->mixer_path_set, u->mixer_handle, mixer_callback, u);
- else
- pa_alsa_path_set_callback(u->mixer_path, u->mixer_handle, mixer_callback, u);
+ if (u->mixer_path_set)
+ pa_alsa_path_set_set_callback(u->mixer_path_set, u->mixer_handle, mixer_callback, u);
+ else
+ pa_alsa_path_set_callback(u->mixer_path, u->mixer_handle, mixer_callback, u);
+ }
return 0;
}
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list