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 - All sound is permanently disabled after receiving phone call.
Summary: All sound is permanently disabled after receiving phone call.
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.0
Hardware: iPhone/iPod touch iOS (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-03 15:52 UTC by Diego
Modified: 2016-11-30 19:12 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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!