diff options
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/dbus-util.c | 7 | ||||
-rw-r--r-- | src/pulsecore/flist.c | 4 | ||||
-rw-r--r-- | src/pulsecore/flist.h | 4 | ||||
-rw-r--r-- | src/pulsecore/sink.c | 33 |
4 files changed, 29 insertions, 19 deletions
diff --git a/src/pulsecore/dbus-util.c b/src/pulsecore/dbus-util.c index 8b203051..09ab071b 100644 --- a/src/pulsecore/dbus-util.c +++ b/src/pulsecore/dbus-util.c @@ -595,14 +595,19 @@ void pa_dbus_send_proplist_variant_reply(DBusConnection *c, DBusMessage *in_repl void pa_dbus_append_basic_array(DBusMessageIter *iter, int item_type, const void *array, unsigned n) { DBusMessageIter array_iter; + unsigned i; + unsigned item_size; pa_assert(iter); pa_assert(dbus_type_is_basic(item_type)); pa_assert(array || n == 0); + item_size = basic_type_size(item_type); + pa_assert_se(dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, signature_from_basic_type(item_type), &array_iter)); - pa_assert_se(dbus_message_iter_append_fixed_array(&array_iter, item_type, array, n)); + for (i = 0; i < n; ++i) + pa_assert_se(dbus_message_iter_append_basic(&array_iter, item_type, &((uint8_t*) array)[i * item_size])); pa_assert_se(dbus_message_iter_close_container(iter, &array_iter)); }; diff --git a/src/pulsecore/flist.c b/src/pulsecore/flist.c index 1867525b..23af5dd4 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 7fb50359..915b1135 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); diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 7b4e626d..3cadbff6 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); } } @@ -2905,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) { @@ -3006,20 +3004,25 @@ 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; - - /* 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; 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); } |