Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    Sep 2015
    Posts
    100

    Two USB DAC initialisation problems

    Hi,

    I am working on an arm64-based, squeezebox touch-like system.

    The system plays through a USB DAC (C_MEDIA 6632A) using squeezelite.

    The results vary depending on how I start up the system:

    If I connect and power on the DAC first, then the squeezebox system, I get this:

    1. The DAC is picked up as soon as usb starts and can be listed using lsusb and aplay -l
    2. As soon as the init process starts ALSA, the DAC plays white noise until squeezelite starts. Squeezelite is set up to play through "Direct hardware device without any conversion".
    3. When squeezelite has started the DAC is silent and plays music very nicely (no pops, clicks or XRUN's).

    If I start the squeezelite system before powering on the DAC:

    1. usb starts without finding the DAC (not surprising)
    2. alsa starts with no soundcards (as I have removed all other driver modules except for snd_usb_audio from the kernel)
    3. squeezelite also fails to start as the configured soundcard is missing (also not surprising)
    BUT
    4. if I then plug or start the DAC, it is still not registered (dmesg shows nothing and lsusb still doesn't list it). This persists even through a cold reboot of the system. Nothing found. The only way I have found to make the DAC discoverable again is to plug it into a different system. If I do that, then procedure one works as expected.

    Obviously, in a real-life system, we have to handle starting components in different orders.

    The same DAC connected to a squeezebox touch plays no white noise on startup and can be turned on or connected beofore or after the touch, without problems. SO


    1. How can I start the system/ALSA making sure that the DAC is silent (I have heard that this may have to do with dither, which produces white noise on non-zero silent streams, but which also reduces distortion when playing audio - something I obvioulsy want).

    2. What can I do to force discovery of the DAC even when it is hotplugged? I don't understand why the DAC should remain invisible also when cold rebooting the system. Can anyone offer an explanation?
    If I can work out what's going on , then it should be possible to catch it and script a workaround.

    Very glad for any advice.

    BR.

    --Marius--

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Location
    UK
    Posts
    713
    Based on what OS, kernel, and software stack?

    The udev system should handle initialisation of the DAC if it's plugged in post boot. You should at least see a kernel log message when the DAC joins the USB bus, even if no driver subsequently loads to manage it.
    --
    Hardware: 3x Touch, 1x Radio, 2x Receivers, 1 HP Microserver NAS with Debian+LMS 7.9.0
    Music: ~1300 CDs, as 450 GB of 16/44k FLACs. No less than 3x 24/44k albums..

  3. #3
    Senior Member
    Join Date
    Sep 2015
    Posts
    100
    Quote Originally Posted by drmatt View Post
    Based on what OS, kernel, and software stack?

    The udev system should handle initialisation of the DAC if it's plugged in post boot. You should at least see a kernel log message when the DAC joins the USB bus, even if no driver subsequently loads to manage it.
    Armbian os (xenial) with logsleep (allwinner) kernel 3.10.104 (the only viable kernel for the pine64 soc device at the moment).

    Having posted, I can't reproduce the second scenario now, so please forget that for the moment.

    The white noise is still present though, as soon as alsa loads.

    Stack would probably be something like:

    1. ehci:
    Code:
    dmesg:
    [ 3092.731854] ehci_irq: highspeed device connect
    [ 3092.953708] usb 2-1: new high-speed USB device number 2 using sunxi-ehci
    [ 3093.181941] usbcore: registered new interface driver usbhid
    [ 3093.181952] usbhid: USB HID core driver
    [ 3094.710561] input: SMSL AUDIO Sanskrit PRO as /devices/soc.0/1c1b000.ehci1-controller/usb2/2-1/2-1:1.2/input/input6
    [ 3094.712441] hid-generic 0003:0D8C:0062.0001: input,hidraw0: USB HID v1.00 Device [SMSL AUDIO Sanskrit PRO] on usb-sunxi-ehci-1/input2
    2. ALSA:
    Code:
    aplay -L
    null
        Discard all samples (playback) or generate zero samples (capture)
    pulse
        PulseAudio Sound Server
    default:CARD=PRO
        Sanskrit PRO, USB Audio
        Default Audio Device
    sysdefault:CARD=PRO
        Sanskrit PRO, USB Audio
        Default Audio Device
    front:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        Front speakers
    surround21:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        2.1 Surround output to Front and Subwoofer speakers
    surround40:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        4.0 Surround output to Front and Rear speakers
    surround41:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        4.1 Surround output to Front, Rear and Subwoofer speakers
    surround50:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        5.0 Surround output to Front, Center and Rear speakers
    surround51:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        5.1 Surround output to Front, Center, Rear and Subwoofer speakers
    surround71:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
    iec958:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        IEC958 (S/PDIF) Digital Audio Output
    dmix:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        Direct sample mixing device
    dsnoop:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        Direct sample snooping device
    hw:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        Direct hardware device without any conversions
    plughw:CARD=PRO,DEV=0
        Sanskrit PRO, USB Audio
        Hardware device with all software conversions
    squeezelite:
    Code:
    squeezelite-R2 -l
    Output devices:
      null                           - Discard all samples (playback) or generate zero samples (capture)
      pulse                          - PulseAudio Sound Server
      default                       
      sysdefault:CARD=PRO            - Sanskrit PRO, USB Audio - Default Audio Device
      front:CARD=PRO,DEV=0           - Sanskrit PRO, USB Audio - Front speakers
      surround21:CARD=PRO,DEV=0      - Sanskrit PRO, USB Audio - 2.1 Surround output to Front and Subwoofer speakers
      surround40:CARD=PRO,DEV=0      - Sanskrit PRO, USB Audio - 4.0 Surround output to Front and Rear speakers
      surround41:CARD=PRO,DEV=0      - Sanskrit PRO, USB Audio - 4.1 Surround output to Front, Rear and Subwoofer speakers
      surround50:CARD=PRO,DEV=0      - Sanskrit PRO, USB Audio - 5.0 Surround output to Front, Center and Rear speakers
      surround51:CARD=PRO,DEV=0      - Sanskrit PRO, USB Audio - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
      surround71:CARD=PRO,DEV=0      - Sanskrit PRO, USB Audio - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
      iec958:CARD=PRO,DEV=0          - Sanskrit PRO, USB Audio - IEC958 (S/PDIF) Digital Audio Output
      dmix:CARD=PRO,DEV=0            - Sanskrit PRO, USB Audio - Direct sample mixing device
      dsnoop:CARD=PRO,DEV=0          - Sanskrit PRO, USB Audio - Direct sample snooping device
      hw:CARD=PRO,DEV=0              - Sanskrit PRO, USB Audio - Direct hardware device without any conversions
      plughw:CARD=PRO,DEV=0          - Sanskrit PRO, USB Audio - Hardware device with all software conversions
    The default output device for squeezelite is
    hw:CARD=PRO,DEV=0 - Sanskrit PRO, USB Audio - Direct hardware device without any conversions

    which obviously causes squeezelite startup to fail when the card is not found.

    I'm thinking that I should modify the startup script for squeezelite to wait until the hw:CARD=PRO,DEV=0 is present, before starting. Should be a way of doing that, or taking the squeezelite start script out of init and link it to a udev rule ???

    But I'm sure that I'm not the first to have the problem, so there's probably a standard solution lying around somewhere, if I can find it.

    Regarding the white noise, I'm guessing that alsa is initialising the device in the wrong mode somehow. Again: any standard solution that may be missing on my system??

    As soon as squeezelite starts, the noise disappears.

    BR.
    Last edited by Learnincurve; 2017-03-09 at 05:24.

  4. #4
    Senior Member
    Join Date
    Apr 2013
    Location
    UK
    Posts
    713
    I would agree with you, but I'd be guessing as to what the exact cause is. I've seen devices behave like this before, and it's very much device-specific. Unless you can show that Alsa is kicking off a stream and sending garbage I would definitely think it's the DAC driver.

    As a general comment I might look at jackd as a way of insulation against hot plug or live sound device changes. It should be able to provide a virtual default sound output path that you can then redirect to whatever physical audio output eventually becomes ready.

    However, kicking off squeezelite from udev might also be pretty effective and would potentially support multiple independent audio outputs at the same time, assuming the UI could cope with this.
    --
    Hardware: 3x Touch, 1x Radio, 2x Receivers, 1 HP Microserver NAS with Debian+LMS 7.9.0
    Music: ~1300 CDs, as 450 GB of 16/44k FLACs. No less than 3x 24/44k albums..

  5. #5
    Senior Member
    Join Date
    Sep 2015
    Posts
    100
    Quote Originally Posted by drmatt View Post
    I would agree with you, but I'd be guessing as to what the exact cause is. I've seen devices behave like this before, and it's very much device-specific. Unless you can show that Alsa is kicking off a stream and sending garbage I would definitely think it's the DAC driver.

    As a general comment I might look at jackd as a way of insulation against hot plug or live sound device changes. It should be able to provide a virtual default sound output path that you can then redirect to whatever physical audio output eventually becomes ready.

    However, kicking off squeezelite from udev might also be pretty effective and would potentially support multiple independent audio outputs at the same time, assuming the UI could cope with this.
    Thanks drmatt!

    The first problem now seems intermittent, so very hard to get closer to what might be causing it. Regarding the second, I have it down to a aplit second of noise now, after removing the module from modules-load and firing off a small stream of silence through a udev rule when the DAC is plugged/discovered at startup. Still a split-second too much though .


    --Marius--

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •