react-native-audio-api 0.6.0-rc.4 → 0.6.0

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.
Files changed (206) hide show
  1. package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +35 -2
  2. package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +4 -0
  3. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +31 -17
  4. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +1 -3
  5. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +56 -2
  6. package/android/src/main/java/com/swmansion/audioapi/AudioAPIPackage.kt +0 -12
  7. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +35 -12
  8. package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +30 -29
  9. package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +20 -22
  10. package/android/src/main/java/com/swmansion/audioapi/system/MediaReceiver.kt +19 -9
  11. package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionCallback.kt +30 -11
  12. package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +53 -26
  13. package/android/src/main/java/com/swmansion/audioapi/system/VolumeChangeListener.kt +10 -5
  14. package/android/src/oldarch/NativeAudioAPIModuleSpec.java +39 -0
  15. package/common/cpp/audioapi/AudioAPIModuleInstaller.h +20 -14
  16. package/common/cpp/audioapi/HostObjects/AudioBufferSourceNodeHostObject.h +2 -3
  17. package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.h +24 -11
  18. package/common/cpp/audioapi/HostObjects/AudioParamHostObject.h +1 -0
  19. package/common/cpp/audioapi/HostObjects/AudioRecorderHostObject.h +10 -89
  20. package/common/cpp/audioapi/HostObjects/AudioScheduledSourceNodeHostObject.h +3 -24
  21. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +2 -2
  22. package/common/cpp/audioapi/HostObjects/OscillatorNodeHostObject.h +2 -3
  23. package/common/cpp/audioapi/core/AudioContext.cpp +4 -1
  24. package/common/cpp/audioapi/core/AudioContext.h +1 -1
  25. package/common/cpp/audioapi/core/AudioNode.cpp +31 -2
  26. package/common/cpp/audioapi/core/AudioNode.h +7 -1
  27. package/common/cpp/audioapi/core/AudioParam.cpp +84 -2
  28. package/common/cpp/audioapi/core/AudioParam.h +14 -1
  29. package/common/cpp/audioapi/core/BaseAudioContext.cpp +7 -1
  30. package/common/cpp/audioapi/core/BaseAudioContext.h +7 -1
  31. package/common/cpp/audioapi/core/OfflineAudioContext.cpp +3 -2
  32. package/common/cpp/audioapi/core/OfflineAudioContext.h +1 -1
  33. package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +19 -56
  34. package/common/cpp/audioapi/core/analysis/AnalyserNode.h +3 -2
  35. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +28 -26
  36. package/common/cpp/audioapi/core/effects/GainNode.cpp +9 -9
  37. package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +5 -2
  38. package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +56 -0
  39. package/common/cpp/audioapi/core/inputs/AudioRecorder.h +13 -13
  40. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +14 -10
  41. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +1 -1
  42. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +7 -6
  43. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +5 -3
  44. package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +15 -10
  45. package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +35 -1
  46. package/common/cpp/audioapi/core/utils/AudioNodeManager.h +15 -1
  47. package/common/cpp/audioapi/events/AudioEventHandlerRegistry.cpp +108 -0
  48. package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +62 -0
  49. package/common/cpp/audioapi/events/AudioEventHandlerRegistryHostObject.h +48 -0
  50. package/common/cpp/audioapi/jsi/JsiPromise.cpp +3 -4
  51. package/common/cpp/audioapi/utils/AudioArray.h +1 -1
  52. package/common/cpp/audioapi/utils/CircularAudioArray.cpp +94 -0
  53. package/common/cpp/audioapi/utils/CircularAudioArray.h +26 -0
  54. package/ios/audioapi/ios/AudioAPIModule.h +13 -0
  55. package/ios/audioapi/ios/AudioAPIModule.mm +115 -6
  56. package/ios/audioapi/ios/core/IOSAudioRecorder.h +3 -10
  57. package/ios/audioapi/ios/core/IOSAudioRecorder.mm +15 -52
  58. package/ios/audioapi/ios/core/NativeAudioPlayer.m +2 -0
  59. package/ios/audioapi/ios/core/NativeAudioRecorder.m +7 -3
  60. package/ios/audioapi/ios/events/IOSAudioEventHandlerRegistry.h +7 -0
  61. package/ios/audioapi/ios/events/IOSAudioEventHandlerRegistry.mm +12 -0
  62. package/ios/audioapi/ios/system/AudioEngine.h +5 -0
  63. package/ios/audioapi/ios/system/AudioEngine.mm +7 -15
  64. package/ios/audioapi/ios/system/AudioSessionManager.h +3 -1
  65. package/ios/audioapi/ios/system/AudioSessionManager.mm +36 -17
  66. package/ios/audioapi/ios/system/LockScreenManager.h +3 -3
  67. package/ios/audioapi/ios/system/LockScreenManager.mm +36 -48
  68. package/ios/audioapi/ios/system/NotificationManager.h +3 -3
  69. package/ios/audioapi/ios/system/NotificationManager.mm +21 -29
  70. package/lib/commonjs/api.js +4 -4
  71. package/lib/commonjs/api.js.map +1 -1
  72. package/lib/commonjs/core/AudioBufferSourceNode.js +2 -2
  73. package/lib/commonjs/core/AudioBufferSourceNode.js.map +1 -1
  74. package/lib/commonjs/core/AudioNode.js +8 -2
  75. package/lib/commonjs/core/AudioNode.js.map +1 -1
  76. package/lib/commonjs/core/AudioParam.js +2 -1
  77. package/lib/commonjs/core/AudioParam.js.map +1 -1
  78. package/lib/commonjs/core/AudioRecorder.js +11 -28
  79. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  80. package/lib/commonjs/core/AudioScheduledSourceNode.js +4 -1
  81. package/lib/commonjs/core/AudioScheduledSourceNode.js.map +1 -1
  82. package/lib/commonjs/core/BiquadFilterNode.js +4 -4
  83. package/lib/commonjs/core/BiquadFilterNode.js.map +1 -1
  84. package/lib/commonjs/core/GainNode.js +1 -1
  85. package/lib/commonjs/core/GainNode.js.map +1 -1
  86. package/lib/commonjs/core/OscillatorNode.js +2 -2
  87. package/lib/commonjs/core/OscillatorNode.js.map +1 -1
  88. package/lib/commonjs/core/StereoPannerNode.js +1 -1
  89. package/lib/commonjs/core/StereoPannerNode.js.map +1 -1
  90. package/lib/commonjs/events/AudioEventEmitter.js +22 -0
  91. package/lib/commonjs/events/AudioEventEmitter.js.map +1 -0
  92. package/lib/commonjs/events/AudioEventSubscription.js +20 -0
  93. package/lib/commonjs/events/AudioEventSubscription.js.map +1 -0
  94. package/lib/commonjs/events/index.js +21 -0
  95. package/lib/commonjs/events/index.js.map +1 -0
  96. package/lib/commonjs/events/types.js +6 -0
  97. package/lib/commonjs/events/types.js.map +1 -0
  98. package/lib/commonjs/hooks/useSytemVolume.js +1 -1
  99. package/lib/commonjs/hooks/useSytemVolume.js.map +1 -1
  100. package/lib/commonjs/specs/NativeAudioAPIModule.js +3 -3
  101. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  102. package/lib/commonjs/specs/index.js +2 -16
  103. package/lib/commonjs/specs/index.js.map +1 -1
  104. package/lib/commonjs/system/AudioManager.js +26 -26
  105. package/lib/commonjs/system/AudioManager.js.map +1 -1
  106. package/lib/module/api.js +2 -2
  107. package/lib/module/api.js.map +1 -1
  108. package/lib/module/core/AudioBufferSourceNode.js +2 -2
  109. package/lib/module/core/AudioBufferSourceNode.js.map +1 -1
  110. package/lib/module/core/AudioNode.js +7 -2
  111. package/lib/module/core/AudioNode.js.map +1 -1
  112. package/lib/module/core/AudioParam.js +2 -1
  113. package/lib/module/core/AudioParam.js.map +1 -1
  114. package/lib/module/core/AudioRecorder.js +11 -28
  115. package/lib/module/core/AudioRecorder.js.map +1 -1
  116. package/lib/module/core/AudioScheduledSourceNode.js +4 -1
  117. package/lib/module/core/AudioScheduledSourceNode.js.map +1 -1
  118. package/lib/module/core/BiquadFilterNode.js +4 -4
  119. package/lib/module/core/BiquadFilterNode.js.map +1 -1
  120. package/lib/module/core/GainNode.js +1 -1
  121. package/lib/module/core/GainNode.js.map +1 -1
  122. package/lib/module/core/OscillatorNode.js +2 -2
  123. package/lib/module/core/OscillatorNode.js.map +1 -1
  124. package/lib/module/core/StereoPannerNode.js +1 -1
  125. package/lib/module/core/StereoPannerNode.js.map +1 -1
  126. package/lib/module/events/AudioEventEmitter.js +16 -0
  127. package/lib/module/events/AudioEventEmitter.js.map +1 -0
  128. package/lib/module/events/AudioEventSubscription.js +15 -0
  129. package/lib/module/events/AudioEventSubscription.js.map +1 -0
  130. package/lib/module/events/index.js +6 -0
  131. package/lib/module/events/index.js.map +1 -0
  132. package/lib/module/events/types.js +4 -0
  133. package/lib/module/events/types.js.map +1 -0
  134. package/lib/module/hooks/useSytemVolume.js +1 -1
  135. package/lib/module/hooks/useSytemVolume.js.map +1 -1
  136. package/lib/module/specs/NativeAudioAPIModule.js +3 -2
  137. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  138. package/lib/module/specs/index.js +2 -3
  139. package/lib/module/specs/index.js.map +1 -1
  140. package/lib/module/system/AudioManager.js +27 -27
  141. package/lib/module/system/AudioManager.js.map +1 -1
  142. package/lib/typescript/api.d.ts +2 -1
  143. package/lib/typescript/api.d.ts.map +1 -1
  144. package/lib/typescript/core/AudioNode.d.ts +2 -1
  145. package/lib/typescript/core/AudioNode.d.ts.map +1 -1
  146. package/lib/typescript/core/AudioParam.d.ts +4 -2
  147. package/lib/typescript/core/AudioParam.d.ts.map +1 -1
  148. package/lib/typescript/core/AudioRecorder.d.ts +4 -14
  149. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  150. package/lib/typescript/core/AudioScheduledSourceNode.d.ts +3 -1
  151. package/lib/typescript/core/AudioScheduledSourceNode.d.ts.map +1 -1
  152. package/lib/typescript/events/AudioEventEmitter.d.ts +10 -0
  153. package/lib/typescript/events/AudioEventEmitter.d.ts.map +1 -0
  154. package/lib/typescript/events/AudioEventSubscription.d.ts +11 -0
  155. package/lib/typescript/events/AudioEventSubscription.d.ts.map +1 -0
  156. package/lib/typescript/events/index.d.ts +4 -0
  157. package/lib/typescript/events/index.d.ts.map +1 -0
  158. package/lib/typescript/events/types.d.ts +50 -0
  159. package/lib/typescript/events/types.d.ts.map +1 -0
  160. package/lib/typescript/hooks/useSytemVolume.d.ts.map +1 -1
  161. package/lib/typescript/interfaces.d.ts +10 -10
  162. package/lib/typescript/interfaces.d.ts.map +1 -1
  163. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +15 -3
  164. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  165. package/lib/typescript/specs/index.d.ts +2 -3
  166. package/lib/typescript/specs/index.d.ts.map +1 -1
  167. package/lib/typescript/system/AudioManager.d.ts +8 -4
  168. package/lib/typescript/system/AudioManager.d.ts.map +1 -1
  169. package/lib/typescript/system/types.d.ts +1 -34
  170. package/lib/typescript/system/types.d.ts.map +1 -1
  171. package/lib/typescript/types.d.ts +0 -1
  172. package/lib/typescript/types.d.ts.map +1 -1
  173. package/package.json +3 -3
  174. package/src/api.ts +6 -3
  175. package/src/core/AudioBufferSourceNode.ts +2 -2
  176. package/src/core/AudioNode.ts +8 -3
  177. package/src/core/AudioParam.ts +5 -2
  178. package/src/core/AudioRecorder.ts +22 -62
  179. package/src/core/AudioScheduledSourceNode.ts +13 -2
  180. package/src/core/BiquadFilterNode.ts +4 -4
  181. package/src/core/GainNode.ts +1 -1
  182. package/src/core/OscillatorNode.ts +2 -2
  183. package/src/core/StereoPannerNode.ts +1 -1
  184. package/src/events/AudioEventEmitter.ts +29 -0
  185. package/src/events/AudioEventSubscription.ts +26 -0
  186. package/src/events/index.ts +4 -0
  187. package/src/events/types.ts +64 -0
  188. package/src/hooks/useSytemVolume.ts +2 -1
  189. package/src/interfaces.ts +19 -20
  190. package/src/specs/NativeAudioAPIModule.ts +23 -2
  191. package/src/specs/index.ts +2 -4
  192. package/src/system/AudioManager.ts +39 -38
  193. package/src/system/types.ts +1 -41
  194. package/src/types.ts +0 -8
  195. package/android/src/main/java/com/swmansion/audioapi/AudioManagerModule.kt +0 -64
  196. package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionEventEmitter.kt +0 -88
  197. package/android/src/oldarch/NativeAudioManagerModuleSpec.java +0 -99
  198. package/ios/audioapi/ios/AudioManagerModule.h +0 -18
  199. package/ios/audioapi/ios/AudioManagerModule.mm +0 -93
  200. package/lib/commonjs/specs/NativeAudioManagerModule.js +0 -36
  201. package/lib/commonjs/specs/NativeAudioManagerModule.js.map +0 -1
  202. package/lib/module/specs/NativeAudioManagerModule.js +0 -33
  203. package/lib/module/specs/NativeAudioManagerModule.js.map +0 -1
  204. package/lib/typescript/specs/NativeAudioManagerModule.d.ts +0 -15
  205. package/lib/typescript/specs/NativeAudioManagerModule.d.ts.map +0 -1
  206. package/src/specs/NativeAudioManagerModule.ts +0 -45
