carsten_h wrote: 
> 
> 
> I also have to restore the ALSA-settings with:
> > 
Code:
--------------------
  >   > sudo /usr/local/sbin/alsactl restore
--------------------
> > 
> in my script.
> 
> Is this something that can be included in this. I don't know when this
> is normally called. When I start the Pi with powered on speakers, it
> is done. So maybe there is more that should be done when switching on
> things later.

I've been looking into this.  I have the same issue as described in
'this thread'
(https://forums.slimdevices.com/showthread.php?111540-Alsa-mixer-on-picore-cannot-save)
- in my boot log I see:

Code:
--------------------
    Starting ALSA configuration...alsactl: init:1787: Cannot find soundcard 
'USB'...
  alsactl: load_state:1763: Cannot find soundcard 'USB'...
  .alsactl: load_state:1763: Cannot find soundcard 'USB'...
  .alsactl: load_state:1763: Cannot find soundcard 'USB'...
  .alsactl: load_state:1763: Cannot find soundcard 'USB'...
  .alsactl: load_state:1763: Cannot find soundcard 'USB'...
  .alsactl: load_state:1763: Cannot find soundcard 'USB'...
  ALSA restore error!
--------------------


This seems to be due to two separate issues:
1) My sound card isn't called 'USB', it's called 'DAC'
2) Even if named correctly, then timing seems to be an issue - the ALSA
configuration has to happen after the sound card has been detected.

The workaround for 1) is, as you say, to issue 'sudo
/usr/local/sbin/alsactl restore'.  So I think there are two places in
the scripts where this has to be issued.

Firstly, it has to be issued when the SQLITE-control.sh script is
looking for the sound card immediately after boot.  So that's in the
'find' section.  Place that command as indicated in bold:

Code:
--------------------
    find ) # create the file with the kernel name
                idVendor="xxxx"
                idProduct="xxxx"
                echo "Searching for DAC with idVendor=$idVendor and 
idProduct=$idProduct in dmesg" >> /var/log/pcp_DAC.log
                dacdev=$(dmesg | grep -m 1 "idVendor=$idVendor, 
idProduct=$idProduct" | awk -F usb {'print $2'} | awk -F : {'print $1'})
                echo $dacdev > /tmp/DACdevice.txt
                if [ -z $dacdev ]; then
                        echo "DAC not detected" >> /var/log/pcp_DAC.log
                else
                        echo "DAC detected on $dacdev" >> /var/log/pcp_DAC.log
                        *sudo /usr/local/sbin/alsactl restore*
                fi
                ;;
--------------------


Secondly, it has to be issued whenever squeezelite (re)starts in
response to the udev rule.  I think the best place for that is at the
end of the restartSQLITE.sh script

Code:
--------------------
    #!/bin/sh
  
  attempts=5 # number of tries
  count=$attempts 
  while [ "$(sudo /usr/local/etc/init.d/squeezelite status)" == "Squeezelite 
not running." ]; do
        if [ $((count--)) -le 0 ]; then
                echo  "Squeezelite failed to initialize within $attempts 
attempts." >> /var/log/pcp_DAC.log
                exit 1 
        fi
        echo  "Attempting to start squeezelite" >> /var/log/pcp_DAC.log
        sudo /usr/local/etc/init.d/squeezelite restart >> /var/log/pcp_DAC.log
        sleep 1 # time interval (seconds) between tries
  done
  *sudo /usr/local/sbin/alsactl restore*
--------------------


I've updated my scripts quite a bit, mostly so that they don't need to
be personalised with the vendor and product ids, but also to include
that 'imaketherules' script as an option within SQLITE-control.  The
output that's visible in the pCP Logs section is also a bit tidier. 
I'll post the updated scripts when I've tested them a bit more.


------------------------------------------------------------------------
chill's Profile: http://forums.slimdevices.com/member.php?userid=10839
View this thread: http://forums.slimdevices.com/showthread.php?t=113661

_______________________________________________
unix mailing list
unix@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to