You are not logged in.

#1 2016-01-05 18:06:36

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

[WORKAROUND] Surround sound output intermittent.

Edit, Workaround: Although the cause is unkown, pulseaudio keeps the configured ouput so long as module-switch-on-port-available is not loaded. This module is ususally enabled for bluetooh's expected behavior (switch audio to connected headphones), but in my case it's broken. It's not default last I checked.

Before anyone asks: I've read dozens of tutorials on to setting up 5.1 surround sound with ffmpeg, alsa and pulseaudio, 99.9% of which boil down to the same asound.rc file, which I am using.

The surround sound output intermittently unloads, reverting to--randomly--either a digital or analog stereo output. It can usually be fixed with a few clicks in pavucontrol, but then at any given moment (sometimes after a long time, sometimes very soon after the last fix) it may happen again. It looks like the kernel module for the card is being abruptly reinitialized; sometimes causing pavucontrol's list of outputs to go crazy (several items may flicker in and out of the list while it is open); sometimes crashing pavucontrol; sometimes crashing the pulseaudio daemon (which auto(re)spawns, and continues to work for a while).

How can I get either pulseaudio, alsa, or the kernel to tell me what is going on?

I highly suspect the problem is with pulseaudio itself--a bug that needs to be triaged--but I know a report would be a waste of time as there are too many other components available to blame.

EDIT: more, worsening symptoms.

EDIT again: testing a settings change: specified the 5.1 output and its stereo input as defaults in /etc/pulse/default.pa, replacing the default setting. I forsee a problem, if pulseaudio fails to recognize the existence of the 5.1 output on init the specification will only confuse it.

Last edited by quequotion (2016-01-10 08:29:13)

Offline

#2 2016-01-06 09:14:23

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,056

Re: [WORKAROUND] Surround sound output intermittent.

Whatever asoundrc you are using, throw it away (or post it first, but it likely is interfering heavily instead of helping), and configure pulseaudio correctly. Post

aplay -l
aplay -L
pacmd list-cards
pacmd list-sinks

and your daemon.conf and default.pa (from /etc/pulse or ~/.config/pulse whichever you made adjustments in)

Last edited by V1del (2016-01-06 09:16:35)

Offline

#3 2016-01-06 14:34:20

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

V1del wrote:

Whatever asoundrc you are using, throw it away (or post it first, but it likely is interfering heavily instead of helping), and configure pulseaudio correctly. Post

aplay -l
aplay -L
pacmd list-cards
pacmd list-sinks

and your daemon.conf and default.pa (from /etc/pulse or ~/.config/pulse whichever you made adjustments in)

The alsa configuration has not changed since this was in a working state for the last several months. Pulseaudio is configured correctly. So is alsa. The a52 encodec ac3 output has to be created as an alsa device; pulseaudio does not natively support surround sound on this kind of card.*

The latest from pusleaudio -vvv

alsa-util.c: Error opening PCM device a52:1: No such file or directory

For every digital output profile above stereo....

*to put it more technically: pulseaudio regcognizes the digital output on the card, but natively supports only stereo encoding on the device; the alsa a52 plugin streams audio through libav to encode it as AC3 5.1, then adds an alsa card profile that allows pulseaudio to output 5.1 channels over the digital port (it isn't just a simple pipe; pulseaudio sees the device as having six discreet channels).

Offline

#4 2016-01-06 14:38:38

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

Possible workaround: disable all autodetection and specify the card manually.

/etc/pulse/default.pa

# Manually specify device
load-module module-alsa-card device_id="0" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes  

# Manually specify device profile
set-card-profile alsa_card.pci-0000_00_1b.0 output:iec958-ac3-surround-51+input:analog-stereo

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
#load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
#load-module module-detect
.endif

There are probably lots of downsides to this.

EDIT: Nope; not stable. Card still switches back to analog/digital stereo profile at random intervals; though possibly less often.

Last edited by quequotion (2016-01-07 15:28:57)

Offline

#5 2016-01-06 14:51:45

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [WORKAROUND] Surround sound output intermittent.

a52 encode? you sure? Trying to implement Dolby Digital "Live" yourself with ALSA? Or do you actually just want passthrough...

FWIW:

In order to allow passthrough to work with PulseAudio then it MUST be set to use a 2.0 channel configuration, despite the 2.0 setting this will still allow 5.1 audio from AC3, DTS, and EAC3.

http://kodi.wiki/view/PulseAudio#PulseA … figuration

Last edited by tom.ty89 (2016-01-06 14:56:06)

Offline

#6 2016-01-06 21:34:55

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

tom.ty89 wrote:

a52 encode? you sure? Trying to implement Dolby Digital "Live" yourself with ALSA? Or do you actually just want passthrough...

FWIW:

In order to allow passthrough to work with PulseAudio then it MUST be set to use a 2.0 channel configuration, despite the 2.0 setting this will still allow 5.1 audio from AC3, DTS, and EAC3.

http://kodi.wiki/view/PulseAudio#PulseA … figuration

Passthrough in pulseaudio is no good. I need an always-available 5.1 surround sound output; that's what I've configured for.

Despite what the documentation would lead you to believe, passthrough basically dosen't work. You need to have applications that support this kind of output and it's always had problems with shared access. Furthermore, it doesn't actually work; I cannot recall the last time I have observed that this actually does work (I have tested--pulseaudio always downmixes to stereo for digital stereo profile, regardless of input encoding). Even if it did work as it theoretically should, it's not worth the trouble of finding applications that support it and configuring each of them to use it consisently--then doing it all over again after each update.

Last edited by quequotion (2016-01-09 17:14:16)

Offline

#7 2016-01-06 21:51:50

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

EDIT: If you are coming across this post after alsa-plugins 1.1.7 was released, know that this manual a52 configuration is deprecated and incompatible. DO NOT USE THIS CONFIGURATION.

Audio Configuration

/etc/asound.conf

# Alsa Resampler
defaults.pcm.rate_converter "speexrate_best"

# Use PulseAudio by default
pcm.!default {
  type pulse
  fallback "sysdefault"
  hint {
    show on
    description "Default ALSA Output (currently PulseAudio Sound Server)"
  }
}

ctl.!default {
  type pulse
  fallback "sysdefault"
}

# Digital 5.1 AC3 Output
pcm.a52 {
  @args [CARD]
  @args.CARD {
    type string
  }
  type rate
  slave {
    pcm {
      type a52
      bitrate 448
      channels 6
      card $CARD
    }
  rate 48000 #required somehow, otherwise nothing happens in PulseAudio
  }
}

Right down to the cargo-cult proof of purchase rate 48000 comment.

/etc/pulse/default.pa

#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.nofail

### Load something into the sample cache
#load-sample-lazy x11-bell /usr/share/sounds/freedesktop/stereo/bell.oga
#load-sample-lazy pulse-hotplug /usr/share/sounds/freedesktop/stereo/device-added.oga
#load-sample-lazy pulse-coldplug /usr/share/sounds/freedesktop/stereo/device-added.oga
#load-sample-lazy pulse-access /usr/share/sounds/freedesktop/stereo/message.oga

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

# Manually specify device
load-module module-alsa-card device_id="0" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes  

# Manually specify device profile
set-card-profile alsa_card.pci-0000_00_1b.0 output:iec958-ac3-surround-51+input:analog-stereo

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
#load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
#load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish

### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor

### Load additional modules from GConf settings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gconf.so
.nofail
load-module module-gconf
.fail
.endif

### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
#load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

# X11 modules should not be started from default.pa so that one daemon
# can be shared by multiple sessions.

### Load X11 bell module
#load-module module-x11-bell sample=x11-bell

### Register ourselves in the X11 session manager
#load-module module-x11-xsmp

### Publish connection data in the X11 root window
#.ifexists module-x11-publish.so
#.nofail
#load-module module-x11-publish
#.fail
#.endif

#Load DBUS protocol
.ifexists module-dbus-protocol.so
load-module module-dbus-protocol
.endif

#Load Equalizer
.ifexists module-equalizer-sink.so
load-module module-equalizer-sink
.endif

### Make some devices default
#set-default-sink output
set-default-sink alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51
#set-default-source input
set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo

/etc/pulse/daemon.conf

# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for
## more information. Default values are commented out.  Use either ; or # for
## commenting.

; daemonize = no
; fail = yes
; allow-module-loading = yes
; allow-exit = yes
; use-pid-file = yes
; system-instance = no
; local-server-type = user
; enable-shm = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
; lock-memory = no
; cpu-limit = no

; high-priority = yes
; nice-level = -11
nice-level = -18

; realtime-scheduling = yes
; realtime-priority = 5
realtime-priority = 8

exit-idle-time=0
; exit-idle-time = 20
; scache-idle-time = 20

; dl-search-path = (depends on architecture)

; load-default-script-file = yes
; default-script-file = /etc/pulse/default.pa

; log-target = auto
; log-level = notice
; log-meta = no
; log-time = no
; log-backtrace = 0

; resample-method = speex-float-1
 resample-method = speex-float-10
; enable-remixing = yes
; enable-lfe-remixing = yes
enable-lfe-remixing = yes
; lfe-crossover-freq = 120
 lfe-crossover-freq = 250

; flat-volumes = yes

; rlimit-fsize = -1
; rlimit-data = -1
; rlimit-stack = -1
; rlimit-core = -1
; rlimit-as = -1
; rlimit-rss = -1
; rlimit-nproc = -1
; rlimit-nofile = 256
; rlimit-memlock = -1
; rlimit-locks = -1
; rlimit-sigpending = -1
; rlimit-msgqueue = -1
; rlimit-nice = 31
; rlimit-rtprio = 9
; rlimit-rttime = 200000

; default-sample-format = s16le
;default-sample-format = float32le
; default-sample-rate = 44100
; alternate-sample-rate = 48000
default-sample-rate = 48000
alternate-sample-rate = 48000
; default-sample-channels = 2
; default-channel-map = front-left,front-right

; default-fragments = 4
; default-fragment-size-msec = 25
default-fragments = 3
default-fragment-size-msec = 12

; enable-deferred-volume = yes
; deferred-volume-safety-margin-usec = 8000
; deferred-volume-extra-delay-usec = 0

Last edited by quequotion (2021-06-20 02:51:34)

Offline

#8 2016-01-06 22:04:48

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,056

Re: [WORKAROUND] Surround sound output intermittent.

The intermittent unload could be due to exit-idle-time, can you set that to -1 and see if that improves things? on such a non  standard setup, might help with things. Any real reason you are being so reluctant providing your files/output? maybe there's some discrepancy we can catch...

exit-idle-time=0 makes it exit immediately as soon as there is no sink playing, so it really might be that

Last edited by V1del (2016-01-06 22:06:50)

Offline

#9 2016-01-07 05:53:34

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

V1del wrote:

exit-idle-time=0 makes it exit immediately as soon as there is no sink playing, so it really might be that

That is suspicious; but it's unloading while audio is playing. I wouldn't put it past pulseaudio to have a bug that falsely detects idle time. Testing that now.

EDIT: Unfortunately no, this did not help. Card still reverts to digital/analog stereo while playing audio.

Any real reason you are being so reluctant providing your files/output? maybe there's some discrepancy we can catch...

Yes. My configuration works; has worked for quite some time; was working without any trouble until very recently, etc. Although I am hoping there's an option I could change to stablize the a52 plugin, I know how much people like to call something "non-standard" and reject any associated request until the offending customizations are removed, regardless of having any logical reason to doubt those customizations. I find the distiction tedious; most of the options in my configuration are required for my system.

Last edited by quequotion (2016-01-07 06:15:01)

Offline

#10 2016-01-07 09:59:46

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [WORKAROUND] Surround sound output intermittent.

quequotion wrote:

Passthrough in pulseaudio is no good. I need an always-available 5.1 surround sound output; that's what I've configured for.

But...a52 encode wouldn't help you workaround this anyway coz it's still "Passthrough in pulseaudio" as long as you continue to use pulse...?

The only situation you want a52 encode is you want to output 5.1 through spdif (but not hdmi/dp), because the bandwidth is not enough for 5.1 pcm. Not to mention that it makes no sense if the source is already 5.1 AC3 (e.g. DVD).

So I just wanted to confirm this, in case you're doing something irrelevant to the issues you've been experiencing (and further complicated it).

Offline

#11 2016-01-07 14:13:49

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

tom.ty89 wrote:

But...a52 encode wouldn't help you workaround this anyway coz it's still "Passthrough in pulseaudio" as long as you continue to use pulse...?

As I already said, no It is not a passthrough pipe. The alsa plugin creates a virtual device--using libav--that pulseaudio sees as a six-channel port on the digital output. None of this is new or unusual.

The only situation you want a52 encode is you want to output 5.1 through spdif

That is exactly what is going on here. Pulseaudio does not natively support surround sound on this type of card; alsa configuration is required.

the bandwidth is not enough for 5.1 pcm

It's a little more complicated than that; the encoding used by the alsa a52 plugin is not free as in freedom. The cards that support this were intended to do so in Windows using the commercially available method.

Not to mention that it makes no sense if the source is already 5.1 AC3

That would be true if passthrough in pulseaudio worked, but it does not (at least not in any practical, real-world tested way). I don't want to write a long explanation and proof of this; suffice to say it will never be an option for me.

in case you're doing something irrelevant to the issues you've been experiencing (and further complicated it).

I find this is often the case. The problem seems to be that, no matter how well I know anything related to FOSS, there are always a number of things I've never heard of related to it. Most often this is the result of my own laziness, no known method of logging the error, a depressing lack of documentation, new developments, or bugs the developers do not recognize--though not necessarily in that order.

as long as you continue to use pulse...

Call me crazy, but I like pulseaudio, it's capabilities, and configuration options. I like how it treats alsa as a driver backend.

Last edited by quequotion (2016-01-07 15:44:44)

Offline

#12 2016-01-07 15:11:09

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

Another possible workaround: Although I've already tried this dozens of times, perhaps my timing has not been right.

After deleting the cache in ~/.config/pulse/ the card is holding the configured profile (so far). I have done this many, many times, but the last particular time I did this, while the surround sound output was temporarily working:

rm ~/.config/pulse/{c1d700c432e0452ba687a29f11cbc444-*,cookie}; pulseaudio -k

My theory, if this holds, is that pulseaudio must die and save its cache in a working state before it can ever be started in a working state.

EDIT: Nope, only lasted about twenty minutes.

Last edited by quequotion (2016-01-07 15:28:22)

Offline

#13 2016-01-07 16:30:06

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [WORKAROUND] Surround sound output intermittent.

It has nothing to do with pulse at all. You won't be able to have 5.1 surround pcm through S/PDIF anywhere, not even with blu-ray players from big brands. End of story.

And I don't think you need to create some virtual device to make pulseaudio take it as a multichannel-capable device, since if you use pulse to pass compressed signals (ac3, dts...), a DIGITAL STEREO profile is what exactly it NEEDS. Multichannel profile is only needed for multichannel PCM (which is only possible through HDMI/DP, not S/PDIF). What you need to do is to ALLOW the "passthrough" FORMATS you want through pactl/pavucontrol. (I have no idea what passthrough pipe you're talking about, "passthrough" here simply means sending non-PCM signals to ANY kind of pulse sink, virtual, physical, whatsoever)

Who cares about licensing here. But yeah, as I've said, a52 encode is basically "dolby digital live" in ALSA. Although I am not sure if it does pro-logic-ish upmixing automatically. (And if so, that can be a reason for you to use it)

I've never said PulseAudio is bad. It's you've been saying that it's broken for AC3 passthrough...What I meant is I feel like you don't really know how AC3 passthrough works in Pulse, and keep thinking that it's impossible. Truth is no matter if you want to use a52 encode or not, to Pulse it's still AC3 passthrough, since a sink is a sink, it does not matter whether it's so-called "physical" or virtual

Hmm never mind. I was wrong, cause you're sending 5.1 PCM to the virtual sink. (Are you?)

Last edited by tom.ty89 (2016-01-07 16:48:51)

Offline

#14 2016-01-07 18:53:57

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

tom.ty89 wrote:

Hmm never mind. I was wrong, cause you're sending 5.1 PCM to the virtual sink. (Are you?)

Yeah. I know, that's right. (Yes I am.)

As I said I'm not going to get into the details--although I'll concede that it may be the case of SPDIF (fiber optic) outputs in particular--but pulseaudio passthrough simply cannot be made to work for me, my system, or my interests.

Alsa's a52 plugin can be made to work; does work, and fulfills my requirements for audio output: all audio through surround sound mixing at all times (enhanced by per-channel equalization to spatiate stereo sources and sharpen the distinction of surround sound sources), but something is very wrong with it right now.

Last edited by quequotion (2016-01-08 06:39:50)

Offline

#15 2016-01-08 00:20:18

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [WORKAROUND] Surround sound output intermittent.

Btw apparently pulseaudio automatically looks for a52 "PCMs" ANYWAY, all I need is the following alsa conf (.asoundrc / asound.conf):

pcm.a52 {
    @args [ CARD ]
    @args.CARD {
        type string
    }
    type a52
    card $CARD
}

However, pulse will dump core when I switch to the profile: https://bugs.freedesktop.org/show_bug.cgi?id=93637

Last edited by tom.ty89 (2016-01-08 00:20:39)

Offline

#16 2016-01-08 06:48:49

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

tom.ty89 wrote:

Btw apparently pulseaudio automatically looks for a52 "PCMs"
However, pulse will dump core when I switch to the profile: https://bugs.freedesktop.org/show_bug.cgi?id=93637

Thank you for checking into this. Something is broken; it's strange and possibly a bug in pulseaudio--I concurr. I think your pulseaudio core dumps because the plugin needs to have it's bitrate, etc specified explicitly, but that's just a theory (and possibly a bug in pulseaudio's autoconfiguration).

Either way, I hope for progress on your bug report. Less config would be better, if pulse can profile the a52 outputs properly on its own.

Last edited by quequotion (2016-01-08 06:57:31)

Offline

#17 2016-01-08 08:46:24

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

The most annoying symptom is an occasional struggle (rapidly loading and dropping, followed by flickering menus, pulseaudio daemon crash, pavucontrol crash, respawn--rinse--repeat). This is sporadic; seems as though something gets worse, has better times, and then gets fried again.

Another card I have in the machine is an emu10k1 with both analog (onboard mixer/obnoxious proprietary cable) and spdif (non-fiber; some kind of copper tip what is this I don't even-) plus bonus onboard MIDI transcoding and wavetable (still haven't got this obnoxious cable--for a yamaha keyboard's MIDI io port: PS/1 to MIDI-Gameport).

I suppose I'll hook up ye' ol 90's analog, 3.3v faulty-32bit DMA PCI option in the mean time. Maybe later.

The connector for its digital output supports 3 and 4-pole minijacks.
https://heim.ifi.uio.no/haakoh/emu10k1/

End to end 4-pole minijack cable? Obnoxious.

Last edited by quequotion (2016-01-10 08:39:56)

Offline

#18 2016-01-08 09:03:59

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [WORKAROUND] Surround sound output intermittent.

Both rate, channels, bitrate, format are optional because they all have sane defaults. You can also test with speaker-test / aplay to see whether it's working (-D plug:a52:CARD_ID_OR_NAME). "plug" is for automatic conversion where necessary ("Access type not available for playback", because mmap i/o mode is needed, confirmed with `aplay -M` without "plug"). I have no AC3 decoder/receiver or whatsover here so I can't test whether the signal is valid, but speaker-test is running.

Your alsa conf wrap it with a "rate" plugin instead, which seems to do similar thing as "plug", but it's more specific. It probably doesn't work the same way internally though, coz somehow it can stop pulseaudio from dumping core. However, from what I observed when playing something with mpv, it doesn't seem to work properly either (a huge delay before the start of playback or so).

FWIW "rate 48000 #required somehow, otherwise nothing happens in PulseAudio" is silly because a rate plugin isn't valid without a rate parameter...

Ref:
http://git.alsa-project.org/?p=alsa-plu … xt;hb=HEAD
http://www.alsa-project.org/alsa-doc/al … ugins.html

Last edited by tom.ty89 (2016-01-08 09:04:19)

Offline

#19 2016-01-08 12:46:32

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

tom.ty89 wrote:

huge delay before the start of playback

How fast is your CPU? The encoding being done by libav, in addition to potential resampling by both alsa and pulseaudio can build up to a high load without the proper precautions, not to mention there are a number of ways pulseudio can break itself (see my configuration for some of them--in particular both alsa and pulseaudio should use the same speex/soxr profile, alternate and default rates must be the same, module-suspend-on-idle must be disabled, a high priority boost helps--especially with the FFT equalizer, etc).

Last edited by quequotion (2016-01-08 12:47:20)

Offline

#20 2016-01-08 16:04:30

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

Next theory: hibernation may exasperate the issue. Login starts pulseaudio with a52 surround-sound enabled with current setup. Reboots after hibernation are not necessarily so successful.

Edit: Nope, no particular connection there.

Recent changes: now blackisting the nvidia hdmi (snd_intel_hda_hdmi) and emu10k1 audio devices. There's an IVTV capture card audio device in there somewhere too; but maybe not enabled at the moment (there's an option for the driver to have or not have alsa io devices).

At the very least I should be saving some resources in addition to making pulseaudio more predictable; but still not certain of the setup.

qpaeq is doing it's usual post-upgrade "python is broken" act, so I haven't tested the FFT equalizer since last reboot. 5.1 has been holding for a while; no guarantees.

EDIT: Reinstalled all of qpaeq's qt and python dependencies, and fixed (as usual) a bug that prevents it from working on separate channels (hilarious fix, will report later).

Last edited by quequotion (2016-01-10 08:44:44)

Offline

#21 2016-01-08 17:12:27

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

Slightly updated audio configuration (little substantial change):

Nothing to see here, move along.
/etc/asound.conf

same as above

Testing out the suspend on idle module (seems to be fine now) and set equalizer as defult sink.
/etc/pulse/default.pa

-set-default-sink alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51
+set-default-sink alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51.equalizer

LFE channel was picking up too much speech; making everyone barry white.
/etc/pulse/daemon.conf

-lfe-crossover-freq = 250
+lfe-crossover-freq = 200

So far so good; holding for over an hour since the last boot. Haven't tried to hibernate yet; expecting breakage.

What it looks like when it works:
Screenshot_from_2016_01_09_02_05_13.jpg

EDIT: When I woke up the next morning, the a52 module had been unloaded. Given how long it took, I blame the suspend-on-idle module for that one, plus pulseaudio fails to resume the surround sound profile (default sink) when the card becomes active again. Considering the drops I experienced while I had this module disabled, suspend-on-idle cannot be faulted for my overall trouble.

EDIT again: Nope, since second reboot occasional drops have come back. The random interval seems to have gotten longer; that could be attributed to the simplification of pulseaudio (no hardware detection, no auto-configuration, two less audio devices to consider).

Last edited by quequotion (2016-01-09 10:36:32)

Offline

#22 2016-01-08 17:59:24

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [WORKAROUND] Surround sound output intermittent.

It has nothing to do with my CPU (it's an Haswell i5 anyway), when I use ALSA directly there is no such delay. It has something to do with pulse coz I see the logs get flooded too (not to mention that it core dumped when it's not wrapped by the non-sense rate plugin).

Btw I just tried something interesting, apparently the a52 plugin itself has a bug on channel mapping too. So this is what've done:
https://gist.github.com/tomty89/a4390688a6094a75f277

This shows a comparison between the wav file written directly from the speaker-test directly (st.wav) and the ac3 file I encode with a manual ffmpeg command (ff.ac3). As you can see, everything is preserved but the LFE is made LFE:
https://ptpb.pw/5XJR.png
And this shows a comparision between the the ac3 file from ffmpeg and the one written from the output of a52 plugin. If you compare carefully, you can see that Front Center and Rear Left is swapped, LFE and Rear Right is also swapped:
https://ptpb.pw/YaKg.png

Here is a pair of ac3 samples that shows the problem clearly (a lady will be telling the channels one by one):
Original: https://ptpb.pw/9XdC.ac3
ALSA a52 plugin re-encoded from mpv output: https://ptpb.pw/SQ_7.ac3

EDIT:

quequotion wrote:

LFE channel was picking up too much speech; making everyone barry white.

The bug I just found is probably the reason...

EDIT 2:

quequotion wrote:

in particular both alsa and pulseaudio should use the same speex/soxr profile, alternate and default rates must be the same

This does not make sense. ALSA should not be doing any resampling anymore (hence plug/rate plugin shouldn't be needed) because that should be the job of PulseAudio only. From what I can see in the log it assumes it supports only 48kHz anyway, so as long as you do not use "rate 44100" in the a52 plugin (not the rate wrapper, or well, MAYBE that too, if you use it), pulse should take care of all the resampling needed.

Last edited by tom.ty89 (2016-01-08 18:08:47)

Offline

#23 2016-01-09 09:16:41

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

tom.ty89 wrote:

apparently the a52 plugin itself has a bug on channel mapping too. So this is what've done:
https://gist.github.com/tomty89/a4390688a6094a75f277

This shows a comparison between the wav file written directly from the speaker-test directly (st.wav) and the ac3 file I encode with a manual ffmpeg command (ff.ac3). As you can see, everything is preserved but the LFE is made LFE:
https://ptpb.pw/5XJR.png
And this shows a comparision between the the ac3 file from ffmpeg and the one written from the output of a52 plugin. If you compare carefully, you can see that Front Center and Rear Left is swapped, LFE and Rear Right is also swapped:
https://ptpb.pw/YaKg.png

I am not experiencing this bug. My channels are as distinct as I expect them to be and discriminate in the proper order (both speaker-test and gnome's speaker test are fully distinct on all six channels). I believe the problems you are experiencing may be because of the lack of configuration; you might improve your situation by specifying a channel layout for pulseaudio manually (not required with the rate plugin)

quequotion wrote:

LFE channel was picking up too much speech; making everyone barry white.

The bug I just found is probably the reason..

I'lll look into it; I was thinking it was more along the lines of too much mid-tone sent to the subwofer (not all audio sources being equal, upmixed stereo and poorly mastered surround sound tend to send voice through center and front speakers). I use qpaeq to spatialize* upmixed stereo, etc by equalizing each channel to further discriminate the output (mute all high frequencies on the LFE channel, optimize for voice (-low, -high, +mid) on the center channel, optimize for SFX on the rear channels (+low, +high, -mid), and reduce bass on the front speakers (leave it to the subwoofer). In addition the preamp is useful for balancing and panning the output: I boost the rear, cener, and lfe channels and cut the front speakers quite low; most of the surround sound sources I've come across are pretty loud on the front channels.

*I'm probably using the wrong word here; I have done nothing to change how the upmixed stereo is routed to the speakers. The equalization is only giving upmixed stereo the illusion of channel discrimination by distinguishing each channel's output.

quequotion wrote:

in particular both alsa and pulseaudio should use the same speex/soxr profile, alternate and default rates must be the same

This does not make sense. ALSA should not be doing any resampling anymore (hence plug/rate plugin shouldn't be needed) because that should be the job of PulseAudio only. From what I can see in the log it assumes it supports only 48kHz anyway, so as long as you do not use "rate 44100" in the a52 plugin (not the rate wrapper, or well, MAYBE that too, if you use it), pulse should take care of all the resampling needed.

Oh yeah, this is a stupid thing to have to do---but you do have to do it. The frequency for the rate plugin, pulseaudio's default rate, and its alternate rate must be the same: otherwise pulseaudio will eventually attempt to change the bitrate, crashing the a52 plugin. Remember how I said I don't want to get into the details?

The point of setting alsa and pulseaudio's resamplers to the same one is to be absolutely certain that no cpu is being wasted resampling twice. If you enable the FFT equalizer on the surround sound output the necessity of this becomes more apparent. Also, you may have noticed my custom settings for default-fragments and default-fragment-size-msec; these were calculated according to the suggested method--it is important to set these with consideration for resampling six channels: default or mistaken settings cause heavy cpu usage, skipping, popping, module unloads and daemon crashes.

Last edited by quequotion (2016-01-09 16:53:55)

Offline

#24 2016-01-09 18:10:32

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [WORKAROUND] Surround sound output intermittent.

Interestingly, I can NEITHER make mpv output 6ch to ALSA pulse plugin or make mplayer output 6ch directly to pulse, while I CAN do the vice versa. I wonder if it's just coincidence or it actually has something to do with the channel order conflict.

EDIT: It's just an irrelevant bug (https://trac.mplayerhq.hu/ticket/2241) in current mplayer and mpv needs ":ignore-chmap" and "--audio-channels="5.1(alsa)" for "-ao alsa:device=[pulse]"

Last edited by tom.ty89 (2016-01-14 13:23:21)

Offline

#25 2016-01-09 18:13:02

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 814
Website

Re: [WORKAROUND] Surround sound output intermittent.

New theory: it could be module-switch-on-port-available misfiring.

Found this suspicious line from pulseaudio -vvv:

[pulseaudio] module-switch-on-port-available.c: Trying to switch to port analog-output-headphones

Headphones are not connected. I see in pavucontrol that "(unplugged)" constantly flickers at the end of the selected (5.1) profile now.

Too bad if this is the problem. This module is required to get expected behavior from bluetooth headphones (on connect, speakers should cut out, audio should redirect to headphones). Not that it really works either; most of the time I have to redirect streams with pavucontrol anyway.

Edit: Looks like this is it; 24hrs without an unload.

What could be triggering module-switch-on-port-available like that?

Last edited by quequotion (2016-01-10 04:38:41)

Offline

Board footer

Powered by FluxBB