Is it possible to have multiple audio outputs? Pi3

I have made changes to my system to accomodate my specific needs using stuff I’ve found on forums and somehow got it all to work, without really understanding HOW it works.
What it does is it creates an audio loopback output for streaming. It works perfectly, but what I am wanting (hoping) to do is to have kodi ALSO send audio to the analog output (the 3.5mm jack).

To get it working, I had to, as root:

nano ~/.asoundrc

And add this:

pcm.multi {
type route;
slave.pcm {
type multi;
slaves.a.pcm “output”;
slaves.b.pcm “loopin”;
slaves.a.channels 2;
slaves.b.channels 2;
bindings.0.slave a;
bindings.0.channel 0;
bindings.1.slave a;
bindings.1.channel 1;
bindings.2.slave b;
bindings.2.channel 0;
bindings.3.slave b;
bindings.3.channel 1;
}

ttable.0.0 1;
ttable.1.1 1;
ttable.0.2 1;
ttable.1.3 1;

}

pcm.!default {
type plug
slave.pcm “multi”
}

pcm.output {
type hw
card ALSA
}

pcm.loopin {
type plug
slave.pcm “plughw:Loopback,0,0”
}

pcm.loopout {
type plug
slave.pcm “plughw:Loopback,1,0”
}

That gives me ALSA: Loopback(loopin), LOOPBACK PCM in Kodi’s audio section
Is there something I can add to this (or somewhere else) that will also pipe the audio to the 3.5mm jack? Similar to how you can select HDMI and Analog audio together in Kodi. Or any other way, really.

One other thing that might be relevant. I am running 17.6 Dec 31 2018 and I can’t upgrade.

I’ve been looking into this since the option to have HDMI and analogue at the same time disappeared. On 19.3 it’s not easy. On 17.6 you should just be able to add two more channels to your multi pcm, but I haven’t found time to fire up 17.6 to see what the slave would be for analogue.

So how would I find what those lines would be?

Did you check that thread here?

The solution seems to be very simple.

I don’t think it’s possible. On versions previous to Kodi 19, output can be directed to the chip direct, which supports both HDMI and analogue, or through ALSA, but there’s no ALSA driver for the analogue output. So if you are using ALSA, you can’t use the analogue jack.

Your link is to a thread on V19. The OP is on 17.6 which is different.

Does that include HDMI? I could make HDMI audio work if that is possible/easier. The HDMI audio passthrough setting doesn’t work.

I thought you already had HDMI output in parallel with your loopback device. There must be something I’m missing, here.

Can you post debug logs, please, and clarify if you get any sound locally.

I would love to post the debug logs, but I am not sure how to do that. I’m sorry, I thought I was clear. When I add the above to asoundrc, it gives me a loopback audio, which I can select in Kodi as the default audio device. But no other local audio. Not through the 3.5mm jack or through HDMI. This is an internet radio station, which works perfectly. But I need a way to pipe the same audio stream through another (3.5 jack or HDMI) output, which feeds the FM transmitter I have. Currently I have to use a second Pi to feed the FM transmitter. If I could get the audio to also come through the analog or HDMI, then I would only need one Pi. There are a whole list of things it would improve by doing this.

Gotit. The .asoundrc you posted should in theory achieve what you want. I thought you had HDMI output already and just wanted to add analogue. There must be a ‘mistake’ in that file. ALSA is very finicky. What I notice so far:

  • it should not be necessary to make the file as root - that may be counter-productive
  • the bit that starts pcm.!default - I don’t think that has any effect
  • I suspect you need a plug plug-in for the HDMI output to make sure it receives the right type of signal

… but I guess you are not seeing ‘multi’ then, or ‘output’ in that menu?

For debug logs, so we can confirm my diagnosis:

To get a better understanding of the problem you are experiencing we need more information from you. The best way to get this information is for you to upload logs that demonstrate your problem. You can learn more about how to submit a useful support request here.

Depending on the used skin you have to set the settings-level to standard or higher, in summary:

  • enable debug logging at settings->system->logging

  • reboot the OSMC device twice(!)

  • reproduce the issue

  • upload the log set (all configs and logs!) either using the Log Uploader method within the My OSMC menu in the GUI or the ssh method invoking command grab-logs -A

  • publish the provided URL from the log set upload, here

Thanks for your understanding. We hope that we can help you get up and running again shortly.

OSMC skin screenshot:

I’ll fire up a Pi with Kodi 18 and see if I can quickly make something that works on that.

That would be amazing. But if possible, you might want 17.6 instead of 18. I don’t know how much different it is, but I’m on 17.6 and can’t upgrade.

Should be the same. But I’m struggling here and the next 48 hrs is going to be a bit busy, I’m afraid.

This is where I got to:

osmc@pi2:~$ cat .asoundrc
pcm.multi {
type plug
        slave.pcm {
        type route;
        slave.pcm {
                type multi;
                slaves.a.pcm "output";
                slaves.b.pcm "loopin";
                slaves.a.channels 2;
                slaves.b.channels 2;
                bindings.0.slave a;
                bindings.0.channel 0;
                bindings.1.slave a;
                bindings.1.channel 1;
                bindings.2.slave b;
                bindings.2.channel 0;
                bindings.3.slave b;
                bindings.3.channel 1;
        }

        ttable.0.0 1;
        ttable.1.1 1;
        ttable.0.2 1;
        ttable.1.3 1;

}
}

pcm.!default {
type plug
slave.pcm "multi"
}

pcm.output {
type plug
slave.pcm "hw:CARD=ALSA,DEV=0"
}

pcm.loopin {
type plug
slave.pcm "plughw:Loopback,0,0"
}

pcm.loopout {
type plug
slave.pcm "plughw:Loopback,1,0"
}

The trick is to try each ‘pcm’ from the bottom up with

speaker-test -c2 -t wav -l3 -Doutput

It seems to work with -Dloopin but gives errors with -Dmulti.

I’ve been trying to get this working for years. So anytime you have a minute. And I appreciate your help. I will still upload the debug logs if you’d like, but it’s not really malfunctioning. I’m just trying to add another pipe. But if they will help, I will.

I even tried a command line web player to play the ‘stream’ to the soundcard but couldn’t get that to work either.

Yeah, no need for the logs as I can reproduce here (sort of).

Actually, although multi doesn’t work for speaker-test it does show up in Kodi. So try it.

Through SSH (bash: speaker-test: command not found) or somewhere in Kodi? Addon?

You would need to sudo apt-get install alsa-utils.

But did you try my version, anyway? Change your .asoundrc like that and Power->Exit to restart Kodi.

I haven’t got anything to attach to the loopout device.

I’m sorry. I didn’t see that edit. Trying now.

No change.

did (multi) not show up?

It did. (ALSA: bcm2835 ALSA (multi), bcm2835 ALSA) And I have selected it but now I don’t get audio from anywhere.

Oh dear. You did take my whole file, yes? (with the change to the “output” bit).

I get sound from HDMI and suppose the loopback must be working if I could remember how to test it.