aboutsummaryrefslogtreecommitdiffhomepage
path: root/libao2/ao_pulse.c
diff options
context:
space:
mode:
authorGravatar Uoti Urpala <uau@mplayer2.org>2012-03-25 22:58:48 +0300
committerGravatar Uoti Urpala <uau@mplayer2.org>2012-03-26 03:55:31 +0300
commita0de4bc5000823c058aab6b02a7fdfb48275cb32 (patch)
tree799a49605b04f39e2bc79604f0d93727a43e167d /libao2/ao_pulse.c
parent4fed8ad19771f6c3cfdd01414ba11456007fd9b8 (diff)
ao_pulse, core: make pulse thread wake up core for more data
For ao_pulse, the current latency is not a good indicator of how soon the AO requires new data to avoid underflow. Add an internal pipe that can be used to wake up the input loop from select(), and make the pulseaudio main loop (which runs in a separate thread) use this mechanism when pulse requests more data. The wakeup signal currently contains no information about the reason for the wakup, but audio buffers are always filled when the event loop wakes up. Also, request a latency of 1 second from the Pulseaudio server. The default is normally significantly higher. We don't need low latency, while higher latency helps prevent underflows reduces need for wakeups.
Diffstat (limited to 'libao2/ao_pulse.c')
-rw-r--r--libao2/ao_pulse.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libao2/ao_pulse.c b/libao2/ao_pulse.c
index 659a2bc907..ddaf35716c 100644
--- a/libao2/ao_pulse.c
+++ b/libao2/ao_pulse.c
@@ -30,6 +30,7 @@
#include "libaf/af_format.h"
#include "mp_msg.h"
#include "audio_out.h"
+#include "input/input.h"
#define PULSE_CLIENT_NAME "mplayer2"
@@ -84,6 +85,7 @@ static void stream_request_cb(pa_stream *s, size_t length, void *userdata)
{
struct ao *ao = userdata;
struct priv *priv = ao->priv;
+ mp_input_wakeup(ao->input_ctx);
pa_threaded_mainloop_signal(priv->mainloop, 0);
}
@@ -263,8 +265,14 @@ static int init(struct ao *ao, char *params)
pa_stream_set_write_callback(priv->stream, stream_request_cb, ao);
pa_stream_set_latency_update_callback(priv->stream,
stream_latency_update_cb, ao);
-
- if (pa_stream_connect_playback(priv->stream, sink, NULL,
+ pa_buffer_attr bufattr = {
+ .maxlength = -1,
+ .tlength = pa_usec_to_bytes(1000000, &ss),
+ .prebuf = -1,
+ .minreq = -1,
+ .fragsize = -1,
+ };
+ if (pa_stream_connect_playback(priv->stream, sink, &bufattr,
PA_STREAM_INTERPOLATE_TIMING
| PA_STREAM_AUTO_TIMING_UPDATE, NULL,
NULL) < 0)