react-native-audio-api 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/RNAudioAPI.podspec +65 -40
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +9 -6
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.cpp +7 -3
- package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +4 -2
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +5 -4
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +2 -2
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +2 -0
- package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.cpp +6 -0
- package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.h +1 -0
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +6 -0
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +2 -0
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +2 -1
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +1 -1
- package/ios/audioapi/ios/AudioAPIModule.mm +22 -1
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +1 -1
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +5 -4
- package/ios/audioapi/ios/core/utils/FileOptions.h +3 -1
- package/ios/audioapi/ios/core/utils/FileOptions.mm +9 -3
- package/ios/audioapi/ios/core/utils/IOSFileWriter.h +2 -1
- package/ios/audioapi/ios/core/utils/IOSFileWriter.mm +5 -2
- package/ios/audioapi/ios/system/AudioEngine.mm +4 -2
- package/ios/audioapi/ios/system/AudioSessionManager.h +1 -1
- package/ios/audioapi/ios/system/AudioSessionManager.mm +4 -11
- package/lib/commonjs/core/AudioRecorder.js +3 -3
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/plugin/withAudioAPI.js +6 -1
- package/lib/commonjs/plugin/withAudioAPI.js.map +1 -1
- package/lib/commonjs/system/AudioManager.js +8 -2
- package/lib/commonjs/system/AudioManager.js.map +1 -1
- package/lib/commonjs/system/errors.js +79 -0
- package/lib/commonjs/system/errors.js.map +1 -0
- package/lib/module/core/AudioRecorder.js +3 -4
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/plugin/withAudioAPI.js +7 -2
- package/lib/module/plugin/withAudioAPI.js.map +1 -1
- package/lib/module/system/AudioManager.js +8 -2
- package/lib/module/system/AudioManager.js.map +1 -1
- package/lib/module/system/errors.js +73 -0
- package/lib/module/system/errors.js.map +1 -0
- package/lib/typescript/core/AudioRecorder.d.ts +2 -2
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +1 -1
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/plugin/withAudioAPI.d.ts.map +1 -1
- package/lib/typescript/system/AudioManager.d.ts +2 -2
- package/lib/typescript/system/AudioManager.d.ts.map +1 -1
- package/lib/typescript/system/errors.d.ts +12 -0
- package/lib/typescript/system/errors.d.ts.map +1 -0
- package/lib/typescript/system/types.d.ts +1 -1
- package/lib/typescript/system/types.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +3 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/rnaa_utils.rb +50 -0
- package/src/core/AudioRecorder.ts +4 -3
- package/src/interfaces.ts +1 -1
- package/src/plugin/withAudioAPI.ts +12 -4
- package/src/system/AudioManager.ts +15 -7
- package/src/system/errors.ts +111 -0
- package/src/system/types.ts +1 -1
- package/src/types.ts +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SystemEventName, SystemEventCallback } from '../events/types';
|
|
2
1
|
import type { AudioEventSubscription } from '../events';
|
|
2
|
+
import type { SystemEventCallback, SystemEventName } from '../events/types';
|
|
3
3
|
export type IOSCategory = 'record' | 'ambient' | 'playback' | 'multiRoute' | 'soloAmbient' | 'playAndRecord';
|
|
4
4
|
export type IOSMode = 'default' | 'gameChat' | 'videoChat' | 'voiceChat' | 'measurement' | 'voicePrompt' | 'spokenAudio' | 'moviePlayback' | 'videoRecording';
|
|
5
5
|
export type IOSOption = 'duckOthers' | 'allowAirPlay' | 'mixWithOthers' | 'allowBluetooth' | 'defaultToSpeaker' | 'allowBluetoothA2DP' | 'overrideMutedMicrophoneInterruption' | 'interruptSpokenAudioAndMixWithOthers';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/system/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/system/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE5E,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,SAAS,GACT,UAAU,GACV,YAAY,GACZ,aAAa,GACb,eAAe,CAAC;AAEpB,MAAM,MAAM,OAAO,GACf,SAAS,GACT,UAAU,GACV,WAAW,GACX,WAAW,GACX,aAAa,GACb,aAAa,GACb,aAAa,GACb,eAAe,GACf,gBAAgB,CAAC;AAErB,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,cAAc,GACd,eAAe,GACf,gBAAgB,GAChB,kBAAkB,GAClB,oBAAoB,GACpB,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,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5D,4BAA4B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC1D,cAAc,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC7C"}
|
|
@@ -111,4 +111,7 @@ export interface IIRFilterNodeOptions {
|
|
|
111
111
|
feedback: number[];
|
|
112
112
|
}
|
|
113
113
|
export type DecodeDataInput = number | string | ArrayBuffer;
|
|
114
|
+
export interface AudioRecorderStartOptions {
|
|
115
|
+
fileNameOverride?: string;
|
|
116
|
+
}
|
|
114
117
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C,MAAM,MAAM,MAAM,CAAC,CAAC,IAChB,CAAC;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GAAG,CAAC,CAAC,GAC3B;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,aAAa,GAAG,UAAU,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,SAAS,GACT,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,WAAW,CAAC;AAE/D,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,QAAQ,GACR,UAAU,GACV,UAAU,GACV,QAAQ,CAAC;AAEb,MAAM,WAAW,uBAAuB;IACtC,oBAAoB,EAAE,OAAO,CAAC;CAC/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W,yBAAyB;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification",
|
|
5
5
|
"bin": {
|
|
6
6
|
"setup-rn-audio-api-web": "./scripts/setup-rn-audio-api-web.js"
|
package/scripts/rnaa_utils.rb
CHANGED
|
@@ -6,3 +6,53 @@ def check_if_worklets_enabled()
|
|
|
6
6
|
end
|
|
7
7
|
true
|
|
8
8
|
end
|
|
9
|
+
|
|
10
|
+
def try_to_parse_react_native_package_json(node_modules_dir)
|
|
11
|
+
react_native_package_json_path = File.join(node_modules_dir, 'react-native/package.json')
|
|
12
|
+
if !File.exist?(react_native_package_json_path)
|
|
13
|
+
return nil
|
|
14
|
+
end
|
|
15
|
+
return JSON.parse(File.read(react_native_package_json_path))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def find_audio_api_config()
|
|
19
|
+
result = {
|
|
20
|
+
:worklets_enabled => nil,
|
|
21
|
+
:react_native_common_dir => nil,
|
|
22
|
+
:dynamic_frameworks_audio_api_dir => nil,
|
|
23
|
+
:dynamic_frameworks_worklets_dir => nil
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
result[:worklets_enabled] = check_if_worklets_enabled()
|
|
27
|
+
|
|
28
|
+
react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
|
|
29
|
+
react_native_json = try_to_parse_react_native_package_json(react_native_node_modules_dir)
|
|
30
|
+
|
|
31
|
+
if react_native_json == nil
|
|
32
|
+
# user configuration, just in case
|
|
33
|
+
node_modules_dir = ENV["REACT_NATIVE_NODE_MODULES_DIR"]
|
|
34
|
+
react_native_json = try_to_parse_react_native_package_json(node_modules_dir)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if react_native_json == nil
|
|
38
|
+
raise '[AudioAPI] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="<path to react-native>" && pod install`.'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
pods_root = Pod::Config.instance.project_pods_root
|
|
42
|
+
react_native_common_dir_absolute = File.join(react_native_node_modules_dir, 'react-native', 'ReactCommon')
|
|
43
|
+
react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
|
|
44
|
+
result[:react_native_common_dir] = react_native_common_dir_relative
|
|
45
|
+
|
|
46
|
+
react_native_audio_api_dir_absolute = File.join(__dir__, '..')
|
|
47
|
+
react_native_audio_api_dir_relative = Pathname.new(react_native_audio_api_dir_absolute).relative_path_from(pods_root).to_s
|
|
48
|
+
result[:dynamic_frameworks_audio_api_dir] = react_native_audio_api_dir_relative
|
|
49
|
+
|
|
50
|
+
if result[:worklets_enabled] == true
|
|
51
|
+
react_native_worklets_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native-worklets/package.json')"`), '..')
|
|
52
|
+
react_native_worklets_dir_absolute = File.join(react_native_worklets_node_modules_dir, 'react-native-worklets')
|
|
53
|
+
react_native_worklets_dir_relative = Pathname.new(react_native_worklets_dir_absolute).relative_path_from(pods_root).to_s
|
|
54
|
+
result[:dynamic_frameworks_worklets_dir] = react_native_worklets_dir_relative
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
return result
|
|
58
|
+
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AudioApiError } from '../errors';
|
|
1
2
|
import { AudioEventEmitter, AudioEventSubscription } from '../events';
|
|
2
3
|
import {
|
|
3
4
|
OnAudioReadyEventType,
|
|
@@ -7,6 +8,7 @@ import { IAudioRecorder } from '../interfaces';
|
|
|
7
8
|
import {
|
|
8
9
|
AudioRecorderCallbackOptions,
|
|
9
10
|
AudioRecorderFileOptions,
|
|
11
|
+
AudioRecorderStartOptions,
|
|
10
12
|
FileDirectory,
|
|
11
13
|
FileFormat,
|
|
12
14
|
FileInfo,
|
|
@@ -15,7 +17,6 @@ import {
|
|
|
15
17
|
import FilePreset from '../utils/filePresets';
|
|
16
18
|
import AudioBuffer from './AudioBuffer';
|
|
17
19
|
import RecorderAdapterNode from './RecorderAdapterNode';
|
|
18
|
-
import { AudioApiError } from '../errors';
|
|
19
20
|
|
|
20
21
|
// Enforces default options, making sure that all properties are defined
|
|
21
22
|
// for the contract with native code.
|
|
@@ -73,13 +74,13 @@ export default class AudioRecorder {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
/** Starts the audio recording process with configured output options */
|
|
76
|
-
start(): Result<{ path: string }> {
|
|
77
|
+
start(options?: AudioRecorderStartOptions): Result<{ path: string }> {
|
|
77
78
|
if (!this.isFileOutputEnabled) {
|
|
78
79
|
this.recorder.start();
|
|
79
80
|
return { status: 'success', path: '' };
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
return this.recorder.start();
|
|
83
|
+
return this.recorder.start(options?.fileNameOverride);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/** Stops the audio recording process and releases internal resources */
|
package/src/interfaces.ts
CHANGED
|
@@ -304,7 +304,7 @@ export interface IAudioRecorderCallbackOptions
|
|
|
304
304
|
|
|
305
305
|
export interface IAudioRecorder {
|
|
306
306
|
// default recorder methods
|
|
307
|
-
start: () => Result<{ path: string }>;
|
|
307
|
+
start: (fileNameOverride?: string) => Result<{ path: string }>;
|
|
308
308
|
stop: () => Result<FileInfo>;
|
|
309
309
|
isRecording: () => boolean;
|
|
310
310
|
isPaused: () => boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AndroidConfig,
|
|
3
|
-
createRunOncePlugin,
|
|
4
3
|
ConfigPlugin,
|
|
5
|
-
|
|
4
|
+
createRunOncePlugin,
|
|
6
5
|
withAndroidManifest,
|
|
7
6
|
withGradleProperties,
|
|
7
|
+
withInfoPlist,
|
|
8
8
|
withPodfile,
|
|
9
9
|
} from '@expo/config-plugins';
|
|
10
10
|
const pkg = require('react-native-audio-api/package.json');
|
|
@@ -75,7 +75,7 @@ const withForegroundService: ConfigPlugin<Options> = (
|
|
|
75
75
|
const serviceElement = {
|
|
76
76
|
$: {
|
|
77
77
|
'android:name':
|
|
78
|
-
'com.swmansion.audioapi.system.
|
|
78
|
+
'com.swmansion.audioapi.system.CentralizedForegroundService',
|
|
79
79
|
'android:stopWithTask': 'true',
|
|
80
80
|
'android:foregroundServiceType': SFTypes,
|
|
81
81
|
},
|
|
@@ -86,8 +86,16 @@ const withForegroundService: ConfigPlugin<Options> = (
|
|
|
86
86
|
mainApplication.service = [];
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
mainApplication.service.
|
|
89
|
+
const existingServiceIndex = mainApplication.service.findIndex((service) =>
|
|
90
|
+
service.$['android:name'].includes(serviceElement.$['android:name'])
|
|
91
|
+
);
|
|
90
92
|
|
|
93
|
+
if (existingServiceIndex !== -1) {
|
|
94
|
+
mainApplication.service[existingServiceIndex] = serviceElement;
|
|
95
|
+
return mod;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
mainApplication.service.push(serviceElement);
|
|
91
99
|
return mod;
|
|
92
100
|
});
|
|
93
101
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { AudioEventEmitter, AudioEventSubscription } from '../events';
|
|
2
|
+
import { SystemEventCallback, SystemEventName } from '../events/types';
|
|
3
|
+
import { NativeAudioAPIModule } from '../specs';
|
|
4
|
+
import { parseNativeError } from './errors';
|
|
1
5
|
import {
|
|
2
|
-
SessionOptions,
|
|
3
|
-
PermissionStatus,
|
|
4
6
|
AudioDevicesInfo,
|
|
5
7
|
IAudioManager,
|
|
8
|
+
PermissionStatus,
|
|
9
|
+
SessionOptions,
|
|
6
10
|
} from './types';
|
|
7
|
-
import { SystemEventName, SystemEventCallback } from '../events/types';
|
|
8
|
-
import { AudioEventEmitter, AudioEventSubscription } from '../events';
|
|
9
|
-
import { NativeAudioAPIModule } from '../specs';
|
|
10
11
|
|
|
11
12
|
class AudioManager implements IAudioManager {
|
|
12
13
|
private readonly audioEventEmitter: AudioEventEmitter;
|
|
@@ -18,8 +19,15 @@ class AudioManager implements IAudioManager {
|
|
|
18
19
|
return NativeAudioAPIModule.getDevicePreferredSampleRate();
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
setAudioSessionActivity(enabled: boolean): Promise<boolean> {
|
|
22
|
-
|
|
22
|
+
async setAudioSessionActivity(enabled: boolean): Promise<boolean> {
|
|
23
|
+
try {
|
|
24
|
+
const success =
|
|
25
|
+
await NativeAudioAPIModule.setAudioSessionActivity(enabled);
|
|
26
|
+
|
|
27
|
+
return success;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw parseNativeError(error);
|
|
30
|
+
}
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
setAudioSessionOptions(options: SessionOptions) {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { AudioApiError } from '../errors';
|
|
2
|
+
|
|
3
|
+
export interface NativeActivationErrorMetadata {
|
|
4
|
+
nativeDesc: string;
|
|
5
|
+
nativeCode: number;
|
|
6
|
+
nativeDomain: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ErrorWithUserInfo {
|
|
10
|
+
userInfo?: {
|
|
11
|
+
meta?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ErrorWithNativeError {
|
|
16
|
+
nativeError?: {
|
|
17
|
+
userInfo: {
|
|
18
|
+
meta?: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface ErrorWithDetails {
|
|
24
|
+
details?: {
|
|
25
|
+
meta?: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function parseNativeCode(code: number): string {
|
|
30
|
+
switch (code) {
|
|
31
|
+
case 0:
|
|
32
|
+
return 'NoError';
|
|
33
|
+
case -50:
|
|
34
|
+
return 'BadParam';
|
|
35
|
+
case 1836282486:
|
|
36
|
+
return 'MediaServicesFailed';
|
|
37
|
+
case 560030580:
|
|
38
|
+
return 'IsBusy';
|
|
39
|
+
case 560161140:
|
|
40
|
+
return 'IncompatibleCategory';
|
|
41
|
+
case 560557684:
|
|
42
|
+
return 'CannotInterruptOthers';
|
|
43
|
+
case 1701737535:
|
|
44
|
+
return 'MissingEntitlement';
|
|
45
|
+
case 1936290409:
|
|
46
|
+
return 'SiriIsRecording';
|
|
47
|
+
case 561015905:
|
|
48
|
+
return 'CannotStartPlaying';
|
|
49
|
+
case 561145187:
|
|
50
|
+
return 'CannotStartRecording';
|
|
51
|
+
case 561017449:
|
|
52
|
+
return 'InsufficientPriority';
|
|
53
|
+
case 561145203:
|
|
54
|
+
return 'ResourceNotAvailable';
|
|
55
|
+
case 2003329396:
|
|
56
|
+
return 'Unspecified';
|
|
57
|
+
case 561210739:
|
|
58
|
+
return 'ExpiredSession';
|
|
59
|
+
case 1768841571:
|
|
60
|
+
return 'SessionNotActive';
|
|
61
|
+
default:
|
|
62
|
+
return 'NoError';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class SessionActivationError extends AudioApiError {
|
|
67
|
+
nativeErrorInfo?: NativeActivationErrorMetadata;
|
|
68
|
+
|
|
69
|
+
constructor(nativeErrorInfo?: NativeActivationErrorMetadata) {
|
|
70
|
+
if (!nativeErrorInfo) {
|
|
71
|
+
super('Failed to activate audio session with unknown error');
|
|
72
|
+
this.name = 'SessionActivationError';
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const codeName = parseNativeCode(nativeErrorInfo.nativeCode);
|
|
77
|
+
|
|
78
|
+
super(
|
|
79
|
+
`[${codeName}] Failed to activate audio session, code: ${nativeErrorInfo.nativeCode}`
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
this.name = 'SessionActivationError';
|
|
83
|
+
this.nativeErrorInfo = nativeErrorInfo;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function parseNativeError(error: unknown): SessionActivationError {
|
|
88
|
+
const errorMeta =
|
|
89
|
+
(error as ErrorWithUserInfo)?.userInfo?.meta ??
|
|
90
|
+
(error as ErrorWithNativeError)?.nativeError?.userInfo?.meta ??
|
|
91
|
+
(error as ErrorWithDetails)?.details?.meta;
|
|
92
|
+
|
|
93
|
+
console.log('Parsed error meta:', errorMeta);
|
|
94
|
+
|
|
95
|
+
if (!errorMeta || typeof errorMeta !== 'object') {
|
|
96
|
+
return new SessionActivationError();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const { nativeCode, nativeDesc, nativeDomain } =
|
|
100
|
+
errorMeta as unknown as NativeActivationErrorMetadata;
|
|
101
|
+
|
|
102
|
+
if (isNaN(nativeCode) || !nativeDesc || !nativeDomain) {
|
|
103
|
+
return new SessionActivationError();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return new SessionActivationError({
|
|
107
|
+
nativeCode,
|
|
108
|
+
nativeDesc,
|
|
109
|
+
nativeDomain,
|
|
110
|
+
});
|
|
111
|
+
}
|
package/src/system/types.ts
CHANGED