HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: pgruebele@cox.net on 2012-11-30 03:04:34

Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: pgruebele@cox.net on 2012-11-30 03:04:34
Hi.

I develop windows device drivers and am testing a driver against the WASAPI 3.0 plugin.

This plugin apears to have a bug:

Sometimes it gets stuck between songs of different sample rates and juut stays there at the beginning of the new song.  When this happens the device driver never receives a STOP state and never is requested to change sample rates.

When this happens the device driver simply stops receiving audio packets, and continues to get polled for audio position.  When it works, there are either 0 or 1 position polls before the stream is stopped (STOP state).  So, either it hangs for good or it works immediately.  If I stop playback everything works again.  It may have something to do with the fact that my buffer position advances with very high precision.  It almost seems that if the plugin sent the last packet, and it it then manages to poll the position 2 times, this causes it to go into a weird state of waiting for the buffer position to stop moving (which it is not suppsed to do until exiting the RUN state. 

If I modify the driver to stop advancing the postition when it runs out of audio packets, then foobar no longer gets stuck.  I can't release my driver like that since this violates Microsoft specs.

Cheers
Philip

Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: SevenTwo on 2012-12-01 18:31:13
Sometimes it gets stuck between songs of different sample rates and juut stays there at the beginning of the new song.  When this happens the device driver never receives a STOP state and never is requested to change sample rates.


I had also exactly the same behavior here with two songs.

Now I checked again: flac has 44.1kHz and mp3 has 48kHz

Sometimes foobar hangs at beginning of 2nd song, position slider disappears and flickers.
Until I click on slider or double click the song to resume playback.

intel d525mw, atom d525, w7x64sp1 upd, foobar 1.1.18, only official components, wasapi push 200ms, buffer 500ms, realtek hda -> speaker

Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: pgruebele@cox.net on 2012-12-01 18:41:33
Yes, I can confirm that this is EXACTLY the same behaviour I see.  THis must be a WASAPI plugin bug...

Does anyone know how to get in touch with Pete (I think he is the author), in order to get this fixed?

Cheers
Philip
Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: Peter on 2012-12-03 09:55:56
Problem acknowledged, thanks for reporting.
Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: Peter on 2012-12-03 12:00:27
Beta version:
http://www.foobar2000.org/temp/WASAPI-beta....fb2k-component (http://www.foobar2000.org/temp/WASAPI-beta/WASAPI-3.1-b1.fb2k-component)

No changes since 3.0 other than this fix.
Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: pgruebele@cox.net on 2012-12-03 23:08:15
Beta version:
http://www.foobar2000.org/temp/WASAPI-beta....fb2k-component (http://www.foobar2000.org/temp/WASAPI-beta/WASAPI-3.1-b1.fb2k-component)

No changes since 3.0 other than this fix.



Thanks for the quick fix.  3.1 appears to fix this.  I will do some more testing and let you know if there are any problems.

Cheers
Philip
Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: pgruebele@cox.net on 2013-01-04 12:39:29
Beta version:
http://www.foobar2000.org/temp/WASAPI-beta....fb2k-component (http://www.foobar2000.org/temp/WASAPI-beta/WASAPI-3.1-b1.fb2k-component)

No changes since 3.0 other than this fix.



Hi Pete.  Doing further testing shows that WASAPI push now works reliably,  but there appears to be a problem with WASAPI event mode.

It appears that you are calling IAudioClient->Initialize() with the periodicity parameter set to about 10ms.  This will sometimes cause event mode to underflow the buffer of WaveCyclic miniport drivers which have a DPC periodicity of 10ms, causing the well known popping/clicking effect.  This could be solved by setting this parameter to 15ms (5ms higher than required) or even 20ms.

I'm not 100% sure about this but if you provide a test build I can confirm whether or not this theory is correct.

Cheers
Philip Gruebele
Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: ExUser on 2013-01-04 15:02:30
It appears that you are calling IAudioClient->Initialize() with the periodicity parameter set to about 10ms.  This will sometimes cause event mode to underflow the buffer of WaveCyclic miniport drivers which have a DPC periodicity of 10ms, causing the well known popping/clicking effect.  This could be solved by setting this parameter to 15ms (5ms higher than required) or even 20ms.
Try changing Preferences > Advanced > Playback > WASAPI > Hardware buffer in MS - event mode
Title: WASAPI plugin 3.0 (release) sometimes stop playback between songs
Post by: pgruebele@cox.net on 2013-01-04 15:22:59
It appears that you are calling IAudioClient->Initialize() with the periodicity parameter set to about 10ms.  This will sometimes cause event mode to underflow the buffer of WaveCyclic miniport drivers which have a DPC periodicity of 10ms, causing the well known popping/clicking effect.  This could be solved by setting this parameter to 15ms (5ms higher than required) or even 20ms.
Try changing Preferences > Advanced > Playback > WASAPI > Hardware buffer in MS - event mode


I am trying that now, thanks.  It appears to work but I will test a bit more.  The WASAPI plugin should call IAudioClient::GetDevicePeriod() to obtain the correct default no?  If not, any chance this can be changed to 15 by default?  That would save a lot of people a lot of headaches...