You are not logged in.

#1 2014-07-06 17:39:41

rabcor
Banned
Registered: 2013-02-09
Posts: 500

[Solved]Alsa funkiness (sound breaking)

(Note: I originally thought this was a steam issue, but turns out it's not only steam that can break my sound (see the update on the bottom))

I get an issue with Steam where I get a short (less than 1s) sound on repeat/loop (usually it's some part of the message notification sound, or a trailer that I was watching) sounding a bit like a broken record, randomly occurring after keeping steam open for long periods of time in the background. Only fix I've found so far is to restart steam.

I have the Enlightenmen 18 Window Manager.

Notable errors:

Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 78: saw unknown, expected number
[0706/170950:ERROR:object_proxy.cc(239)] Failed to call method: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.NetworkManager was not provided by any .service files
[0706/170950:WARNING:proxy_service.cc(958)] PAC support disabled because there is no system implementation

PulseAudio connect failed (used only for Mic Volume Control) with error: Access denied

** (steam:7341): WARNING **: Could not initialize NMClient /org/freedesktop/NetworkManager: The name org.freedesktop.NetworkManager was not provided by any .service files

(steam:7341): LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that doesn't believe we're it's parent.

[0706/171536:ERROR:reference_audio_renderer.cc(46)] Not implemented reached in virtual void media::ReferenceAudioRenderer::OnCreated(media::AudioOutputController*)
[0706/171536:ERROR:reference_audio_renderer.cc(50)] Not implemented reached in virtual void media::ReferenceAudioRenderer::OnPlaying(media::AudioOutputController*)
[0706/171657:ERROR:reference_audio_renderer.cc(54)] Not implemented reached in virtual void media::ReferenceAudioRenderer::OnPaused(media::AudioOutputController*)
AL lib: pulseaudio.c:612: Context did not connect: Access denied

I don't have any reliable method to reproduce the issue, and it does not seem to output an error of it's own in the terminal output when it occurs. I have noticed that this is more likely to occur when steam has been open for prolonged periods. I am not using pulseaudio, just Alsa. I also noticed when I was running a Wine game (not through steam) that this issue occurred, and it seemed to contaminate the sound outputs for whine too (I got like a "double" sound for every sound effect the game played). If the sound was completely broken on steam and making a loop like I explained at the start of this post and then I close steam while the Wine game is running, the sound from steam will remain until I shut down the game too (i.e. seems that this isn't just breakage internally in steam, but in alsa itself)

The one thing I have tried to solve this was install lib32-libpulse, this did not seem to fix the errors nor the problem. I imagine installing pulseaudio could fix this problem, but pulseaudio downright hates my sound card, so I would rather not use it.

I also have two other issues too that are less severe.

1: Mouse cursor sometimes gets locked in steam instance (Right clicking will show the steam context menu, pressing "stop" in that context menu will solve the issue. This sometimes happens when I use "Ctrl + C"(copy) or "Ctrl + V"(paste) when I'm typing in the discussions)
2: Fullscreen videos will not go fullscreen (they will only fill the steam window)

Update:

I found a bulletproof way to make a similar issue occur.

If I open facebook in firefox, and get a message notification while I am playing a movie in Cmplayer (my media player of choice) the sound in CMplayer breaks (but firefox's sound keeps working normally)

Update2:
I was rather desperate to get this fixed so I installed pulseaudio as much as I despise it, the quality of my audio is damaged by it, but this problem was as I suspected fixed by installing it. I am guessing pulseaudio is set up partially to prevent issues like this one, but I would relaly prefer not to have it. This does not rid me of all the errors however (reference_audio_renderer errors persist) but it does create a new error for steam:

[0706/215704:ERROR:alsa_output.cc(684)] Failed querying delay: Input/output error

Last edited by rabcor (2014-07-11 16:28:34)

Offline

#2 2014-07-06 22:46:00

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved]Alsa funkiness (sound breaking)

With pulseaudio killed, can you play multiple sounds at the same time? Speaker-test should be sufficient for this. What uses sound with PA killed in your "bulletproof" situation?

fuser -v /dev/snd/*

Offline

#3 2014-07-07 12:01:41

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: [Solved]Alsa funkiness (sound breaking)

i can play multiple sounds at a time they all go through the same PCM I think, this is output. Is that normal? (running steam video, chrome video and cmplayer video)

$ fuser -v /dev/snd/*
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  xandis      508 F.... enlightenment
/dev/snd/pcmC0D0p:   xandis      709 F...m steam
                     xandis      739 F...m chrome
                     xandis     1651 F...m cmplayer

As for my "bulletproof" problem reproduction i need to find a way to make a sound like the facebook notification sound from firefox to test that.

Edit: Firefox is right now refusing to play any sound at all after I uninstalled pulseaudio. It does not throw out an error either. Everything else seems to be playing sound just fine.

I tried clearing out the following pulseaudio dependences and restarting again, it had no effect.

gtkmm3  libcanberra-pulse  rtkit sbc  webrtc-audio-processing

Last edited by rabcor (2014-07-07 12:23:00)

Offline

#4 2014-07-07 15:03:25

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved]Alsa funkiness (sound breaking)

Yes, they all use card 0 device 0 for playback. The output confirms, dmix and therefore pcm.default are intact (default configuration).

Did you run firefox in a terminal? Is /etc/asound.conf there? Remeber to remove pulseaudio-alsa package.

Offline

#5 2014-07-07 23:16:46

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: [Solved]Alsa funkiness (sound breaking)

I think installing and uninstalling pulse somehow fixed the issue, but if it did not I have set up a dmix in asound.conf which will fix it either way which probably ensures that this can't happen anymore.

Offline

#6 2014-07-08 00:05:29

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved]Alsa funkiness (sound breaking)

There is a perfectly fine working version of dmix definition in the default configuration that comes with alsa:

less /usr/share/alsa/pcm/dmix.conf

No need to change that. Also that definition is more flexible, it accepts runtime arguments.

if you do not overwrite pcm.default in any configuration file, then dmix will stay the default output, ensuring multiple sounds at the same time.

Offline

#7 2014-07-08 11:05:28

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: [Solved]Alsa funkiness (sound breaking)

I always had to have an asound.conf in the name of upmixing 2.0 to 5.1 This is the content of my asound.conf before I made the changes. I also had a problem with a game where I had crackling noises on 48khz so I had to tell alsa to force 96khz (or 44.1khz but since my card supports 96khz that's what I went with) to avoid that.

pcm.!default {
        slave.pcm "surround51"
        slave.channels 6
	type route

        # Front and rear
        ttable.0.0 0.7
        ttable.1.1 0.7
        ttable.2.2 0.6
        ttable.3.3 0.6

        # Center and LFE
        ttable.4.4 1
        ttable.5.5 1

        # Front left/right to center
        ttable.0.4 0.5
        ttable.1.4 0.5

        # Front left/right to rear
        ttable.0.2 0.5
        ttable.1.3 0.5
}

Now it looks like this and everything seems to be working fine (except that mono sound only plays from my left speaker and I haven't defined a way to downmix 7.1 to 5.1):

pcm.dmixed {
	type asym
	playback.pcm {
		# See plugin:dmix at http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		type dmix

		# Don't block other users, e.g. the Timidity midi-player daemon
		# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		ipc_key_add_uid true

		ipc_key 5678293
		ipc_perm 0660
		ipc_gid audio

		# Don't put the rate here! Otherwise it resets the rate & channels set below, as shown by:  cat /proc/asound/card0/pcm0p/sub0/hw_params
		slave {
			# 2 for stereo, 6 for surround51, 8 for surround71
			channels 6
			pcm {
				# mplayer chooses S32_LE, but others usually S16_LE
				format S32_LE
				#format S16_LE

				# 44100 or 48000
				# 44100 for music, 48000 is compatible with most h/w
				#rate 44100
				rate 96000

				# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
				# Maybe helps
				nonblock true

				type hw
				card 0
				device 0
				subdevice 0
			}

			# mplayer2 chooses 1024
			# period_size 512 with buffer_size 16384 stops crackling in xmame
			# 320 breaks flash - https://bbs.archlinux.org/viewtopic.php?id=129458
			#period_size 512
			period_size 1024
			#period_size 512

			# 4096 might make sound crackle
			# mplayer2 chooses 8192. Half-Life 2 chooses 16384.
			# If too large, use CONFIG_SND_HDA_PREALLOC_SIZE=2048
			buffer_size 16384
		}
	}
	capture.pcm "hw:0"
}

pcm.!default{
	type plug
	slave.pcm "upmix20_51"
}


pcm.!surround20 {
	type plug
	slave.pcm "upmix20_51"
}

pcm.!surround40 {
	type plug
	slave.pcm "dmixed"
	route_policy duplicate
}

pcm.!surround51 {
	type plug
	slave.pcm "dmixed"
}

pcm.upmix20_51 {
        slave.pcm "dmixed"
        slave.channels 6
	type route

        # Front and rear
        ttable.0.0 0.7
        ttable.1.1 0.7
        ttable.2.2 0.6
        ttable.3.3 0.6

        # Center and LFE
        ttable.4.4 1
        ttable.5.5 1

        # Front left/right to center
        ttable.0.4 0.5
        ttable.1.4 0.5

        # Front left/right to rear
        ttable.0.2 0.5
        ttable.1.3 0.5
}

Is there a better way for me to achieve the results of the above config? Because I'm all ears.

Last edited by rabcor (2014-07-08 11:09:23)

Offline

#8 2014-07-08 12:12:54

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved]Alsa funkiness (sound breaking)

emeres wrote:

There is a perfectly fine working version of dmix definition in the default configuration that comes with alsa

That's a lie.

It may appear perfectly fine if only *stereo* is outputted.

If surround sound is *sometimes* outputted, it has the appearance of breaking randomly, because ALSA cannot switch from stereo to surround output on-the-fly - it must have been "originally" opened for surround sound.

Offline

#9 2014-07-08 12:32:35

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved]Alsa funkiness (sound breaking)

For mono upmixing to stereo you can use:

##Upmixing
pcm.mono {	type plug;
		slave.pcm "default";
		ttable.0.0    1;
		ttable.0.1    1;	}

Even though I have 3 sound cards capable of 7.1 surround sound, I still prefer using headphones. I was thinking of using runtime arguments with a wrapper, that would detect current number of channels used, to automatically use an appropriate pcm surround definition, in other words something dynamic in contrast to conventional static alsa definitions. Maybe one of ladspa v1 or v2 plugins can do that in a more friendly way.

@brebs
Up to that point he did not state what configuration he was using. Stereo is the majority case from my observations, so I assumed that. You better watch it with that terminology. I certainly did not lie. I agree with limited capabilities of alsa when it comes to surround/stereo sound combinations.

Edit: You may need to use another slave.pcm for the pcm.mono.

Last edited by emeres (2014-07-08 12:38:20)

Offline

#10 2014-07-10 15:13:23

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: [Solved]Alsa funkiness (sound breaking)

emeres wrote:

For mono upmixing to stereo you can use:

##Upmixing
pcm.mono {	type plug;
		slave.pcm "default";
		ttable.0.0    1;
		ttable.0.1    1;	}

Not all applications allow me to specify the PCM I want to use for playback (Mono and Stereo sources all seem to use the !default pcm for me), also this will only upmix mono to stereo, I would like to further upmix this from stereo to surround afterwards, How do I do that?

Last edited by rabcor (2014-07-10 15:13:50)

Offline

#11 2014-07-10 15:18:02

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved]Alsa funkiness (sound breaking)

Using environment variables and runtime arguments. Take a look at the wiki, although I recommend something like this instead (gives you more flexibility).

Add another ttable entries?

##Upmixing mono to quadrophony
pcm.I1O4 {	type plug;
		slave.pcm "default";
		ttable.0.0    1;
		ttable.0.1    1;
		ttable.0.2    1;
		ttable.0.3    1;	}

##Upmixing stereo to quadrophony
pcm.I2O4 {	type plug;
		slave.pcm "default";
		ttable.0.0    1;
		ttable.1.1    1;
		ttable.0.2    1;
		ttable.1.3    1;	}

Read about route and plug pcm plugins.

Again slave.pcm should probably be different, and check ttable entries I tend to mix source with target.

Last edited by emeres (2014-07-10 15:37:38)

Offline

#12 2014-07-11 00:20:20

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: [Solved]Alsa funkiness (sound breaking)

Thanks I think I understand how ttables works, but I can't seem to make that ALSA_DEFAULT_PCM variable work.

I set like so

pcm.!default {
        	type plug
		slave.pcm {
                        	@func getenv
				vars [ ALSA_DEFAULT_PCM ]
				default "upmix20_51" }
}

but running the following

env ALSA_DEFAULT_PCM=mono

won't change the PCM for the next application I run. (It stays on upmix20_51)

Last edited by rabcor (2014-07-11 00:20:40)

Offline

#13 2014-07-11 00:32:04

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved]Alsa funkiness (sound breaking)

rabcor wrote:

but running the following

env ALSA_DEFAULT_PCM=mono

won't change the PCM for the next application I run. (It stays on upmix20_51)

That is because you set the variable with env command. Either set it in shell (may have some limitations, see man bash for reference, I do not recall), export it or use with env as intended:

env ALSA_DEFAULT_PCM=mono _application_;
man env;
man export;

I recommend using env since I do not need to change the default alsa device every time I run a different application.

Last edited by emeres (2014-07-11 00:41:08)

Offline

#14 2014-07-11 16:28:02

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: [Solved]Alsa funkiness (sound breaking)

thanks.

Offline

Board footer

Powered by FluxBB