Xcode keeps pausing my music

2020-07-06 02:55发布

问题:

First of all i know this is a programming forums, but my problem concerns Xcode and the problem happens with me while CODING.

When i use Xcode, when it is stopped in breakpoints while debugging the sound of the music played ( in my Mac music player ) is gone !!! i know this is awkward but it happens. Does any one has a solution or at least a reason for this?

After googling this problem i just found one case talking about the same problem here in this Link

I'm not using Spotify like the case in the link i'm using another music player called Vox

I have changed Vox and changed it with Deezer and it has the same problem

Update 1

As mentioned in the Accepted Answer, This problem only happened while using Cocos2dx in Xcode, When i returned back to the use Xcode with just iOS sdk without the Cocos2dx this problem doesn't exist any more.

回答1:

I had the same issue and I figured it had something to do with CocosDenshion. Do you use it? If so, try to not create a CDSoundEngine. Does it fix the issue? You could create it only in your release build.



回答2:

This is happening when your capture audio session in your application and debug something.

The case to reproduce this using Xcode + simulator (on device you will have phone's audio session, so it can not be reproduced with the following snippet). Sometimes it stops just after breakpoint occurs, sometimes - after about a minute (i think, session expires after that time, or something like that)

Create empty project and override didFinishLaunchingWithOptions

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

   NSError *setCategoryError = nil;
   [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
   if (setCategoryError) // set breakpoint here
    NSLog(@"Error setting category! %@", setCategoryError);
     return YES;
}

I think, on breakpoint session somehow stops music playing. so - check your project for the code, which manipulates with audio session (AVAudioSession). Hope, this helps.



回答3:

Had the same problem, super annoying.

Fixed it by routing sound through soundflower.

https://github.com/mLupine/SoundflowerBed/releases

Then install soundflower bed:

https://github.com/mattingalls/Soundflower/releases/tag/2.0b2

Look for the soundflower icon in your menu bar on the right, select your output device of choice, then go to your sound options and select soundflower as the output.

Hope that helps!



回答4:

The Simulator is the iOS/watchOS/tvOS user space running on the host mac kernel, so it shares its audio subsystem with the mac. When stopped in the debugger none of the audio callbacks can be serviced. I suspect this happens when you have an active audio session with active callbacks.

Please file a bug at https://bugreport.apple.com and provide a sample project if you can.



标签: xcode