Personal computing discussed

Moderators: SecretSquirrel, notfred

 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Pulseaudio or MOC issue on pause/play

Mon Aug 07, 2017 5:48 pm

I just fixed a problem where pulseaudio was delaying audio output by a second or two and placing bursty/crackly noise leading/during/following it. This started with my upgrade to a mobo using an ALC1220 (this kernel does support it). It usually started with Firefox's startup, but wasn't consistent. Even though this problem was with the mobo's audio, plugging/unplugging my USB DAC would start or stop the problem (having it plugged in tended to fix it). Turning off pulse's timer-based scheduling seems to have done the trick. This paragraph is just for background, because something is definitely wonky here and it's probably related.

The new problem that happens in the same circumstances is that whenever MOC starts playing something (including a new track), the playback point slides forward by a few seconds at maybe 50x rate (including the garbled/staticy noise generated by this) before continuing normally. [Edit to clarify: this problem showed up in place of the other when I disabled timer-based scheduling.] If I let it sit for a few minutes after pausing, it probably won't do this, but if it hasn't been more than ~15 seconds, it will slide almost every time. Average slides might be 5 seconds, but some are barely perceptible and some are by as much as a minute. If something else is playing at the same time, the slide will be much slower, like 10x rate, but distances seem to be the same. I haven't tested every use case I've got, but VLC and Youtube both seem to be flawless now.

The only other thing that seems odd or wrong about this audio config is that the card shows up as "HD-Audio Generic" in some places. Alsamixer shows both HD-Audio Generic and Realtek ALC1220 (card and chip, respectively). The right kernel modules seem to be loaded and kernel logs show nothing amiss. MOC won't give me any useful info at all. Without -v, the only unexpected text pulse ever throws out is this:

E: [alsa-sink-ALC1220 Analog] alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write.
E: [alsa-sink-ALC1220 Analog] alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_hda_intel'. Please report this issue to the ALSA developers.
E: [alsa-sink-ALC1220 Analog] alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.

This only happens once per boot of pulse, generally within a few minutes of startup, and doesn't seem immediately correlated with the start of the glitch (but it's possible it is). With -v, pulse mostly spams stdout with ridiculous amounts of redundant info on mundane activity, and I can't find anything amiss throughout that. That spamming does slow down the slide rate a bit though, and the amount of spam when sliding is as if the skipped audio had actually been played.

