There is hardware that can reroute its output back to some capture device, but most sound devices do not support this.
You could load the snd-aloop driver and create a virtual device using the multi plugin to route the output to both the actual device and the loopback device, but it is likely that the sample clocks of the two devices will diverge if they are running for too long.
I would recommend to create a virtual device using the file plugin to copy the data to your application through a pipe.
Put something like the following into /etc/asound.conf
or into your ~/.asoundrc
:
pcm.mydevice {
type plug
slave.pcm {
type file
slave.pcm "hw:0,0" # or whatever your actual output device is
file "|/some/where/myapplication"
}
}
and tell the other applications to use ALSA device mydevice
.