[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.19-548-gb0042ce
Colin Guthrie
gitmailer-noreply at 0pointer.de
Tue Sep 7 08:02:37 PDT 2010
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 c36ab6896fd75931531f709844ea7f95c5829228 (commit)
- Log -----------------------------------------------------------------
b0042ce alsa-time-test: make test usable for capture too
e382589 alsa-source: refactor smoother and device start
2ee7cd1 smoother: avoid losing precision
-----------------------------------------------------------------------
Summary of changes:
src/modules/alsa/alsa-source.c | 26 ++++++++++++-----
src/pulsecore/time-smoother.c | 4 +--
src/tests/alsa-time-test.c | 59 +++++++++++++++++++++++++++++-----------
3 files changed, 62 insertions(+), 27 deletions(-)
-----------------------------------------------------------------------
commit 2ee7cd15b3cbfbde466b9edb0eb87f6b32a14dbb
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Mon Sep 6 15:22:26 2010 +0200
smoother: avoid losing precision
Avoid losing precision by subtracting uint64 values before converting them to
doubles.
diff --git a/src/pulsecore/time-smoother.c b/src/pulsecore/time-smoother.c
index 1371ad5..0696cab 100644
--- a/src/pulsecore/time-smoother.c
+++ b/src/pulsecore/time-smoother.c
@@ -320,10 +320,8 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
calc_abc(s);
- tx = (double) x;
-
/* Move to origin */
- tx -= (double) s->ex;
+ tx = (double) (x - s->ex);
/* Horner scheme */
ty = (tx * (s->c + tx * (s->b + tx * s->a)));
commit e382589d846f3ef6650359601ac1cdd82b82106f
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Mon Sep 6 15:26:19 2010 +0200
alsa-source: refactor smoother and device start
Move the code to start the capture and the smoother closer together to improve
smoother accuracy.
Rework things to look more like the alsa sink where the device is started in
only one place.
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 8ed300b..dbaa305 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -116,6 +116,8 @@ struct userdata {
pa_bool_t use_mmap:1, use_tsched:1;
+ pa_bool_t first;
+
pa_rtpoll_item *alsa_rtpoll_item;
snd_mixer_selem_channel_id_t mixer_map[SND_MIXER_SCHN_LAST];
@@ -397,7 +399,7 @@ static int try_recover(struct userdata *u, const char *call, int err) {
return -1;
}
- snd_pcm_start(u->pcm_handle);
+ u->first = TRUE;
return 0;
}
@@ -946,13 +948,13 @@ static int unsuspend(struct userdata *u) {
/* FIXME: We need to reload the volume somehow */
- snd_pcm_start(u->pcm_handle);
-
u->read_count = 0;
- pa_smoother_reset(u->smoother, pa_rtclock_now(), FALSE);
+ pa_smoother_reset(u->smoother, pa_rtclock_now(), TRUE);
u->smoother_interval = SMOOTHER_MIN_INTERVAL;
u->last_smoother_update = 0;
+ u->first = TRUE;
+
pa_log_info("Resumed successfully...");
return 0;
@@ -1003,8 +1005,6 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
if (u->source->thread_info.state == PA_SOURCE_INIT) {
if (build_pollfd(u) < 0)
return -PA_ERR_IO;
-
- snd_pcm_start(u->pcm_handle);
}
if (u->source->thread_info.state == PA_SOURCE_SUSPENDED) {
@@ -1240,6 +1240,15 @@ static void thread_func(void *userdata) {
pa_usec_t sleep_usec = 0;
pa_bool_t on_timeout = pa_rtpoll_timer_elapsed(u->rtpoll);
+ if (u->first) {
+ pa_log_info("Starting capture.");
+ snd_pcm_start(u->pcm_handle);
+
+ pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE);
+
+ u->first = FALSE;
+ }
+
if (u->use_mmap)
work_done = mmap_read(u, &sleep_usec, revents & POLLIN, on_timeout);
else
@@ -1299,7 +1308,7 @@ static void thread_func(void *userdata) {
if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
goto fail;
- snd_pcm_start(u->pcm_handle);
+ u->first = TRUE;
} else if (revents && u->use_tsched && pa_log_ratelimit())
pa_log_debug("Wakeup from ALSA!");
@@ -1553,6 +1562,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
u->module = m;
u->use_mmap = use_mmap;
u->use_tsched = use_tsched;
+ u->first = TRUE;
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
@@ -1563,7 +1573,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
TRUE,
5,
pa_rtclock_now(),
- FALSE);
+ TRUE);
u->smoother_interval = SMOOTHER_MIN_INTERVAL;
dev_id = pa_modargs_get_value(
commit b0042cec71ffb09d3720fdcc4223de8153fed67a
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Mon Sep 6 17:48:56 2010 +0200
alsa-time-test: make test usable for capture too
Extend the test to also work for capture devices.
diff --git a/src/tests/alsa-time-test.c b/src/tests/alsa-time-test.c
index 233bbe6..1a572b3 100644
--- a/src/tests/alsa-time-test.c
+++ b/src/tests/alsa-time-test.c
@@ -12,7 +12,7 @@ static uint64_t timespec_us(const struct timespec *ts) {
int main(int argc, char *argv[]) {
const char *dev;
- int r;
+ int r, cap;
snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams;
snd_pcm_status_t *status;
@@ -38,8 +38,12 @@ int main(int argc, char *argv[]) {
start_us = timespec_us(&start);
dev = argc > 1 ? argv[1] : "front:AudioPCI";
+ cap = argc > 2 ? atoi(argv[2]) : 0;
- r = snd_pcm_open(&pcm, dev, SND_PCM_STREAM_PLAYBACK, 0);
+ if (cap == 0)
+ r = snd_pcm_open(&pcm, dev, SND_PCM_STREAM_PLAYBACK, 0);
+ else
+ r = snd_pcm_open(&pcm, dev, SND_PCM_STREAM_CAPTURE, 0);
assert(r == 0);
r = snd_pcm_hw_params_any(pcm, hwparams);
@@ -78,7 +82,10 @@ int main(int argc, char *argv[]) {
r = snd_pcm_sw_params_current(pcm, swparams);
assert(r == 0);
- r = snd_pcm_sw_params_set_avail_min(pcm, swparams, 1);
+ if (cap == 0)
+ r = snd_pcm_sw_params_set_avail_min(pcm, swparams, 1);
+ else
+ r = snd_pcm_sw_params_set_avail_min(pcm, swparams, 0);
assert(r == 0);
r = snd_pcm_sw_params_set_period_event(pcm, swparams, 0);
@@ -117,13 +124,19 @@ int main(int argc, char *argv[]) {
r = snd_pcm_poll_descriptors(pcm, pollfds, n_pollfd);
assert(r == n_pollfd);
+ if (cap) {
+ r = snd_pcm_start(pcm);
+ assert(r == 0);
+ }
+
for (;;) {
snd_pcm_sframes_t avail, delay;
struct timespec now, timestamp;
unsigned short revents;
- int written = 0;
+ int handled = 0;
uint64_t now_us, timestamp_us;
snd_pcm_state_t state;
+ unsigned long long pos;
r = poll(pollfds, n_pollfd, 0);
assert(r >= 0);
@@ -131,7 +144,10 @@ int main(int argc, char *argv[]) {
r = snd_pcm_poll_descriptors_revents(pcm, pollfds, n_pollfd, &revents);
assert(r == 0);
- assert((revents & ~POLLOUT) == 0);
+ if (cap == 0)
+ assert((revents & ~POLLOUT) == 0);
+ else
+ assert((revents & ~POLLIN) == 0);
avail = snd_pcm_avail(pcm);
assert(avail >= 0);
@@ -152,18 +168,22 @@ int main(int argc, char *argv[]) {
assert(!revents || avail > 0);
- if (avail) {
+ if ((!cap && avail) || (cap && (unsigned)avail >= buffer_size)) {
snd_pcm_sframes_t sframes;
- static const uint16_t samples[2] = { 0, 0 };
+ static const uint16_t psamples[2] = { 0, 0 };
+ uint16_t csamples[2];
- sframes = snd_pcm_writei(pcm, samples, 1);
+ if (cap == 0)
+ sframes = snd_pcm_writei(pcm, psamples, 1);
+ else
+ sframes = snd_pcm_readi(pcm, csamples, 1);
assert(sframes == 1);
- written = 1;
+ handled = 1;
sample_count++;
}
- if (!written &&
+ if (!handled &&
memcmp(×tamp, &last_timestamp, sizeof(timestamp)) == 0 &&
avail == last_avail &&
delay == last_delay) {
@@ -174,19 +194,26 @@ int main(int argc, char *argv[]) {
now_us = timespec_us(&now);
timestamp_us = timespec_us(×tamp);
- printf("%llu\t%llu\t%llu\t%li\t%li\t%i\t%i\t%i\n",
+ if (cap == 0)
+ pos = (unsigned long long) ((sample_count - handled - delay) * 1000000LU / 44100);
+ else
+ pos = (unsigned long long) ((sample_count - handled + delay) * 1000000LU / 44100);
+
+ printf("%llu\t%llu\t%llu\t%llu\t%li\t%li\t%i\t%i\t%i\n",
(unsigned long long) (now_us - start_us),
(unsigned long long) (timestamp_us ? timestamp_us - start_us : 0),
- (unsigned long long) ((sample_count - 1 - delay) * 1000000LU / 44100),
+ pos,
+ (unsigned long long) sample_count,
(signed long) avail,
(signed long) delay,
revents,
- written,
+ handled,
state);
- /** When this assert is hit, most likely something bad
- * happened, i.e. the avail jumped suddenly. */
- assert((unsigned) avail <= buffer_size);
+ if (cap == 0)
+ /** When this assert is hit, most likely something bad
+ * happened, i.e. the avail jumped suddenly. */
+ assert((unsigned) avail <= buffer_size);
last_avail = avail;
last_delay = delay;
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list