I am needing to send audio through both HDMI and the 3.5 mm headphone jack simultaneously. I have not been able to find anything on this. Is this even possible?
Not comming up with a complete answer but some thoughts on that matter.
Let's have a look at the hardware side: schematics unfortunately not helpful for the Pi B+ and not even available for the Pi2, so we are stuck with B Rev 2.1 here for now.
The audio output of the headphone jack is generated by PWM. Right from the BCM2835's GPIO pins 40 and 45 through a RC Low-pass filter. (See schematics, page 2.)
Audio on the HDMI on the other hand is supposedly digitally transmitted. Wikipedia states: "For digital audio, if an HDMI device has audio, it is required to implement the baseline format: stereo (uncompressed) PCM." And indeed the before mentioned PWM-based analog audio is not feed to the HDMI connector.
So now we've verified some old news: analog headphones jack vs. digital HDMI. From my point of view those two should be addressed separately and independently thus also (quasi-)simultaneously. Now
PulseAudio should be able to stream from one source to multiple pieces of sound hardware. I still wonder why there's nothing to find on the web concerning this.
I would love to be able to do same thing as well. At least I try to contribute to this trend with some ideas hoping in eventual cooperative development.
What comes over my mind is, that there maybe could (and should) be two instances of driver module loaded in parallel, each for one signal route. However this would require some kernel module level parameters like in the ideal sample below, each creating one ALSA device (number 0 for HDMI and 3 for earphones in the sample). You then could send some sound to one and other to the other (or copy to both).
Tried to google for snd_bcm2835 module source code homepage (to evaluate feasibility of simple patch), but no luck (and time), so I gave up for now. If someone finds the source and contributes the link, I will look at that again.
NOTE !!! The following is only ideal sample of kernel module load commands. In actual Raspberry Pi software no such parameters (AFAIK) exists!
modprobe snd_bcm2835 out=hdmi alsa=0 modprobe snd_bcm2835 out=ear alsa=3