1

I'm coding an app on my raspberry-pi 3 running on Ubuntu-MATE. I use C++ on code::blocks with SDL and SDL_Mixer to play mp3 files (I'm still using the v1.2 of the SDL libs).

I get no error when I init SDL, but when I init SDL_Mixer with this line :

Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 1, 1024)

It returns -1, so I get the error message with the Mix_GetError() method, and it gives me a "Can't setup PulseAudio stream" message.

I'm not aware of what PulseAudio is, so after some research I understood it's used for network streaming audio streams. Why this module is needed at the init of the lib, and is there a way to go around it ? I don't intend to use network features in my app.

Also, I checked with a "sudo apt-get install pulseaudio" to make sure I wasn't missing some libs, but my packet manager seems to indicate that I have the latest update...

Any clues would really help me a lot !

Thanks

G.Vernier
  • 369
  • 2
  • 14

1 Answers1

1

I finally resolved it myself... it was a fricking typo. I wrote 444100 instead of 44100 for the frequency init parameter :/

Everything now load correctly (for SDL, I just used SDL_INIT_EVERYTHING for the ones who asked). By the way, I only use SDL to use SDL_Mixer; I suppose SDL_Mixer can't run as standalone, so which module can I load in SDL to only init the basics ?

Also, now I'm curious : why does SDL_Mixer needs PulseAudio to init ?

Thanks

G.Vernier
  • 369
  • 2
  • 14
  • 1
    `SDL_INIT_AUDIO`. It have to output sound somewhere. On linux, usual core audio system is either ALSA or OSS (almost extinct now), but historically there is usually a 'sound daemon' that mixes sounds from multiple programs and dispatches it to ALSA. Nowadays this sound daemon is usually pulseaudio. You can ask SDL to outut directly to ALSA, but it may fail (e.g. pulseaudio already holding device exclusively). – keltar Apr 20 '16 at 11:14