0

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
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
  • why are you releasing `audioPlayerPointer`, which you never allocated or initialized? Also, is this really all the app is (plus a main file and/or a storyboard or xib), or is there more going on in other parts of a much bigger app? – Michael Dautermann Aug 01 '15 at 07:53
  • the error comes when I press that simple button which should activate the audio player. It doesn't give any sound but this error, however the app doesn't crash. I could try this only in simulator because now I don't have any device to try it there. – Janos Sandor Aug 01 '15 at 07:53
  • sorry, I started to write an extra comment, before you wrote, so this is a tutorial code I've got when I started to learn Xcode programming, storyboard has got one single button, and this is the app itself. just a tutorial – Janos Sandor Aug 01 '15 at 07:55
  • appdelegate.h and .m, a launchscreen.xib and the main.storyboard (and the horn.wav) are in the project next to these two files I copied in – Janos Sandor Aug 01 '15 at 07:57
  • oh, well audioPlayerPointer is not used in this code, so I can delete it – Janos Sandor Aug 01 '15 at 08:01

1 Answers1

0

AVAudioPlayer needs both a valid input and output in order to set itself up. This isn't a problem on a real device (which has these things built in), but it is a problem in the simulator where there's no built-in microphone on the MacMini.

If you have a microphone, try plugging it into the "line in" port on your MacMini (I found this probable solution in the comments of the answer to this very related question). Make sure to select "line-in" as the input in System Preferences, too.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • I connected a mic to line-in. – Janos Sandor Aug 01 '15 at 08:08
  • If you have a registered Apple Developer account, I recommend filing a bug at http://bugreporter.apple.com & describe exactly what you experienced and the workaround you had to do to get it to work. AVAudioPlayer should be able to emit sounds even without a valid input. Most Apple engineers in Cupertino have top-of-the-line MacPro workstations and they forget that there is a huge developer community out in the world that is doing development with MacMinis, so they aren't properly testing the simulator with real-world scenarios like what you have to deal with. A bug would remind them of this. – Michael Dautermann Aug 01 '15 at 08:13
  • Okay, thanks for all of these, I will report this bug to them, now I'm struggling with the line-in input because on another app of mine I need a microphone input, and as I've read the line-in input is not for mics. The MacMini doesn't recognize my external audio card's mic input too, so I think I'll have some work today on this :) Thank you! – Janos Sandor Aug 01 '15 at 09:07