-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use new IAudioClient3 interface for low-latency audio in shared mode #385
Comments
To my understanding the additional API of If you have comparison of the lowest latency you could achieve with |
I was under the impression this could let us get around the usual minimum latency in shared mode; however I may indeed be misunderstanding. I'll try to give it a shot though. Thanks for the input. |
I believe using It looks like this might reduce latency by a few of milliseconds as the system switches to small buffers for that endpoint.
|
@rakosrudolf, thank you for referencing Microsoft docs regarding this issue. According to the documentation the promise about low-latency in Shared mode is not guaranteed by the platform:
Anyway, taking into account that low-latency possibility might exist, this new API can be incorporated into PA WASAPI as previously proposed by @adzm to provide such possibility for PA WASAPI users. |
We've set this to priority P3 (Normal) but @dmitrykos can change it to whatever he likes. |
Was there any progress on this? It would be a very welcome enhancement if so. |
As I have mentioned earlier, if someone would develop a small test which would try to contrast Also, |
The best I can do that is within reasonable time-scope for me (I'm not familiar with either Windows audio or PortAudio codebase and I'm severely time-constrained) is a practical round-trip latency experiment. Setup:
Software:
IAudioClient2 IAudioClient3 Test Results The results are really interesting! Then for the PA/IAudioClient2 results - firstly, the sub-10ms result for Exclusive Mode is absolutely phenomenal (if anywhere near accurate!). Then the Shared Mode result is as previously expected. Interestingly it is basically double the IAudioClient3 Shared Mode result. CONCLUSION |
I'm sceptical you can compare RTL Utility's built-in "Windows Audio" mode with KoordASIO/PA. The code paths are very different and in particular they likely have different internal buffer sizes which would act as confounding factors. If I understand your protocol correctly, you didn't even pick the same buffer sizes between the two. This makes it difficult to draw any meaningful conclusions. What would be much more interesting is to compare RTL Utility's "Windows Audio" with "Windows Audio (Shared Low Latency Mode)". Presumably that's just switching between |
@danryu it is great to see test results. The Exclusive mode testing is not useful in relation to On Windows 10 and higher PA is using According to the docs The difference of latency in Shared mode you observed, 34 vs 17, is due to double buffering used by PA WASAPI implementation. I will check if double buffering can be safely omitted and if yes, propose to add an additional PA WASAPI option to switch off double buffering, so that user would be able to achieve lowest possible latency in Shard mode at expense of some pops & clicks of course if CPU of the machine gets loaded with other tasks. |
@dechamps thanks for weighing in. I fully admit that the test was not very rigorous, and involved apples and oranges - it was simply intended as a quick-and-dirty indicator of the different configurations' potential. I am primarily interested in getting sub-10ms RTL on generic Windows hardware - so any route that can get me there is interesting. @dmitrykos Thanks for all the notes. I appreciate now why
That would be very welcome - many thanks. |
@dmitrykos Would it be useful if I opened a separate issue for this, for tracking purposes? Also, I'm very happy to fork and do some quick hacks/tests. I was wondering if there was perhaps a simple hack to do in |
@danryu I got possibility to debug PA WASAPI implementation. In my tests I am not able to get lower Shared Mode latency than 22 ms for 48000 Hz input stream.
For experiment I also replaced I also tried polling or event mode ( In all cases initialized audio client instance returns 1056 frames as max endpoint buffer via If you have interest, could you modify static PaUint32 _GetFramesPerHostBuffer(PaUint32 userFramesPerBuffer, PaTime suggestedLatency, double sampleRate, PaUint32 TimerJitterMs)
{
PaUint32 frames = userFramesPerBuffer + max( 0, (PaUint32)(suggestedLatency * sampleRate) );
frames += (PaUint32)((sampleRate * 0.001) * TimerJitterMs);
return frames;
} |
portaudio/src/hostapi/wasapi/pa_win_wasapi.c Lines 3947 to 3951 in 68e963a
Please note that I encountered the issue while experimenting with |
The new IAudioClient3 interface supports lower latency audio as described here although I am uncertain how to apply this to pa_win_wasapi.c offhand. The IAudioClient3 interface is already used, though the functions InitializeSharedAudioStream and GetSharedModeEnginePeriod / GetCurrentSharedModeEnginePeriod are not used apparently.
The text was updated successfully, but these errors were encountered: