[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.16-test2-43-g59659e1
Lennart Poettering
gitmailer-noreply at 0pointer.de
Fri Jul 24 11:22:06 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 f6763917ee757845e2c52e36975d948bc93d8b6e (commit)
- Log -----------------------------------------------------------------
59659e1 interpol-test: allow configuration of latency
211d0f3 client: limit block size for zero-copy operations to mempool block size
e7ca058 client: make volume struct const
5efb072 alsa: throw timing data away after device resume
-----------------------------------------------------------------------
Summary of changes:
src/modules/alsa/alsa-sink.c | 6 ++-
src/modules/alsa/alsa-source.c | 4 +-
src/pulse/stream.c | 15 ++++++-
src/pulse/stream.h | 15 ++++---
src/pulsecore/time-smoother.c | 41 ++++++++++----------
src/pulsecore/time-smoother.h | 2 +-
src/tests/interpol-test.c | 81 ++++++++++++++++++++++++++-------------
7 files changed, 104 insertions(+), 60 deletions(-)
-----------------------------------------------------------------------
commit 5efb07281d5be1cddaed5b0610325fedd7f599ec
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jul 24 20:13:52 2009 +0200
alsa: throw timing data away after device resume
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 46562cb..7fc602b 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -899,9 +899,13 @@ static int unsuspend(struct userdata *u) {
if (build_pollfd(u) < 0)
goto fail;
+ u->write_count = 0;
+ pa_smoother_reset(u->smoother, pa_rtclock_now(), TRUE);
+
u->first = TRUE;
u->since_start = 0;
+
pa_log_info("Resumed successfully...");
return 0;
@@ -1204,7 +1208,7 @@ static int process_rewind(struct userdata *u) {
if (rewind_nbytes <= 0)
pa_log_info("Tried rewind, but was apparently not possible.");
else {
- u->write_count -= out_frames * u->frame_size;
+ u->write_count -= rewind_nbytes;
pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
pa_sink_process_rewind(u->sink, rewind_nbytes);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 8a1fbe5..ed9c148 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -854,7 +854,9 @@ static int unsuspend(struct userdata *u) {
/* FIXME: We need to reload the volume somehow */
snd_pcm_start(u->pcm_handle);
- pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE);
+
+ u->read_count = 0;
+ pa_smoother_reset(u->smoother, pa_rtclock_now(), TRUE);
pa_log_info("Resumed successfully...");
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 5baf5c2..a22816a 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -827,7 +827,7 @@ static void create_stream_complete(pa_stream *s) {
if (s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
s->auto_timing_interval_usec = AUTO_TIMING_INTERVAL_START_USEC;
pa_assert(!s->auto_timing_update_event);
- s->auto_timing_update_event = pa_context_rttime_new(s->context, pa_rtclock_now() + s->auto_timing_interval_usec, &auto_timing_update_callback, s);
+ s->auto_timing_update_event = pa_context_rttime_new(s->context, pa_rtclock_now() + s->auto_timing_interval_usec, &auto_timing_update_callback, s);
request_auto_timing_update(s, TRUE);
}
diff --git a/src/pulsecore/time-smoother.c b/src/pulsecore/time-smoother.c
index 9d5a070..1289f2b 100644
--- a/src/pulsecore/time-smoother.c
+++ b/src/pulsecore/time-smoother.c
@@ -108,29 +108,11 @@ pa_smoother* pa_smoother_new(
s = pa_xnew(pa_smoother, 1);
s->adjust_time = adjust_time;
s->history_time = history_time;
- s->time_offset = 0;
+ s->min_history = min_history;
s->monotonic = monotonic;
-
- s->px = s->py = 0;
- s->dp = 1;
-
- s->ex = s->ey = s->ry = 0;
- s->de = 1;
-
- s->history_idx = 0;
- s->n_history = 0;
-
- s->last_y = s->last_x = 0;
-
- s->abc_valid = FALSE;
-
- s->paused = FALSE;
s->smoothing = smoothing;
- s->min_history = min_history;
-
- s->paused = paused;
- s->time_offset = s->pause_time = time_offset;
+ pa_smoother_reset(s, time_offset, paused);
return s;
}
@@ -514,9 +496,26 @@ pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay)
return (pa_usec_t) llrint((double) y_delay / nde);
}
-void pa_smoother_reset(pa_smoother *s) {
+void pa_smoother_reset(pa_smoother *s, pa_usec_t time_offset, pa_bool_t paused) {
pa_assert(s);
+ s->px = s->py = 0;
+ s->dp = 1;
+
+ s->ex = s->ey = s->ry = 0;
+ s->de = 1;
+
+ s->history_idx = 0;
s->n_history = 0;
+
+ s->last_y = s->last_x = 0;
+
s->abc_valid = FALSE;
+
+ s->paused = paused;
+ s->time_offset = s->pause_time = time_offset;
+
+ /* #ifdef DEBUG_DATA */
+ pa_log_debug("reset()");
+/* #endif */
}
diff --git a/src/pulsecore/time-smoother.h b/src/pulsecore/time-smoother.h
index 5244a7e..63d33e4 100644
--- a/src/pulsecore/time-smoother.h
+++ b/src/pulsecore/time-smoother.h
@@ -52,7 +52,7 @@ void pa_smoother_set_time_offset(pa_smoother *s, pa_usec_t x_offset);
void pa_smoother_pause(pa_smoother *s, pa_usec_t x);
void pa_smoother_resume(pa_smoother *s, pa_usec_t x, pa_bool_t abrupt);
-void pa_smoother_reset(pa_smoother *s);
+void pa_smoother_reset(pa_smoother *s, pa_usec_t time_offset, pa_bool_t paused);
void pa_smoother_fix_now(pa_smoother *s);
commit e7ca058427e795b9c2b436c4a819e8d8354ee9de
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jul 24 20:20:34 2009 +0200
client: make volume struct const
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index a22816a..bbd0149 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -1172,7 +1172,7 @@ int pa_stream_connect_playback(
const char *dev,
const pa_buffer_attr *attr,
pa_stream_flags_t flags,
- pa_cvolume *volume,
+ const pa_cvolume *volume,
pa_stream *sync_stream) {
pa_assert(s);
diff --git a/src/pulse/stream.h b/src/pulse/stream.h
index fecc587..eeffc0c 100644
--- a/src/pulse/stream.h
+++ b/src/pulse/stream.h
@@ -405,7 +405,7 @@ int pa_stream_connect_playback(
const char *dev /**< Name of the sink to connect to, or NULL for default */ ,
const pa_buffer_attr *attr /**< Buffering attributes, or NULL for default */,
pa_stream_flags_t flags /**< Additional flags, or 0 for default */,
- pa_cvolume *volume /**< Initial volume, or NULL for default */,
+ const pa_cvolume *volume /**< Initial volume, or NULL for default */,
pa_stream *sync_stream /**< Synchronize this stream with the specified one, or NULL for a standalone stream*/);
/** Connect the stream to a source */
commit 211d0f3dcb23c6d63dd6a212826a872ce972e4ee
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jul 24 20:21:30 2009 +0200
client: limit block size for zero-copy operations to mempool block size
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index bbd0149..72d49e1 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -1207,6 +1207,17 @@ int pa_stream_begin_write(
PA_CHECK_VALIDITY(s->context, data, PA_ERR_INVALID);
PA_CHECK_VALIDITY(s->context, nbytes && *nbytes != 0, PA_ERR_INVALID);
+ if (*nbytes != (size_t) -1) {
+ size_t m, fs;
+
+ m = pa_mempool_block_size_max(s->context->mempool);
+ fs = pa_frame_size(&s->sample_spec);
+
+ m = (m / fs) * fs;
+ if (*nbytes > m)
+ *nbytes = m;
+ }
+
if (!s->write_memblock) {
s->write_memblock = pa_memblock_new(s->context->mempool, *nbytes);
s->write_data = pa_memblock_acquire(s->write_memblock);
diff --git a/src/pulse/stream.h b/src/pulse/stream.h
index eeffc0c..cb8b74d 100644
--- a/src/pulse/stream.h
+++ b/src/pulse/stream.h
@@ -425,7 +425,7 @@ int pa_stream_disconnect(pa_stream *s);
* to a pointer and an address of the number of bytes you want to
* write. On return the two values will contain a pointer where you
* can place the data to write and the maximum number of bytes you can
- * write. On return *nbytes can be larger or have the same value as
+ * write. On return *nbytes can be smaller or have the same value as
* you passed in. You need to be able to handle both cases. Accessing
* memory beyond the returned *nbytes value is invalid. Acessing the
* memory returned after the following pa_stream_write() or
@@ -442,7 +442,7 @@ int pa_stream_disconnect(pa_stream *s);
* amount of time pass after calling pa_stream_begin_write() and
* before calling pa_stream_write(). If you want to cancel a
* previously called pa_stream_begin_write() without calling
- * pa_stream_write() use pa_stream_cancel_write() instead. Calling
+ * pa_stream_write() use pa_stream_cancel_write(). Calling
* pa_stream_begin_write() twice without calling pa_stream_write() or
* pa_stream_cancel_write() in between will return exactly the same
* pointer/nbytes values.\since 0.9.16 */
@@ -492,10 +492,11 @@ int pa_stream_write(
pa_seek_mode_t seek /**< Seek mode, must be PA_SEEK_RELATIVE for upload streams */);
/** Read the next fragment from the buffer (for recording streams).
- * data will point to the actual data and length will contain the size
- * of the data in bytes (which can be less than a complete framgnet).
- * Use pa_stream_drop() to actually remove the data from the
- * buffer. If no data is available will return a NULL pointer */
+ * data will point to the actual data and nbytes will contain the size
+ * of the data in bytes (which can be less or more than a complete
+ * fragment). Use pa_stream_drop() to actually remove the data from
+ * the buffer. If no data is available this will return a NULL
+ * pointer */
int pa_stream_peek(
pa_stream *p /**< The stream to use */,
const void **data /**< Pointer to pointer that will point to data */,
commit 59659e1db64d2a88787943da75cf6c510d0ad98f
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jul 24 20:22:19 2009 +0200
interpol-test: allow configuration of latency
diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c
index 0c906d3..007555c 100644
--- a/src/tests/interpol-test.c
+++ b/src/tests/interpol-test.c
@@ -43,20 +43,37 @@ static pa_context *context = NULL;
static pa_stream *stream = NULL;
static pa_mainloop_api *mainloop_api = NULL;
static pa_bool_t playback = TRUE;
+static pa_usec_t latency = 0;
static void stream_write_cb(pa_stream *p, size_t nbytes, void *userdata) {
/* Just some silence */
- pa_assert_se(pa_stream_write(p, pa_xmalloc0(nbytes), nbytes, pa_xfree, 0, PA_SEEK_RELATIVE) == 0);
+
+ for (;;) {
+ void *data;
+
+ pa_assert_se((nbytes = pa_stream_writable_size(p)) != (size_t) -1);
+
+ if (nbytes <= 0)
+ break;
+
+ pa_assert_se(pa_stream_begin_write(p, &data, &nbytes) == 0);
+ pa_memzero(data, nbytes);
+ pa_assert_se(pa_stream_write(p, data, nbytes, NULL, 0, PA_SEEK_RELATIVE) == 0);
+ }
}
static void stream_read_cb(pa_stream *p, size_t nbytes, void *userdata) {
- /* We don't care, just drop the data */
+ /* We don't care about the data, just drop it */
- while (pa_stream_readable_size(p) > 0) {
- const void *d;
- size_t b;
+ for (;;) {
+ const void *data;
- pa_assert_se(pa_stream_peek(p, &d, &b) == 0);
+ pa_assert_se((nbytes = pa_stream_readable_size(p)) != (size_t) -1);
+
+ if (nbytes <= 0)
+ break;
+
+ pa_assert_se(pa_stream_peek(p, &data, &nbytes) == 0);
pa_assert_se(pa_stream_drop(p) == 0);
}
}
@@ -82,27 +99,36 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_READY: {
pa_stream_flags_t flags = PA_STREAM_AUTO_TIMING_UPDATE;
-
+ pa_buffer_attr attr;
static const pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE,
.rate = 44100,
.channels = 2
};
+ pa_zero(attr);
+ attr.maxlength = (uint32_t) -1;
+ attr.tlength = latency > 0 ? (uint32_t) pa_usec_to_bytes(latency, &ss) : (uint32_t) -1;
+ attr.prebuf = (uint32_t) -1;
+ attr.minreq = (uint32_t) -1;
+ attr.fragsize = (uint32_t) -1;
+
#ifdef INTERPOLATE
flags |= PA_STREAM_INTERPOLATE_TIMING;
#endif
+ if (latency > 0)
+ flags |= PA_STREAM_ADJUST_LATENCY;
+
fprintf(stderr, "Connection established.\n");
- stream = pa_stream_new(c, "interpol-test", &ss, NULL);
- assert(stream);
+ pa_assert_se(stream = pa_stream_new(c, "interpol-test", &ss, NULL));
if (playback) {
- pa_assert_se(pa_stream_connect_playback(stream, NULL, NULL, flags, NULL, NULL) == 0);
+ pa_assert_se(pa_stream_connect_playback(stream, NULL, &attr, flags, NULL, NULL) == 0);
pa_stream_set_write_callback(stream, stream_write_cb, NULL);
} else {
- pa_assert_se(pa_stream_connect_record(stream, NULL, NULL, flags) == 0);
+ pa_assert_se(pa_stream_connect_record(stream, NULL, &attr, flags) == 0);
pa_stream_set_read_callback(stream, stream_read_cb, NULL);
}
@@ -123,7 +149,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
int main(int argc, char *argv[]) {
pa_threaded_mainloop* m = NULL;
- int k, r;
+ int k;
struct timeval start, last_info = { 0, 0 };
pa_usec_t old_t = 0, old_rtc = 0;
#ifdef CORK
@@ -134,24 +160,22 @@ int main(int argc, char *argv[]) {
playback = argc <= 1 || !pa_streq(argv[1], "-r");
- /* Set up a new main loop */
- m = pa_threaded_mainloop_new();
- assert(m);
-
- mainloop_api = pa_threaded_mainloop_get_api(m);
+ latency =
+ (argc >= 2 && !pa_streq(argv[1], "-r")) ? atoi(argv[1]) :
+ (argc >= 3 ? atoi(argv[2]) : 0);
- context = pa_context_new(mainloop_api, argv[0]);
- assert(context);
+ /* Set up a new main loop */
+ pa_assert_se(m = pa_threaded_mainloop_new());
+ pa_assert_se(mainloop_api = pa_threaded_mainloop_get_api(m));
+ pa_assert_se(context = pa_context_new(mainloop_api, argv[0]));
pa_context_set_state_callback(context, context_state_callback, NULL);
- r = pa_context_connect(context, NULL, 0, NULL);
- assert(r >= 0);
+ pa_assert_se(pa_context_connect(context, NULL, 0, NULL) >= 0);
pa_gettimeofday(&start);
- r = pa_threaded_mainloop_start(m);
- assert(r >= 0);
+ pa_assert_se(pa_threaded_mainloop_start(m) >= 0);
/* #ifdef CORK */
for (k = 0; k < 20000; k++)
@@ -160,7 +184,7 @@ int main(int argc, char *argv[]) {
/* #endif */
{
pa_bool_t success = FALSE, changed = FALSE;
- pa_usec_t t, rtc;
+ pa_usec_t t, rtc, d;
struct timeval now, tv;
pa_bool_t playing = FALSE;
@@ -169,7 +193,8 @@ int main(int argc, char *argv[]) {
if (stream) {
const pa_timing_info *info;
- if (pa_stream_get_time(stream, &t) >= 0)
+ if (pa_stream_get_time(stream, &t) >= 0 &&
+ pa_stream_get_latency(stream, &d, NULL) >= 0)
success = TRUE;
if ((info = pa_stream_get_timing_info(stream))) {
@@ -191,14 +216,16 @@ int main(int argc, char *argv[]) {
pa_bool_t cork_now;
#endif
rtc = pa_timeval_diff(&now, &start);
- printf("%i\t%llu\t%llu\t%llu\t%llu\t%lli\t%u\t%u\n", k,
+ printf("%i\t%llu\t%llu\t%llu\t%llu\t%lli\t%u\t%u\t%llu\t%llu\n", k,
(unsigned long long) rtc,
(unsigned long long) t,
(unsigned long long) (rtc-old_rtc),
(unsigned long long) (t-old_t),
(signed long long) rtc - (signed long long) t,
changed,
- playing);
+ playing,
+ (unsigned long long) latency,
+ (unsigned long long) d);
fflush(stdout);
old_t = t;
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list