When mixing with others using AVAudioSession I have terrible sounds quality for others sounds

Viewed 783

I basically setup a session with play and record and mix with others option to keep underlying ipod keep on playing while my app runs.

It mostly works but I get two issues: 1) the ipod sound sounds terrible when mixed; 2) I've got glitches in sounds when my app set the session before playing sound.

Any idea why? Here is my code:

    NSError *error = NULL;
    BOOL     success;

    AVAudioSession *session = [AVAudioSession sharedInstance];

    success = [session setActive:NO error:&error];
    if (!success){
        NSLog(@"startAudioMixAndBackground: session setActive:NO, %@", error.description);
    }


     AVAudioSessionCategoryOptions options = AVAudioSessionCategoryOptionAllowBluetooth
        |AVAudioSessionCategoryOptionMixWithOthers;

    success = [session setCategory:AVAudioSessionCategoryPlayAndRecord
                        withOptions: options
                             error: &error];
    if (error) {
        // Do some error handling
        NSLog(@"startAudioMixAndBackground: setCategory:AVAudioSessionCategoryPlayback, %@", error.description);
    }

    //activate the audio session
    success = [session setActive:YES error:&error];
0 Answers
Related