Stable: 2.5.2
Development: 2.6-alpha3
Hi,
I'm having hard time to force MOC to play through speakers and I would need a hand troubleshooting this.
My audio HW:
Device-1: Intel 100 Series/C230 Series Family HD Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel bus ID: 00:1f.3
Device-2: NVIDIA GP104 High Definition Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel bus ID: 01:00.1
Sound Server: ALSA v: k5.3.0-19-generic
MOC Version:
This is : Music On Console
Version : 2.6-alpha3
Built : Feb 15 2019 15:42:04
Compiled with : OSS ALSA JACK DEBUG Network streams resample
Running on : Linux 5.3.0-19-generic x86_64
Author : Damian Pietras
Homepage : http://moc.daper.net/
E-Mail : mocmaint@daper.net
Copyright : (C) 2003-2016 Damian Pietras and others
License : GNU General Public License, version 2 or later
ALSA part of MOC config:
# ALSA output settings. If you need to dump the audio produced by MOC
# to a file for diagnostic purposes, the following setting of 'ALSADevice'
# should do that:
#
# ALSADevice=tee:hw,'/tmp/out.wav',wav
#
#ALSADevice = default
ALSAMixer1 = Master
#ALSAMixer1 = PCM
ALSAMixer2 = Master
If more info is needed - I'll provide.
tomaszg
Tue, 2019-10-29 21:33
Permalink
Are the speakers handled by
Are the speakers handled by the same sound card as headphones? If so then switching output would be handled well beyond MOC. I suppose the second device is HDMI output - if the speakers are connected this way, you would need to change ALSADevice variable to something like "default:CARD=NVIDIA" (you can check precise device name via aplay -L).
Dany Gee
Wed, 2019-10-30 07:17
Permalink
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC1150 Analog [ALC1150 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC1150 Digital [ALC1150 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
System settings show the speakers are HDMI 2 - GP104 HD Audio Controller
What exactly should I put as ALSADevice in the config?
Dany Gee
Wed, 2019-10-30 08:54
Permalink
Speaker Test
Speaker test play nicely through HDMI with this:
speaker-test -D hw:1,7 -c2 -t wav
But when I put ALSADevice = hw:1,7 in MOC config, I get this:
Running the server...
Trying ALSA...
Trying JACK...
Trying OSS...
FATAL_ERROR: No valid sound driver!
FATAL_ERROR: Server exited!
tomaszg
Wed, 2019-10-30 09:03
Permalink
I've always had problem
I've always had problem determining correct Alsa device names. "hw" devices are usually bad, since they allow only one client to connect at the time and may not support volume control, rate conversion and so on.
I suggested "aplay -L" (capital L) which lists device names you could try. Maybe "default:CARD=NVIDIA,DEV=?" or "hdmi:CARD=NVidia,DEV=?" might do the trick?
Dany Gee
Wed, 2019-10-30 10:18
Permalink
aplay -L
When I put into config:
ALSADevice = hw:CARD=NVidia,DEV=7
I get:
mocp
FATAL_ERROR: Error in config file: stray '=' on line 162!
(where line 162 is ALSADevice = hw:CARD=NVidia,DEV=7)
I've checked all the nvidia devices and all give the same error:
FATAL_ERROR: Error in config file: stray '=' on line 162!
I must be still missing something here <thinking...>
aplay -L output:
aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
default:CARD=PCH
HDA Intel PCH, ALC1150 Analog
Default Audio Device
sysdefault:CARD=PCH
HDA Intel PCH, ALC1150 Analog
Default Audio Device
front:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Front speakers
surround21:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Digital
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Direct sample mixing device
dmix:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Direct sample snooping device
dsnoop:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Direct sample snooping device
hw:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Direct hardware device without any conversions
hw:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Hardware device with all software conversions
plughw:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Hardware device with all software conversions
usbstream:CARD=PCH
HDA Intel PCH
USB Stream Output
hdmi:CARD=NVidia,DEV=0
HDA NVidia, HDMI 0
HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
HDA NVidia, HDMI 1
HDMI Audio Output
hdmi:CARD=NVidia,DEV=2
HDA NVidia, HDMI 2
HDMI Audio Output
hdmi:CARD=NVidia,DEV=3
HDA NVidia, HDMI 3
HDMI Audio Output
dmix:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct sample mixing device
dmix:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct sample mixing device
dmix:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Direct sample mixing device
dmix:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Direct sample mixing device
dsnoop:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct sample snooping device
dsnoop:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct sample snooping device
dsnoop:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Direct sample snooping device
dsnoop:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Direct sample snooping device
hw:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct hardware device without any conversions
hw:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct hardware device without any conversions
hw:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Direct hardware device without any conversions
hw:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Direct hardware device without any conversions
plughw:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Hardware device with all software conversions
plughw:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Hardware device with all software conversions
plughw:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Hardware device with all software conversions
plughw:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Hardware device with all software conversions
usbstream:CARD=NVidia
HDA NVidia
USB Stream Output
tomaszg
Wed, 2019-10-30 10:22
Permalink
You need to add quotes around
You need to add quotes around value, i.e. ALSADevice="hw:CARD=NVidia,DEV=7".
Dany Gee
Wed, 2019-10-30 11:13
Permalink
Still no-go
Adding quotes seems not to help much.
Now I get:
mocp
Running the server...
Trying ALSA...
Trying JACK...
Trying OSS...
FATAL_ERROR: No valid sound driver!
FATAL_ERROR: Server exited!
But here is something strange...
When trying "default:CARD=PCH" - i get FATAL_ERROR: No valid sound driver!
When trying "default" it works, and plays through headphones.
Looks like all we need is to find the correct HDMI/Nvidia device alias/name that is perhaps one word?
Dany Gee
Wed, 2019-10-30 11:35
Permalink
Logically...
Speaker test properly plays for hw:0 = headphones and hw:1,7 = HDMI.
MOC properly plays for hw:0 = headphones and does not play for hw:1,7.
What can be the cause here?
Dany Gee
Wed, 2019-10-30 12:29
Permalink
Debug output for MOC with hw:1,7
Oct 30 13:28:28.103448: alsa.c:477 alsa_init(): Initialising ALSA device: hw:1,7
Oct 30 13:28:28.103970: alsa.c:157 alsa_log_cb(): ALSA said: Unknown parameter 1
Oct 30 13:28:28.103982: alsa.c:157 alsa_log_cb(): ALSA said: Parse arguments error: No such file or directory
Oct 30 13:28:28.103986: alsa.c:157 alsa_log_cb(): ALSA said: Invalid CTL hw:1,7
Oct 30 13:28:28.103992: alsa.c:415 alsa_open_mixer(): ERROR: Can't attach mixer: No such file or directory
Oct 30 13:28:28.103994: server.c:672 add_event_all(): No events have been added because there are no clients
jcf
Fri, 2019-11-08 02:37
Permalink
ALSA Device Name Matching
The issue here is how to tell MOC the ALSA output device to which to direct the audio.
ALSA's device naming has never been entirely clear to me either, but I can report the following for my system to see if you can apply it to yours.
On my system there are two sound cards:
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Audio [C-Media USB Audio], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: SB [HDA ATI SB], device 0: ID 892 Analog [ID 892 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: SB [HDA ATI SB], device 1: ID 892 Digital [ID 892 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
Then we get:
# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=Audio
C-Media USB Audio, USB Audio
Default Audio Device
front:CARD=Audio,DEV=0
C-Media USB Audio, USB Audio
Front speakers
...
default:CARD=SB
HDA ATI SB, ID 892 Analog
Default Audio Device
front:CARD=SB,DEV=0
HDA ATI SB, ID 892 Analog
Front speakers
...
iec958:CARD=SB,DEV=0
HDA ATI SB, ID 892 Digital
IEC958 (S/PDIF) Digital Audio Output
(I've removed the plethora of other devices which follow two
front
devices.)Running these commands work as expected on the first device speakers:
AUDIODEV=hw:0 play x.wav
aplay -D hw:0 aplay x.wav
AUDIODEV=default play x.wav
aplay -D default aplay x.wav
AUDIODEV=default:CARD=Audio play x.wav
aplay -D default:CARD=Audio aplay x.wav
And these as expected on the second device speakers:
AUDIODEV=hw:1 play x.wav
aplay -D hw:1 play x.wav
AUDIODEV=default:CARD=1 play x.wav
aplay -D default:CARD=1 play x.wav
AUDIODEV=default:CARD=SB play x.wav
aplay -D default:CARD=SB play x.wav
These do not work:
AUDIODEV=default:CARD=SB,DEV=0 play x.wav
aplay -D default:CARD=SB,DEV=0 play x.wav
The only ones which work as the
ALSADevice
setting for MOC arehw:0
,hw:1
anddefault
. But the direct hardware devices do not support volume control.So, MOC should accept the likes of
default:CARD=SB
but doesn't. More precisely, ALSA does not accept it when MOC passes that to it, but it obviously does when eitheraplay
(1) orplay
(1) do.I have a hypothesis as to why that is so, but if it were true then MOC would not be able to play even on the
default
device. It has to do with the order in which the MOC code does things, but for it to work withdefault
it would mean that ALSA always keeps that device open, and I don't know if that is the case or not.So, that's where we are at. If you can apply the above to your situation then you may have a solution (albeit not a very good one). MOC should be able to use the more explicit device names and it will need to be pursued further.
Or, if you are brave enough to tackle ALSA configuration files, you could create a simply named device in your
~/.asoundrc
file and which maps to the actual headphones device (possibly via an appropriate mixer to get volume control) and see if that works.tomaszg
Fri, 2019-11-08 11:33
Permalink
> So, MOC should accept the
> So, MOC should accept the likes of default:CARD=SB but doesn't.
At least in one case it did accept it for me. However I run a modified version of MOC and I would have to check with vanilla and see what happens.
jcf
Fri, 2019-11-08 19:19
Permalink
It's Not MOC, Actually
As I indicated, it's actually ALSA which is rejecting it. If you can reproduce your success, that might tell us something.
tomaszg
Fri, 2019-11-08 20:44
Permalink
I have now two machines which
I have now two machines which run with similar devices. In one case it is AlsaDevice="iec958:CARD=Generic_1,DEV=0", in the other: AlsaDevice= "default:CARD=PCH". Surprisingly in the second case I see in the log:
Trying ALSA...
Nov 8 21:36:45.875418: alsa.c:550 alsa_init(): Initialising ALSA device: default:CARD=PCH
Nov 8 21:36:45.876359: alsa.c:213 alsa_log_cb(): ALSA said: Unknown parameters CARD=PCH
Nov 8 21:36:45.876370: alsa.c:213 alsa_log_cb(): ALSA said: Invalid CTL default:CARD=PCH
Nov 8 21:36:45.876383: alsa.c:490 alsa_open_mixer(): ERROR: Can't attach mixer: Invalid argument
Nov 8 21:36:45.876388: server.c:677 add_event_all(): No events have been added because there are no clients
Nov 8 21:36:45.899212: audio.c:1070 print_output_capabilities(): Sound driver capabilities: channels 1 - 10000, sample rate 48000 - 48000, formats: 8-bit signed, 8-bit unsigned, 16-bit signed, 16-bit unsigned, 24-bit signed (as 32-bit samples), 24-bit unsigned (as 32-bit samples), 24-bit signed (in 3bytes format), 24-bit unsigned (in 3bytes format), 32-bit signed, 32-bit unsigned little-endian (native)
but it does work! Without setting ALSAdevice option (and with no .asoundrc) I get a fatal:
Nov 8 21:39:24.016295: alsa.c:550 alsa_init(): Initialising ALSA device: default
Nov 8 21:39:24.017360: alsa.c:430 alsa_init_mixer_channel(): ERROR: Can't find mixer PCM
Nov 8 21:39:24.017378: server.c:677 add_event_all(): No events have been added because there are no clients
Nov 8 21:39:24.017387: alsa.c:430 alsa_init_mixer_channel(): ERROR: Can't find mixer Master
Nov 8 21:39:24.017392: server.c:677 add_event_all(): No events have been added because there are no clients
Nov 8 21:39:24.019886: alsa.c:213 alsa_log_cb(): ALSA said: unable to open slave
Nov 8 21:39:24.020011: alsa.c:228 alsa_open_device(): ERROR: Can't open audio: No such file or directory
Nov 8 21:39:24.020021: server.c:677 add_event_all(): No events have been added because there are no clients
FATAL_ERROR: No valid sound driver!
If I use asoundrc to change the default, I get the sound in both cases (with or without Alsadevice option).
In the case of the first machine, I see similar behaviour in the log, but it is further complicated, probably due to the fact that it uses digital output. In that instance, MOC starts without ALSADevice option, but is unable to play anything (skips through all tracks).
tomaszg
Fri, 2019-11-08 21:42
Permalink
I compiled a vanilla MOC and
I compiled a vanilla MOC and it seems it is broken ;) My success immediately turned into defeat - I get:
Nov 8 22:40:04.140026: alsa.c:477 alsa_init(): Initialising ALSA device: default:CARD=PCH
Nov 8 22:40:04.148947: alsa.c:157 alsa_log_cb(): ALSA said: Unknown parameters CARD=PCH
Nov 8 22:40:04.149097: alsa.c:157 alsa_log_cb(): ALSA said: Invalid CTL default:CARD=PCH
Nov 8 22:40:04.149177: alsa.c:415 alsa_open_mixer(): ERROR: Can't attach mixer: Invalid argument
Nov 8 22:40:04.149208: server.c:672 add_event_all(): No events have been added because there are no clients
FATAL_ERROR: No valid sound driver!
jcf
Sat, 2019-11-09 08:38
Permalink
It's All A Mystery
There's something we're just not understanding about what the ALSA naming means and how it should be used. I have in the past looked for a good explanation of this but without success.
tomaszg
Sat, 2019-11-09 09:48
Permalink
It's not exactly problem with
It's not exactly problem with naming as it works for my fork. Seems the important difference in the codebase is that my fork allows for no mixer channel: https://gitlab.com/tomaszg/mocp/commit/7da9a2af6bacb57aaac05f6c4a4b3d669e998499 I was able to make mainline MOC to run with my ALSADevice setting by applying this commit and commenting out some asserts. Seems we might need to change mixer channels as well to make them work with other devices.
Still it is interesting why does ALSA report it doesn't understand the option while it apparently does (it does play correctly!).
jcf
Sat, 2019-11-09 08:40
Permalink
Have We Seen This Before?
Do you think that might be related to any of these posts?
tomaszg
Sat, 2019-11-09 09:50
Permalink
No, it doesn't play anything.
No, it doesn't play anything. MOC attempts to play the file, fails and moves on to the next one. I didn't debug it further as it seemed to be caused by deliberate misconfiguration on my part.