balena-io-experimental / balena-sound

Build a single or multi-room streamer for an existing audio device using a Raspberry Pi! Supports Bluetooth, Airplay and Spotify Connect
https://balena.io/blog/turn-your-old-speakers-or-hi-fi-into-bluetooth-receivers-using-only-a-raspberry-pi/
MIT License
2.42k stars 430 forks source link

Pi 4B not working with Hifiberry DAC2 HD #357

Closed richardpringle closed 3 years ago

richardpringle commented 3 years ago

I had everything working beautifully before plugging in the DAC.

I tried some things from #296 to no avail. The aux output isn't working either anymore.

Here are the logs from the audio container:

23.11.20 22:47:57 (-0500)  audio  
23.11.20 22:47:57 (-0500)  audio  --- Audio ---
23.11.20 22:47:57 (-0500)  audio  Starting audio service with settings:
23.11.20 22:47:57 (-0500)  audio  - Pulse log level: NOTICE
23.11.20 22:47:57 (-0500)  audio  - Default output: DAC
23.11.20 22:47:57 (-0500)  audio  
23.11.20 22:47:57 (-0500)  audio  Detected audio cards:
23.11.20 22:47:57 (-0500)  audio  0 Headphones bcm2835_headphonbcm2835Headphones-bcm2835Headphones
23.11.20 22:47:57 (-0500)  audio  1 sndrpihifiberry HifiberryDacplu-snd_rpi_hifiberry_dacplushd
23.11.20 22:47:57 (-0500)  audio  
23.11.20 22:47:57 (-0500)  audio  
23.11.20 22:48:26 (-0500)  audio  Setting audio routing rules. Note that this can be changed after startup.
23.11.20 22:48:26 (-0500)  audio  Routing 'balena-sound.input' to 'balena-sound.output'.
23.11.20 22:48:26 (-0500)  audio  Routing 'balena-sound.output' to 'alsa_output.dac.stereo-fallback'.
23.11.20 22:48:26 (-0500)  audio  W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
23.11.20 22:48:27 (-0500)  audio  E: [pulseaudio] module-loopback.c: No such sink.
23.11.20 22:48:27 (-0500)  audio  E: [pulseaudio] module.c: Failed to load module "module-loopback" (argument: "source="balena-sound.output.monitor" sink="alsa_output.dac.stereo-fallback""): initialization failed.
23.11.20 22:48:27 (-0500)  audio  E: [pulseaudio] main.c: Sink alsa_output.dac.stereo-fallback does not exist.
23.11.20 22:48:27 (-0500)  audio  W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
23.11.20 22:48:27 (-0500)  audio  W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

The audio jack doesn't seem to work either.

The output from running pactl list sinks in the audio container is as follows:

root@bec19b8c0a64:/usr/src# pactl list sinks
Sink #0
        State: SUSPENDED
        Name: alsa_output.bcm2835.stereo-fallback
        Description: Built-in Audio Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 6
        Mute: no
        Volume: front-left: 56210 /  86% / -4.00 dB,   front-right: 56210 /  86% / -4.00 dB
                balance 0.00
        Base Volume: 56210 /  86% / -4.00 dB
        Monitor Source: alsa_output.bcm2835.stereo-fallback.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_MUTE_CTRL 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 = "bcm2835 Headphones"
                alsa.id = "bcm2835 Headphones"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "bcm2835 Headphones"
                alsa.long_card_name = "bcm2835 Headphones"
                alsa.driver_name = "snd_bcm2835"
                device.bus_path = "/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0"
                sysfs.path = "/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0"
                device.form_factor = "internal"
                device.string = "hw:0"
                device.buffering.buffer_size = "131072"
                device.buffering.fragment_size = "131072"
                device.access_mode = "mmap+timer"
                device.profile.name = "stereo-fallback"
                device.profile.description = "Stereo"
                device.description = "Built-in Audio Stereo"
                alsa.mixer_name = "Broadcom Mixer"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Ports:
                analog-output-headphones: Headphones (priority: 9900)
        Active Port: analog-output-headphones
        Formats:
                pcm

