Failed to open audio each time when I try running it.
Failed to load ../music/azogs_march_2.ogg, error Module format not recognized
/* gcc SDL_PlayMusic.c `sdl-config --cflags --libs` -lSDL_mixer -o player */ #include "stdlib.h" #include "SDL/SDL.h" #include "SDL/SDL_mixer.h" int musicPlaying = 0; //Is the music playing, or not? void musicFinished() { //Music is done! musicPlaying = 0; } int main(int argc, char *argv[]) { if (argc<2) { printf("Give the filename (wav/ogg/mp3/mid) \n"); return 1; } Mix_Music *music; //Pointer to our music, in memory int audio_rate = 22050; //Frequency of audio playback Uint16 audio_format = AUDIO_S16SYS; //Format of the audio we're playing int audio_channels = 2; //2 channels = stereo int audio_buffers = 4096; //Size of the audio buffers in memory //Initialize SDL audio if (SDL_Init(SDL_INIT_AUDIO) != 0) { printf("Unable to initialize SDL: %s\n", SDL_GetError()); return 1; } //Initialize SDL_mixer with our chosen audio settings if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) { printf("Unable to initialize audio: %s\n", Mix_GetError()); return 1; } music = Mix_LoadMUS(argv[1]); if(music == NULL) { printf("Unable to load music file: %s\n", Mix_GetError()); return 1; } //Play music! if(Mix_PlayMusic(music, 0) == -1) { printf("Unable to play music file: %s\n", Mix_GetError()); return 1; } //The music is playing! musicPlaying = 1; //Make sure that the musicFinished() function is called when the music stops playing Mix_HookMusicFinished(musicFinished); //Wait for the music to stop while(musicPlaying) { //Do nothing for a bit SDL_Delay(100); } //Release the memory allocated to our music Mix_HaltMusic(); Mix_FreeMusic(music); //Need to make sure that SDL_mixer and SDL have a chance to clean up Mix_CloseAudio(); SDL_Quit(); //Return success! return 0; }