@@ -2,73 +2,34 @@
2
2
 
3
3
  #include <audioapi/core/Constants.h>
4
4
  #include <audioapi/dsp/VectorMath.h>
5
+ #include <audioapi/events/AudioEventHandlerRegistry.h>
5
6
  #include <audioapi/ios/core/IOSAudioRecorder.h>
6
7
  #include <audioapi/utils/AudioArray.h>
7
8
  #include <audioapi/utils/AudioBus.h>
9
+ #include <audioapi/utils/CircularAudioArray.h>
10
+ #include <unordered_map>
8
11
 
9
12
  namespace audioapi {
10
13
 
11
14
  IOSAudioRecorder::IOSAudioRecorder(
12
15
  float sampleRate,
13
16
  int bufferLength,
14
- const std::function<void(void)> &onError,
15
- const std::function<void(void)> &onStatusChange,
16
- const std::function<void(std::shared_ptr<AudioBus>, int, double)> &onAudioReady)
17
- : AudioRecorder(sampleRate, bufferLength, onError, onStatusChange, onAudioReady)
17
+ const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry)
18
+ : AudioRecorder(sampleRate, bufferLength, audioEventHandlerRegistry)
18
19
  {
19
- circularBuffer_ = std::make_shared<AudioBus>(std::max(2 * bufferLength, 2048), 1, sampleRate);
20
-
21
20
  AudioReceiverBlock audioReceiverBlock = ^(const AudioBufferList *inputBuffer, int numFrames, AVAudioTime *when) {
22
21
  if (isRunning_.load()) {
23
- // copying to circularBuffer_
24
- auto *circularBufferChannel = circularBuffer_->getChannel(0)->getData();
25
- auto *inputChannel = (float *)inputBuffer->mBuffers[0].mData;
26
-
27
- auto framesToProcess = numFrames;
28
- auto framesToCopy = 0;
29
-
30
- if (writeIdx_ + numFrames > circularBuffer_->getSize()) {
31
- framesToCopy = circularBuffer_->getSize() - writeIdx_;
32
- memcpy(circularBufferChannel + writeIdx_, inputChannel, framesToCopy * sizeof(float));
33
- framesToProcess -= framesToCopy;
34
- writeIdx_ = 0;
35
- }
36
-
37
- memcpy(circularBufferChannel + writeIdx_, inputChannel + framesToCopy, framesToProcess * sizeof(float));
38
-
39
- writeIdx_ += framesToProcess;
40
- if (writeIdx_ >= circularBuffer_->getSize()) {
41
- writeIdx_ = 0;
42
- }
43
-
44
- // copying to output bus and invoking callback
45
- auto availableFrames =
46
- writeIdx_ >= readIdx_ ? writeIdx_ - readIdx_ : circularBuffer_->getSize() - (readIdx_ - writeIdx_);
47
-
48
- while (availableFrames >= bufferLength_) {
49
- auto bus = std::make_shared<AudioBus>(bufferLength_, 1, sampleRate_);
50
- auto *outputChannel = bus->getChannel(0)->getData();
51
-
52
- framesToProcess = bufferLength_;
53
- framesToCopy = 0;
54
- if (readIdx_ + bufferLength_ > circularBuffer_->getSize()) {
55
- framesToCopy = circularBuffer_->getSize() - readIdx_;
56
- memcpy(outputChannel, circularBufferChannel + readIdx_, framesToCopy * sizeof(float));
57
- framesToProcess -= framesToCopy;
58
- readIdx_ = 0;
59
- }
60
-
61
- memcpy(outputChannel + framesToCopy, circularBufferChannel + readIdx_, framesToProcess * sizeof(float));
22
+ auto *inputChannel = static_cast<float *>(inputBuffer->mBuffers[0].mData);
23
+ circularBuffer_->push_back(inputChannel, numFrames);
24
+ }
62
25
 
63
- readIdx_ += framesToProcess;
64
- if (readIdx_ >= circularBuffer_->getSize()) {
65
- readIdx_ = 0;
66
- }
26
+ while (circularBuffer_->getNumberOfAvailableFrames() >= bufferLength_) {
27
+ auto bus = std::make_shared<AudioBus>(bufferLength_, 1, sampleRate_);
28
+ auto *outputChannel = bus->getChannel(0)->getData();
67
29
 
68
- onAudioReady_(bus, bufferLength_, [when sampleTime] / [when sampleRate]);
30
+ circularBuffer_->pop_front(outputChannel, bufferLength_);
69
31
 
70
- availableFrames -= bufferLength_;
71
- }
32
+ invokeOnAudioReadyCallback(bus, bufferLength_, [when sampleTime] / [when sampleRate]);
72
33
  }
73
34
  };
74
35
 
@@ -103,6 +64,8 @@ void IOSAudioRecorder::stop()
103
64
 
104
65
  isRunning_.store(false);
105
66
  [audioRecorder_ stop];
67
+
68
+ sendRemainingData();
106
69
  }
107
70
 
108
71
  } // namespace audioapi
@@ -37,6 +37,7 @@
37
37
  NSLog(@"[AudioPlayer] start");
38
38
 
39
39
  AudioEngine *audioEngine = [AudioEngine sharedInstance];
40
+ assert(audioEngine != nil);
40
41
  self.sourceNodeId = [audioEngine attachSourceNode:self.sourceNode format:self.format];
41
42
  }
42
43
 
@@ -45,6 +46,7 @@
45
46
  NSLog(@"[AudioPlayer] stop");
46
47
 
47
48
  AudioEngine *audioEngine = [AudioEngine sharedInstance];
49
+ assert(audioEngine != nil);
48
50
  [audioEngine detachSourceNodeWithId:self.sourceNodeId];
49
51
  self.sourceNodeId = nil;
50
52
  }
@@ -14,7 +14,7 @@
14
14
 
15
15
  self.receiverBlock = [receiverBlock copy];
16
16
 
17
- float devicePrefferedSampleRate = [[[AudioSessionManager sharedInstance] getDevicePreferredSampleRate] floatValue];
17
+ float devicePrefferedSampleRate = [[AVAudioSession sharedInstance] sampleRate];
18
18
 
19
19
  self.inputFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32
20
20
  sampleRate:devicePrefferedSampleRate
@@ -91,12 +91,16 @@
91
91
 
92
92
  - (void)start
93
93
  {
94
- [[AudioEngine sharedInstance] attachInputNode:self.sinkNode];
94
+ AudioEngine *audioEngine = [AudioEngine sharedInstance];
95
+ assert(audioEngine != nil);
96
+ [audioEngine attachInputNode:self.sinkNode];
95
97
  }
96
98
 
97
99
  - (void)stop
98
100
  {
99
- [[AudioEngine sharedInstance] detachInputNode];
101
+ AudioEngine *audioEngine = [AudioEngine sharedInstance];
102
+ assert(audioEngine != nil);
103
+ [audioEngine detachInputNode];
100
104
  }
101
105
 
102
106
  - (void)cleanup
@@ -0,0 +1,7 @@
1
+ #pragma once
2
+
3
+ #import <Foundation/Foundation.h>
4
+
5
+ @interface IOSAudioEventHandlerRegistry : NSObject
6
+
7
+ -
@@ -0,0 +1,12 @@
1
+ // #import <audioapi/ios/events/IOSAudioEventHandlerRegistry.h>
2
+ //
3
+ // #include <memory>
4
+ // #include
5
+ //
6
+ //@implementation IOSAudioEventHandlerRegistry {
7
+ // std::shared_ptr<AudioEventHandlerRegistry> _eventHandler;
8
+ //
9
+ //
10
+ // }
11
+ //
12
+ //@end
@@ -3,12 +3,17 @@
3
3
  #import <AVFoundation/AVFoundation.h>
4
4
  #import <Foundation/Foundation.h>
5
5
 
6
+ @class AudioSessionManager;
7
+
6
8
  @interface AudioEngine : NSObject
7
9
 
8
10
  @property (nonatomic, strong) AVAudioEngine *audioEngine;
9
11
  @property (nonatomic, strong) NSMutableDictionary *sourceNodes;
10
12
  @property (nonatomic, strong) NSMutableDictionary *sourceFormats;
11
13
  @property (nonatomic, strong) AVAudioSinkNode *inputNode;
14
+ @property (nonatomic, weak) AudioSessionManager *sessionManager;
15
+
16
+ - (instancetype)initWithAudioSessionManager:(AudioSessionManager *)sessionManager;
12
17
 
13
18
  + (instancetype)sharedInstance;
14
19
  - (void)cleanup;
@@ -7,22 +7,10 @@ static AudioEngine *_sharedInstance = nil;
7
7
 
8
8
  + (instancetype)sharedInstance
9
9
  {
10
- static dispatch_once_t onceToken;
11
-
12
- dispatch_once(&onceToken, ^{
13
- _sharedInstance = [[self alloc] initPrivate];
14
- });
15
-
16
10
  return _sharedInstance;
17
11
  }
18
12
 
19
- - (instancetype)init
20
- {
21
- @throw [NSException exceptionWithName:@"Singleton" reason:@"Use +[AudioEngine sharedInstance]" userInfo:nil];
22
- return nil;
23
- }
24
-
25
- - (instancetype)initPrivate
13
+ - (instancetype)initWithAudioSessionManager:(AudioSessionManager *)sessionManager
26
14
  {
27
15
  if (self = [super init]) {
28
16
  self.audioEngine = [[AVAudioEngine alloc] init];
@@ -31,9 +19,12 @@ static AudioEngine *_sharedInstance = nil;
31
19
  self.sourceNodes = [[NSMutableDictionary alloc] init];
32
20
  self.sourceFormats = [[NSMutableDictionary alloc] init];
33
21
 
34
- [[AudioSessionManager sharedInstance] setActive:true];
22
+ self.sessionManager = sessionManager;
23
+ [self.sessionManager setActive:true];
35
24
  }
36
25
 
26
+ _sharedInstance = self;
27
+
37
28
  return self;
38
29
  }