Sink #1
        State: SUSPENDED
        Name: alsa_output.1.stereo-fallback
        Description: Built-in Audio Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 7
        Mute: no
        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
        Monitor Source: alsa_output.1.stereo-fallback.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "HiFiBerry DAC+ HD HiFi pcm179x-hifi-0"
                alsa.id = "HiFiBerry DAC+ HD HiFi pcm179x-hifi-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "1"
                alsa.card_name = "snd_rpi_hifiberry_dacplushd"
                alsa.long_card_name = "snd_rpi_hifiberry_dacplushd"
                alsa.driver_name = "snd_soc_hifiberry_dacplushd"
                device.bus_path = "/devices/platform/soc/soc:sound/sound/card1"
                sysfs.path = "/devices/platform/soc/soc:sound/sound/card1"
                device.form_factor = "internal"
                device.string = "hw:1"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "stereo-fallback"
                device.profile.description = "Stereo"
                device.description = "Built-in Audio Stereo"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Ports:
                analog-output: Analog Output (priority: 9900)
        Active Port: analog-output
        Formats:
                pcm

Sink #2
        State: IDLE
        Name: balena-sound.input
        Description: Null Output
        Driver: module-null-sink.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 23
        Mute: no
        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
        Monitor Source: balena-sound.input.monitor
        Latency: 58704 usec, configured 66666 usec
        Flags: DECIBEL_VOLUME LATENCY 
        Properties:
                device.description = "Null Output"
                device.class = "abstract"
                device.icon_name = "audio-card"
        Formats:
                pcm

Sink #3
        State: RUNNING
        Name: balena-sound.output
        Description: Null Output
        Driver: module-null-sink.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 24
        Mute: no
        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
        Monitor Source: balena-sound.output.monitor
        Latency: 58788 usec, configured 66666 usec
        Flags: DECIBEL_VOLUME LATENCY 
        Properties:
                device.description = "Null Output"
                device.class = "abstract"
                device.icon_name = "audio-card"
        Formats:
                pcm

Sink #4
        State: SUSPENDED
        Name: snapcast
        Description: Unix FIFO sink /var/cache/snapcast/snapfifo
        Driver: module-pipe-sink.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 25
        Mute: no
        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
        Monitor Source: snapcast.monitor
        Latency: 0 usec, configured 0 usec
        Flags: DECIBEL_VOLUME LATENCY 
        Properties:
                device.string = "/var/cache/snapcast/snapfifo"
                device.description = "Unix FIFO sink /var/cache/snapcast/snapfifo"
                device.icon_name = "audio-card"
        Formats:
                pcm

... so the device is there as Sink #1 (which is different than in #296 where it was Sink #0). So it's being detected at alsa_output.1.stereo-fallback.monitor instead of alsa_output.dac.stereo-fallback.monitor.

Output from http://<device_ip>:3000/support

{
   "config" : {
      "device" : {
         "type" : "raspberrypi4-64",
         "ip" : "192.168.1.15"
      },
      "audioBlock" : {
         "_events" : {},
         "name" : "BalenaAudio",
         "connected" : true,
         "address" : "tcp:192.168.1.15:4317",
         "chunks" : [],
         "requests" : [],
         "lastRequestId" : 26,
         "socket" : {
            "_pendingEncoding" : "",
            "connecting" : false,
            "_host" : null,
            "_server" : null,
            "_writableState" : {
               "highWaterMark" : 16384,
               "writing" : false,
               "bufferedRequestCount" : 0,
               "errorEmitted" : false,
               "sync" : false,
               "autoDestroy" : false,
               "needDrain" : false,
               "emitClose" : false,
               "lastBufferedRequest" : null,
               "ended" : false,
               "pendingcb" : 0,
               "writecb" : null,
               "objectMode" : false,
               "finalCalled" : false,
               "destroyed" : false,
               "bufferProcessing" : false,
               "corked" : 0,
               "bufferedRequest" : null,
               "writelen" : 0,
               "length" : 0,
               "corkedRequestsFree" : {
                  "entry" : null,
                  "next" : null
               },
               "decodeStrings" : false,
               "defaultEncoding" : "utf8",
               "finished" : false,
               "ending" : false,
               "prefinished" : false,
               "afterWriteTickInfo" : null
            },
            "allowHalfOpen" : false,
            "writable" : true,
            "_hadError" : false,
            "_pendingData" : null,
            "_readableState" : {
               "multiAwaitDrain" : false,
               "awaitDrainWriters" : null,
               "buffer" : {
                  "tail" : null,
                  "length" : 0,
                  "head" : null
               },
               "length" : 0,
               "encoding" : null,
               "resumeScheduled" : false,
               "readableListening" : true,
               "defaultEncoding" : "utf8",
               "needReadable" : true,
               "highWaterMark" : 16384,
               "readingMore" : false,
               "sync" : false,
               "reading" : true,
               "autoDestroy" : false,
               "emitClose" : false,
               "endEmitted" : false,
               "emittedReadable" : false,
               "flowing" : false,
               "pipesCount" : 0,
               "decoder" : null,
               "ended" : false,
               "objectMode" : false,
               "destroyed" : false,
               "pipes" : null
            },
            "_parent" : null,
            "_eventsCount" : 4,
            "server" : null,
            "readable" : true,
            "_events" : {},
            "_sockname" : null
         },
         "subToEvents" : true,
         "_eventsCount" : 2,
         "pulseAddress" : {
            "port" : 4317,
            "host" : "192.168.1.15"
         },
         "defaultSink" : "balena-sound.input",
         "pulseCookie" : {
            "data" : [
               152,
               121,
               162,
               165,
               85,
               0,
               0,
               0,
               255,
               255,
               255,
               255,
               255,
               255,
               255,
               255,
               1,
               16,
               162,
               165,
               85,
               0,
               0,
               0,
               255,
               255,
               255,
               255,
               54,
               9,
               0,
               0,
               152,
               121,
               162,
               165,
               85,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               255,
               255,
               255,
               255,
               0,
               0,
               0,
               0,
               152,
               121,
               162,
               165,
               85,
               0,
               0,
               0,
               0,
               122,
               162,
               165,
               85,
               0,
               0,
               0,
               72,
               119,
               162,
               165,
               85,
               0,
               0,
               0,
               120,
               118,
               162,
               165,
               85,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               24,
               122,
               162,
               165,
               85,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               146,
               24,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               104,
               121,
               162,
               165,
               85,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               255,
               255,
               255,
               255,
               72,
               122,
               162,
               165,
               85,
               0,
               0,
               0,
               255,
               255,
               255,
               255,
               54,
               9,
               0,
               0,
               24,
               122,
               162,
               165,
               85,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               255,
               255,
               255,
               255,
               0,
               0,
               0,
               0,
               24,
               122,
               162,
               165,
               85,
               0,
               0,
               0,
               128,
               122,
               162,
               165,
               85,
               0,
               0,
               0,
               72,
               119,
               162,
               165,
               85,
               0,
               0,
               0,
               160,
               118,
               162,
               165,
               85,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               152,
               122,
               162,
               165,
               85,
               0,
               0,
               0,
               1,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               146,
               24,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0,
               0
            ],
            "type" : "Buffer"
         }
      },
      "mode" : "STANDALONE",
      "multiroom" : {
         "master" : "192.168.1.15",
         "forced" : false
      }
   },
   "volume" : 100,
   "sinks" : [
      {
         "formats" : "Headphones",
         "monitorSourceIndex" : 0,
         "cardIndex" : 0,
         "baseVolume" : 56210,
         "moduleIndex" : 6,
         "name" : "alsa_output.bcm2835.stereo-fallback",
         "sampleSpec" : {
            "rate" : 44100,
            "format" : 3,
            "channels" : 2
         },
         "channelVolumes" : {
            "channels" : 2,
            "volumes" : [
               56210,
               56210
            ]
         },
         "activePortName" : "analog-output-headphones",
         "index" : 0,
         "description" : "Built-in Audio Stereo",
         "driverName" : "module-alsa-card.c",
         "latency" : "0n",
         "monitorSourceName" : "alsa_output.bcm2835.stereo-fallback.monitor",
         "properties" : [
            [
               "alsa.resolution_bits",
               "16"
            ],
            [
               "device.api",
               "alsa"
            ],
            [
               "device.class",
               "sound"
            ],
            [
               "alsa.class",
               "generic"
            ],
            [
               "alsa.subclass",
               "generic-mix"
            ],
            [
               "alsa.name",
               "bcm2835 Headphones"
            ],
            [
               "alsa.id",
               "bcm2835 Headphones"
            ],
            [
               "alsa.subdevice",
               "0"
            ],
            [
               "alsa.subdevice_name",
               "subdevice #0"
            ],
            [
               "alsa.device",
               "0"
            ],
            [
               "alsa.card",
               "0"
            ],
            [
               "alsa.card_name",
               "bcm2835 Headphones"
            ],
            [
               "alsa.long_card_name",
               "bcm2835 Headphones"
            ],
            [
               "alsa.driver_name",
               "snd_bcm2835"
            ],
            [
               "device.bus_path",
               "/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0"
            ],
            [
               "sysfs.path",
               "/devices/platform/soc/fe00b840.mailbox/bcm2835_audio/sound/card0"
            ],
            [
               "device.form_factor",
               "internal"
            ],
            [
               "device.string",
               "hw:0"
            ],
            [
               "device.buffering.buffer_size",
               "131072"
            ],
            [
               "device.buffering.fragment_size",
               "131072"
            ],
            [
               "device.access_mode",
               "mmap+timer"
            ],
            [
               "device.profile.name",
               "stereo-fallback"
            ],
            [
               "device.profile.description",
               "Stereo"
            ],
            [
               "device.description",
               "Built-in Audio Stereo"
            ],
            [
               "alsa.mixer_name",
               "Broadcom Mixer"
            ],
            [
               "module-udev-detect.discovered",
               "1"
            ],
            [
               "device.icon_name",
               "audio-card"
            ]
         ],
         "ports" : 1,
         "state" : 2,
         "channelMap" : {
            "types" : [
               1,
               2
            ],
            "channels" : 2
         },
         "volumeSteps" : 65537,
         "flagsRaw" : 183,
         "isMuted" : false,
         "configLatency" : "0n"
      },
      {
         "sampleSpec" : [
            {
               "properties" : [],
               "encoding" : 1
            }
         ],
         "channelVolumes" : "Built-in Audio Stereo",
         "description" : "analog-output-headphones",
         "activePortName" : 2,
         "index" : 9900,
         "latency" : {
            "channels" : 2,
            "volumes" : [
               65536,
               65536
            ]
         },
         "driverName" : false,
         "properties" : "alsa_output.1.stereo-fallback.monitor",
         "monitorSourceName" : 7,
         "state" : 166,
         "ports" : 65536,
         "configLatency" : "0n",
         "volumeSteps" : [
            [
               "alsa.resolution_bits",
               "16"
            ],
            [
               "device.api",
               "alsa"
            ],
            [
               "device.class",
               "sound"
            ],
            [
               "alsa.class",
               "generic"
            ],
            [
               "alsa.subclass",
               "generic-mix"
            ],
            [
               "alsa.name",
               "HiFiBerry DAC+ HD HiFi pcm179x-hifi-0"
            ],
            [
               "alsa.id",
               "HiFiBerry DAC+ HD HiFi pcm179x-hifi-0"
            ],
            [
               "alsa.subdevice",
               "0"
            ],
            [
               "alsa.subdevice_name",
               "subdevice #0"
            ],
            [
               "alsa.device",
               "0"
            ],
            [
               "alsa.card",
               "1"
            ],
            [
               "alsa.card_name",
               "snd_rpi_hifiberry_dacplushd"
            ],
            [
               "alsa.long_card_name",
               "snd_rpi_hifiberry_dacplushd"
            ],
            [
               "alsa.driver_name",
               "snd_soc_hifiberry_dacplushd"
            ],
            [
               "device.bus_path",
               "/devices/platform/soc/soc:sound/sound/card1"
            ],
            [
               "sysfs.path",
               "/devices/platform/soc/soc:sound/sound/card1"
            ],
            [
               "device.form_factor",
               "internal"
            ],
            [
               "device.string",
               "hw:1"
            ],
            [
               "device.buffering.buffer_size",
               "352800"
            ],
            [
               "device.buffering.fragment_size",
               "176400"
            ],
            [
               "device.access_mode",
               "mmap+timer"
            ],
            [
               "device.profile.name",
               "stereo-fallback"
            ],
            [
               "device.profile.description",
               "Stereo"
            ],
            [
               "device.description",
               "Built-in Audio Stereo"
            ],
            [
               "module-udev-detect.discovered",
               "1"
            ],
            [
               "device.icon_name",
               "audio-card"
            ]
         ],
         "isMuted" : {
            "channels" : 2,
            "format" : 3,
            "rate" : 44100
         },
         "flagsRaw" : 1,
         "channelMap" : 1,
         "baseVolume" : "module-alsa-card.c",
         "moduleIndex" : "alsa_output.1.stereo-fallback",
         "monitorSourceIndex" : {
            "channels" : 2,
            "types" : [
               1,
               2
            ]
         },
         "formats" : 65537,
         "cardIndex" : "0n",
         "name" : 0
      },
      {
         "name" : 1,
         "monitorSourceIndex" : 2,
         "formats" : [
            [
               "device.description",
               "Null Output"
            ],
            [
               "device.class",
               "abstract"
            ],
            [
               "device.icon_name",
               "audio-card"
            ]
         ],
         "cardIndex" : "12406n",
         "baseVolume" : false,
         "moduleIndex" : 0,
         "monitorSourceName" : "balena-sound.input",
         "properties" : 23,
         "flagsRaw" : {
            "types" : [
               1,
               2
            ],
            "channels" : 2
         },
         "volumeSteps" : "balena-sound.input.monitor",
         "channelMap" : 9900,
         "isMuted" : [
            {
               "encoding" : 1,
               "properties" : []
            }
         ],
         "configLatency" : {
            "volumes" : [
               65536,
               65536
            ],
            "channels" : 2
         },
         "ports" : "module-null-sink.c",
         "state" : 2,
         "sampleSpec" : "Analog Output",
         "channelVolumes" : "analog-output",
         "driverName" : {
            "rate" : 44100,
            "format" : 3,
            "channels" : 2
         },
         "latency" : "Null Output",
         "index" : 1,
         "activePortName" : 162,
         "description" : "analog-output"
      },
      {
         "name" : 65536,
         "baseVolume" : false,
         "moduleIndex" : 0,
         "monitorSourceIndex" : 3,
         "formats" : [
            [
               "device.description",
               "Null Output"
            ],
            [
               "device.class",
               "abstract"
            ],
            [
               "device.icon_name",
               "audio-card"
            ]
         ],
         "cardIndex" : "12382n",
         "configLatency" : {
            "channels" : 2,
            "volumes" : [
               65536,
               65536
            ]
         },
         "volumeSteps" : "balena-sound.output.monitor",
         "channelMap" : 4294967295,
         "flagsRaw" : {
            "types" : [
               1,
               2
            ],
            "channels" : 2
         },
         "isMuted" : [
            {
               "encoding" : 1,
               "properties" : []
            }
         ],
         "state" : 3,
         "ports" : "module-null-sink.c",
         "properties" : 24,
         "monitorSourceName" : "balena-sound.output",
         "latency" : "Null Output",
         "driverName" : {
            "format" : 3,
            "rate" : 44100,
            "channels" : 2
         },
         "description" : 1,
         "index" : "66666n",
         "activePortName" : 162,
         "channelVolumes" : "",
         "sampleSpec" : 65537
      },
      {
         "monitorSourceName" : "snapcast",
         "properties" : 25,
         "ports" : "module-pipe-sink.c",
         "state" : 4,
         "channelMap" : 4294967295,
         "volumeSteps" : "snapcast.monitor",
         "flagsRaw" : {
            "types" : [
               1,
               2
            ],
            "channels" : 2
         },
         "isMuted" : [
            {
               "encoding" : 1,
               "properties" : []
            }
         ],
         "configLatency" : {
            "channels" : 2,
            "volumes" : [
               65536,
               65536
            ]
         },
         "channelVolumes" : "",
         "sampleSpec" : 65537,
         "index" : "66666n",
         "activePortName" : 34,
         "description" : 0,
         "driverName" : {
            "format" : 3,
            "rate" : 44100,
            "channels" : 2
         },
         "latency" : "Unix FIFO sink /var/cache/snapcast/snapfifo",
         "name" : 65536,
         "formats" : [
            [
               "device.string",
               "/var/cache/snapcast/snapfifo"
            ],
            [
               "device.description",
               "Unix FIFO sink /var/cache/snapcast/snapfifo"
            ],
            [
               "device.icon_name",
               "audio-card"
            ]
         ],
         "cardIndex" : "0n",
         "monitorSourceIndex" : 4,
         "baseVolume" : false,
         "moduleIndex" : 0
      }
   ],
   "constants" : {
      "port" : 3000,
      "mode" : "STANDALONE",
      "multiroom" : {
         "forced" : false
      },
      "coteDelay" : 5000,
      "debug" : false,
      "balenaDeviceType" : "raspberrypi4-64",
      "volume" : 100
   },
   "audio" : {
      "hostname" : "bec19b8c0a64",
      "user" : "root",
      "name" : "pulseaudio",
      "channelMap" : {
         "types" : [
            1,
            2
         ],
         "channels" : 2
      },
      "defaultSource" : "balena-sound.input.monitor",
      "version" : "13.0",
      "sampleSpec" : {
         "format" : 3,
         "rate" : 44100,
         "channels" : 2
      },
      "cookie" : 4095909592,
      "defaultSink" : "balena-sound.input"
   }
}

And running dmesg | grep hifi

root@bec19b8c0a64:/usr/src# dmesg | grep hifi
[    8.980998] snd-rpi-hifiberry-dacplushd soc:sound: pcm179x-hifi <-> fe203000.i2s mapping ok
[    8.989655] snd-rpi-hifiberry-dacplushd soc:sound: ASoC: no DMI vendor name!

and finally dmesg | grep snd

root@bec19b8c0a64:/usr/src# dmesg | grep snd
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_headphones=1 bcm2708_fb.fbwidth=0 bcm2708_fb.fbheight=0 bcm2708_fb.fbdepth=16 bcm2708_fb.fbswap=1 smsc95xx.macaddr=DC:A6:32:3A:4C:B2 vc_mem.mem_base=0x3f000000 vc_mem.mem_size=0x3f600000  dwc_otg.lpm_enable=0 console=tty1 console=ttyS0,115200 rootfstype=ext4 rootwait root=UUID=ba1eadef-f68c-4f2e-a845-a0ee01c229a1 rootwait
[    8.808429] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[    8.980998] snd-rpi-hifiberry-dacplushd soc:sound: pcm179x-hifi <-> fe203000.i2s mapping ok
[    8.989655] snd-rpi-hifiberry-dacplushd soc:sound: ASoC: no DMI vendor name!
richardpringle commented 3 years ago

