1

这是我们所做的:

我们将框架添加到我们的项目中

在我们的课程之一中具有以下内容:

GCSearchViewController.h

@interface GCSearchViewController : UIViewController<UISearchBarDelegate, GNSearchResultReady, GNAudioSourceDelegate>

GCSearchViewController.m

// - As per the web tutorial

#import <GracenoteMusicID/GNConfig.h>

#import <GracenoteMusicID/GNOperations.h>

#import <GracenoteMusicID/GNSearchResponse.h>

#import <GracenoteMusicID/GNSearchResult.h>

// - As per what we saw in the demo app

#import <GracenoteMusicID/GNRecognizeStream.h>

#import <GracenoteMusicID/GNAudioConfig.h>

#import <GracenoteMusicID/GNAudioSourceMic.h>

#import <AVFoundation/AVAudioSession.h>


…


#pragma mark - Gracenote Delegate


-(void) identifySong {

[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL response){

NSLog(@"Allow microphone use response: %d", response);

if (response) {

[GNOperations recognizeMIDStreamFromMic:self config:self.config];


}

}];

}


- (void) GNResultReady:(GNSearchResult *) result

{

GNSearchResponse *best = [result bestResponse];

if (![result isFailure] && (best.artist!=nil)) {

NSLog(@"Artist %@", best.artist);

NSLog(@"Song name %@", best.trackTitle);

} else {

NSLog(@"No Match");

}

}


- (void) audioBufferDidBecomeReady:(GNAudioSource*)audioSource samples:(NSData*)samples {

NSError *err;

err = [self.recognizeFromPCM writeBytes:samples];



if (err) {

NSLog(@"ERROR: %@",[err localizedDescription]);

}

}

此代码在模拟器中运行正常,但每当我们在设备(ipod touch 5th 或 iphone 5)上运行它时,应用程序就会因以下错误而中断:

2013-11-16 22:00:40.402 GC[1758:60b] 22:00:40.401 ERROR: [0x3c29f18c] >aurioc> 783: failed: -10851 (enable 1, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 1 ch, 44100 Hz, Int16>)

Error: 0xffffd59d2013-11-16 22:00:52.904 Leaf[1758:60b] Allow microphone use response: 1

2013-11-16 22:00:52.925 GC[1758:60b] 22:00:52.925 ERROR: [0x3c29f18c] >aurioc> 783: failed: -10851 (enable 1, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 1 ch, 44100 Hz, Int16>)

Error: 0xffffd59d2013-11-16 22:00:52.927 GC[1758:60b] *** Assertion failure in -[GNFingerprinterQueue startupTimerFired], /home/mobile/z-15003-ecma-3.2/cddb-clients/mmid/iOSMobileSDK/3.2/Classes/Private/GNFingerprinterQueue.m:291

2013-11-16 22:00:52.930 GC[1758:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'audioSource is nil'

*** First throw call stack:

(0x2fb66f4b 0x39e7b6af 0x2fb66e25 0x3050efe3 0x151849 0x1520e5 0x3054ae9b 0x2fb32183 0x2fb31653 0x2fb2fe47 0x2fa9ac27 0x2fa9aa0b 0x3478a283 0x3233e049 0x7b621 0x3a383ab7)

libc++abi.dylib: terminating with uncaught exception of type NSException

我们的应用程序针对的是 iOS7 ......感谢任何关于如何使其工作的指针

4

1 回答 1

2

这是获取麦克风硬件的错误。错误日志:

2013-11-16 22:00:40.402 GC[1758:60b] 22:00:40.401 错误:[0x3c29f18c] >aurioc> 783:失败:-10851(启用 1,outf< 2 ch,0 Hz,Float32,非-inter> inf< 1 ch, 44100 Hz, Int16>)

上述错误发生在两种情况下:

  1. 麦克风硬件配置不正确或
  2. RemoteIO 无法获取硬件。

这通常发生在模拟器上,但如果麦克风无法访问,则可能发生在设备上。如果 AVAudioSession 配置不正确或搞砸了,也会发生错误。检查 AVAudioSession 配置并尝试删除 iOS 应用程序,重新安装它并进行干净的构建。

于 2013-11-19T21:12:53.987 回答