Page 1 of 2

USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 30 Dec 2017, 15:09
by sonycman
Hello!
I've got a Raspberry PI 3 B and facing a no sound issue with RuneAudio.
Tried both RuneAudio_rpi2_rp3_0.4-beta_20160321 and RuneAudio_rpi2_rp3_0.4-beta_20170229 images.

Runeaudio sees my Parasound USB DAC just as normal and it is selected in the WebUI.
But when I'am trying to playback the music time progress indication freezes at zero and there is no sound output from the DAC.

Debug information here and attached also.

I've managed to bypass this problem myself.
There is wrongfully set option in the mpd.conf file:
device "hw:0," <- no subdevice number at all

So I changed it to:
device "hw:0,0"
and protect the file from modification on reboot by using chattr +i command.

Now my DAC plays fine and sound is just great!

This is only a temporary solution and I wish you guys correct it the right way when you can.

Thanks for otherwise great sound system!
Regards,
Vladimir.

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 02 Jan 2018, 15:05
by sonycman
Frank, can you tell me, please, which application writes to mpd.conf at each boot?
If you can't emulate this bug youself I could try to dig deeply on my side...

Regards,
Vlad

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 02 Jan 2018, 21:41
by hondagx35
Hi Vlad,

Frank, can you tell me, please, which application writes to mpd.conf at each boot?

see here:
https://github.com/hondagx35/RuneUI/blob/0.4b/app/libs/runeaudio.php#L2238

Frank

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 02 Jan 2018, 23:35
by sonycman
Hi Frank.

Thanks for the hint!
Would you, please, show me how to enable debug function runelog and how to take a look at its output?

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 03 Jan 2018, 02:43
by sonycman
Hello!

I got some progress!
Line 1972 of the file runeaudio.php, original contents:
Code: Select all
$description = sysCmd("aplay -l -v | grep \"\[".$card."\]\"");


This script extracts the audio card device number.
But in my case, when I`am trying to execute it in the raspberry`s console - grep part did`nt filter out extra output and the wrong data being captured for further processing.

Output of the console with the original script code:
Code: Select all
 aplay -l -v | grep "[PARASOUND]"
**** List of PLAYBACK Hardware Devices ****
card 0: Audio [PARASOUND - Digital Audio], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

grep does not worked at all, device number has been lost.

Then I just removed square brackets from the script, and now its worked:
Code: Select all
  aplay -l -v | grep "PARASOUND"
card 0: Audio [PARASOUND - Digital Audio], device 0: USB Audio [USB Audio]

garbage has been filtered out, device number retrieved as intended.

So in short, I'am edited the line 1972 like this:
Code: Select all
$description = sysCmd("aplay -l -v | grep \"".$card."\"");

and it solves my problem! No more messing with write protection and settings are working too!

Regards,
Vlad.

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 11 Jan 2018, 11:56
by janui
Hi Vlad,
This is a reply to this post: runeaudio-0-4-beta-for-raspberry-pi2-3-t4434-420.html#p24169
Looks like you have identified the problem, not so sure about your solution. The code looks like it is expecting the full name of the sound card 'PARASOUND - Digital Audio' and this should be stored in the variable '$card'. It also looks like the contents of '$card' have been truncated to the first space. I would suggest that a better solution would be to make sure '$card' contains the complete name of the sound card. It will then be consistent with any other places in the code where it is used. The real problem is that the name of your dac contains the string ' - ' which is used as a delimiter when determining ‘$card’. So it goes wrong in the line '$card = explode(' - ', $card);'. I have a feeling that this will work:
Code: Select all
$card = explode(' - ', $card, 2);

I do not have a USB DAC to test this. Let me know if it works.
janui

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 11 Jan 2018, 15:35
by sonycman
Thanks, janui, I'll test it as soon as I can.

Just curious, why the authors did added these brackets at all?
Is these brackets are really necessary there?

Square bracket is a special character and needs extra care when using it.
Most probably they are used incorrect syntax and now we have the issue here.

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 11 Jan 2018, 17:05
by janui
Hi sonycman,
Some smart guys built Rune. I expect that the square brackets are needed for something.
janui

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 11 Jan 2018, 20:32
by sonycman
Hi janui,
[ ] is a special character in the regular expression, it is used to denote a range.
And a special escape sequence should be used to pass these brackets as an ordinary literal character to the "grep" command.
The code in .php file does not specify any range while searching for a sound card name, it looking for a constant text string.

So meaning of the brackets here is beyond my understanding, and instead of attempting to escape them correctly would'nt it be easier to just delete them both?

I'll see what I can get and will report later...

Re: USB DAC incorrectly set in mpd.conf (NO SOUND)

PostPosted: 11 Jan 2018, 23:57
by sonycman
Hello, janui!

Finally I got debug output enabled so now I can see exactly what is happening inside!
So my DAC has the following description string (output of cat /proc/asound/cards | grep : | cut -b 1-3,21-):
Code: Select all
 0 : USB-Audio - PARASOUND - Digital Audio

and after explode and trim commands in original code it turns to:
Code: Select all
aplay -l -v | grep "\[PARASOUND\]"

brackets correctly escaped with backslashes, but because the output of (aplay -l -v) is:
Code: Select all
card 0: Audio [PARASOUND - Digital Audio], device 0: USB Audio [USB Audio]

grep command couldn't find [PARASOUND] (there is no second closing bracket in the above text) and produces zero output, which leads to erratic behavior and subdevice number in hw:0,0 gone missing.

I got fixed this by deleting the square brackets completely, in that case the "grep" worked out fine by locating the partial name PARASOUND.

Your suggestion is worked too, by extending the card name to PARASOUND - Digital Audio, it matches perfectly with the brackets in aplay output!
Thanks again, janui.

So now we have at least two ways to go to fix this issue.
Please, devs, include this fix into your next build!

Regards,
Vlad.