diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 1f74d91..7f41b08 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2,7 +2,7 @@ PODS: - boost (1.76.0) - CocoaAsyncSocket (7.6.5) - DoubleConversion (1.1.6) - - dr-pogodin-react-native-audio (1.7.5): + - dr-pogodin-react-native-audio (1.7.6): - hermes-engine - RCT-Folly (= 2021.07.22.00) - RCTRequired @@ -1297,7 +1297,7 @@ SPEC CHECKSUMS: boost: 57d2868c099736d80fcd648bf211b4431e51a558 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 - dr-pogodin-react-native-audio: ed6a831e40143f4ad56db80e318b6a35fff6750e + dr-pogodin-react-native-audio: f47c8dcaac38c0891ca3fcdd0d051cc27b4ebb18 dr-pogodin-react-native-fs: bb2051cf55bd125d705d5fa227439e091ac91bf1 FBLazyVector: 71803c074f6325f10b5ec891c443b6bbabef0ca7 Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818 diff --git a/example/ios/ReactNativeAudioExample.xcodeproj/project.pbxproj b/example/ios/ReactNativeAudioExample.xcodeproj/project.pbxproj index fa67631..c404489 100644 --- a/example/ios/ReactNativeAudioExample.xcodeproj/project.pbxproj +++ b/example/ios/ReactNativeAudioExample.xcodeproj/project.pbxproj @@ -656,8 +656,8 @@ "$(inherited)", "-Wl", "-ld_classic", - " ", - "-Wl -ld_classic ", + "-Wl", + "-ld_classic", ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; @@ -736,8 +736,8 @@ "$(inherited)", "-Wl", "-ld_classic", - " ", - "-Wl -ld_classic ", + "-Wl", + "-ld_classic", ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; diff --git a/ios/RNASamplePlayer.mm b/ios/RNASamplePlayer.mm index 4317469..611cd62 100644 --- a/ios/RNASamplePlayer.mm +++ b/ios/RNASamplePlayer.mm @@ -67,7 +67,7 @@ - (void) play:(RCTPromiseResolveBlock)resolve NSError *error; AVAudioEngine *engine = player.engine; if (engine.running != YES && [engine startAndReturnError:&error] != YES) { - [[RNAudioException INTERNAL_ERROR:error.localizedDescription] reject:reject]; + [[RNAudioException fromError:error] reject:reject]; return; } [player play]; diff --git a/ios/RNAudioException.h b/ios/RNAudioException.h index 1b367cc..c4f730c 100644 --- a/ios/RNAudioException.h +++ b/ios/RNAudioException.h @@ -12,9 +12,12 @@ typedef void (^OnError)(NSString *error); @interface RNAudioException : NSException - (id) initWithName:(NSString*)name details:(NSString*)details; + - (id) initWithName:(NSString*)name details:(NSString*)details + code:(NSInteger)code userInfo:(NSDictionary*)userInfo; + - (NSError*) error; - (RNAudioException*) log; - (RNAudioException*) reject:(RCTPromiseRejectBlock)reject; @@ -23,7 +26,9 @@ typedef void (^OnError)(NSString *error); + (RNAudioException*) name:(NSString*)name; + (RNAudioException*) name:(NSString*)name details:(NSString*)details; -+ (RNAudioException*) INTERNAL_ERROR:(NSString*)details; ++ (RNAudioException*) INTERNAL_ERROR:(NSInteger)code + details:(NSString*)details; + + (RNAudioException*) OPERATION_FAILED:(NSString*)details; + (RNAudioException*) UNKNOWN_PLAYER_ID:(RCTPromiseRejectBlock)reject; + (RNAudioException*) UNKNOWN_SAMPLE_NAME:(RCTPromiseRejectBlock)reject; diff --git a/ios/RNAudioException.mm b/ios/RNAudioException.mm index f5b52b0..4726d64 100644 --- a/ios/RNAudioException.mm +++ b/ios/RNAudioException.mm @@ -16,9 +16,11 @@ - (id) initWithName:(NSString *)name details:(NSString *)details } - (id) initWithName:(NSString*)name - details:(NSString*)details - userInfo:(NSDictionary*)userInfo + details:(NSString*)details + code:(NSInteger)code + userInfo:(NSDictionary*)userInfo { + self->_code = code; self = [super initWithName:name reason:details userInfo:userInfo]; return self; } @@ -57,6 +59,7 @@ + (RNAudioException*) fromError:(NSError*)error return [[RNAudioException alloc] initWithName:error.domain details:error.localizedDescription + code:error.code userInfo:error.userInfo]; } @@ -87,11 +90,14 @@ + (RNAudioException*) name:(NSString*)name details:(NSString*)details return [[RNAudioException alloc] initWithName:name details:details]; } -+ (RNAudioException*) INTERNAL_ERROR:(NSString*)details ++ (RNAudioException*) INTERNAL_ERROR:(NSInteger)code + details:(NSString *)details { return [[RNAudioException alloc] initWithName:@"Internal error" - details:details]; + details:details + code:code + userInfo:nil]; } + (RNAudioException*) OPERATION_FAILED:(NSString *)details diff --git a/ios/ReactNativeAudio.mm b/ios/ReactNativeAudio.mm index 7ced47c..ecaed17 100644 --- a/ios/ReactNativeAudio.mm +++ b/ios/ReactNativeAudio.mm @@ -211,7 +211,8 @@ - (dispatch_queue_t)methodQueue { NSNumber *id = [NSNumber numberWithDouble:playerId]; if (samplePlayers[id] != nil) { - [[RNAudioException INTERNAL_ERROR:@"Sample player ID is occupied"] + [[RNAudioException INTERNAL_ERROR:0 + details:@"Sample player ID is occupied"] reject:reject]; return; } diff --git a/package-lock.json b/package-lock.json index d0de63b..df41778 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dr.pogodin/react-native-audio", - "version": "1.7.5", + "version": "1.7.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dr.pogodin/react-native-audio", - "version": "1.7.5", + "version": "1.7.6", "license": "MIT", "dependencies": { "@dr.pogodin/js-utils": "^0.0.6" diff --git a/package.json b/package.json index a38ce96..9ef42a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dr.pogodin/react-native-audio", - "version": "1.7.5", + "version": "1.7.6", "description": "React Native: access to the audio input stream", "main": "lib/commonjs/index", "module": "lib/module/index",