We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2569

Summary: All sound is permanently disabled after receiving phone call.
Product: SDL_mixer Reporter: Diego <diegoacevedo91>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72
Version: 2.0.0   
Hardware: iPhone/iPod touch   
OS: iOS (All)   

Description Diego 2014-06-03 15:52:50 UTC
When music or channels are playing sound and a phone call is received, all sound is then permanently disabled. An app restart is required to restart the sound (or maybe just a Mix_CloseAudio and Mix_OpenAudio, this was untested).
The error is reproduced when a phone call is received while running the following code on an iPhone 4S running iOS 7.1.1 and an iPhone 5C running 7.0.4.

////CODE
#include "SDL.h"
#include "SDL_mixer.h"

#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 480

int main(int argc, char *argv[]) {

    SDL_Window *window;
    SDL_Renderer *renderer;
    int done;
    SDL_Event event;

    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        printf("Could not initialize SDL\n");
        return 1;
    }
    
    if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) < 0)
        printf("Unable to init audio: %s\n", Mix_GetError());
    
    Mix_Music *music = Mix_LoadMUS("music.wav");

    window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL);
    renderer = SDL_CreateRenderer(window, -1, 0);

    done = 0;
    while (!done) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                done = 1;
            }
        }
        
        SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
        SDL_RenderClear(renderer);
        SDL_RenderPresent(renderer);
        
        Mix_PlayMusic(music,0);
        SDL_Delay(3000);

    }

    SDL_Quit();

    return 0;
}
Comment 1 Diego 2015-02-21 23:30:17 UTC
A Mix_CloseAudio and Mix_OpenAudio does allow the sound to restart.
Comment 2 Alex Szpakowski 2016-09-18 22:22:53 UTC
This should be fixed as of https://hg.libsdl.org/SDL/rev/e9c3e64fdc84
Comment 3 Diego 2016-11-30 19:12:24 UTC
Works great! Thanks!