- Michael J. Hammel - https://www.graphics-muse.org/wp -

PiBox: bluetooth for video means no omxplayer

One of the longterm goals for pibox [1] is to integrate it into the home.  I want to see the PiBox Server provide centralized communication for an array of iot [2] devices.  One way to do this is with Bluetooth Low-Energy, aka BLE, aka Bluetooth 4.0.  This specification allows very low power sensors to report information to services that can do something useful with the information:  close the shades when the temperature goes up, let the roomba loose when the dog's sheddings are accumulating, turn off the stove when granny forgets to take her meds.

Before I can do this I needed to get bluetooth classic working on the server.  This turned out to be fairly easy.  The kernel [3] supports it and there is the BlueZ userspace tools, plus the bluez-tools wrappers to make it even easier.  After much procrastination I finally got around to testing these on a server with a 4.0-compatible USB dongle.  After a little fiddling with the /etc/bluetooth/audio.conf and /etc/asound.conf files I was able to play a simple wav file to a bluetooth speaker.  Easy-peazy.

The next logical step was to get omxplayer, the hardware-accelerated video [4] player for the raspberry pi [5] that I use to play videos full screen, to switch from the analog output to ALSA.  Turns out this can't be done, or at least it isn't done yet.  omxplayer doesn't support ALSA.  So you can't play the audio stream from a video over bluetooth.  So much for my drive-in movie with wireless speakers.  I looked at what might be required for this (there were hints from the omxplayer developers) but it seems a bit over my head and would distract from the larger scale goals for the project.  I'm a one man team.  There's only so much time in a year.

So I've started banging my head for alternatives.  The obvious one is to plug an analog-to-bluetooth transmitter into the analog output port of the Pi.  Too easy.  Though I have one on order for the short term (hey, we still use it when we go camping).  But that would also require a larger box to hide the transmitter.  And how do I switch between bluetooth and analog output?  I may not always want bluetooth.  Nah, I'm just kidding.  Everyone loves bluetooth.

Another alternative is to switch to a different video player [6], like mplayer [7].  That would get me a software switchable option for audio output.  I tried this on a Model B+ but the performance was terrible since the GPU isn't used.  First, to get a nearly smooth playback the image had to be halved while being decoded on the CPU.  And there was no way to rescale it to the display size at display time.  So this was functionally unusable.

The next alternative (this is computing and there is ALWAYS another alternative) is to switch boards.  I looked at several competitors like BananaPi an Odroid.  The former looks like a possibility.  But then I took another look at the newest version of the Pi, the Raspberry Pi 2 Model B.  It's a quad-core with each core spec'd at 1GHz, slightly more than the original Pi's 900MHz.  Not to mention the possibility of overclocking and additional on-board memory.   So mplayer, which does work with ALSA but which requires the CPU to do the decoding, might just work on this board.

So I placed an order for one Pi 2 which has a slightly different Broadcom chip.  I've already rebuilt the toolchain [8] for this new chip.  That's an adventure in itself, but fortunately doesn't appear to require major changes to the toolchain.  I'm unclear if I have the toolchain optimized.  It doesn't use the latest linaro [9] gcc [10] releases so I'm doubting it.  But if my toolchain shows any possibility of running mplayer then I can always upgrade my crosstool [11]-NG release to get access to the latest Linaro bits.