mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.17k stars 569 forks source link

No audio through usb aux #1268

Closed RedFreelancer closed 3 years ago

RedFreelancer commented 3 years ago

Hi all, im new to the whole coding scene and wanted to jump right in but i keep getting the same issue. I want to play the audio out usb aux but it keeps deciding that it wants to play through HDMI my usb is hw:2

please find below my -h log

Usage: shairport-sync [options...]
  or:  shairport-sync [options...] -- [audio output-specific options]

Options:
    -h, --help              show this help.
    -d, --daemon            daemonise.
    -j, --justDaemoniseNoPIDFile            daemonise without a PID file.
    -V, --version           show version information.
    -k, --kill              kill the existing shairport daemon.
    -D, --disconnectFromOutput  disconnect immediately from the output device.
    -R, --reconnectToOutput  reconnect to the output device.
    -c, --configfile=FILE   read configuration settings from FILE. Default is /etc/shairport-sync.conf.

The following general options are for backward compatibility. These and all new options have settings in the configuration file, by default /etc/shairport-sync.conf:
    -v, --verbose           -v print debug information; -vv more; -vvv lots.
    -p, --port=PORT         set RTSP listening port.
    -a, --name=NAME         set advertised name.
    -L, --latency=FRAMES    [Deprecated] Set the latency for audio sent from an unknown device.
                            The default is to set it automatically.
                            The default is to set it automatically.
    -S, --stuffing=MODE set how to adjust current latency to match desired latency, where
                            "basic" (default) inserts or deletes audio frames from packet frames with low processor overhead, and
                            "soxr" uses libsoxr to minimally resample packet frames -- moderate processor overhead.
                            "soxr" option only available if built with soxr support.
    -B, --on-start=PROGRAM  run PROGRAM when playback is about to begin.
    -E, --on-stop=PROGRAM   run PROGRAM when playback has ended.
                            For -B and -E options, specify the full path to the program, e.g. /usr/bin/logger.
                            Executable scripts work, but must have the appropriate shebang (#!/bin/sh) in the headline.
    -w, --wait-cmd          wait until the -B or -E programs finish before continuing.
    -o, --output=BACKEND    select audio output method.
    -m, --mdns=BACKEND      force the use of BACKEND to advertize the service.
                            if no mdns provider is specified,
                            shairport tries them all until one works.
    -r, --resync=THRESHOLD  [Deprecated] resync if error exceeds this number of frames. Set to 0 to stop resyncing.
    -t, --timeout=SECONDS   go back to idle mode from play mode after a break in communications of this many seconds (default 120). Set to 0 never to exit play mode.
    --statistics            print some interesting statistics -- output to the logfile if running as a daemon.
    --tolerance=TOLERANCE   [Deprecated] allow a synchronization error of TOLERANCE frames (default 88) before trying to correct it.
    --password=PASSWORD     require PASSWORD to connect. Default is not to require a password.
    --logOutputLevel        log the output level setting -- useful for setting maximum volume.
    --metadata-pipename=PIPE send metadata to PIPE, e.g. --metadata-pipename=/tmp/shairport-sync-metadata.
                            The default is /tmp/shairport-sync-metadata.
    --get-coverart          send cover art through the metadata pipe.

Available mDNS backends:
    avahi
    external-avahi

Available audio outputs:
    alsa (default)
    pa
    pipe
    stdout
    dummy

Options for output alsa:
    -d output-device    set the output device [default*|...]
    -m mixer-device     set the mixer device ['output-device'*|...]
    -c mixer-control    set the mixer control [Master*|...]
    -i mixer-index      set the mixer index [0*|...]
    *) default option

Options for output pa:
 no settings.

Options for output pipe:
    pipe takes 1 argument: the name of the FIFO to write to.

Options for output stdout:
    stdout takes no arguments

Options for output dummy:
    There are no options for dummy audio.

image

RedFreelancer commented 3 years ago

Here is my log for the config file:

// Sample Configuration File for Shairport Sync
// Commented out settings are generally the defaults, except where noted.

