Audio will play in 3.2 sim but not in 4.x - iphone

This streaming audio app will play in 3.2 simulator, but not in 4.x sim or my 4.1 iPhone.
The console logs are as follows:
4.0 Sim
This GDB was configured as "x86_64-apple-darwin".Attaching to process 13237.
[Switching to process 13237]
2010-11-15 19:54:49.606 Issues[13237:1c07] AddRunningClient starting device on non-zero client count
2010-11-15 19:55:16.220 Issues[13237:6307] AQMEIO_Base::DoStartIO: timeout
2010-11-15 19:55:16.498 Issues[13237:6307] AQMEDevice::StartIO: error -66681
2010-11-15 19:55:16.499 Issues[13237:6307] CA_UISoundClientBase::StartPlaying: AddRunningClient failed (status = -66681).
2010-11-15 19:55:46.499 Issues[13237:1c07] AQMEIO_Base::DoStartIO: timeout
2010-11-15 19:55:46.777 Issues[13237:1c07] AQMEDevice::StartIO: error -66681
2010-11-15 19:55:46.778 Issues[13237:1c07] Audio queue start failed. err: ˇ˛˚á -66681
[Switching to process 13237]
4.1 Device
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
target remote-mobile /tmp/.XcodeGDBRemote-11399-40
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to thread 11523]
[Switching to thread 11523]
sharedlibrary apply-load-rules all
[Switching to thread 13059]
[Switching to thread 11523]

If it makes you feel better, I have had this exact problem for a couple weeks with no solution in sight. I think it occurred when I upgraded my ipad to 4.2 but I am not sure. I was still able to use the 3.2 simulator for my music app testing, but now I have been making my app universal and there is no way to test the iphone code on the simulator.
EDIT: I fixed it!!
The only other google search result for this error led me to poke around in my audio settings. I have a Blackmagic Intensity Pro HDMI capture card and it was set as my audio input device. I changed it to "Line in" or whatever, restarted my Mac, and then the simulator worked again!
I was also messing around with my audio output settings, so it's hard to know for sure what actually solved it, but the key is: mess around with your audio settings, restart your Mac and cross your fingers.
one more edit: I had this same problem occur with a webcam on my other, work computer. I changed the audio from the input of the web cam back to line in, and it worked again. How are more people not seeing this?

I had this problem, and fixed it by unplugging an external microphone which was hooked up via USB. Not sure why this fixed it, but it did.

I have the problem too, but i fixed it in some minutes, thank to Ethical. Although the problem is same, my code is different, my code supplie in the video player. My code run good in the ipad/iphone device, but not in simulator. When the video start playing, the simulator freezon, the output is like you, but i remember i plug in the earphone just now, and pull out some miniutes later, so the setting of audio player changed, i think. So, i plug in the earphone again and restart my mac. The problem solved. So just restart your mac, or check the setting of audio player.

+1 .... Checking and changing the Mac's audio input also worked for me. I had no sound in the simulator (Mac Pro) but my app worked fine on the device (iPad 3) calling
[[SimpleAudioEngine sharedEngine] playEffect:#"soundname.caf"];
In the sim, there was a long lag after first trying to play a sound (my app seemed to hang, with high CPU usage). After a long time it would give a AQMEIO_Base::DoStartIO: timeout error and the app would resume, albeit without sound. Happened every time I ran it.
The sound output was shown as line out, but sound input was set to digital. Changing the input to line in made sound work in the simulator.
There is still a cascade of warnings in the sim on startup, starting with:
Error loading
/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:
dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
and ending in
Default audio device changed. Restart the simulator to have it use the newly-selected device.
But sound now works and I can test the app using the simulator.

Try to play your audio on MPMovidePlayerController instead of MPMediaPlayer

Related

SwiftUI Preview turns on microphone

Does anyone know how to stop swiftUI previews from turning the microphone on? I wear bluetooth headphones while I work and every time a preview boots up it enables the mic. This degrades my audio quality since the headphones then split their bandwidth between playback and input.
My workaround has been to go into sound settings and just switch my default input to either my webcam or the macbook itself. It's so weird that the preview in xcode would turn on the mic every time it is enabled though.
Context: I have a MBP 2019 Xcode 12.4 Catalina
Thanks!
I've found that the Xcode Previews like to fuss around with the coreaudiod deamon, causing all sorts of issues (mics going on, audio stuttering, duplicated output). Try to manually kill all of those deamons from the terminal level. Apps that need this daemon to work should automatically restart needed deamon instances on their own, while Xcode won't do this.
sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`

Trying to play an audio file

I'm trying to play an audio file in a cocos2d application. Here is the line which tries to play the sound:
[[SimpleAudioEngine sharedEngine] playEffect:#"pig_squeal.wav"];
If I put a log near this line, the log appears, and I can play the sound with iTunes. But when the sound should be played, there is a message displayed:
AudioStreamBasicDescription: 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
What's the problem?
This was discussed in comments but I've amalgamated all the possibilities of why it may not work here.:
That's not an error message, just some information.
Is the sound definitely in your library and a part of the target?
You haven't changed the volume of the SimpleAudioEngine or the volume of your device isn't all the way down?
Click the sound in your library. Press Option+Command+1 to bring up the file editor. Scroll down to "Target Membership" and ensure the sound is checked for your target.
Try a different sound effect too? Try and narrow the problem down to "is it SimpleAudioEngine".
Also try and playBackgroundMusic for a sound (This was the solution in this case)
And try an mp3
There isn't a problem. It's a status message written to the log when you initialise the current OpenAL context using alcMakeContextCurrent. As far as I'm aware, you can't get rid of the message.
There is no problems with your code for the Playing of the Sound. Please check the Sound file has been added to the project also do check the format of the sound. It should play the Sound whenever you call the Play Effect. Please also try to PRELOAD the sound effect in the init method.
that message means the song was read correctly and should be playing. possible reasons you don't hear it?
volume turned down.
device malfunctioning
audio has silence in it
audio file is large and will take a long time to load.
sound has been redirect to come out of the headphones or the ear piece (even if not attached)
But the sound is loading and most likely playing.
If you are getting a crash while running in device from xcode pls try this(worked for me). Dissconnect the device from Xcode and run the app in the device. I dont know why it worked like that. But when I did this there was no crash.

Paypal iphone integration error

[PayPal initializeWithAppID:#"APP-80W284485P519543T" forEnvironment:ENV_SANDBOX];
UIButton *button = [[PayPal getInstance] getPayButtonWithTarget:self andAction:#selector(payWithPayPal) andButtonType:BUTTON_278x43];
Any one of line, If I am writting in my application's viewDidLoad or appDidFinishLauch, then it works fine on simulator, but while I do run it on iOS5 (iPod Touch) it gives the following error, and goes hang or crash...
Program received signal: “EXC_BAD_ACCESS”.
warning: check_safe_call: could not restore current frame
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Can't find dlopen function, so it is not possible to load shared libraries.)
What is meaning of this issue, and how to solve it?
NOTE: The issue is only in iOS5, in all other devices and simulators, its working fine,
I am using Mac OS 10.6 and SDK is 4.
Can anyone has issue like this, or know how to solve it?

iOS 5 Audio Alarms Don't Sound Without kAudioSessionProperty_OverrideCategoryMixWithOthers On

I have an audio app that is having some problems with the way iOS 5 has changed audio behaviors. When my app's audio is playing (AVAudioSessionCategoryPlayback), and a Clock.app alarm or timer is fired from the OS, the UIAlertView notification pops up, but without the audio alert. My application sound ducks fine to get out of the way of the audio alert, but the alarm app's audio alert does not sound.
Naturally, tons of support requests poured in over the iOS 5 change. I have solved this temporarily by setting kAudioSessionProperty_OverrideCategoryMixWithOthers which lets the alarm audio come through, but there are a few very undesirable side-effects when doing this:
Other app's audio can play with/over mine.
The remote control events are not routed to my app, but to iPod.app.
None of the above drawbacks are acceptable for my app's requirements. I have been hacking away at this for some time now but haven't been able to crack it. How can I setup my audio such that:
My app's audio still uses the AVAudioSessionCategoryPlayback category for background audio.
The Clock.app alarms still have their audio alerts make sound
The app still responds to remote control notifications
After writing this question I went to file a bug report on this. I created a small sample project that I thought would replicate the issue, but I could not replicate it! This caused me to dig in deep once again and try to figure out what was up here…
I fired up an iOS alarm, then I placed a break point in audioPlayerBeginInterruption: and traced through my code line by line in the debugger. I noticed that before my code ran (while I was paused in the debugger), the iOS 5 alarm was sounding! Luckily it still sounded even as I was stepping through my app, so I was able to figure out which pieces of code specifically caused it to stop sounding.
Part of my interruptionHandler is to (obviously) stop the internal audio of my app to let the interruption come through. I never thought to inspect this method before, but turns out the problem existed in there. My stop method would call prepareToPlay immediately after stopping to make resuming faster the next time.
[self.player stop];
[self.player prepareToPlay]; // <- iOS 5 alarm sound stopped here.
The docs state the prepareToPlay method
preloads buffers and acquires the audio hardware needed for playback, which minimizes the lag between calling the play method and the start of sound output.
Sounds reasonable, and this worked for lesser iOS versions. My hypothesis is that  must have made a change to the Clock.app alarm system such that the new alarm sounds use the hardware, whereas before it used the software. This is what I think is causing the iOS 5 alarms to be silent in some apps.
Removing the prepareToPlay lines caused the alarm to sound without using kAudioSessionProperty_OverrideCategoryMixWithOthers, thus solving all my issues laid out in this question.
TL;DR
Remove the prepareToPlay calls from your stop sound code logic. It will take a microsecond longer to start later, but will allow interruptions to sound.

OpenAL initializing impairs performance of my iPhone game

I have a bad performance problem with OpenAL in my iPhone game. My game runs smoothly with 60fps but when I initialize OpenAL the game begins to jerk. This is my initialisation code:
ALCdevice* device = alcOpenDevice(NULL);
ALCcontext *context;
if(device) {
context = alcCreateContext(device, NULL);
alcMakeContextCurrent(context);
}
I don't create any OpenAL Sources nor load/play any sounds. The jittering (the game jerks all the time) is caused by the initializing of OpenAL.
The XCode instruments are saying that the game runs with stable 60fps yet it's obviously jittering (when I don't run the code above the game runs smoothly).
This also doesn't happen on an old iPod Touch 2G with iOS 3.1.3. On all my other devices with iOS 4 the jittering happens, which is also crazy.
I also tried to put the OpenAL stuff in a separate thread but it doesn't help.
Has anybody noticed a similar behaviour?
Try calling alcGetError() after context set up to ensure it succeeded.
Is this failing on the simulator or on an actual phone?
Are you doing anything with sound after the code you posted? In the code you posted if alcOpenDevice fails then you won't have a context, yet you don't return either.