39
30
 
@@ -49,7 +40,8 @@ static AudioEngine *_sharedInstance = nil;
49
40
  self.sourceFormats = nil;
50
41
  self.inputNode = nil;
51
42
 
52
- [[AudioSessionManager sharedInstance] setActive:false];
43
+ [self.sessionManager setActive:false];
44
+ self.sessionManager = nil;
53
45
  }
54
46
 
55
47
  - (bool)rebuildAudioEngine
@@ -13,12 +13,14 @@
13
13
  @property (nonatomic, assign) AVAudioSessionCategory sessionCategory;
14
14
  @property (nonatomic, assign) AVAudioSessionCategoryOptions sessionOptions;
15
15
 
16
- + (instancetype)sharedInstance;
16
+ - (instancetype)init;
17
17
  - (void)cleanup;
18
18
  - (bool)configureAudioSession;
19
19
 
20
20
  - (NSNumber *)getDevicePreferredSampleRate;
21
21
  - (void)setAudioSessionOptions:(NSString *)category mode:(NSString *)mode options:(NSArray *)options;
22
22
  - (bool)setActive:(bool)active;
23
+ - (NSString *)requestRecordingPermissions;
24
+ - (NSString *)checkRecordingPermissions;
23
25
 
24
26
  @end
@@ -2,24 +2,7 @@
2
2
 
3
3
  @implementation AudioSessionManager
4
4
 
5
- static AudioSessionManager *_sharedInstance = nil;
6
-
7
- + (instancetype)sharedInstance
8
- {
9
- static dispatch_once_t onceToken;
10
- dispatch_once(&onceToken, ^{
11
- _sharedInstance = [[self alloc] initPrivate];
12
- });
13
- return _sharedInstance;
14
- }
15
-
16
5
  - (instancetype)init
