[pulseaudio-discuss] [PATCH] protocol-native: set a minimum audio latency for a "phone" input stream
Lin, Mengdong
mengdong.lin at intel.com
Sun Jun 12 20:08:29 PDT 2011
I got buffer underruns when moving sinks for a "live" stream. Flag "adjust_latency" will decrease the latency each time when I move the sink and can cause buffer underrun.
http://lists.freedesktop.org/archives/pulseaudio-discuss/2011-June/010146.html
Is it OK to set a minimum total latency (300ms) for a "live" (phone) playback stream, considering that a BT headset sink has a fixed latency of 128ms?
Thanks
Amanda
diff --git a/pulseaudio-0.9.22/src/pulsecore/protocol-native.c b/pulseaudio-0.9.22/src/pulsecore/protocol-native.c
index 4952ee4..570a0c7 100755
--- a/pulseaudio-0.9.22/src/pulsecore/protocol-native.c
+++ b/pulseaudio-0.9.22/src/pulsecore/protocol-native.c
@@ -856,6 +856,8 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
}
/* Called from main context */
+#define MIN_PHONE_TOTAL_LATENCY_USEC 300000
+
static void fix_playback_buffer_attr(playback_stream *s) {
size_t frame_size, max_prebuf;
pa_usec_t orig_tlength_usec, tlength_usec, orig_minreq_usec, minreq_usec, sink_usec;
@@ -933,6 +935,13 @@ static void fix_playback_buffer_attr(playback_stream *s) {
* able to fulfill it and give the application also minreq
* time to fill it up again for the next request Makes 2 times
* minreq in plus.. */
+ const char *role;
+
+ role = pa_proplist_gets(s->sink_input->proplist, PA_PROP_MEDIA_ROLE);
+ if(role && pa_streq("phone", role)) {
+ if(tlength_usec < MIN_PHONE_TOTAL_LATENCY_USEC)
+ tlength_usec = MIN_PHONE_TOTAL_LATENCY_USEC;
+ }
if (tlength_usec > minreq_usec*2)
sink_usec = (tlength_usec - minreq_usec*2)/2;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20110613/2e277249/attachment.htm>
More information about the pulseaudio-discuss
mailing list