Final Platform Layer»Blog

Fighting with Audio/ALSA Playback

For quite some time now, i am fighting with the ALSA output driver in FPL.
I dont know why but for some unknown reason my logitech blutooth headset wont produce any sound in FPL in combination with ALSA output on linux at all. All the parameters looks totally legit, but when i call snd_pcm_writei() i dont hear anything at all - just 100% silence.

Now here comes the weird thing:
The library "mini_al.h" (which is btw the best audio output library), totally works fine for the same audio device, with ALSA as a backend, the same sample rate, same format, same everything.

I even compared every little call and parameters from FPL against mini_al.h and i dont see any major difference.
Weirdly enough, the initial sound system of FPL is a direct port from mini_al.h based on a very old version with removed conversions/dsp/os-calls limited to only alsa and dsound. Even after migrating all the major changes from mini_al.h snd_pcm_writei() is still playing silence.

So my next plan is to compare every single byte of the written samples against the working mini_al.h one. If all the parameters are correct and all calls are the same - thats the only thing i can think of.
I have no idea why, but the problem is gone after changing the audio device from headset to speaker to headset again. No code change. ALSA is weird. Need to include pulse audio in the future.