17
- {
18
- @throw [NSException exceptionWithName:@"Singleton" reason:@"Use +[AudioSessionManager sharedInstance]" userInfo:nil];
19
- return nil;
20
- }
21
-
22
- - (instancetype)initPrivate
23
6
  {
24
7
  if (self = [super init]) {
25
8
  self.audioSession = [AVAudioSession sharedInstance];
@@ -192,4 +175,40 @@ static AudioSessionManager *_sharedInstance = nil;
192
175
  return true;
193
176
  }
194
177
 
178
+ - (NSString *)requestRecordingPermissions
179
+ {
180
+ [self.audioSession requestRecordPermission:^(BOOL granted){
181
+ }];
182
+ return [self checkRecordingPermissions];
183
+ }
184
+
185
+ - (NSString *)checkRecordingPermissions
186
+ {
187
+ if (@available(iOS 17, *)) {
188
+ NSInteger res = [[AVAudioApplication sharedInstance] recordPermission];
189
+ switch (res) {
190
+ case AVAudioApplicationRecordPermissionUndetermined:
191
+ return @"Undetermined";
192
+ case AVAudioApplicationRecordPermissionGranted:
193
+ return @"Granted";
194
+ case AVAudioApplicationRecordPermissionDenied:
195
+ return @"Denied";
196
+ default:
197
+ return @"Undetermined";
198
+ }
199
+ } else {
200
+ NSInteger res = [self.audioSession recordPermission];
201
+ switch (res) {
202
+ case AVAudioSessionRecordPermissionUndetermined:
203
+ return @"Undetermined";
204
+ case AVAudioSessionRecordPermissionGranted:
205
+ return @"Granted";
206
+ case AVAudioSessionRecordPermissionDenied:
207
+ return @"Denied";
208
+ default:
209
+ return @"Undetermined";
210
+ }
211
+ }
212
+ }
213
+
195
214
  @end
@@ -4,16 +4,16 @@
4
4
  #import <Foundation/Foundation.h>
5
5
  #import <MediaPlayer/MediaPlayer.h>
6
6
 
7
- @class AudioManagerModule;
7
+ @class AudioAPIModule;
8
8
 
9
9
  @interface LockScreenManager : NSObject
10
10
 
11
- @property (nonatomic, weak) AudioManagerModule *audioManagerModule;
11
+ @property (nonatomic, weak) AudioAPIModule *audioAPIModule;
12
12
 
13
13
  @property (nonatomic, weak) MPNowPlayingInfoCenter *playingInfoCenter;
14
14
  @property (nonatomic, copy) NSString *artworkUrl;
15
15
 
16
- + (instancetype)sharedInstanceWithAudioManagerModule:(AudioManagerModule *)audioManagerModule;
16
+ - (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule;
17
17
  - (void)cleanup;
18
18
 
19
19
  - (void)setLockScreenInfo:(NSDictionary *)info;
@@ -1,5 +1,5 @@
1
1
  #import <MediaPlayer/MediaPlayer.h>
2
- #import <audioapi/ios/AudioManagerModule.h>
2
+ #import <audioapi/ios/AudioAPIModule.h>
3
3
  #import <audioapi/ios/system/LockScreenManager.h>
4
4
 
5
5
  #define LOCK_SCREEN_INFO \
@@ -14,30 +14,14 @@
14
14
 
15
15
  @implementation LockScreenManager
16
16
 
17
- static LockScreenManager *_sharedInstance = nil;
18
-
19
- + (instancetype)sharedInstanceWithAudioManagerModule:(AudioManagerModule *)audioManagerModule
20
- {
21
- static dispatch_once_t onceToken;
22
- dispatch_once(&onceToken, ^{
23
- _sharedInstance = [[self alloc] initPrivateWithAudioManagerModule:audioManagerModule];
24
- });
25
- return _sharedInstance;
26
- }
27
-
28
- - (instancetype)init
29
- {
30
- @throw [NSException exceptionWithName:@"Singleton" reason:@"Use +[LockScreenManager sharedInstance]" userInfo:nil];
31
- return nil;
32
- }
33
-
34
- - (instancetype)initPrivateWithAudioManagerModule:(AudioManagerModule *)audioManagerModule
17
+ - (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule
35
18
  {
36
19
  if (self = [super init]) {
37
- self.audioManagerModule = audioManagerModule;
20
+ self.audioAPIModule = audioAPIModule;
38
21
  self.playingInfoCenter = [MPNowPlayingInfoCenter defaultCenter];
39
22
  [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
40
23
  }
24
+
41
25
  return self;
42
26
  }
43
27
 
@@ -176,31 +160,31 @@ static LockScreenManager *_sharedInstance = nil;
176
160
  {
177
161
  MPRemoteCommandCenter *remoteCenter = [MPRemoteCommandCenter sharedCommandCenter];
178
162
 
179
- if ([name isEqual:@"play"]) {
163
+ if ([name isEqual:@"remotePlay"]) {
180
164
  [self enableCommand:remoteCenter.playCommand withSelector:@selector(onPlay:) enabled:enabled];
181
- } else if ([name isEqual:@"pause"]) {
165
+ } else if ([name isEqual:@"remotePause"]) {
182
166
  [self enableCommand:remoteCenter.pauseCommand withSelector:@selector(onPause:) enabled:enabled];
183
- } else if ([name isEqual:@"stop"]) {
167
+ } else if ([name isEqual:@"remoteStop"]) {
184
168
  [self enableCommand:remoteCenter.stopCommand withSelector:@selector(onStop:) enabled:enabled];
185
- } else if ([name isEqual:@"togglePlayPause"]) {
169
+ } else if ([name isEqual:@"remoteTogglePlayPause"]) {
186
170
  [self enableCommand:remoteCenter.togglePlayPauseCommand withSelector:@selector(onTogglePlayPause:) enabled:enabled];
187
- } else if ([name isEqual:@"changePlaybackRate"]) {
171
+ } else if ([name isEqual:@"remoteChangePlaybackRate"]) {
188
172
  [self enableCommand:remoteCenter.changePlaybackRateCommand
189
173
  withSelector:@selector(onChangePlaybackRate:)
190
174
  enabled:enabled];
191
- } else if ([name isEqual:@"nextTrack"]) {
175
+ } else if ([name isEqual:@"remoteNextTrack"]) {
192
176
  [self enableCommand:remoteCenter.nextTrackCommand withSelector:@selector(onNextTrack:) enabled:enabled];
193
- } else if ([name isEqual:@"previousTrack"]) {
177
+ } else if ([name isEqual:@"remotePreviousTrack"]) {
194
178
  [self enableCommand:remoteCenter.previousTrackCommand withSelector:@selector(onPreviousTrack:) enabled:enabled];
195
- } else if ([name isEqual:@"skipForward"]) {
179
+ } else if ([name isEqual:@"remoteSkipForward"]) {
196
180
  [self enableCommand:remoteCenter.skipForwardCommand withSelector:@selector(onSkipForward:) enabled:enabled];
197
- } else if ([name isEqual:@"skipBackward"]) {
181
+ } else if ([name isEqual:@"remoteSkipBackward"]) {
198
182
  [self enableCommand:remoteCenter.skipBackwardCommand withSelector:@selector(onSkipBackward:) enabled:enabled];
199
- } else if ([name isEqual:@"seekForward"]) {
183
+ } else if ([name isEqual:@"remoteSeekForward"]) {
200
184
  [self enableCommand:remoteCenter.seekForwardCommand withSelector:@selector(onSeekForward:) enabled:enabled];
201
- } else if ([name isEqual:@"seekBackward"]) {
185
+ } else if ([name isEqual:@"remoteSeekBackward"]) {
202
186
  [self enableCommand:remoteCenter.seekBackwardCommand withSelector:@selector(onSeekBackward:) enabled:enabled];
203
- } else if ([name isEqual:@"changePlaybackPosition"]) {
187
+ } else if ([name isEqual:@"remoteChangePlaybackPosition"]) {
204
188
  [self enableCommand:remoteCenter.changePlaybackPositionCommand
205
189
  withSelector:@selector(onChangePlaybackPosition:)
206
190
  enabled:enabled];
@@ -218,77 +202,81 @@ static LockScreenManager *_sharedInstance = nil;
218
202
 
219
203
  - (MPRemoteCommandHandlerStatus)onPlay:(MPRemoteCommandEvent *)event
220
204
  {
221
- [self.audioManagerModule sendEventWithName:@"onRemotePlay" body:@{}];
205
+ [self.audioAPIModule invokeHandlerWithEventName:@"remotePlay" eventBody:nil];
222
206
  return MPRemoteCommandHandlerStatusSuccess;
223
207
  }
224
208
 
225
209
  - (MPRemoteCommandHandlerStatus)onPause:(MPRemoteCommandEvent *)event
226
210
  {
227
- [self.audioManagerModule sendEventWithName:@"onRemotePause" body:@{}];
211
+ [self.audioAPIModule invokeHandlerWithEventName:@"remotePause" eventBody:nil];
228
212
  return MPRemoteCommandHandlerStatusSuccess;
229
213
  }
230
214
 
231
215
  - (MPRemoteCommandHandlerStatus)onStop:(MPRemoteCommandEvent *)event
232
216
  {
233
- [self.audioManagerModule sendEventWithName:@"onRemoteStop" body:@{}];
217
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteStop" eventBody:nil];
234
218
  return MPRemoteCommandHandlerStatusSuccess;
235
219
  }
236
220
 
237
221
  - (MPRemoteCommandHandlerStatus)onTogglePlayPause:(MPRemoteCommandEvent *)event
238
222
  {
239
- [self.audioManagerModule sendEventWithName:@"onRemoteTogglePlayPause" body:@{}];
223
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteTogglePlayPause" eventBody:nil];
240
224
  return MPRemoteCommandHandlerStatusSuccess;
241
225
  }
242
226
 
243
227
  - (MPRemoteCommandHandlerStatus)onChangePlaybackRate:(MPChangePlaybackRateCommandEvent *)event
244
228
  {
245
- [self.audioManagerModule sendEventWithName:@"onRemoteChangePlaybackRate"
246
- body:@{@"value" : [NSNumber numberWithDouble:event.playbackRate]}];
229
+ NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.playbackRate]};
230
+
231
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteChangePlaybackRate" eventBody:body];
247
232
  return MPRemoteCommandHandlerStatusSuccess;
248
233
  }
249
234
 
250
235
  - (MPRemoteCommandHandlerStatus)onNextTrack:(MPRemoteCommandEvent *)event
251
236
  {
252
- [self.audioManagerModule sendEventWithName:@"onRemoteNextTrack" body:@{}];
237
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteNextTrack" eventBody:nil];
253
238
  return MPRemoteCommandHandlerStatusSuccess;
254
239
  }
255
240
 
256
241
  - (MPRemoteCommandHandlerStatus)onPreviousTrack:(MPRemoteCommandEvent *)event
257
242
  {
258
- [self.audioManagerModule sendEventWithName:@"onRemotePreviousTrack" body:@{}];
243
+ [self.audioAPIModule invokeHandlerWithEventName:@"remotePreviousTrack" eventBody:nil];
259
244
  return MPRemoteCommandHandlerStatusSuccess;
260
245
  }
261
246
 
262
247
  - (MPRemoteCommandHandlerStatus)onSeekForward:(MPRemoteCommandEvent *)event
263
248
  {
264
- [self.audioManagerModule sendEventWithName:@"onRemoteSeekForward" body:nil];
249
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekForward" eventBody:nil];
265
250
  return MPRemoteCommandHandlerStatusSuccess;
266
251
  }
267
252
 
268
253
  - (MPRemoteCommandHandlerStatus)onSeekBackward:(MPRemoteCommandEvent *)event
269
254
  {
270
- [self.audioManagerModule sendEventWithName:@"onRemoteSeekBackward" body:@{}];
255
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteSeekBackward" eventBody:nil];
271
256
  return MPRemoteCommandHandlerStatusSuccess;
272
257
  }
273
258
 
274
259
  - (MPRemoteCommandHandlerStatus)onSkipForward:(MPSkipIntervalCommandEvent *)event
275
260
  {
276
- [self.audioManagerModule sendEventWithName:@"onRemoteSkipForward"
277
- body:@{@"value" : [NSNumber numberWithDouble:event.interval]}];
261
+ NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.interval]};
262
+
263
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipForward" eventBody:body];
278
264
  return MPRemoteCommandHandlerStatusSuccess;
279
265
  }
280
266
 
281
267
  - (MPRemoteCommandHandlerStatus)onSkipBackward:(MPSkipIntervalCommandEvent *)event
282
268
  {
283
- [self.audioManagerModule sendEventWithName:@"onRemoteSkipBackward"
284
- body:@{@"value" : [NSNumber numberWithDouble:event.interval]}];
269
+ NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.interval]};
270
+
271
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteSkipBackward" eventBody:body];
285
272
  return MPRemoteCommandHandlerStatusSuccess;
286
273
  }
287
274
 
288
275
  - (MPRemoteCommandHandlerStatus)onChangePlaybackPosition:(MPChangePlaybackPositionCommandEvent *)event
289
276
  {
290
- [self.audioManagerModule sendEventWithName:@"onRemoteChangePlaybackPosition"
291
- body:@{@"value" : [NSNumber numberWithDouble:event.positionTime]}];
277
+ NSDictionary *body = @{@"value" : [NSNumber numberWithDouble:event.positionTime]};
278
+
279
+ [self.audioAPIModule invokeHandlerWithEventName:@"remoteChangePlaybackPosition" eventBody:body];
292
280
  return MPRemoteCommandHandlerStatusSuccess;
293
281
  }
294
282
 
@@ -3,11 +3,11 @@
3
3
  #import <AVFoundation/AVFoundation.h>
4
4
  #import <Foundation/Foundation.h>
5
5
 
6
- @class AudioManagerModule;
6
+ @class AudioAPIModule;
7
7
 
8
8
  @interface NotificationManager : NSObject
9
9
 
10
- @property (nonatomic, weak) AudioManagerModule *audioManagerModule;
10
+ @property (nonatomic, weak) AudioAPIModule *audioAPIModule;
11
11
  @property (nonatomic, weak) NSNotificationCenter *notificationCenter;
12
12
 
13
13
  @property (nonatomic, assign) bool isInterrupted;
@@ -15,7 +15,7 @@
15
15
  @property (nonatomic, assign) bool audioInterruptionsObserved;
16
16
  @property (nonatomic, assign) bool volumeChangesObserved;
17
17
 
18
- + (instancetype)sharedInstanceWithAudioManagerModule:(AudioManagerModule *)audioManagerModule;
18
+ - (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule;
19
19
  - (void)cleanup;
20
20
 
21
21
  - (void)observeAudioInterruptions:(BOOL)enabled;
@@ -1,32 +1,16 @@
1
- #import <audioapi/ios/AudioManagerModule.h>
1
+ #import <audioapi/ios/AudioAPIModule.h>
2
2
  #import <audioapi/ios/system/AudioEngine.h>
3
3
  #import <audioapi/ios/system/AudioSessionManager.h>
4
4
  #import <audioapi/ios/system/NotificationManager.h>
5
5
 
6
6
  @implementation NotificationManager
7
7
 
8
- static NotificationManager *_sharedInstance = nil;
9
8
  static NSString *VolumeObservationContext = @"VolumeObservationContext";
10
9
 
11
- + (instancetype)sharedInstanceWithAudioManagerModule:(AudioManagerModule *)audioManagerModule
12
- {
13
- static dispatch_once_t onceToken;
14
- dispatch_once(&onceToken, ^{
15
- _sharedInstance = [[self alloc] initPrivateWithAudioManagerModule:audioManagerModule];
16
- });
17
- return _sharedInstance;
18
- }
19
-
20
- - (instancetype)init
21
- {
22
- @throw [NSException exceptionWithName:@"Singleton" reason:@"Use +[NotificationManager sharedInstance]" userInfo:nil];
23
- return nil;
24
- }
25
-
26
- - (instancetype)initPrivateWithAudioManagerModule:(AudioManagerModule *)audioManagerModule
10
+ - (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule
27
11
  {
28
12
  if (self = [super init]) {
29
- self.audioManagerModule = audioManagerModule;
13
+ self.audioAPIModule = audioAPIModule;
30
14
  self.notificationCenter = [NSNotificationCenter defaultCenter];
31
15
  self.audioInterruptionsObserved = false;
32
16
 
@@ -84,8 +68,9 @@ static NSString *VolumeObservationContext = @"VolumeObservationContext";
84
68
  context:(void *)context
85
69
  {
86
70
  if ([keyPath isEqualToString:@"outputVolume"] && context == &VolumeObservationContext) {
87
- NSNumber *volume = [NSNumber numberWithFloat:[change[@"new"] floatValue]];
88
- [self.audioManagerModule sendEventWithName:@"onVolumeChange" body:@{@"value" : volume}];
71
+ NSDictionary *body = @{@"value" : [NSNumber numberWithFloat:[change[@"new"] floatValue]]};
72
+
73
+ [self.audioAPIModule invokeHandlerWithEventName:@"volumeChange" eventBody:body];
89
74
  }
90
75
  }
91
76
 
@@ -115,17 +100,22 @@ static NSString *VolumeObservationContext = @"VolumeObservationContext";
115
100
  NSInteger interruptionOption = [notification.userInfo[AVAudioSessionInterruptionOptionKey] integerValue];
116
101
 
117
102
  if (interruptionType == AVAudioSessionInterruptionTypeBegan) {
118
- [self.audioManagerModule sendEventWithName:@"onInterruption"
119
- body:@{@"type" : @"began", @"shouldResume" : @"false"}];
103
+ NSDictionary *body = @{@"type" : @"began", @"shouldResume" : @false};
104
+
105
+ [self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
120
106
  return;
121
107
  }
122
108
 
123
109
  if (interruptionOption == AVAudioSessionInterruptionOptionShouldResume) {
124
- [self.audioManagerModule sendEventWithName:@"onInterruption" body:@{@"type" : @"ended", @"shouldResume" : @"true"}];
110
+ NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @true};
111
+
112
+ [self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
125
113
  return;
126
114
  }
127
115
 
128
- [self.audioManagerModule sendEventWithName:@"onInterruption" body:@{@"type" : @"ended", @"shouldResume" : @"false"}];
116
+ NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @false};
117
+
118
+ [self.audioAPIModule invokeHandlerWithEventName:@"interruption" eventBody:body];
129
119
  }
130
120
 
131
121
  - (void)handleRouteChange:(NSNotification *)notification
@@ -163,14 +153,16 @@ static NSString *VolumeObservationContext = @"VolumeObservationContext";
163
153
  break;
164
154
  }
165
155
 
166
- [self.audioManagerModule sendEventWithName:@"onRouteChange" body:@{@"reason" : @"reasonStr"}];
156
+ NSDictionary *body = @{@"reason" : reasonStr};
157
+
158
+ [self.audioAPIModule invokeHandlerWithEventName:@"routeChange" eventBody:body];
167
159
  }
168
160
 
169
161
  - (void)handleMediaServicesReset:(NSNotification *)notification
170
162
  {
171
163
  NSLog(@"[NotificationManager] Media services have been reset, tearing down and rebuilding everything.");
172
- AudioEngine *audioEngine = [AudioEngine sharedInstance];
173
- AudioSessionManager *audioSessionManager = [AudioSessionManager sharedInstance];
164
+ AudioEngine *audioEngine = self.audioAPIModule.audioEngine;
165
+ AudioSessionManager *audioSessionManager = self.audioAPIModule.audioSessionManager;
174
166
 
175
167
  [self cleanup];
176
168
  [audioSessionManager configureAudioSession];
@@ -180,7 +172,7 @@ static NSString *VolumeObservationContext = @"VolumeObservationContext";
180
172
 
181
173
  - (void)handleEngineConfigurationChange:(NSNotification *)notification
182
174
  {
183
- AudioEngine *audioEngine = [AudioEngine sharedInstance];
175
+ AudioEngine *audioEngine = self.audioAPIModule.audioEngine;
184
176
 
185
177
  if (![audioEngine isRunning]) {
186
178
  NSLog(
@@ -177,7 +177,7 @@ Object.defineProperty(exports, "useSystemVolume", {
177
177
  return _useSytemVolume.default;
178
178
  }
179
179
  });
180
- var _NativeAudioAPIModule = _interopRequireDefault(require("./specs/NativeAudioAPIModule"));
180
+ var _specs = require("./specs");
181
181
  var _AudioBuffer = _interopRequireDefault(require("./core/AudioBuffer"));
182
182
  var _AudioBufferSourceNode = _interopRequireDefault(require("./core/AudioBufferSourceNode"));
183
183
  var _AudioContext = _interopRequireDefault(require("./core/AudioContext"));
@@ -202,10 +202,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
202
202
 
203
203
  /* eslint-disable no-var */
204
204
 
205
- if (global.createAudioContext == null || global.createOfflineAudioContext == null || global.createAudioRecorder == null) {
206
- if (!_NativeAudioAPIModule.default) {
205
+ if (global.createAudioContext == null || global.createOfflineAudioContext == null || global.createAudioRecorder == null || global.AudioEventEmitter == null) {
206
+ if (!_specs.NativeAudioAPIModule) {
207
207
  throw new Error(`Failed to install react-native-audio-api: The native module could not be found.`);
208
208
  }
209
- _NativeAudioAPIModule.default.install();
209
+ _specs.NativeAudioAPIModule.install();
210
210
  }
211
211
  //# sourceMappingURL=api.js.map