(I have two Pis and two DACs so I don't think any of the hardware is faulty)

richardpringle commented 3 years ago

To update: when I hardcode alsa_output.1.stereo-fallback in the start.sh script, everything works perfectly (although I still get one of those 24.11.20 13:39:49 (-0500) audio E: [pulseaudio] main.c: Sink alsa_output.dac.stereo-fallback does not exist. instead of two).

I'm actually not quite sure what happens when I use the one-click-deploy with Balena-cloud. Before manually pushing edits, would Balena-Cloud have picked up new versions from this repo? Or would I have had to upgrade manually anyway?

richardpringle commented 3 years ago

And another question (feel free to get me to write this in a forum somewhere)... are there more configuration options? I see from this

Sink #1
        State: SUSPENDED
        Name: alsa_output.1.stereo-fallback
        Description: Built-in Audio Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 7
        Mute: no
        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
        Monitor Source: alsa_output.1.stereo-fallback.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "HiFiBerry DAC+ HD HiFi pcm179x-hifi-0"
                alsa.id = "HiFiBerry DAC+ HD HiFi pcm179x-hifi-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "1"
                alsa.card_name = "snd_rpi_hifiberry_dacplushd"
                alsa.long_card_name = "snd_rpi_hifiberry_dacplushd"
                alsa.driver_name = "snd_soc_hifiberry_dacplushd"
                device.bus_path = "/devices/platform/soc/soc:sound/sound/card1"
                sysfs.path = "/devices/platform/soc/soc:sound/sound/card1"
                device.form_factor = "internal"
                device.string = "hw:1"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "stereo-fallback"
                device.profile.description = "Stereo"
                device.description = "Built-in Audio Stereo"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Ports:
                analog-output: Analog Output (priority: 9900)
        Active Port: analog-output
        Formats:
                pcm

that the resolution is 16bits and the sample rate is configured to 44.1kHz. From the datasheet, it looks like this board can handle a resolution of 24bits and a sample rate all the way up to 192kHz, is it possible to change these values?

shawaj commented 3 years ago

@richardpringle did you change the dtparams to say audio=off instead of audio=on ?

aandroide commented 3 years ago

i bet it's the latest pulseaudio update causing the problem. you can try to downgrade pulseaudio and restart: sudo apt install pulseaudio=12.2-4+deb10u1 libpulse0=12.2-4+deb10u1 pulseaudio-utils=12.2-4+deb10u1 libpulsedsp=12.2-4+deb10u1

richardpringle commented 3 years ago

@shawaj, tried, didn't help

@aandroide, I could downgrade, but that's just as much effort as hardcoding the name of the Sink

shawaj commented 3 years ago

@richardpringle with the audio=off set is it still sink 1 not sink 0?

shawaj commented 3 years ago

Aha I've spotted the issue I think.

The udev rules don't currently have an entry for snd-rpi-hifiberry-dacplushd https://github.com/balenablocks/audio/blob/master/udev/95-balena-audio.rules

Relates to #296

Will submit a PR to fix this later.

shawaj commented 3 years ago

PR is here https://github.com/balenablocks/audio/pull/48

shawaj commented 3 years ago

@richardpringle until the PR is merged, you should be able to get this working by following the instructions here https://github.com/balenalabs/balena-sound/issues/377#issuecomment-752152387

shawaj commented 3 years ago

Duplicate of #377

shawaj commented 3 years ago

Closing this issue now in favour of #377

Necessary changes were pulled to the audio block in https://github.com/balenablocks/audio/pull/49

You can update by using git pull and balena push -c to rebuild if using balena CLI to build again without using cached images.