[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-84-g8d9c26e
Lennart Poettering
gitmailer-noreply at 0pointer.de
Thu May 7 17:05:21 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 e0f08219bb6b5ed9fd92623997074410051ed671 (commit)
- Log -----------------------------------------------------------------
8d9c26e core: cache requested latency only when we are running, not while we are still constructing
99a6a47 core: make sure we fix up flags/monitor flags already in pa_sink_new() instead of pa_sink_put()
3766850 core: introduce pa_{sink,source}_set_fixed_latency()
92a6141 macro: add macros for initializing memory
-----------------------------------------------------------------------
Summary of changes:
src/modules/alsa/alsa-sink.c | 4 +-
src/modules/alsa/alsa-source.c | 4 +-
src/modules/bluetooth/module-bluetooth-device.c | 12 ++--
src/modules/module-pipe-sink.c | 2 +-
src/modules/module-pipe-source.c | 2 +-
src/modules/module-sine-source.c | 3 +-
src/modules/oss/module-oss.c | 4 +-
src/pulsecore/macro.h | 3 +
src/pulsecore/sink-input.c | 2 +-
src/pulsecore/sink.c | 62 ++++++++++++++---------
src/pulsecore/sink.h | 1 +
src/pulsecore/source.c | 43 ++++++++++------
src/pulsecore/source.h | 1 +
13 files changed, 87 insertions(+), 56 deletions(-)
-----------------------------------------------------------------------
commit 92a61418882a68e913d2a40ae28e815a68c456f8
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu May 7 22:03:04 2009 +0200
macro: add macros for initializing memory
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 73438e6..e9888c3 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -261,6 +261,9 @@ typedef int pa_bool_t;
#define PA_DEBUG_TRAP raise(SIGTRAP)
#endif
+#define pa_memzero(x,l) (memset((x), 0, (l)))
+#define pa_zero(x) (pa_memzero(&(x), sizeof(x)))
+
/* We include this at the very last place */
#include <pulsecore/log.h>
commit 3766850c8b98b3fe8abb3b5634d4801cbdb95377
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri May 8 01:56:21 2009 +0200
core: introduce pa_{sink,source}_set_fixed_latency()
This allows us to forward the fixed latency directly from the sink to
the monitor source withut having to wait for pa_sink_put().
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 4d8dade..2745a14 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -473,7 +473,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle
u->since_start += frames * u->frame_size;
#ifdef DEBUG_TIMING
- pa_log_debug("Wrote %lu bytes", (unsigned long) (frames * u->frame_size));
+ pa_log_debug("Wrote %lu bytes (of possible %lu bytes)", (unsigned long) (frames * u->frame_size), (unsigned long) n_bytes);
#endif
if ((size_t) frames * u->frame_size >= n_bytes)
@@ -1730,7 +1730,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
pa_log_info("Time scheduling watermark is %0.2fms",
(double) pa_bytes_to_usec(u->tsched_watermark, &ss) / PA_USEC_PER_MSEC);
} else
- u->sink->fixed_latency = pa_bytes_to_usec(u->hwbuf_size, &ss);
+ pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(u->hwbuf_size, &ss));
reserve_update(u);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index d49035c..af567c9 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -455,7 +455,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled
u->read_count += frames * u->frame_size;
#ifdef DEBUG_TIMING
- pa_log_debug("Read %lu bytes", (unsigned long) (frames * u->frame_size));
+ pa_log_debug("Read %lu bytes (of possible %lu bytes)", (unsigned long) (frames * u->frame_size), (unsigned long) n_bytes);
#endif
if ((size_t) frames * u->frame_size >= n_bytes)
@@ -1582,7 +1582,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
pa_log_info("Time scheduling watermark is %0.2fms",
(double) pa_bytes_to_usec(u->tsched_watermark, &ss) / PA_USEC_PER_MSEC);
} else
- u->source->fixed_latency = pa_bytes_to_usec(u->hwbuf_size, &ss);
+ pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->hwbuf_size, &ss));
reserve_update(u);
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index ecb5e83..c5c55a1 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1608,9 +1608,9 @@ static int add_sink(struct userdata *u) {
u->sink->parent.process_msg = sink_process_msg;
pa_sink_set_max_request(u->sink, u->block_size);
- u->sink->fixed_latency =
- (u->profile == PROFILE_A2DP ? FIXED_LATENCY_PLAYBACK_A2DP : FIXED_LATENCY_PLAYBACK_HSP) +
- pa_bytes_to_usec(u->block_size, &u->sample_spec);
+ pa_sink_set_fixed_latency(u->sink,
+ (u->profile == PROFILE_A2DP ? FIXED_LATENCY_PLAYBACK_A2DP : FIXED_LATENCY_PLAYBACK_HSP) +
+ pa_bytes_to_usec(u->block_size, &u->sample_spec));
}
if (u->profile == PROFILE_HSP) {
@@ -1659,9 +1659,9 @@ static int add_source(struct userdata *u) {
u->source->userdata = u;
u->source->parent.process_msg = source_process_msg;
- u->source->fixed_latency =
- (/* u->profile == PROFILE_A2DP ? FIXED_LATENCY_RECORD_A2DP : */ FIXED_LATENCY_RECORD_HSP) +
- pa_bytes_to_usec(u->block_size, &u->sample_spec);
+ pa_source_set_fixed_latency(u->source,
+ (/* u->profile == PROFILE_A2DP ? FIXED_LATENCY_RECORD_A2DP : */ FIXED_LATENCY_RECORD_HSP) +
+ pa_bytes_to_usec(u->block_size, &u->sample_spec));
}
if (u->profile == PROFILE_HSP) {
diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c
index 9d3e55d..304d01c 100644
--- a/src/modules/module-pipe-sink.c
+++ b/src/modules/module-pipe-sink.c
@@ -293,7 +293,7 @@ int pa__init(pa_module*m) {
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_rtpoll(u->sink, u->rtpoll);
pa_sink_set_max_request(u->sink, PIPE_BUF);
- u->sink->fixed_latency = pa_bytes_to_usec(PIPE_BUF, &u->sink->sample_spec);
+ pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(PIPE_BUF, &u->sink->sample_spec));
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c
index df72d79..6ed4fbf 100644
--- a/src/modules/module-pipe-source.c
+++ b/src/modules/module-pipe-source.c
@@ -277,7 +277,7 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
- u->source->fixed_latency = pa_bytes_to_usec(PIPE_BUF, &u->source->sample_spec);
+ pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(PIPE_BUF, &u->source->sample_spec));
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
diff --git a/src/modules/module-sine-source.c b/src/modules/module-sine-source.c
index a5f1ce7..a6e15d8 100644
--- a/src/modules/module-sine-source.c
+++ b/src/modules/module-sine-source.c
@@ -264,8 +264,7 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
- u->source->fixed_latency = u->block_usec;
-
+ pa_source_set_fixed_latency(u->source, u->block_usec);
if (!(u->thread = pa_thread_new(thread_func, u))) {
pa_log("Failed to create thread.");
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 9f7863f..ab26137 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -1325,8 +1325,8 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
+ pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->in_hwbuf_size, &u->source->sample_spec));
u->source->refresh_volume = TRUE;
- u->source->fixed_latency = pa_bytes_to_usec(u->in_hwbuf_size, &u->source->sample_spec);
if (use_mmap)
u->in_mmap_memblocks = pa_xnew0(pa_memblock*, u->in_nfrags);
@@ -1387,8 +1387,8 @@ int pa__init(pa_module*m) {
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_rtpoll(u->sink, u->rtpoll);
+ pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(u->out_hwbuf_size, &u->sink->sample_spec));
u->sink->refresh_volume = TRUE;
- u->sink->fixed_latency = pa_bytes_to_usec(u->out_hwbuf_size, &u->sink->sample_spec);
pa_sink_set_max_request(u->sink, u->out_hwbuf_size);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 30fa557..06c8b52 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2050,6 +2050,22 @@ void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency,
pa_source_set_latency_range_within_thread(s->monitor_source, min_latency, max_latency);
}
+/* Called from main thread, before the sink is put */
+void pa_sink_set_fixed_latency(pa_sink *s, pa_usec_t latency) {
+ pa_sink_assert_ref(s);
+
+ pa_assert(pa_sink_get_state(s) == PA_SINK_INIT);
+
+ if (latency < ABSOLUTE_MIN_LATENCY)
+ latency = ABSOLUTE_MIN_LATENCY;
+
+ if (latency > ABSOLUTE_MAX_LATENCY)
+ latency = ABSOLUTE_MAX_LATENCY;
+
+ s->fixed_latency = latency;
+ pa_source_set_fixed_latency(s->monitor_source, latency);
+}
+
/* Called from main context */
size_t pa_sink_get_max_rewind(pa_sink *s) {
size_t r;
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 352282b..e33b3cf 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -229,6 +229,7 @@ void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p);
void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind);
void pa_sink_set_max_request(pa_sink *s, size_t max_request);
void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
+void pa_sink_set_fixed_latency(pa_sink *s, pa_usec_t latency);
void pa_sink_detach(pa_sink *s);
void pa_sink_attach(pa_sink *s);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 2190250..a772dc6 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1276,6 +1276,21 @@ void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_laten
pa_source_invalidate_requested_latency(s);
}
+/* Called from main thread, before the source is put */
+void pa_source_set_fixed_latency(pa_source *s, pa_usec_t latency) {
+ pa_source_assert_ref(s);
+
+ pa_assert(pa_source_get_state(s) == PA_SOURCE_INIT);
+
+ if (latency < ABSOLUTE_MIN_LATENCY)
+ latency = ABSOLUTE_MIN_LATENCY;
+
+ if (latency > ABSOLUTE_MAX_LATENCY)
+ latency = ABSOLUTE_MAX_LATENCY;
+
+ s->fixed_latency = latency;
+}
+
/* Called from main thread */
size_t pa_source_get_max_rewind(pa_source *s) {
size_t r;
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index b502c22..2978f57 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -210,6 +210,7 @@ void pa_source_set_rtpoll(pa_source *s, pa_rtpoll *p);
void pa_source_set_max_rewind(pa_source *s, size_t max_rewind);
void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency);
+void pa_source_set_fixed_latency(pa_source *s, pa_usec_t latency);
void pa_source_detach(pa_source *s);
void pa_source_attach(pa_source *s);
commit 99a6a4742f01fc62e5d6b56ec18ee36b7905456a
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri May 8 02:02:06 2009 +0200
core: make sure we fix up flags/monitor flags already in pa_sink_new() instead of pa_sink_put()
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 0229918..0d05b00 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -819,7 +819,7 @@ pa_usec_t pa_sink_input_set_requested_latency_within_thread(pa_sink_input *i, pa
usec = i->sink->fixed_latency;
if (usec != (pa_usec_t) -1)
- usec = PA_CLAMP(usec, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
+ usec = PA_CLAMP(usec, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
i->thread_info.requested_sink_latency = usec;
pa_sink_invalidate_requested_latency(i->sink);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 06c8b52..3eb759c 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -184,6 +184,12 @@ pa_sink* pa_sink_new(
return NULL;
}
+ if (!(flags & PA_SINK_HW_VOLUME_CTRL))
+ flags |= PA_SINK_DECIBEL_VOLUME;
+
+ if ((flags & PA_SINK_DECIBEL_VOLUME) && core->flat_volumes)
+ flags |= PA_SINK_FLAT_VOLUME;
+
s->parent.parent.free = sink_free;
s->parent.process_msg = pa_sink_process_msg;
@@ -263,7 +269,9 @@ pa_sink* pa_sink_new(
pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Monitor of %s", dn ? dn : s->name);
pa_proplist_sets(source_data.proplist, PA_PROP_DEVICE_CLASS, "monitor");
- s->monitor_source = pa_source_new(core, &source_data, 0);
+ s->monitor_source = pa_source_new(core, &source_data,
+ ((flags & PA_SINK_LATENCY) ? PA_SOURCE_LATENCY : 0) |
+ ((flags & PA_SINK_DYNAMIC_LATENCY) ? PA_SOURCE_DYNAMIC_LATENCY : 0));
pa_source_new_data_done(&source_data);
@@ -349,31 +357,18 @@ void pa_sink_put(pa_sink* s) {
pa_assert(s->rtpoll);
pa_assert(s->thread_info.min_latency <= s->thread_info.max_latency);
- if (!(s->flags & PA_SINK_HW_VOLUME_CTRL)) {
- s->flags |= PA_SINK_DECIBEL_VOLUME;
- s->base_volume = PA_VOLUME_NORM;
- }
-
s->thread_info.soft_volume = s->soft_volume;
s->thread_info.soft_muted = s->muted;
- if (s->flags & PA_SINK_DECIBEL_VOLUME)
- s->n_volume_steps = PA_VOLUME_NORM+1;
-
- if (s->core->flat_volumes)
- if (s->flags & PA_SINK_DECIBEL_VOLUME)
- s->flags |= PA_SINK_FLAT_VOLUME;
-
- if (s->flags & PA_SINK_LATENCY)
- s->monitor_source->flags |= PA_SOURCE_LATENCY;
-
- if (s->flags & PA_SINK_DYNAMIC_LATENCY) {
- s->monitor_source->flags |= PA_SOURCE_DYNAMIC_LATENCY;
- s->fixed_latency = 0;
- } else if (s->fixed_latency <= 0)
- s->fixed_latency = DEFAULT_FIXED_LATENCY;
+ pa_assert((s->flags & PA_SINK_HW_VOLUME_CTRL) || (s->base_volume == PA_VOLUME_NORM && s->flags & PA_SINK_DECIBEL_VOLUME));
+ pa_assert(!(s->flags & PA_SINK_DECIBEL_VOLUME) || s->n_volume_steps == PA_VOLUME_NORM+1);
+ pa_assert(!(s->flags & PA_SINK_DYNAMIC_LATENCY) == (s->fixed_latency != 0));
+ pa_assert(!(s->flags & PA_SINK_LATENCY) == !(s->monitor_source->flags & PA_SOURCE_LATENCY));
+ pa_assert(!(s->flags & PA_SINK_DYNAMIC_LATENCY) == !(s->monitor_source->flags & PA_SOURCE_DYNAMIC_LATENCY));
- s->monitor_source->fixed_latency = s->fixed_latency;
+ pa_assert(s->monitor_source->fixed_latency == s->fixed_latency);
+ pa_assert(s->monitor_source->thread_info.min_latency == s->thread_info.min_latency);
+ pa_assert(s->monitor_source->thread_info.max_latency == s->thread_info.max_latency);
pa_assert_se(sink_set_state(s, PA_SINK_IDLE) == 0);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index a772dc6..92387f6 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -174,6 +174,9 @@ pa_source* pa_source_new(
return NULL;
}
+ if (!(flags & PA_SOURCE_HW_VOLUME_CTRL))
+ flags |= PA_SOURCE_DECIBEL_VOLUME;
+
s->parent.parent.free = source_free;
s->parent.process_msg = pa_source_process_msg;
@@ -308,20 +311,12 @@ void pa_source_put(pa_source *s) {
pa_assert(s->rtpoll);
pa_assert(s->thread_info.min_latency <= s->thread_info.max_latency);
- if (!(s->flags & PA_SOURCE_HW_VOLUME_CTRL)) {
- s->flags |= PA_SOURCE_DECIBEL_VOLUME;
-
- s->thread_info.soft_volume = s->soft_volume;
- s->thread_info.soft_muted = s->muted;
- }
-
- if (s->flags & PA_SOURCE_DECIBEL_VOLUME)
- s->n_volume_steps = PA_VOLUME_NORM+1;
+ s->thread_info.soft_volume = s->soft_volume;
+ s->thread_info.soft_muted = s->muted;
- if (s->flags & PA_SOURCE_DYNAMIC_LATENCY)
- s->fixed_latency = 0;
- else if (s->fixed_latency <= 0)
- s->fixed_latency = DEFAULT_FIXED_LATENCY;
+ pa_assert((s->flags & PA_SOURCE_HW_VOLUME_CTRL) || (s->base_volume == PA_VOLUME_NORM && s->flags & PA_SOURCE_DECIBEL_VOLUME));
+ pa_assert(!(s->flags & PA_SOURCE_DECIBEL_VOLUME) || s->n_volume_steps == PA_VOLUME_NORM+1);
+ pa_assert(!(s->flags & PA_SOURCE_DYNAMIC_LATENCY) == (s->fixed_latency != 0));
pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0);
commit 8d9c26e3b6d29d3922a7cc740f273e34ea97498e
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri May 8 02:02:36 2009 +0200
core: cache requested latency only when we are running, not while we are still constructing
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 3eb759c..0f594da 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1858,8 +1858,11 @@ pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s) {
if (result != (pa_usec_t) -1)
result = PA_CLAMP(result, s->thread_info.min_latency, s->thread_info.max_latency);
- s->thread_info.requested_latency = result;
- s->thread_info.requested_latency_valid = TRUE;
+ if (PA_SINK_IS_LINKED(s->thread_info.state)) {
+ /* Only cache if properly initialized */
+ s->thread_info.requested_latency = result;
+ s->thread_info.requested_latency_valid = TRUE;
+ }
return result;
}
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 92387f6..47bc5fb 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1113,8 +1113,11 @@ pa_usec_t pa_source_get_requested_latency_within_thread(pa_source *s) {
if (result != (pa_usec_t) -1)
result = PA_CLAMP(result, s->thread_info.min_latency, s->thread_info.max_latency);
- s->thread_info.requested_latency = result;
- s->thread_info.requested_latency_valid = TRUE;
+ if (PA_SOURCE_IS_LINKED(s->thread_info.state)) {
+ /* Only cache this if we are fully set up */
+ s->thread_info.requested_latency = result;
+ s->thread_info.requested_latency_valid = TRUE;
+ }
return result;
}
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list