// General Settings
general =
{
//      name = "%H"; // This means "Hostname" -- see below. This is the name the service will advertise to iTunes.
//              The default is "Hostname" -- i.e. the machine's hostname with the first letter capitalised (ASCII only.)
//              You can use the following substitutions:
//                              %h for the hostname,
//                              %H for the Hostname (i.e. with first letter capitalised (ASCII only)),
//                              %v for the version number, e.g. 3.0 and
//                              %V for the full version string, e.g. 3.0-OpenSSL-Avahi-ALSA-soxr-metadata-sysconfdir:/etc
//              Overall length can not exceed 50 characters. Example: "Shairport Sync %v on %H".
//      password = "secret"; // leave this commented out if you don't want to require a password
//      interpolation = "basic"; // aka "stuffing". Default is "basic", alternative is "soxr". Use "soxr" only if you have a reasonably fast processor.
//      output_backend = "alsa"; // Run "shairport-sync -h" to get a list of all output_backends, e.g. "alsa", "pipe", "stdout". The default is the first one.
//      mdns_backend = "avahi"; // Run "shairport-sync -h" to get a list of all mdns_backends. The default is the first one.
//      port = 5000; // Listen for service requests on this port
//      udp_port_base = 6001; // start allocating UDP ports from this port number when needed
//      udp_port_range = 100; // look for free ports in this number of places, starting at the UDP port base. Allow at least 10, though only three are needed in a steady state.
//      drift_tolerance_in_seconds = 0.002; // allow a timing error of this number of seconds of drift away from exact synchronisation before attempting to correct it
//      resync_threshold_in_seconds = 0.050; // a synchronisation error greater than this number of seconds will cause resynchronisation; 0 disables it
//      ignore_volume_control = "no"; // set this to "yes" if you want the volume to be at 100% no matter what the source's volume control is set to.
//      volume_range_db = 60 ; // use this advanced setting to set the range, in dB, you want between the maximum volume and the minimum volume. Range is 30 to 150 dB. Leave it commented o$//      volume_max_db = 0.0 ; // use this advanced setting, which must have a decimal point in it, to set the maximum volume, in dB, you wish to use.
//              The setting is for the hardware mixer, if chosen, or the software mixer otherwise. The value must be in the mixer's range (0.0 to -96.2 for the software mixer).
//              Leave it commented out to use mixer's maximum volume.
//      volume_control_profile = "standard" ; // use this advanced setting to specify how the airplay volume is transferred to the mixer volume.
//              "standard" makes the volume change more quickly at lower volumes and slower at higher volumes.
//              "flat" makes the volume change at the same rate at all volumes.
//      run_this_when_volume_is_set = "/full/path/to/application/and/args"; //  Run the specified application whenever the volume control is set or changed.
//              The desired AirPlay volume is appended to the end of the command line – leave a space if you want it treated as an extra argument.
//              AirPlay volume goes from 0 to -30 and -144 means "mute".

//      regtype = "_raop._tcp"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp".
//      playback_mode = "stereo"; // This can be "stereo", "mono", "reverse stereo", "both left" or "both right". Default is "stereo".
//      alac_decoder = "hammerton"; // This can be "hammerton" or "apple". This advanced setting allows you to choose
//              the original Shairport decoder by David Hammerton or the Apple Lossless Audio Codec (ALAC) decoder written by Apple.
//      interface = "name"; // Use this advanced setting to specify the interface on which Shairport Sync should provide its service. Leave it commented out to get the default, which is to$
//      audio_backend_latency_offset_in_seconds = 0.0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.$//      audio_backend_buffer_desired_length_in_seconds = 0.15; // If set too small, buffer underflow occurs on low-powered machines. Too long and the response time to volume changes become$//      audio_backend_silent_lead_in_time = 2.0; // This optional advanced setting, from 0.0 and 4.0 seconds, sets the length of the period of silence that precedes the start of the audio.$//      dbus_service_bus = "system"; // The Shairport Sync dbus interface, if selected at compilation, will appear
//              as "org.gnome.ShairportSync" on the whichever bus you specify here: "system" (default) or "session".
//      mpris_service_bus = "system"; // The Shairport Sync mpris interface, if selected at compilation, will appear
//              as "org.gnome.ShairportSync" on the whichever bus you specify here: "system" (default) or "session".
};

// Advanced parameters for controlling how Shairport Sync runs a play session
sessioncontrol =
{
//      run_this_before_play_begins = "/full/path/to/application and args"; // make sure the application has executable permission. If it's a script, include the shebang (#!/bin/...) on th$//      run_this_after_play_ends = "/full/path/to/application and args"; // make sure the application has executable permission. If it's a script, include the shebang (#!/bin/...) on the f$//      wait_for_completion = "no"; // set to "yes" to get Shairport Sync to wait until the "run_this..." applications have terminated before continuing
//      allow_session_interruption = "no"; // set to "yes" to allow another device to interrupt Shairport Sync while it's playing from an existing audio source
//      session_timeout = 120; // wait for this number of seconds after a source disappears before terminating the session and becoming available again.
};

// Back End Settings

