<!doctype html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body>...which does not apply to a media player that is bound by the packet size.<br><br><div class="gmail_quote">Le 25 octobre 2019 13:38:04 GMT+03:00, Thomas Guillem <thomas@gllm.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><br></div><div><a href="https://docs.microsoft.com/en-us/windows/win32/coreaudio/exclusive-mode-streams">https://docs.microsoft.com/en-us/windows/win32/coreaudio/exclusive-mode-streams</a><br></div><div><br></div><div>"Applications that use exclusive-mode streams often do so because they 
require low latencies in the data paths between the audio endpoint 
devices and the application threads that access the endpoint buffers."<br></div><div><br></div><div><br></div><div>On Fri, Oct 25, 2019, at 12:18, Rémi Denis-Courmont wrote:<br></div><blockquote type="cite" id="qt"><div>I don't see how it reduces latency, no. Audio latency is largely bound by the packet/period size, not by exclusive mode.<br></div><div><br></div><div class="qt-gmail_quote"><div>Le 25 octobre 2019 10:17:21 GMT+03:00, Thomas Guillem <thomas@gllm.fr> a écrit :<br></div><blockquote style="margin-top:0pt;margin-right:0pt;margin-bottom:0pt;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;" class="qt-gmail_quote"><pre class="qt-k9mail"><div><br></div><div><br></div><div>On Thu, Oct 24, 2019, at 20:55, Rémi Denis-Courmont wrote:<br></div><blockquote style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:1px;padding-left:1ex;" class="qt-gmail_quote"><div>Le torstaina 24. lokakuuta 2019, 15.37.13 EEST Thomas Guillem a écrit :<br></div><blockquote style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(173, 127, 168);border-left-style:solid;border-left-width:1px;padding-left:1ex;" class="qt-gmail_quote"><div>cf. WASAPI_EXCLUSIVE_LONGTEXT<hr> modules/audio_output/wasapi.c | 174 +++++++++++++++++++++++++++++++++-<br></div><div> 1 file changed, 170 insertions(+), 4 deletions(-)<br></div><div><br></div><div>diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c<br></div><div>index daa946f8afc..91defb250fb 100644<br></div><div>--- a/modules/audio_output/wasapi.c<br></div><div>+++ b/modules/audio_output/wasapi.c<br></div><div>@@ -588,6 +588,154 @@ static void Stop(aout_stream_t *s)<br></div><div>     free(sys);<br></div><div> }<br></div><div><br></div><div>+/*<br></div><div>+ * This function will try to find the closest PCM format that is accepted<br></div><div>by + * the sound card. Exclusive here means a direct access to the sound<br></div><div>card. The + * format arguments and the return code of this function behave<br></div><div>exactly like + * IAudioClient_IsFormatSupported().<br></div><div>+ */<br></div><div>+static HRESULT GetExclusivePCMFormat(IAudioClient *c, const WAVEFORMATEX<br></div><div>*pwf, +                                     WAVEFORMATEX **ppwf_closest) +{<br></div><div>+    HRESULT hr;<br></div><div>+    const AUDCLNT_SHAREMODE exclusive = AUDCLNT_SHAREMODE_EXCLUSIVE;<br></div><div>+<br></div><div>+    *ppwf_closest = NULL;<br></div><div>+<br></div><div>+    /* First try the input format */<br></div><div>+    hr = IAudioClient_IsFormatSupported(c, exclusive, pwf, NULL);<br></div><div>+<br></div><div>+    if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)<br></div><div>+    {<br></div><div>+        assert(hr != S_FALSE); /* S_FALSE reserved for shared mode */<br></div><div>+        return hr;<br></div><div>+    }<br></div><div>+<br></div><div>+    /* This format come from vlc_ToWave() */<br></div><div>+    assert(pwf->wFormatTag == WAVE_FORMAT_EXTENSIBLE);<br></div><div>+    const WAVEFORMATEXTENSIBLE *pwfe = (void *) pwf;<br></div><div>+    assert(IsEqualIID(&pwfe->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)<br></div><div>+        || IsEqualIID(&pwfe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM));<br></div><div>+<br></div><div>+    /* Allocate the output closest format */<br></div><div>+    WAVEFORMATEXTENSIBLE *pwfe_closest =<br></div><div>+        CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE));<br></div><div>+    if (!pwfe_closest)<br></div><div>+        return E_FAIL;<br></div><div>+    WAVEFORMATEX *pwf_closest = &pwfe_closest->Format;<br></div><div>+<br></div><div>+    /* Setup the fallback arrays. There are 3 properties to check: the<br></div><div>format, +     * the samplerate and the channels. There are maximum of 4<br></div><div>formats to +     * check, 3 samplerates, and 2 channels configuration. So,<br></div><div>that is a +     * maximum of 4x3x2=24 checks */<br></div><div>+<br></div><div>+    /* The format fallback order is dependent of the input format. We don't<br></div><div>+     * want to use a high quality format when it's not needed but we<br></div><div>prefer to +     * use a high quality format instead of a lower one */<br></div><div>+    static const uint16_t bits_pcm8_fallback[] =  {  8, 16, 24, 32 };<br></div><div>+    static const uint16_t bits_pcm16_fallback[] = { 16, 24, 32, 8  };<br></div><div>+    static const uint16_t bits_pcm24_fallback[] = { 24, 32, 16, 8  };<br></div><div>+    static const uint16_t bits_pcm32_fallback[] = { 32, 24, 16, 8  };<br></div><div>+<br></div><div>+    static const size_t bits_fallback_size =<br></div><div>ARRAY_SIZE(bits_pcm8_fallback); +<br></div><div>+    const uint16_t *bits_fallback;<br></div><div>+    switch (pwf->wBitsPerSample)<br></div><div>+    {<br></div><div>+        case 64: /* fall through */<br></div><div>+        case 32: bits_fallback = bits_pcm32_fallback; break;<br></div><div>+        case 24: bits_fallback = bits_pcm24_fallback; break;<br></div><div>+        case 16: bits_fallback = bits_pcm16_fallback; break;<br></div><div>+        case 8:  bits_fallback = bits_pcm8_fallback;  break;<br></div><div>+        default: vlc_assert_unreachable();<br></div><div>+    }<br></div><div>+<br></div><div>+    /* Check the input samplerate, then 48kHz and 44.1khz */<br></div><div>+    const uint32_t samplerate_fallback[] = {<br></div><div>+        pwf->nSamplesPerSec,<br></div><div>+        pwf->nSamplesPerSec == 48000 ? 0 : 48000,<br></div><div>+        pwf->nSamplesPerSec == 44100 ? 0 : 44100,<br></div><div>+    };<br></div><div>+    const size_t samplerate_fallback_size =<br></div><div>ARRAY_SIZE(samplerate_fallback); +<br></div><div>+    /* Check the input number of channels, then stereo */<br></div><div>+    const uint16_t channels_fallback[] = {<br></div><div>+        pwf->nChannels,<br></div><div>+        pwf->nChannels == 2 ? 0 : 2,<br></div><div>+    };<br></div><div>+    const size_t channels_fallback_size = ARRAY_SIZE(channels_fallback);<br></div></blockquote><div>Really the only point in exclusive mode is bit exact. If you need to convert, <br></div><div>there is really no point, especially if the sample rate and/or the channel <br></div><div>mappings differ. This is waaaaay needlessly complicated.<br></div></blockquote><div><br></div><div>An other point of exclusive is to reduce the audio latency.<br></div><div><br></div><div>> <br></div><blockquote style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:1px;padding-left:1ex;" class="qt-gmail_quote"><div>-- <br></div><div>レミ・デニ-クールモン<br></div><div><a href="http://www.remlab.net/">http://www.remlab.net/</a><hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div><hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></pre></blockquote></div><div><br></div><div>-- <br></div><div>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. <br></div><div>_______________________________________________<br></div><div>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div>https://mailman.videolan.org/listinfo/vlc-devel<br></div></blockquote><div><br></div></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>