You are not logged in.

#1 2017-06-22 12:20:30

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,481

[SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

Hi all,
As i understood, the config option alternate-sample-rate should make pulseaudio switch to a different sample-rate when there is only a stream connected to the output that matches that value.
I prefer to keep the default to 44100 to hear music and just switch to 48000 when i watch movies.
So, to test, i killed everything using pulseaudio and tried to watch a movie via mpv, but the sample-rate did not switch.

This is what happens when i'm watching a movie with source audio sampled at 48Khz

1# mpv mediafile.mkv -ao pulse
[..]
AO: [pulse] 48000Hz stereo 2ch float
[..]

2# grep rate /etc/pulse/daemon.conf 
default-sample-rate = 44100
alternate-sample-rate = 48000

2# cat /proc/asound/card0/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1) #<--------------------------------
period_size: 44100
buffer_size: 88200


2# pacmd list-sink-inputs|grep media
                media.name = "Simultaneous output on Built-in Audio Analog Stereo"
                media.role = "filter"
                module-stream-restore.id = "sink-input-by-media-role:filter"
                media.icon_name = "mpv"
                media.name = "mediafile.mkv - mpv"

2# killall mpv ; pacmd list-sink-inputs
mpv: no process found
0 sink input(s) available.

Switching the main sample-rate to 48000 makes everything work at 48khz, so switching is possible.

Anybody knows why this happens? Thanks


-edit-

When nothing is playing, i see the following sources:

koko@Gozer# pacmd list-sources
3 source(s) available.
    index: 0
        name: <alsa_output.pci-0000_00_1b.0.analog-stereo.monitor>
        driver: <module-alsa-card.c>
        flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: SUSPENDED
        suspend cause: IDLE 
        priority: 1950
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 0,00 ms
        max rewind: 0 KiB
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        configured latency: 0,00 ms; range is 0,50 .. 2000,00 ms
        monitor_of: 0
        card: 1 <alsa_card.pci-0000_00_1b.0>
        module: 7
        properties:
                device.description = "Monitor of Built-in Audio Analog Stereo"
                device.class = "monitor"
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.long_card_name = "HDA Intel PCH at 0xf7300000 irq 28"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:1b.0"
                sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "8ca0"
                device.product.name = "9 Series Chipset Family HD Audio Controller"
                device.form_factor = "internal"
                device.string = "0"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
    index: 1
        name: <alsa_input.pci-0000_00_1b.0.analog-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: SUSPENDED
        suspend cause: IDLE 
        priority: 9959
        volume: front-left: 65540 / 100% / 0,00 dB,   front-right: 65540 / 100% / 0,00 dB
                balance 0,00
        base volume: 6554 /  10% / -60,00 dB
        volume steps: 65537
        muted: no
        current latency: 0,00 ms
        max rewind: 0 KiB
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        configured latency: 0,00 ms; range is 0,50 .. 2000,00 ms
        card: 1 <alsa_card.pci-0000_00_1b.0>
        module: 7
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "ALC887-VD Analog"
                alsa.id = "ALC887-VD Analog"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.long_card_name = "HDA Intel PCH at 0xf7300000 irq 28"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:1b.0"
                sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "8ca0"
                device.product.name = "9 Series Chipset Family HD Audio Controller"
                device.form_factor = "internal"
                device.string = "front:0"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Built-in Audio Analog Stereo"
                alsa.mixer_name = "Realtek ALC887-VD"
                alsa.components = "HDA:10ec0887,10438616,00100302"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-input-microphone"
                analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: yes)
                        properties:
                                device.icon_name = "audio-input-microphone"
                analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: no)
                        properties:

        active port: <analog-input-rear-mic>
  * index: 2
        name: <combined.monitor>
        driver: <module-combine-sink.c>
        flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: SUSPENDED
        suspend cause: IDLE 
        priority: 1000
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 0,00 ms
        max rewind: 0 KiB
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        configured latency: 0,00 ms; range is 0,50 .. 200,00 ms
        monitor_of: 1
        module: 12
        properties:
                device.description = "Monitor Source of Simultaneous output to Built-in Audio Analog Stereo"
                device.class = "monitor"
                device.icon_name = "audio-input-microphone"

Maybe something is interfering? I don't think so, since they are all in "SUSPENDED" state, and "SUSPENDED" is a condition that should allow pulse to switch sample-rare...

http://www.mail-archive.com/pulseaudio-discuss@lists.freedesktop.org/msg04950.html wrote:

Switching  between default and alternate values is
enabled only when the sinks/sources are suspended.


Anybody understand why this happens? Thanks

Last edited by kokoko3k (2017-06-22 13:32:55)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#2 2017-06-22 12:29:35

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

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

What happens if you do not use a combined sink input, for the sink that mpv is playing to, but explicitly play to a detected, single card sink? There's a good chance that this configuration leads to the lowest common denominator being used. Full outputs of

pacmd list-sinks
pacmd list-sink-input

might also help.

Edit: Just saw your edit, but yeah you want sinks not sources, sources are microphones or loopbacks/monitors of sinks

Last edited by V1del (2017-06-22 12:31:08)

Offline

#3 2017-06-22 12:34:32

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,481

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

I just moved to pulseaudio, so I don't know how to make mpv outputs to a "detected, single card sink"

(edit: seems that since mpv 0.23 the audio driver suboptions are gone, and i cannot find an option to specify the pulse sync anymore: Error parsing option pulse-sink (option not found))

Here's the output you requested:

no file playing:

koko@Gozer# pacmd list-sinks
2 sink(s) available.
    index: 0
        name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: SUSPENDED
        suspend cause: IDLE 
        priority: 9959
        volume: front-left: 30817 /  47% / -19,66 dB,   front-right: 30817 /  47% / -19,66 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 0,00 ms
        max request: 0 KiB
        max rewind: 0 KiB
        monitor source: 0
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        configured latency: 0,00 ms; range is 0,50 .. 2000,00 ms
        card: 1 <alsa_card.pci-0000_00_1b.0>
        module: 7
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "ALC887-VD Analog"
                alsa.id = "ALC887-VD Analog"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.long_card_name = "HDA Intel PCH at 0xf7300000 irq 28"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:1b.0"
                sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "8ca0"
                device.product.name = "9 Series Chipset Family HD Audio Controller"
                device.form_factor = "internal"
                device.string = "front:0"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Built-in Audio Analog Stereo"
                alsa.mixer_name = "Realtek ALC887-VD"
                alsa.components = "HDA:10ec0887,10438616,00100302"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: yes)
                        properties:

                analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-headphones"
        active port: <analog-output-lineout>
  * index: 1
        name: <combined>
        driver: <module-combine-sink.c>
        flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: SUSPENDED
        suspend cause: IDLE 
        priority: 1000
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 0,00 ms
        max request: 34 KiB
        max rewind: 0 KiB
        monitor source: 2
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        configured latency: 0,00 ms; range is 0,50 .. 200,00 ms
        module: 12
        properties:
                device.class = "filter"
                device.description = "Simultaneous output to Built-in Audio Analog Stereo"
                device.icon_name = "audio-card"
  
koko@Gozer# pacmd list-sink-inputs
0 sink input(s) available.

48khz file playing:

koko@Gozer# pacmd list-sink-inputs
2 sink input(s) available.
    index: 4
        driver: <module-combine-sink.c>
        flags: VARIABLE_RATE DONT_MOVE NO_CREATE_SUSPEND 
        state: RUNNING
        sink: 0 <alsa_output.pci-0000_00_1b.0.analog-stereo>
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        muted: no
        current latency: 0,00 ms
        requested latency: 85,00 ms
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        resample method: trivial
        module: 12
        properties:
                media.name = "Simultaneous output on Built-in Audio Analog Stereo"
                media.role = "filter"
                module-stream-restore.id = "sink-input-by-media-role:filter"
    index: 5
        driver: <protocol-native.c>
        flags: 
        state: RUNNING
        sink: 1 <combined>
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        muted: no
        current latency: 125,00 ms
        requested latency: 85,00 ms
        sample spec: float32le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        resample method: speex-float-1
        module: 9
        client: 17 <mpv Media Player>
        properties:
                media.icon_name = "mpv"
                media.name = "mediafile.mkv - mpv"
                application.name = "mpv Media Player"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "32"
                application.process.id = "30901"
                application.process.user = "koko"
                application.process.host = "Gozer"
                application.process.binary = "mpv"
                application.language = "C"
                window.x11.display = ":0"
                application.process.machine_id = "a761fac3a0a97b32a4a0646949abf276"
                application.process.session_id = "c3"
                application.icon_name = "mpv"
                module-stream-restore.id = "sink-input-by-application-name:mpv Media Player"

Last edited by kokoko3k (2017-06-22 12:45:28)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#4 2017-06-22 12:52:51

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

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

Well a combined sink was configured somewhere (/etc/pulse/default.pa or ~/.config/pulse/default.pa or some graphical mixer application or paprefs or similar) and it looks like mpv creates an unmovable stream... Try to reset your homedir conf

rm -r /tmp/pulse* ~/.pulse* ~/.config/pulse
systemctl --user restart pulseaudio
pacmd set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo

and retry repost the other two outputs if there's still uncertainity somewhere (you might also want to post your full /etc/pulse/default.pa)

Edit: Oh wait, false alarm in that regard, simply run

pacmd move-sink-input 5 alsa_output.pci-0000_00_1b.0.analog-stereo #Verify the correct sink-input index with the sink-inputs command

Last edited by V1del (2017-06-22 13:57:14)

Offline

#5 2017-06-22 13:19:15

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,481

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

koko@Gozer# sudo rm -rv /tmp/pulse* ~/.pulse* ~/.config/pulse
removed directory '/tmp/pulse-pvGuSwCNcv6J'
removed '/home/koko/.pulse-cookie'
removed '/home/koko/.config/pulse/a761fac3a0a97b32a4a0646949abf276-default-sink'
removed '/home/koko/.config/pulse/a761fac3a0a97b32a4a0646949abf276-default-source'
removed '/home/koko/.config/pulse/a761fac3a0a97b32a4a0646949abf276-stream-volumes.tdb'
removed '/home/koko/.config/pulse/a761fac3a0a97b32a4a0646949abf276-runtime'
removed '/home/koko/.config/pulse/a761fac3a0a97b32a4a0646949abf276-device-volumes.tdb'
removed '/home/koko/.config/pulse/cookie'
removed '/home/koko/.config/pulse/a761fac3a0a97b32a4a0646949abf276-card-database.tdb'
removed directory '/home/koko/.config/pulse'
koko@Gozer# sudo killall pulseaudio
koko@Gozer# sudo killall pulseaudio
pulseaudio: no process found
# sudo systemctl restart pulseaudio
Failed to restart pulseaudio.service: Unit pulseaudio.service not found.
koko@Gozer# pulseaudio --start
#(ok this time)

It works, thanks.
The problem was that combined sink then (?)
I've a backup of the removed files, and indeed i see the following:

#cd /mnt/disco2/flyback/20170622_000232.backup/home/koko/.config/pulse
root@Gozer# grep combined *
a761fac3a0a97b32a4a0646949abf276-default-sink:combined
a761fac3a0a97b32a4a0646949abf276-default-source:combined.monitor
Binary file a761fac3a0a97b32a4a0646949abf276-device-volumes.tdb matches
grep: a761fac3a0a97b32a4a0646949abf276-runtime: No such file or directory
Binary file a761fac3a0a97b32a4a0646949abf276-stream-volumes.tdb matches

Still, i cannot find any reference to that "combined" in system wide config files.
in journalctl there is something:

giu 22 15:05:10 Gozer pulseaudio[9188]: We will now load module-combine-sink. Please make sure to remove module-combine from your configuration.
giu 22 15:05:10 Gozer pulseaudio[9188]: module-combine is deprecated: Please use module-combine-sink instead of module-combine!

But this come-up empty!

root@Gozer# grep -ri combine /etc/pulse/

Maybe something manually loading that module (?) or i just set it as default in the past and forgotten?

-EDIT-
Just read you edit after posting.
All seems to work now, but i'd like to understand why it does not before, as it will likely silently re-happen...

As i said, i'm a totally noob on pulseaudio, is that "module-combined-sink" supposed to stay there?

Last edited by kokoko3k (2017-06-22 13:24:28)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#6 2017-06-22 13:30:01

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

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

Oh what commands am I typing, pulseaudio is a systemd user service, so for a restart you would use

systemctl --user restart pulseaudio #As your user, not with sudo

but yeah, the combined module can be loaded during runtime, and many GUIs or other pulseaudio helper applications have a checkbox that you can tick to create a combined sink (and likely a corresponding entry in your local config files would be created by that, which is why I asked you to start from a clean slate by removing those), this doesn't have much use on a single card system obviously.

If you are new to pulseaudio it might also be helpful to install pavucontrol it will relatively intuitively show you these relations and which applications are playing to which sink and will easily allow you to move them around between devices.

However as usual, as the original problem has been solved, don't forget to mark as solved

Edit: (we are too active on this tongue ) No with the removal of the local config, and given that you don't run anything that recreates or readds the combined sink, it shouldn't be present anymore. Usual candidates for the creation of these are paprefs, the GUI mixers of the big DE's all provide you with such a checkbox option as well afaik. Which audio mixer do you use normally?

Last edited by V1del (2017-06-22 13:34:06)

Offline

#7 2017-06-22 13:31:59

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,481

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

Yes Yes, marking as solved just now.
And found the culprit too, it is the plasma "audio volume settings" applet, there is an option that creates that sink.
"Add virtual output device for simultanous output on all local sound cards"

Unchecked, happy, thanks!

Last edited by kokoko3k (2017-06-22 13:33:24)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#8 2017-06-22 13:38:57

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

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

Sweet, an additional tidbit since I now know you are using plasma-pa: To move the streams of applications between sinks, you can go to the applications tab in the volume applet and drag and drop the application to the desired sink. (And pavucontrol isn't as necessary in that case the plasma-pa settings dialog provides pretty much the same overview/featureset)

Last edited by V1del (2017-06-22 13:42:39)

Offline

#9 2017-06-22 13:52:13

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,481

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

an additional tidbit since I now know you are using plasma-pa

Sorry... you know, it is not easy to provide the required informations when you don't know what is required  smile

drag and drop the application to the desired sink

Great, even it is completely counterintuitive, since sinks are shown in another "tab"


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#10 2017-06-22 13:56:30

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

Re: [SOLVED] why isn't pulseaudio switching to "alternate-sample-rate" ?

Yeah that's a bit hidden, but imo a clean solution as opposed to having the fully qualified sinkname mentioned everywhere (the actual settings dialog has more space and uses dropdowns to denote this information).

Offline

Board footer

Powered by FluxBB