// These are parameters for the "alsa" audio back end.
alsa =
{
//      output_device = "hw:USB PnP Sound Device"; // the name of the alsa output device. Use "alsamixer" or "aplay" to find out the names of devices, mixers, etc.
//      mixer_control_name = "PCM"; // the name of the mixer to use to adjust output volume. If not specified, volume in adjusted in software.
//      mixer_device = "default"; // the mixer_device default is whatever the output_device is. Normally you wouldn't have to use this.
//      output_rate = 44100; // can be 44100, 88200, 176400 or 352800, but the device must have the capability.
//      output_format = "S16"; // can be "U8", "S8", "S16", "S24", "S24_3LE", "S24_3BE" or "S32", but the device must have the capability. Except where stated using (*LE or *BE), endiannes$//      disable_synchronization = "no"; // Set to "yes" to disable synchronization. Default is "no".
//      period_size = <number>; // Use this optional advanced setting to set the alsa period size near to this value
//      buffer_size = <number>; // Use this optional advanced setting to set the alsa buffer size near to this value
//      use_mmap_if_available = "yes"; // Use this optional advanced setting to control whether MMAP-based output is used to communicate  with the DAC. Default is "yes"
//      use_hardware_mute_if_available = "no"; // Use this optional advanced setting to control whether the hardware in the DAC is used for muting. Default is "no", for compatibility with $};

// Parameters for the "sndio" audio back end. All are optional.
sndio =
{
//      device = "snd/0"; // optional setting to set the name of the output device. Default is the sndio system default.
//      rate = 44100; // optional setting  which can be 44100, 88200, 176400 or 352800, but the device must have the capability. Default is 44100.
//      format = "S16"; // optional setting  which can be "U8", "S8", "S16", "S24", "S24_3LE", "S24_3BE" or "S32", but the device must have the capability. Except where stated using (*LE o$//      round = <number>; // advanced optional setting to set the period size near to this value
//      bufsz = <number>; // advanced optional setting to set the buffer size near to this value
};

// Parameters for the "pa" PulseAudio  backend.
mikebrady commented 3 years ago

Thanks. A couple of things.

  1. Could you let us know the version of Shairport Sync please? (see the TROUBLESHOOTING and REPORTING ISSUES pages.)
  2. The output_device line is commented out; you need to uncomment it to make it effective. (And when you make changes, you have to restart Shairport Sync, or simply reboot out the whole machine.)
RedFreelancer commented 3 years ago

Hi Mike, Thank you for your reply 1: 3.2.2-OpenSSL-Avahi-ALSA-pa-dummy-stdout-pipe-soxr-convolution-metadata-sysconfdir:/etc 2: I have uncommented the output device and changed it to hw:2 to see if it worked but no luck

mikebrady commented 3 years ago

Thanks. It looks like the volume is up full on hw:2. Let me suggest you update to the latest version 3.3.8. There’s a guide on the INSTALL page. There have been quite a few bug fixes since 3.2.2. Another thing to try, perhaps, is to set the log_verbosity to 1 and turn on statistics. You might then get some useful information on the log.

RedFreelancer commented 3 years ago

Hi Mike, I have updated to 3.3.8 but still no luck. How would i edit the log_verbosity? and turn on statistics. sorry I am new to the whole coding scene

mikebrady commented 3 years ago

Great stuff. There is a diagnostics stanza at the bottom of the configuration file. You can enable statistics and set the log_verbosity there. (Don't forget to uncomment the lines 🙂). Then restart. Now, when you look in the log, you'll see some entries from shairport-sync when starting up and when playing. Use this, or similar, to watch ("follow") the log:

$ sudo journalctl -n 100 -f
RedFreelancer commented 3 years ago

Hi mike, when using the journalctl code it kept spitting out that hw:2 wasnt valid, i changed this to hw:02 and it seemed to fix the issue. Thank you for your help!

mikebrady commented 3 years ago

Great!

mikebrady commented 3 years ago

As a matter of interest, could you post the last part of the output from $ shairport-sync -h please? The part I'm interested in is at the end. For my Raspberry P, with a Pimoroni audio "shim" it is:

Settings and options for the audio backend "alsa":
    -d output-device    set the output device, default is "default".
    -c mixer-control    set the mixer control name, default is to use no mixer.
    -m mixer-device     set the mixer device, default is the output device.
    -i mixer-index      set the mixer index, default is 0.
    hardware output devices:
      "hw:Headphones"
      "hw:sndrpihifiberry"

Settings and options for the audio backend "pipe":
    specify the pathname of the pipe to write to.

I'm interested in what you get below the hardware output devices line. (The output from 3.3.8 is different to what you posted above from version 3.2.2.)

RedFreelancer commented 3 years ago

Hi Mike, Here you go:

Settings and options for the audio backend "alsa":
    -d output-device    set the output device, default is "default".
    -c mixer-control    set the mixer control name, default is to use no mixer.
    -m mixer-device     set the mixer device, default is the output device.
    -i mixer-index      set the mixer index, default is 0.
    hardware output devices:
      "hw:Device"
      "hw:Headphones"