[Edit again: Cutting pulseaudio out of the loop and just using ALSA fixed the other problem with all programs that worked. MOC was not among those, throwing a "ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave". Doesn't look relevant, but it seems worth mentioning and is a slight hole in my debugging efforts.]

I really have no idea how to proceed in debugging this further. Does anyone else have any thoughts?
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Mon Aug 07, 2017 6:12 pm

Sounds like it could be a problem with the Realtek driver. That's a relatively new codec, and the stock driver may not have full support.

In the past, I have solved Realtek audio issues on Linux by grabbing the driver tarball from Realtek's site, and building from source. Haven't had to do this in several years, but like I said, that's a fairly new codec so who knows.

One caveat: The last time I had to do this (probably around 2013), Realtek's driver tarball was actually a complete replacement for the ALSA layer of the audio stack, which is less than desirable. Kind of like fixing a faulty spark plug by ripping out and replacing the entire engine. But it did fix my Realtek issues, FWIW.
Nostalgia isn't what it used to be.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Mon Aug 07, 2017 6:28 pm

Good idea, but the only Linux drivers I see on their site are from 2007 and say kernel 2.4 or 2.6 (!!!). No drivers on Realtek's site look appropriate for it regardless of platform. ASRock's are Win10 only, as expected. The ALC1220 seems to have an amazingly small footprint on the internet, with DDG results for ALC1220 and variant searches mostly being Linux users having trouble with it and people wondering whether it's better than previous Realtek codecs.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Mon Aug 07, 2017 6:38 pm

I can confirm that the three pulse warning lines I posted above are not correlated with the start of the problem. It may also be more strongly correlated with Firefox initialization than I thought, and starting pulse after Firefox may fix it. Trying to do that automatically though.... ugh. Firefox won't play audio at all now without pulse, and it may not figure out pulse exists if it isn't there on boot. So start Firefox with a script that reboots pulse 5 seconds later? This is ridiculous.
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Mon Aug 07, 2017 11:19 pm

synthtel2 wrote:
Good idea, but the only Linux drivers I see on their site are from 2007 and say kernel 2.4 or 2.6 (!!!). No drivers on Realtek's site look appropriate for it regardless of platform.

There's one from 2014, second from the bottom of this page: http://www.realtek.com.tw/Downloads/dow ... wn=false#2

Unfortunately 2014 may still be too old to support that codec, and it only claims support for 3.0, not 4.x. But it's newer than the decade old one you found! :lol:

You could try building the latest kernel & drivers, and see if that helps...
Nostalgia isn't what it used to be.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 08, 2017 10:44 pm

Arch is already giving me kernel 4.12.4, so I can hardly get anything newer without getting actually unstable. :/ Thanks for the link, but the ALC1220 started showing up on Z270 boards mostly, so 2014 probably still wouldn't do it.

I guess I'll just use that FF launch script and revisit this if anything else turns out to break it or be broken by it. So long as nothing else breaks, it's basically fine, but I haven't yet tested half the stuff that might.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Sun Aug 13, 2017 12:27 am

It definitely wasn't fixed (numerous other programs broke in one way or another), but I think I've finally got the playback side sorted out. All the advice on the internet about pulseaudio fragment sizes/counts was pointing in the wrong direction for this; 25 millis of total buffer turns out to be about the maximum it will tolerate. It also really likes tiny fragment sizes, as in one milli. Of course between that and speex-float-10, pulse's CPU usage is headed for plaid, but at least I've now got enough CPU to beast-mode through it. Fortunately it's also enough CPU that it can handle down to ~6ms of buffer without that more common kind of glitchiness.

The mic side of things is not doing so well. Most stuff that tries to capture from it (arecord, Audacity) captures at ~1/10th speed. When stretched by 10x, it sounds about right other than the extremely low sample rate. Things like Mumble that have a fixed timescale just see bursts of massively sped-up sound every half second or so. Audacity captures that same way if there's already a track in the project, for some reason. The upside is that it wasn't this bad before I started tinkering with pulse settings in-depth, so presumably there's a way to fix it around here somewhere.
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Sun Aug 13, 2017 9:45 am

If all the apps that are giving you grief have a JACK backend you may want to look into going that route. Beware that you'll be in for an adventure though, with no guarantee of a successful outcome.

I run JACK as my audio stack, with a Pulseaudio connector for apps that don't support JACK. Essentially, I've shoved Pulse off in a corner and firewalled it off.
Nostalgia isn't what it used to be.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Sun Aug 13, 2017 1:22 pm

I may need JACK anyway (for Reaper). I'm not looking forward to making it and pulse coexist. Pulse is definitely needed though, between Firefox and a version of Unity that won't boot if it can't find pulse (it's a bug, but some games are just stuck with that version). Apulse might be an option if nothing else works.

At the moment playback seems to finally be flawless and it's just the mic that's got issues. The mic does need to work in Firefox, so it's either fix pulse or hope apulse works.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Mon Aug 14, 2017 9:56 pm

Alright, I can't fix the mic, but I can pipe pulse's output into ALSA's input as if it were just another program trying to play audio (making pulse keep a safe distance from the hardware itself). This seems to be working great as far as ALSA is concerned, and with dmix/dsnoop there's no real loss of functionality (in fact getting pulse's inane resample logic out of the chain seems to have noticably improved sound quality), but pulse is still broken. If I try to play audio via pulse, as Firefox forces me to, sometimes all I get is correllated static. I haven't yet figured out any factors that make it work or not work.
 
chuckula
Gold subscriber
Gerbil Jedi
Posts: 1574
Joined: Wed Jan 23, 2008 9:18 pm
Location: Probably where I don't belong.

Re: Pulseaudio or MOC issue on pause/play

Mon Aug 14, 2017 10:22 pm

synthtel2 wrote:
Alright, I can't fix the mic, but I can pipe pulse's output into ALSA's input as if it were just another program trying to play audio (making pulse keep a safe distance from the hardware itself). This seems to be working great as far as ALSA is concerned, and with dmix/dsnoop there's no real loss of functionality (in fact getting pulse's inane resample logic out of the chain seems to have noticably improved sound quality), but pulse is still broken. If I try to play audio via pulse, as Firefox forces me to, sometimes all I get is correllated static. I haven't yet figured out any factors that make it work or not work.


I'm not an expert in Pulse or the more complex systems like Jack whatsoever... all I know is that for basic audio I can avoid them and just use ALSA with typically good results.

Having said that, I noticed that you are using Firefox and if the rumors are true then you are stuck with PulseAudio. Perhaps the Apulse project could be of help? [Edit: Ah crap, you've already spotted Apulse, I missed it the first time, feel free to ignore the rest]. It basically pretends to be PulseAudio while wrapping Alsa and avoiding many of the issues that the real PulseAudio produces for some people. Here's the project website: https://github.com/i-rinat/apulse but you might want to investigate using precompiled packages for your distro.
4770K @ 4.7 GHz; 32GB DDR3-2133; GTX-1080; 512GB 840 Pro (2x); Fractal Define XL-R2; NZXT Kraken-X60
--Many thanks to the TR Forum for advice in getting it built.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Mon Aug 14, 2017 11:48 pm

Thanks anyway, apulse may yet turn out to be the right solution. (The rumors are definitely true and yes I am salty about it.)
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 5:02 pm

It isn't just pulse! Re-enabling that FF launcher fixes that side of things, but there is another issue in ALSA. The mic crackles a bit. I thought I had this narrowed down to programs trying to record at 48 KHz and have been poking at my ALSA resampling settings for hours now, but all I seem to have accomplished is making it crackle in all situations. 48 KHz is still worse though, and it does sound like that kind of error. Other settings like buffer sizes seem to have no effect on this problem.

What would be really useful is some way to override programs' autodetect of available sample rates. Mumble is where this problem first showed up, and it seems to try to capture at 48 KHz regardless of setup.
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 6:17 pm

This really sounds like a driver issue. My guess is that there's only so much you can do until the driver gets fixed.
Nostalgia isn't what it used to be.
 
chuckula
Gold subscriber
Gerbil Jedi
Posts: 1574
Joined: Wed Jan 23, 2008 9:18 pm
Location: Probably where I don't belong.

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 6:23 pm

This is kind of a cop out but if the issue is in the microphone input could you just get a USB mic or some other device that avoids the bad driver?

If this is some professional grade mic then I guess it's a non-starter. I agree that the long term solution shoukd definitely be in getting the drivers fixed.
4770K @ 4.7 GHz; 32GB DDR3-2133; GTX-1080; 512GB 840 Pro (2x); Fractal Define XL-R2; NZXT Kraken-X60
--Many thanks to the TR Forum for advice in getting it built.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 7:06 pm

It's weird because theoretically the driver already is fixed (as of kernel 4.11). Just in case, I did mess with some options for snd_hda_intel too, but they had no effect. (snd_hda_intel and snd_hda_codec_realtek coexist by design, and all of the options are in the intel module.)

It's a Modmic and I'd rather keep it, and I do need a higher quality input than just for voice comms. It looks like Behringer UCA202s have inputs; maybe I should just get one of those.
 
chuckula
Gold subscriber
Gerbil Jedi
Posts: 1574
Joined: Wed Jan 23, 2008 9:18 pm
Location: Probably where I don't belong.

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 7:15 pm

synthtel2 wrote:
It's weird because theoretically the driver already is fixed (as of kernel 4.11). Just in case, I did mess with some options for snd_hda_intel too, but they had no effect. (snd_hda_intel and snd_hda_codec_realtek coexist by design, and all of the options are in the intel module.)

It's a Modmic and I'd rather keep it, and I do need a higher quality input than just for voice comms. It looks like Behringer UCA202s have inputs; maybe I should just get one of those.


Just thinking outside the box but could the issue be hardware related instead of driver related? Sampling rate mismatches in software are definitely a biggy, but could there be some other noise source producing the crackle that's independent of the driver? Electrical noise? Input level being set too high or needing some attenuation?

I'm just coming up with wacky ideas if it happens to not be a driver issue.
4770K @ 4.7 GHz; 32GB DDR3-2133; GTX-1080; 512GB 840 Pro (2x); Fractal Define XL-R2; NZXT Kraken-X60
--Many thanks to the TR Forum for advice in getting it built.
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 7:54 pm

synthtel2 wrote:
It's weird because theoretically the driver already is fixed (as of kernel 4.11). Just in case, I did mess with some options for snd_hda_intel too, but they had no effect. (snd_hda_intel and snd_hda_codec_realtek coexist by design, and all of the options are in the intel module.)

Maybe the mobo designer didn't stick strictly to the reference design, and there's some additional futzing required to properly switch input sources or something. If a vendor-specific driver is required for full functionality under Windows, that's a good indication that they've done something non-standard.

Another thought... you could try poking around in the codec's internal registers using ALSA's "HDA Analyzer" tool (should be a download somewhere on their site). I was able to use that to enable the built-in headphone amp on the ALC887 in my previous build, after giving up on getting a reasonable hedaphone output level any other way. There does not appear to be a downloadable data sheet for the ALC1220 available online, but it may be similar enough to the ALC1150 (which does appear to be available) that you can probably get some hints from that.
Nostalgia isn't what it used to be.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 8:02 pm

chuckula wrote:
Just thinking outside the box but could the issue be hardware related instead of driver related? Sampling rate mismatches in software are definitely a biggy, but could there be some other noise source producing the crackle that's independent of the driver? Electrical noise? Input level being set too high or needing some attenuation?

Hmm, good idea:

Image

That sounds plausibly like a resampling problem, but resample error shouldn't look like that. Instead it looks like random samples are just getting clamped to zero, which explains why the error scales linearly with volume. There's a bit of ringing at ~20 KHz (near max representable) around both sides of a few of the errors. Occasional errors (usually from low amplitude) go past zero to the other side of the line by as much as ~80% of the glitch's amplitude, but none ever glitch away from zero.

I've got no explanation.

HDA Analyzer seems like a good next step as far as software solutions.
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Tue Aug 15, 2017 10:09 pm

I've seen automatic front/rear jack switching flake out and randomly glitch the connection. Maybe it's possible something like that is going on here with your "random zero" samples?
Nostalgia isn't what it used to be.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Wed Aug 30, 2017 10:45 pm

A Behringer UCA202 just arrived, and in addition to the now all-important ADC side, no other source I've ever owned comes close to this thing at sound quality. In a real first, it's got zero NFB-oid blur to the best I can distinguish. Problem solved, no regrets (other than a bit of wasted time). :D
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Wed Aug 30, 2017 11:23 pm

synthtel2 wrote:
A Behringer UCA202 just arrived, and in addition to the now all-important ADC side, no other source I've ever owned comes close to this thing at sound quality. In a real first, it's got zero NFB-oid blur to the best I can distinguish. Problem solved, no regrets (other than a bit of wasted time). :D

Was not familiar with this device. Based on reviews I'm finding, it is a fantastic bang for the buck, as long as you don't try to directly drive headphones. Interesting.
Nostalgia isn't what it used to be.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Thu Aug 31, 2017 12:16 am

I don't even remember which reviews I might have read on it, honestly. It's been a while. Issues with low or high impedance? With Grado SR80es, my typical listening levels are 65-80 dB below max, and if the damping factor somehow still isn't into the range where it doesn't matter, it's at least clearly giving these headphones a lower Qts than I've ever heard from them before.

Edit, low impedance it looks like, and 50 ohm output? That stretches credibility based on what I'm hearing right now. I'll see about measuring it first-hand. If this is 50 ohm, then literally every other device I've ever plugged headphones into has been at least twice as garbage as I thought.

Edit 2 - if it is 50 ohm, some of this modding is almost certainly in this box's future.
 
just brew it!
Gold subscriber
Administrator
Posts: 49745
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Pulseaudio or MOC issue on pause/play

Thu Aug 31, 2017 1:05 am

synthtel2 wrote:
If this is 50 ohm, then literally every other device I've ever plugged headphones into has been at least twice as garbage as I thought.

Not outside the realm of possibility, given the quantity of snake oil being marketed in the audio space.

synthtel2 wrote:
Edit 2 - if it is 50 ohm, some of this modding is almost certainly in this box's future.

Well, the original stock op-amp in this thing was apparently a 4558, which is a 1960s design (4558 was introduced in the '70s, but was essentially a dual 741 on a single die). I remember playing with them when I was learning electronics back in the 1970s, and IIRC they had some pretty severe crossover distortion when driving low-impedance loads (which is probably the reason for the 47 ohm series resistors... raise the load impedance seen by the output stage, at the expense of effective output level and damping factor).

4558s literally cost 10 cents each in lots of 1000 these days. I guess Behringer spared no expense. :lol:

OTOH, based on what I'm reading online, they've apparently used different op-amps at various times, so maybe you got something better. If you got anything other than a 4558 or a 4556 in yours it may not be worth replacing the op-amp; but if you've still got the 47 ohm series resistors you probably still want to at least get rid of those.
Nostalgia isn't what it used to be.
 
synthtel2
Gold subscriber
Gerbil Elite
Topic Author
Posts: 611
Joined: Mon Nov 16, 2015 10:30 am

Re: Pulseaudio or MOC issue on pause/play

Sat Sep 09, 2017 4:48 pm

This has been a driver issue, not a hardware issue - the mic is fine in Windows.

Who is online

Users browsing this forum: No registered users and 1 guest