mumble-voip / mumble

Mumble is an open-source, low-latency, high quality voice chat software.
https://www.mumble.info
Other
6.34k stars 1.11k forks source link

Stuttering audio in Linux with ALSA #2179

Closed Demosthenexx closed 7 years ago

Demosthenexx commented 8 years ago

Audio output on Linux with ALSA is stuttering, voices take twice the time with stuttering silence.

I've isolated the message on STDERR to:

https://github.com/mumble-voip/mumble/blob/b828a0a3fa6e037a4ff6daf7132d3421c27e5fb5/src/mumble/ALSAAudio.cpp#L551

This line is complaining about half the time when audio is being output, spamming STDERR:

ALSAAudio: Non-critical: w=snd_pcm_writei(pcm_handle, outbuff, period_size): Broken pipe ALSAAudio: Non-critical: w=snd_pcm_writei(pcm_handle, outbuff, period_size): Broken pipe ALSAAudio: Non-critical: w=snd_pcm_writei(pcm_handle, outbuff, period_size): Broken pipe

As I understand it, this is playing interlaced audio. Is there perhaps an alignment issue? It seems to happen frequently, about half the time I hear audio.

mkrautz commented 8 years ago

-EPIPE returned from snd_pcm_writei would be a buffer underrun.

I'm trying to understand what sounds Mumble is producing in this case, to understand it better...

Does it seem like it "skips" a buffer every second time the Audio Output device needs a new frame? You mention that voice takes twice the time, with suttering silence in between?...

As I understand it from your post, this is something that happens continuously when you run Mumble?

Thanks.

Demosthenexx commented 8 years ago

Actively discussing on IRC now.

All members in channel using push to talk (ie: not continuous). When someone speaks it seems there's an even chance that it will stutter, and the stuttering behavior continues until they stop speaking. So the entire stream during them actively speaking stutters half the time.

The stuttering behavior is very hard on the ear, completely disjoint, but imagine someone speaking in very short clips with equal silence between. That audio appears to take about twice as long to output. I could see that as packetized audio, where I hear a packet, and then silence, then another.

This is happening nonstop on 1.2.7 and 1.2.15 with a wireless USB headset. No desktop environment or pulseaudio, so I'm able to exclusively assign Mumble to the headset.

Demosthenexx commented 8 years ago

Trying to compile with ALSA_VERBOSE and got a failure at line 377:

ALSAAudio.cpp: In member function ‘virtual void ALSAAudioInput::run()’: ALSAAudio.cpp:327:2: warning: use of old-style cast [-Wold-style-cast] ALSAAudio.cpp:378:26: error: ‘status’ was not declared in this scope compilation terminated due to -Wfatal-errors.

Demosthenexx commented 8 years ago

Adjusted nrpacks option on snd_usb_audio module, and behavior became less frequent. Most likely the USB driver and not Mumble specifically.

netjiro commented 7 years ago

Hi. I'm running into the same kind of stuttering on mumble-1.2.17, linux-4.8.12, with a logitech usb headset on snd_usb_audio. Same stuttering and same error output.

However, as far as I can gather the nrpacks module parameter to snd_usb_audio has been removed, so which kernel version were you using where you had that parameter available for snd_usb_audio?

$ modinfo snd_usb_audio
filename:       /lib/modules/4.8.12-gentoo/kernel/sound/usb/snd-usb-audio.ko
--- lots of stuff ---
parm:           index:Index value for the USB audio adapter. (array of int)
parm:           id:ID string for the USB audio adapter. (array of charp)
parm:           enable:Enable USB audio adapter. (array of bool)
parm:           vid:Vendor ID for the USB audio device. (array of int)
parm:           pid:Product ID for the USB audio device. (array of int)
parm:           device_setup:Specific device setup (if needed). (array of int)
parm:           ignore_ctl_error:Ignore errors from USB controller for mixer interfaces. (bool)
parm:           autoclock:Enable auto-clock selection for UAC2 devices (default: yes). (bool)
parm:           quirk_alias:Quirk aliases, e.g. 0123abcd:5678beef. (array of charp)

Though the reference to nrpacks is still in the kernel docs, and defined in snd-usb-usx2y (though with seemingly different value range).

Any further info on this?

netjiro commented 7 years ago

Cannot reproduce the stuttering from any other program yet, tried multiple simultaneous sources directly connected to alsa playback, no jack or pulseaudio in between.

netjiro commented 7 years ago

Not limited to usb audio adapter, can reproduce the same behaviour from snd_hda_intel on Audio device: Intel Corporation Sunrise Point-H HD Audio (rev 31).

Eriner commented 7 years ago

@netjiro Same boat, I too can reproduce with both snd_usb_audio and snd_hda_intel. See my comment in the PR referenced above.

mkrautz commented 7 years ago

Hi,

@Eriner and @netjiro - do you also get

ALSAAudio: Non-critical: w=snd_pcm_writei(pcm_handle, outbuff, period_size): Broken pipe

in Mumble's stdout/stderr output? Or anything similar?

Are you guys on Arch? (Just to get a point of reference where I can test this...)

Thanks.

Eriner commented 7 years ago

@mkrautz yes, running Arch. I believe I get something similar, however I believe it references a buffer-underrun. Something like: pcm.c:7843:(snd_pcm_recover) underrun occurred, though no one is online right now for me to reproduce. Interestingly, I'm unable to reproduce the issue using my phone with the Plumble client. I'll grab the complete output from STDERR tomorrow.

As an additional note, I've spent an extensive amount of time tweaking my buffer_size, period_size in ALSA's dmix plugin in an attempt to remedy the issue to no avail.

mkrautz commented 7 years ago

@Eriner Have you tried increasing your output delay in Mumble (Audio Output settings)?

netjiro commented 7 years ago

Gentoo here. I was testing on my local network between a nuc an laptop. @mkrautz: Increasing buffer time to very high values (beyond what I considered reasonable) seemed to reduce the frequency of occurrences. I didn't test much though so this could be placebo. I didn't run anything else significant on the machine, an i7-6770HQ. @mkrautz: I don't remember the stdout/stderr output, but the broken pipe message rings familiar.

Eriner commented 7 years ago

@mkrautz Yes, I have. Currently, outputdelay=1, however changing this value to 10 has no impact.

Eriner commented 7 years ago

Here is a link to my .asoundrc

FWIW, I also found an old .asoundrc gist that I had originally uploaded while talking with a friend and trying to debug this issue. Here, pcm "hw:SB,0" == #pcm "hw:0" in the new .asoundrc linked above.

Eriner commented 7 years ago

@netjiro try setting the following in your .asoundrc in the dmix slave settings:

period_size 480
buffer_size 960

This has resolved the issue for me, as far as I can tell.

Demosthenexx commented 5 years ago

Recently had this problem again, because the kernel has removed nrpacks as an option.

Instead I increased the output delay to 50 ms, matching the jitter delay. It had defaulted to 10 ms output delay which must have been insufficient. It seems to work fine now.