summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/modules/alsa-util.c6
-rw-r--r--src/modules/module-alsa-sink.c41
-rw-r--r--src/modules/module-alsa-source.c41
-rw-r--r--src/pulsecore/time-smoother.c6
-rw-r--r--src/utils/pacat.c4
6 files changed, 75 insertions, 26 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e1f2664b..5ed0f6fd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,9 @@ AM_CFLAGS = \
-I$(top_builddir)/src/modules/raop \
$(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS \
$(LTDLINCL) \
+ $(LIBSAMPLERATE_CFLAGS) \
+ $(LIBSNDFILE_CFLAGS) \
+ $(LIBSPEEX_CFLAGS) \
-DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \
-DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \
-DPA_BINARY=\"$(PA_BINARY)\" \
diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 39cea494..20dc400f 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -1051,6 +1051,12 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
pa_log_warn("Got POLLNVAL from ALSA");
if (revents & POLLHUP)
pa_log_warn("Got POLLHUP from ALSA");
+ if (revents & POLLPRI)
+ pa_log_warn("Got POLLPRI from ALSA");
+ if (revents & POLLIN)
+ pa_log_warn("Got POLLIN from ALSA");
+ if (revents & POLLOUT)
+ pa_log_warn("Got POLLOUT from ALSA");
state = snd_pcm_state(pcm);
pa_log_warn("PCM state is %s", snd_pcm_state_name(state));
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index af83103d..6dea172f 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -241,7 +241,7 @@ static size_t check_left_to_play(struct userdata *u, snd_pcm_sframes_t n) {
return left_to_play;
}
-static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
+static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
int work_done = 0;
pa_usec_t max_sleep_usec = 0, process_usec = 0;
size_t left_to_play;
@@ -279,14 +279,23 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
* need to guarantee that clients only have to keep around
* a single hw buffer length. */
- if (pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
+ if (!polled &&
+ pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
break;
- if (PA_UNLIKELY(n <= u->hwbuf_unused_frames))
+ if (PA_UNLIKELY(n <= u->hwbuf_unused_frames)) {
+
+ if (polled)
+ pa_log("ALSA woke us up to write new data to the device, but there was actually nothing to write! "
+ "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
break;
+ }
n -= u->hwbuf_unused_frames;
+ polled = FALSE;
+
/* pa_log_debug("Filling up"); */
for (;;) {
@@ -357,7 +366,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
return work_done;
}
-static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
+static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
int work_done = 0;
pa_usec_t max_sleep_usec = 0, process_usec = 0;
size_t left_to_play;
@@ -392,14 +401,23 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
* need to guarantee that clients only have to keep around
* a single hw buffer length. */
- if (pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
+ if (!polled &&
+ pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
break;
- if (PA_UNLIKELY(n <= u->hwbuf_unused_frames))
+ if (PA_UNLIKELY(n <= u->hwbuf_unused_frames)) {
+
+ if (polled)
+ pa_log("ALSA woke us up to write new data to the device, but there was actually nothing to write! "
+ "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
break;
+ }
n -= u->hwbuf_unused_frames;
+ polled = FALSE;
+
for (;;) {
snd_pcm_sframes_t frames;
void *p;
@@ -1084,6 +1102,7 @@ finish:
static void thread_func(void *userdata) {
struct userdata *u = userdata;
+ unsigned short revents = 0;
pa_assert(u);
@@ -1110,9 +1129,9 @@ static void thread_func(void *userdata) {
goto fail;
if (u->use_mmap)
- work_done = mmap_write(u, &sleep_usec);
+ work_done = mmap_write(u, &sleep_usec, revents & POLLOUT);
else
- work_done = unix_write(u, &sleep_usec);
+ work_done = unix_write(u, &sleep_usec, revents & POLLOUT);
if (work_done < 0)
goto fail;
@@ -1180,7 +1199,6 @@ static void thread_func(void *userdata) {
/* Tell ALSA about this and process its response */
if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
struct pollfd *pollfd;
- unsigned short revents = 0;
int err;
unsigned n;
@@ -1191,7 +1209,7 @@ static void thread_func(void *userdata) {
goto fail;
}
- if (revents & (POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
+ if (revents & (POLLIN|POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
goto fail;
@@ -1201,7 +1219,8 @@ static void thread_func(void *userdata) {
if (revents && u->use_tsched)
pa_log_debug("Wakeup from ALSA!%s%s", (revents & POLLIN) ? " INPUT" : "", (revents & POLLOUT) ? " OUTPUT" : "");
- }
+ } else
+ revents = 0;
}
fail:
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index dd6ca978..f796ef14 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -238,7 +238,7 @@ static size_t check_left_to_record(struct userdata *u, snd_pcm_sframes_t n) {
return left_to_record;
}
-static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
+static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
int work_done = 0;
pa_usec_t max_sleep_usec = 0, process_usec = 0;
size_t left_to_record;
@@ -266,11 +266,20 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
left_to_record = check_left_to_record(u, n);
if (u->use_tsched)
- if (pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
+ if (!polled &&
+ pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
break;
- if (PA_UNLIKELY(n <= 0))
+ if (PA_UNLIKELY(n <= 0)) {
+
+ if (polled)
+ pa_log("ALSA woke us up to read new data from the device, but there was actually nothing to read! "
+ "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio device.");
+
break;
+ }
+
+ polled = FALSE;
for (;;) {
int err;
@@ -336,7 +345,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
return work_done;
}
-static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
+static int unix_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
int work_done = 0;
pa_usec_t max_sleep_usec = 0, process_usec = 0;
size_t left_to_record;
@@ -364,11 +373,20 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
left_to_record = check_left_to_record(u, n);
if (u->use_tsched)
- if (pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
+ if (!polled &&
+ pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
break;
- if (PA_UNLIKELY(n <= 0))
+ if (PA_UNLIKELY(n <= 0)) {
+
+ if (polled)
+ pa_log("ALSA woke us up to read new data from the device, but there was actually nothing to read! "
+ "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
return work_done;
+ }
+
+ polled = FALSE;
for (;;) {
void *p;
@@ -950,6 +968,7 @@ static void source_update_requested_latency_cb(pa_source *s) {
static void thread_func(void *userdata) {
struct userdata *u = userdata;
+ unsigned short revents = 0;
pa_assert(u);
@@ -972,9 +991,9 @@ static void thread_func(void *userdata) {
pa_usec_t sleep_usec = 0;
if (u->use_mmap)
- work_done = mmap_read(u, &sleep_usec);
+ work_done = mmap_read(u, &sleep_usec, revents & POLLIN);
else
- work_done = unix_read(u, &sleep_usec);
+ work_done = unix_read(u, &sleep_usec, revents & POLLIN);
if (work_done < 0)
goto fail;
@@ -1016,7 +1035,6 @@ static void thread_func(void *userdata) {
/* Tell ALSA about this and process its response */
if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
struct pollfd *pollfd;
- unsigned short revents = 0;
int err;
unsigned n;
@@ -1027,7 +1045,7 @@ static void thread_func(void *userdata) {
goto fail;
}
- if (revents & (POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
+ if (revents & (POLLOUT|POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
goto fail;
@@ -1036,7 +1054,8 @@ static void thread_func(void *userdata) {
if (revents && u->use_tsched)
pa_log_debug("Wakeup from ALSA!%s%s", (revents & POLLIN) ? " INPUT" : "", (revents & POLLOUT) ? " OUTPUT" : "");
- }
+ } else
+ revents = 0;
}
fail:
diff --git a/src/pulsecore/time-smoother.c b/src/pulsecore/time-smoother.c
index 6a2ffaa6..65621948 100644
--- a/src/pulsecore/time-smoother.c
+++ b/src/pulsecore/time-smoother.c
@@ -313,7 +313,7 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
/* Move back from origin */
ty += (double) s->ey;
- *y = ty >= 0 ? (pa_usec_t) lrint(ty) : 0;
+ *y = ty >= 0 ? (pa_usec_t) llrint(ty) : 0;
/* Horner scheme */
if (deriv)
@@ -360,7 +360,7 @@ void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y) {
/* And calculate when we want to be on track again */
s->px = s->ex + s->adjust_time;
- s->py = s->ry + (pa_usec_t) lrint(s->dp * (double) s->adjust_time);
+ s->py = s->ry + (pa_usec_t) llrint(s->dp * (double) s->adjust_time);
s->abc_valid = FALSE;
@@ -456,7 +456,7 @@ pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay)
/* pa_log_debug("translate(%llu) = %llu (%0.2f)", (unsigned long long) y_delay, (unsigned long long) ((double) y_delay / nde), nde); */
- return (pa_usec_t) lrint((double) y_delay / nde);
+ return (pa_usec_t) llrint((double) y_delay / nde);
}
void pa_smoother_reset(pa_smoother *s) {
diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index 99df5b9e..ea736e23 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -57,6 +57,7 @@ static char *stream_name = NULL, *client_name = NULL, *device = NULL;
static int verbose = 0;
static pa_volume_t volume = PA_VOLUME_NORM;
+static int volume_is_set = 0;
static pa_sample_spec sample_spec = {
.format = PA_SAMPLE_S16LE,
@@ -283,7 +284,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
if (mode == PLAYBACK) {
pa_cvolume cv;
- if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) {
+ if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL)) < 0) {
fprintf(stderr, _("pa_stream_connect_playback() failed: %s\n"), pa_strerror(pa_context_errno(c)));
goto fail;
}
@@ -627,6 +628,7 @@ int main(int argc, char *argv[]) {
case ARG_VOLUME: {
int v = atoi(optarg);
volume = v < 0 ? 0U : (pa_volume_t) v;
+ volume_is_set = 1;
break;
}