carsten_h wrote: 
> I really don't understand why here at the first switching on of the USB
> speakers still nothing works. Only when switching off and on again it
> works.

I've been experimenting, and I think I have a clue as to what's going
on.  I changed my udev rule from 'bind' to 'add', and indeed I now see
the same behaviour as you: after a reboot, the first time the DAC is
inserted the udev rule is triggered and squeezelite tries to start, but
it fails to do so.  I believe that's because there are no drivers loaded
for the DAC at that stage.  The next time the rule is triggered, by
removing and reinserting the DAC, the drivers have already loaded (from
the first attempt), so squeezelite starts up successfully.

So I first thought that all I needed to do was insert a short delay into
the squeezelite startup script, so that after the rule is triggered
there is enough time to load the drivers.  But that didn't work, even
with an extreme delay of 5 seconds.  That puzzled me, because in my case
the 'bind' action happens only a split-second after the 'add' action, so
only a very short sleep should have been necessary.

But now I see that the script that runs on a udev event seems to block
further activity.  So if I trigger my script on 'add', and my script
causes a 5 second sleep, the subsequent 'bind' action, indicating that
the driver has loaded, is delayed by 5 seconds too, so it doesn't help. 
You can see this in these two dmesg examples.  In the first, I have no
delay in my script.  If you look at the interval between the third-last
line [50.840106] and the 'mc: Linux media interface: v0.10' line
[51.548874] you see it is 0.7s.


Code:
--------------------
    [   35.981372] Finished piCorePlayer v7.0.0 startup.
  [   49.973086] usb 1-1.3: new full-speed USB device number 4 using xhci_hcd
  [   50.079865] usb 1-1.3: New USB device found, idVendor=0451, 
idProduct=2036, bcdDevice= 1.01
  [   50.079871] usb 1-1.3: New USB device strings: Mfr=0, Product=1, 
SerialNumber=0
  [   50.079876] usb 1-1.3: Product: General Purpose USB Hub
  [   50.086925] hub 1-1.3:1.0: USB hub found
  [   50.087861] hub 1-1.3:1.0: 2 ports detected
  [   50.381084] usb 1-1.3.1: new full-speed USB device number 5 using xhci_hcd
  [   50.495051] usb 1-1.3.1: New USB device found, idVendor=08bb, 
idProduct=2704, bcdDevice= 1.00
  [   50.495059] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, 
SerialNumber=0
  [   50.495064] usb 1-1.3.1: Product: USB Audio DAC   
  [   50.495069] usb 1-1.3.1: Manufacturer: Burr-Brown from TI              
  [   50.502513] hid-generic 0003:08BB:2704.0001: hidraw0: USB HID v1.00 Device 
[Burr-Brown from TI               USB Audio DAC   ] on 
usb-0000:01:00.0-1.3.1/input2
  [   50.725086] usb 1-1.3.2: new full-speed USB device number 6 using xhci_hcd
  [   50.834721] usb 1-1.3.2: New USB device found, idVendor=04d8, 
idProduct=ff89, bcdDevice= 0.01
  [   50.834728] usb 1-1.3.2: New USB device strings: Mfr=1, Product=2, 
SerialNumber=0
  [   50.834733] usb 1-1.3.2: Product: DLCP
  [   50.834737] usb 1-1.3.2: Manufacturer: Hypex BV
  [   50.840106] hid-generic 0003:04D8:FF89.0002: hiddev96,hidraw1: USB HID 
v1.11 Device [Hypex BV DLCP] on usb-0000:01:00.0-1.3.2/input0
  [   51.548874] mc: Linux media interface: v0.10
  [   51.584905] usbcore: registered new interface driver snd-usb-audio
--------------------


In the second example, I added a 5 second sleep in my script, and now
the interval before the 'mc: Linux media interface: v0.10' message
appears in dmesg increases to 5.7s

Code:
--------------------
    [   35.868798] Finished piCorePlayer v7.0.0 startup.
  [   62.517101] usb 1-1.3: new full-speed USB device number 4 using xhci_hcd
  [   62.623910] usb 1-1.3: New USB device found, idVendor=0451, 
idProduct=2036, bcdDevice= 1.01
  [   62.623923] usb 1-1.3: New USB device strings: Mfr=0, Product=1, 
SerialNumber=0
  [   62.623934] usb 1-1.3: Product: General Purpose USB Hub
  [   62.631148] hub 1-1.3:1.0: USB hub found
  [   62.633907] hub 1-1.3:1.0: 2 ports detected
  [   62.929100] usb 1-1.3.1: new full-speed USB device number 5 using xhci_hcd
  [   63.043220] usb 1-1.3.1: New USB device found, idVendor=08bb, 
idProduct=2704, bcdDevice= 1.00
  [   63.043233] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, 
SerialNumber=0
  [   63.043243] usb 1-1.3.1: Product: USB Audio DAC   
  [   63.043253] usb 1-1.3.1: Manufacturer: Burr-Brown from TI              
  [   63.051394] hid-generic 0003:08BB:2704.0001: hidraw0: USB HID v1.00 Device 
[Burr-Brown from TI               USB Audio DAC   ] on 
usb-0000:01:00.0-1.3.1/input2
  [   63.277100] usb 1-1.3.2: new full-speed USB device number 6 using xhci_hcd
  [   63.386517] usb 1-1.3.2: New USB device found, idVendor=04d8, 
idProduct=ff89, bcdDevice= 0.01
  [   63.386530] usb 1-1.3.2: New USB device strings: Mfr=1, Product=2, 
SerialNumber=0
  [   63.386540] usb 1-1.3.2: Product: DLCP
  [   63.386550] usb 1-1.3.2: Manufacturer: Hypex BV
  [   63.399229] hid-generic 0003:04D8:FF89.0002: hiddev96,hidraw1: USB HID 
v1.11 Device [Hypex BV DLCP] on usb-0000:01:00.0-1.3.2/input0
  [   69.119063] mc: Linux media interface: v0.10
  [   69.154256] usbcore: registered new interface driver snd-usb-audio
  
--------------------


So I think it's important that the udev rule waits for 'bind' instead of
'add', since that indicates that the driver has either loaded, or is
starting to load (not sure exactly).  If that didn't work in your case,
then maybe the combination of 'bind' with a short sleep in your script
before squeezelite is started would be enough.  If that doesn't work,
maybe there's a specific rule that could look for the snd-usb-audio
driver being loaded.

Or maybe the answer is for the udev script to run in the background
(with '&'), so that it doesn't block further activity.  I don't know if
that works in the case of udev events.  I'll do some more experimenting.


------------------------------------------------------------------------
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