owntone / owntone-server

Linux/FreeBSD DAAP (iTunes) and MPD audio server with support for AirPlay 1 and 2 speakers (multiroom), Apple Remote (and compatibles), Chromecast, Spotify and internet radio.
https://owntone.github.io/owntone-server
GNU General Public License v2.0
2.05k stars 235 forks source link

Which Local Output Soundcard Name Format #262

Closed suiluj closed 8 years ago

suiluj commented 8 years ago

I try to use my usb soundcard as my local output source. Which string do i have to put for card="default"in the config file?

I use a Raspberry Pi 3 and get the following aplay -l output:

pi@raspberrypi:~ $ aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: ALSA [bcm2835 ALSA], Gerät 0: bcm2835 ALSA [bcm2835 ALSA]
  Sub-Geräte: 7/8
  Sub-Gerät #0: subdevice #0
  Sub-Gerät #1: subdevice #1
  Sub-Gerät #2: subdevice #2
  Sub-Gerät #3: subdevice #3
  Sub-Gerät #4: subdevice #4
  Sub-Gerät #5: subdevice #5
  Sub-Gerät #6: subdevice #6
  Sub-Gerät #7: subdevice #7
Karte 0: ALSA [bcm2835 ALSA], Gerät 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 1: Device [C-Media USB Audio Device], Gerät 0: USB Audio [USB Audio]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0

I want to use my C-Media USB Audio Device. card=hw:1 did not work. At the moment it automatically uses my shairport-sync airplay server which is also on my pi. So i get sound through "local" airplay. But i just want to use local output.

Thank you for your help. Regards Julius

ejurgensen commented 8 years ago

I think the best approach would be to keep the setting, and then set the usb card as the default? I am, however, not sure how you do that. Maybe @LordMyschkin can give some advice on this?

LordMyschkin commented 8 years ago

well, I went throught various steps to achieve exactly that. I am not really sure about what exactly changed my usb-soundcard to default; my root/.asoundrc consists of the following lines: pcm.!default { type hw card 1 }

ctl.!default { type hw card 1 }

But I do think the relevant step was just to change the default soundcard in alsamixer.

I had some success in using the output of aplay -L (like "surround51:CARD=CODEC,DEV=0") as device instead of "default" in card = "default" - like card = "surround51:CARD=CODEC,DEV=0" but I did not try out all my outputs because switching the default output was much easier.

Take care that most online recipes on how to manipulate alsa outputs are for Debian Wheezy and not for the current Debian Jessie. I described most of my steps in https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=49928&sid=225d311b22287a3498cd6c5650952d51&start=925

Good luck!

suiluj commented 8 years ago

I am running with the user root and created a file .asoundrcin the folder /root(which is home for the root user. But then forked-daapd crashes if i press on a song to play it. I don't know why. Any idea?

ejurgensen commented 8 years ago

What does the log say? (see the end of /var/log/forked-daapd.log)

suiluj commented 8 years ago

In my .asoundrc is the following configuration for my root user:

 GNU nano 2.2.6                                                     Datei: /root/.asoundrc                                                                                                                 

pcm.!default {
    type hw
    card 1
}
ctl.!default {
    type hw
    card 1
}

(When using card 0the standard raspberrypi audio jack is used, so i changed to card 1.)

I tried twice to use the local output:

First time I already listened music via my shairport-sync server (which runs on my raspberrypi, too). I activated my local output audio while using airplay and got the following log errors

...
[2016-05-25 17:02:35] [  LOG]     scan: Bulk library scan completed in 31 sec
[2016-05-25 17:02:35] [  LOG]  spotify: Can't login! - could not find libspotify
[2016-05-25 17:03:22] [  LOG]   laudio: open '/dev/snd/pcmC1D0p' failed (-16)[2016-05-25 17:03:22] [  LOG]   laudio: Could not open playback device: Das Gerät oder die Ressource ist belegt
[2016-05-25 17:03:22] [  LOG]   player: Could not start ALSA device 'Lokal Pi'
[2016-05-25 17:03:22] [  LOG]   player: Could not activate ALSA device 'Lokal Pi'
[2016-05-25 17:03:22] [  LOG]     dacp: Speakers de/activation failed!
[2016-05-25 17:03:32] [  LOG]     main: Forked Media Server Version 24.1 taking off
...

Das Gerät oder die Ressource ist belegt means something like The device is in use.

So the second time I first deactivated airplay output and then activated my localoutput:

...
[2016-05-25 17:04:02] [  LOG]  spotify: Can't login! - could not find libspotify
[2016-05-25 17:05:33] [  LOG]   laudio: Failed to open PCM or Master mixer element
[2016-05-25 17:05:33] [  LOG]   laudio: Could not open mixer
[2016-05-25 17:05:33] [  LOG]   player: Could not start ALSA device 'Lokal Pi'
[2016-05-25 17:05:33] [  LOG]   player: Could not activate ALSA device 'Lokal Pi'
[2016-05-25 17:05:33] [  LOG]     dacp: Speakers de/activation failed!
...

Why is it failing? I thought the root user just can do everything. I even added the root user to the audio usergroup but I don't know if this is important.

Thank you for your help :)

suiluj commented 8 years ago

Ah I found the solution :)

I had to set the mixer (explained here).

In the local audio part of the forked-daapd.conf file:

# Mixer channel to use for volume control - ALSA/Linux only
# If not set, PCM will be used if available, otherwise Master.
mixer = "Speaker"

So this issue can be closed :) Thanks for the hint with the log file, I only viewd the status of the systemd process before

dony71 commented 7 years ago

@suiluj do you need to disable airplay? I have same issue airplay and forked-daapd using same card 1 and log file error device in use I try to use dmix, but I don't know how to set mixer parameter in configuration I follow output from "amixer --card 1" but still cannot open mixer Anybody can help?

suiluj commented 7 years ago

@dony71 sorry i don't know more than the step which I described above