How to get audio into Asterisk over sound card?

I understand that if I want to send audio to an alsa sound card I can use chan_console.so and use the dial command e.g. dial(console/alsa) along with a properly configured console.conf file.

How about the other way?
How do I get audio from a sound card into Asterisk onto a channel?

If I recall there is a CLI command to “console dial” as if you were placing a call. Effectively because it’s a channel driver the same general thinking applies as if it were a phone.

Let’s say I have audio flowing into the Linux box on the alsa sound card, using console dial into the CLI would create a channel into Asterisk with that exact audio on it?
How does Asterisk distinguish between whether the console channel connects to the ALSA input or the output device?

I’ve always assumed that the soundcard channel drivers were there as code examples, rather than for serious production use. I doubt if anyone is maintaining them.

It doesn’t “connect” to one or the other. The chan_console acts like a phone and it’s best to think of it that way. Audio flowing from Asterisk to chan_console goes to the output device. Audio flowing from chan_console to Asterisk comes from the input device. Looking at the configuration file the devices can be configured in console.conf

To speak to @david551’s comment - these channel drivers (chan_console, chan_alsa, chan_oss) really haven’t been touched in considerable years and so knowledge is scarce for them really besides what is seen in the sample config and the code.

1 Like

So the way to think of it is if e.g. I dial into the console from dialplan with dial(console/alsa), it’s like I would be dialing a phone, where the audio flowing to the console would go to the output device and the audio flowing back comes from the input device?

Yes, that is correct. And the console dial is like you’re dialing from the phone.

So it’s like Asterisk is bridging a call between the console and the device that’s calling it or that is being called from it.

That is effectively what is happening yes. Outside of chan_console Asterisk has no idea, it’s treated the same as if it were a SIP call.