sezo-audio-engine 0.0.10 → 0.0.12

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.
@@ -760,13 +760,32 @@ final class NativeAudioEngine {
760
760
  lastRecordingError = "recording mixer unavailable while engine is running"
761
761
  return false
762
762
  }
763
+ let session = AVAudioSession.sharedInstance()
764
+ if !session.isInputAvailable {
765
+ let routeInfo = describeRoute(session)
766
+ lastRecordingError = "audio input not available (category=\(session.category.rawValue), route=\(routeInfo))"
767
+ return false
768
+ }
763
769
 
764
- let resolvedRate = sampleRate > 0 ? sampleRate : (lastConfig.sampleRate ?? 44100)
765
- let resolvedChannels = channels > 0 ? channels : 1
766
- guard let format = AVAudioFormat(
770
+ let inputFormat = engine.inputNode.inputFormat(forBus: 0)
771
+ let inputSampleRate = inputFormat.sampleRate
772
+ let inputChannels = Int(inputFormat.channelCount)
773
+ guard inputSampleRate > 0, inputChannels > 0 else {
774
+ lastRecordingError = "input hw format invalid (sampleRate=\(inputSampleRate), channels=\(inputChannels))"
775
+ return false
776
+ }
777
+
778
+ let resolvedRate = sampleRate > 0 ? sampleRate : (lastConfig.sampleRate ?? inputSampleRate)
779
+ let resolvedChannels = channels > 0 ? channels : inputChannels
780
+ let format: AVAudioFormat
781
+ if resolvedRate == inputSampleRate && resolvedChannels == inputChannels {
782
+ format = inputFormat
783
+ } else if let preferredFormat = AVAudioFormat(
767
784
  standardFormatWithSampleRate: resolvedRate,
768
785
  channels: AVAudioChannelCount(resolvedChannels)
769
- ) else {
786
+ ) {
787
+ format = preferredFormat
788
+ } else {
770
789
  lastRecordingError = "recording format invalid (sampleRate=\(resolvedRate), channels=\(resolvedChannels))"
771
790
  return false
772
791
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sezo-audio-engine",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Cross-platform Expo module for the Sezo Audio Engine with iOS implementation and background playback.",
5
5
  "license": "MIT",
6
6
  "author": "Sezo",
@@ -38,7 +38,9 @@
38
38
  "android/cpp",
39
39
  "android/build.gradle",
40
40
  "android/settings.gradle",
41
- "ios",
41
+ "ios/AudioEngine",
42
+ "ios/ExpoAudioEngine.podspec",
43
+ "ios/ExpoAudioEngineModule.swift",
42
44
  "dist",
43
45
  "expo-module.config.json",
44
46
  "README.md",
@@ -47,6 +49,7 @@
47
49
  "scripts": {
48
50
  "build": "tsc -p tsconfig.json",
49
51
  "clean": "rm -rf dist",
52
+ "prepack": "rm -rf ios/build",
50
53
  "test": "echo \"TODO: add tests\"",
51
54
  "prepublishOnly": "npm run build"
52
55
  },