Skip to content
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

(Windows) Choppy audio with WASAPI2 #1227

Closed
dbolton opened this issue Jul 9, 2023 · 18 comments
Closed

(Windows) Choppy audio with WASAPI2 #1227

dbolton opened this issue Jul 9, 2023 · 18 comments

Comments

@dbolton
Copy link

dbolton commented Jul 9, 2023

Describe the bug
Choppy audio during normal playback.

To Reproduce
Play audio file from local computer using Strawberry.

Expected behavior
Accurate playback of the audio file.

For comparison, other audio players, all play the same file without choppy audio. I tested using Clementine, Exaile, foobar2000 and Groove.

Screenshots:
I recorded playback for the purpose of sharing with this ticket.
choppy audio.zip
(3 second sample. Choppy audio starts at 1.0 seconds. Ends at 1.5 seconds)

System Information:

  • Operating system: Windows 10
  • Strawberry Version: 1.0.18 (MSCV installer)

Additional context
In case it is important, my audio files happen to all be FLAC format.

I opened the task manager to check CPU usage. It is never above 30% during the choppy audio.

@LebedevRI
Copy link
Contributor

LebedevRI commented Jul 10, 2023

Is that when using VLC engine by any chance?

@jonaski
Copy link
Member

jonaski commented Jul 11, 2023

What output are you using in the Backend settings? Auto, Directsound, WASAPI or WASAPI2?
What buffer settings?
I can't reproduce any issues with any of the outputs even under CPU load.
What CPU and hard-drive do you have?

@dbolton
Copy link
Author

dbolton commented Jul 11, 2023

I had been using the default "Wrapper audio sink for automatically detected audio sink". I switched to "Output to sound card via Direct Sound". After restarting Strawberry I no longer have issues.

So it looks like this issue is limited to the wrapper? Also is it expected that restarting Strawberry is necessary after switching the backend? If so, maybe the settings needs a "restart required" label (like other setting changes that require restart).

Processor: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz 2.19 GHz
Hard disk: Samsung SSD 850 EVO

@jonaski
Copy link
Member

jonaski commented Jul 11, 2023

If Auto is selected, the MSVC version will pick WASAPI2. The MinGW will pick DirectSound if Auto is selected (WASAPI2 isn't possible with MinGW).
So it looks like WASAPI2 is buggy, even though I can't reproduce any issues here.
Same issue was reported in #1214 by @cproensa

@jonaski jonaski changed the title Choppy audio during normal playback. (Windows) Choppy audio with WASAPI2 Jul 11, 2023
@cproensa
Copy link

cproensa commented Jul 11, 2023

Same issue was reported in #1214 by @cproensa

Right, For me WASAPI2 was also choppy and stuttering.
It starts fine, but after some time playing (a couple of minutes, maybe), the chopper starts. Regardles of stopping and resuming playback or playing different files. Once it starts, its consistent and ongoing. All kind of files: mp3, flac, and subsonic streams, etc

However, i dont have a very common or solid setup, to represent a good example. This is: its a firewire (presonus firestudio mobile) external soundcard (with custom drivers). Which already experiences some stuttering when a high load of network activity or file copying is happening. Probably some dma or latency shenanigans with the firewire bus. (but not affected by cpu load though).

Also is it expected that restarting Strawberry is necessary after switching the backend

In my case. Only STOP playing was enough to change the output.

@jonaski
Copy link
Member

jonaski commented Jul 11, 2023

The bug is probably in GStreamer, I will add an entry to the FAQ about it for now.

@dbolton
Copy link
Author

dbolton commented Jul 12, 2023

I tested and can confirm that only WASAPI2 has the issue. WASAPI and DirectSound both work for me.

I normally play through an audio interface (Focusrite Scarlett 2i2, 1st Gen), sample rate 48000, buffer size 256. I also get choppy audio with a sample rate of 41000. In a reversal of what I expected, increasing the buffer size to the max 1024 made the audio dramatically worse (continuous distortion instead of occasional). Decreasing the buffer seemed to help reduce the frequency of choppy audio.

I tried playing through the built-in computer speakers and still got choppy audio but only twice in 15 minutes.

@Kissaki
Copy link

Kissaki commented Jul 15, 2023

I have no issue with local playback, but when streaming my desktop/PC to Steam Link - so the audio output device changes to it - I hear chopped up audio too. May be on Opus files but not on mp3.

@jonaski
Copy link
Member

jonaski commented Jul 30, 2023

Can someone test the latest from https://builds.strawberrymusicplayer.org/windows/msvc/, there is an utility gst-play-1.0.exe, check if the issue occurs also using this utility.:

cd "c:\Program Files\Strawberry Music Player"
gst-play-1.0 --use-playbin3 --audiosink="wasapi2sink" file:///c:/music/test.flac

Replace c:/music/test.flac with an actual file.

@jonaski
Copy link
Member

jonaski commented Jul 30, 2023

I've changed the priority of the output/sinks so that directsound is picked first when Auto is selected (483b42d).
This issue is reported to GStreamer here: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2870

@dbolton
Copy link
Author

dbolton commented Jul 31, 2023

@jonaski Thanks for looking into this. I downloaded the latest msvc-x64.exe. I followed your commands, but got the following error:
Failed to create 'playbin' element. Check your GStreamer installation.

Do I need to install anything besides Strawberry Music Player? I do see gst-play-1.0.exe in the current directory.

@cproensa
Copy link

cproensa commented Aug 1, 2023

I downloaded the latest msvc-x64.exe. I followed your commands, but got the following error:
Failed to create 'playbin' element. Check your GStreamer installation.

same for me

@jonaski
Copy link
Member

jonaski commented Aug 1, 2023

Run this command first:
set GST_PLUGIN_PATH=c:/Program Files/Strawberry Music Player/gstreamer-plugins

@dbolton
Copy link
Author

dbolton commented Aug 2, 2023

I set the variable then reran the original command, but got the same error. Any other tips?

@cproensa
Copy link

cproensa commented Aug 2, 2023

With the env set, the command now plays the file.
But, still, crackling is reproduced after a couple of minutes.
If i retry the command, even with other files, its random. Sometimes the noise starts right away, other times the sound is good but only for some time until it goes bad again.

imagen

@jonaski
Copy link
Member

jonaski commented Aug 2, 2023

Thanks @cproensa

@jonaski
Copy link
Member

jonaski commented Aug 2, 2023

I can reproduce the issue too now with a USB DAC, but not with the internal soundcard.

@jonaski
Copy link
Member

jonaski commented Oct 7, 2023

I've removed WASAPI2 in the newest release, I will add it back when the issue is solved in GStreamer.

@jonaski jonaski closed this as completed Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants