openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.58k forks source link

[pulseaudio] sink volume item state pemanently resets to 0 #1953

Closed bondarmih closed 6 years ago

bondarmih commented 7 years ago

My pulseaudio server configured with number of virtual sinks for multiroom routing. Pulseaudio thing is configured in PaperUI. It is possible to change any sink volume with REST interface or in HABPanel widget, and Pulseaudio server respectively changes it's sink state. But after some delay (15-30 sec) item state resets to 0 itself, at than Pulseaudio sink volume stays invariable. As a result, all volume widgets displays 0 instead of actual values.

2017-02-24 23:47:25.603 [ItemCommandEvent ] - Item 'S3_combined_Volume' received command 83 2017-02-24 23:47:25.607 [ItemStateChangedEvent ] - S3_combined_Volume changed from 0 to 83 2017-02-24 23:47:46.373 [ItemStateChangedEvent ] - S3_combined_Volume changed from 83 to 0

bondarmih commented 7 years ago

My sinks are single-channel. But pattern matcher requires a stereo sink

peuter commented 7 years ago

Can you provide the output of the pactl list sinks command for the volume entry for a single channel sink. e,g, for stereo channel sinks it looks like this:

Volume: front-left: 52429 /  80% / -5,81 dB,   front-right: 52429 /  80% / -5,81 dB
            balance 0,00
bondarmih commented 7 years ago

In my case Volume entry has no named channels.

pactl list sinks output:

Sink #1
    State: SUSPENDED
    Name: alsa_output.0.analog-surround-51
    Description: SB Audigy Analog Surround 5.1
    Driver: module-alsa-card.c
    Sample Specification: s16le 6ch 48000Hz
    Channel Map: front-left,front-right,rear-left,rear-right,front-center,lfe
    Owner Module: 1
    Mute: no
    Volume: 0: 100% 1: 100% 2: 100% 3: 100% 4: 100% 5: 100%
            0: 0,00 dB 1: 0,00 dB 2: 0,00 dB 3: 0,00 dB 4: 0,00 dB 5: 0,00 dB
            balance 0,00
    Base Volume: 100%
                 0,00 dB
    Monitor Source: alsa_output.0.analog-surround-51.monitor
    Latency: 0 usec, configured 0 usec
    Flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
    Properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "ADC Capture/Standard PCM Playback"
        alsa.id = "emu10k1"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "0"
        alsa.card_name = "SB Audigy 1 [SB0092]"
        alsa.long_card_name = "SB Audigy 1 [SB0092] (rev.3, serial:0x531102) at 0xd000, irq 18"
        alsa.driver_name = "snd_emu10k1"
        device.bus_path = "pci-0000:04:02.0"
        sysfs.path = "/devices/pci0000:00/0000:00:1e.0/0000:04:02.0/sound/card0"
        device.bus = "pci"
        device.vendor.id = "1102"
        device.vendor.name = "Creative Labs"
        device.product.name = "SB Audigy"
        device.string = "surround51:0"
        device.buffering.buffer_size = "46080"
        device.buffering.fragment_size = "5760"
        device.access_mode = "serial"
        device.profile.name = "analog-surround-51"
        device.profile.description = "Analog Surround 5.1"
        device.description = "SB Audigy Analog Surround 5.1"
        alsa.mixer_name = "SigmaTel STAC9721,23"
        alsa.components = "AC97a:83847609"
        device.icon_name = "audio-card-pci"
    Ports:
        analog-output;output-amplifier-on: Analog Output / Amplifier (priority: 9910)
        analog-output;output-amplifier-off: Analog Output / No Amplifier (priority: 9900)
    Active Port: analog-output;output-amplifier-on
    Formats:
        pcm

Sink #2
    State: SUSPENDED
    Name: s1_room1
    Description: s1_room1
    Driver: module-remap-sink.c
    Sample Specification: s16le 1ch 48000Hz
    Channel Map: mono
    Owner Module: 2
    Mute: no
    Volume: 0: 100%
            0: 0,00 dB
            balance 0,00
    Base Volume: 100%
                 0,00 dB
    Monitor Source: s1_room1.monitor
    Latency: 0 usec, configured 0 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.master_device = "alsa_output.0.analog-surround-51"
        device.class = "filter"
        device.description = "s1_room1"
        device.icon_name = "audio-card"
    Formats:
        pcm

system.pa: load-module module-remap-sink sink_name=s1_room1 master=alsa_output.0.analog-surround-51 channels=1 master_channel_map=front-left channel_map=mono remix=no sink_properties=device.description="s1_room1"

pactl info output: Server String: /var/run/pulse/native Library Protocol Version: 26 Server Protocol Version: 26 Is Local: yes Client Index: 37938 Tile Size: 65472 User Name: pulse Host Name: bhome01 Server Name: pulseaudio Server Version: 1.1 Default Sample Specification: s16le 1ch 44100Hz Default Channel Map: mono Default Sink: alsa_output.0.analog-surround-51 Default Source: alsa_output.0.analog-surround-51.monitor Cookie: 222d:aac7 Pulseaudio version is 1.1, latest in Ubuntu 12.04.1 repo. Should I update it?

My previous installation of Openhab 1.7.1 works well with this Pulseaudio instance.

peuter commented 7 years ago

I don't know if an update can help but as Pulseaudio 1.1 is rather old, it is worth a try.

jimduchek commented 7 years ago

I am having these exact same symptoms, although I have found the problem and I'm afraid it will not solve bondarmih's issue, but it is a simple fix for mine. The regex does not support a decimal point in the dB reading (i.e. in this locale, the US and I believe the UK as well?) it shows as 1.23 dB, not 1,23 dB. Changing the two dB bits from ([0-9\-, dB]+) to ([0-9\-., dB]+) fixes this.

peuter commented 7 years ago

@jimduchek Can you create a pull request with that fix?

jimduchek commented 7 years ago

@peuter Sure, it'll take me a bit though. I have been meaning to get a build environment setup anyway... sigh sometimes I do miss the days of './configure ; make ; make install' :)

jimduchek commented 7 years ago

2297

peuter commented 6 years ago

As #2297 has been merged I guess we can close this issue?