Recently I updated my Xcode from 5 to 6.4 version and the simulator does not give any sound but some error messages. The simplest codes don't run well, the app itself starts in simulator but there is no audio, the problem might be in some setting because all the codes and programs I have ran well before. I use a brand new mac mini so I imported these codes from a different, older one.
If anyone came across with problems like this please help me!
The error is this:
2015-08-01 09:03:56.730 Testbutton[496:11659] 09:03:56.730 ERROR: 98: Error '!obj' trying to fetch default input device's sample rate
2015-08-01 09:03:56.731 Testbutton[496:11659] 09:03:56.731 ERROR: 100: Error getting audio input device sample rate: '!obj'
2015-08-01 09:03:56.731 Testbutton[496:11659] 09:03:56.731 WARNING: 230: The input device is 0x0; '(null)'
2015-08-01 09:03:56.731 Testbutton[496:11659] 09:03:56.731 WARNING: 234: The output device is 0x26; 'AppleHDAEngineOutput:1B,0,1,2:0'
2015-08-01 09:03:56.732 Testbutton[496:11659] 09:03:56.732 ERROR: 296: error '!obj'
2015-08-01 09:03:56.732 Testbutton[496:11659] 09:03:56.732 ERROR: 113: * * * NULL AQIONode object
2015-08-01 09:03:56.732 Testbutton[496:11403] 09:03:56.732 ERROR: 296: error -66680
2015-08-01 09:03:56.732 Testbutton[496:11403] 09:03:56.732 ERROR: >aq> 1595: failed (-66680); will stop (11025/0 frames)
2015-08-01 09:03:56.736 Testbutton[496:11659] 09:03:56.736 ERROR: 703: Can't make UISound Renderer
The code is this:
// ViewController.m
// Testbutton
#import "ViewController.h"
@interface ViewController ()
{
AVAudioPlayer *_audioPlayer;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Construct URL to sound file
NSString *path = [NSString stringWithFormat:@"%@/horn.wav", [[NSBundle mainBundle] resourcePath]];
NSURL *soundUrl = [NSURL fileURLWithPath:path];
// Create audio player object and initialize with URL to sound
_audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl error:nil];
}
- (IBAction)buttonPressed:(id)sender {
[_audioPlayer play];
}
- (void)dealloc {
[audioPlayerPointer release];
[super dealloc];
}
@end
and there is a header file too with this:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController
{
AVAudioPlayer* audioPlayerPointer;
}
- (IBAction)buttonPressed:(id)sender;
@end