<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
/* Page Definitions */
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=ZH-CN link=blue vlink=purple style='text-justify-trim:punctuation'><div class=WordSection1><p class=MsoNormal><span lang=EN-US>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.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><a href="http://lists.freedesktop.org/archives/pulseaudio-discuss/2011-June/010146.html">http://lists.freedesktop.org/archives/pulseaudio-discuss/2011-June/010146.html</a><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>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?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Amanda<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>diff --git a/pulseaudio-0.9.22/src/pulsecore/protocol-native.c b/pulseaudio-0.9.22/src/pulsecore/protocol-native.c<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>index 4952ee4..570a0c7 100755<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>--- a/pulseaudio-0.9.22/src/pulsecore/protocol-native.c<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+++ b/pulseaudio-0.9.22/src/pulsecore/protocol-native.c<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>@@ -856,6 +856,8 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> /* Called from main context */<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+#define MIN_PHONE_TOTAL_LATENCY_USEC 300000<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> static void fix_playback_buffer_attr(playback_stream *s) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> size_t frame_size, max_prebuf;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> pa_usec_t orig_tlength_usec, tlength_usec, orig_minreq_usec, minreq_usec, sink_usec;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>@@ -933,6 +935,13 @@ static void fix_playback_buffer_attr(playback_stream *s) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> * able to fulfill it and give the application also minreq<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> * time to fill it up again for the next request Makes 2 times<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> * minreq in plus.. */<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+ const char *role;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+ role = pa_proplist_gets(s->sink_input->proplist, PA_PROP_MEDIA_ROLE);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+ if(role && pa_streq("phone", role)) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+ if(tlength_usec < MIN_PHONE_TOTAL_LATENCY_USEC)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+ tlength_usec = MIN_PHONE_TOTAL_LATENCY_USEC;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>+ }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> if (tlength_usec > minreq_usec*2)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> sink_usec = (tlength_usec - minreq_usec*2)/2;<o:p></o:p></span></p></div></body></html>