@siteed/expo-audio-studio 2.16.2 → 2.17.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.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
 
10
10
 
11
+ ## [2.17.0] - 2025-07-31
12
+ ### Changed
13
+ - fix(expo-audio-studio): fix OutOfMemoryError by tracking stream position correctly ([b67e521](https://github.com/deeeed/expo-audio-stream/commit/b67e52142154d07873c5c1ec9c183d524d61e528))
14
+ - chore(expo-audio-studio): release @siteed/expo-audio-studio@2.16.2 ([c4291a8](https://github.com/deeeed/expo-audio-stream/commit/c4291a82cc740b4d4790c69ae7e7cc07f1e8fb1a))
11
15
  ## [2.16.2] - 2025-07-27
12
16
  ### Changed
13
17
  - chore(expo-audio-studio): release @siteed/expo-audio-studio@2.16.1 ([c9614d4](https://github.com/deeeed/expo-audio-stream/commit/c9614d4ebf87d73c3c5b2f7d6e60492fd5e45e64))
@@ -364,7 +368,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
364
368
  - Feature: Audio features extraction during recording.
365
369
  - Feature: Consistent WAV PCM recording format across all platforms.
366
370
 
367
- [unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.16.2...HEAD
371
+ [unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.17.0...HEAD
372
+ [2.17.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.16.2...@siteed/expo-audio-studio@2.17.0
368
373
  [2.16.2]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.16.1...@siteed/expo-audio-studio@2.16.2
369
374
  [2.16.1]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.16.0...@siteed/expo-audio-studio@2.16.1
370
375
  [2.16.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.15.0...@siteed/expo-audio-studio@2.16.0
@@ -90,6 +90,7 @@ class AudioRecorderManager(
90
90
  private var pausedDuration = 0L
91
91
  private var lastEmittedSize = 0L
92
92
  private var lastEmittedCompressedSize = 0L
93
+ private var streamPosition = 0L // Track total bytes processed in the stream
93
94
  private val mainHandler = Handler(Looper.getMainLooper())
94
95
  private val audioRecordLock = Any()
95
96
  private var audioFileHandler: AudioFileHandler = AudioFileHandler(filesDir)
@@ -942,6 +943,7 @@ class AudioRecorderManager(
942
943
  val bytesRead = audioRecord?.read(remainingData, 0, bufferSizeInBytes) ?: -1
943
944
  if (bytesRead > 0) {
944
945
  emitAudioData(remainingData.copyOfRange(0, bytesRead), bytesRead)
946
+ streamPosition += bytesRead // Update stream position for final data
945
947
  }
946
948
  }
947
949
 
@@ -966,6 +968,7 @@ class AudioRecorderManager(
966
968
  if (bytesRead > 0) {
967
969
  val emitStartTime = System.currentTimeMillis()
968
970
  emitAudioData(audioData.copyOfRange(0, bytesRead), bytesRead)
971
+ streamPosition += bytesRead // Update stream position for final data
969
972
  }
970
973
 
971
974
  LogUtils.d(CLASS_NAME, "Stopping recording state = ${audioRecord?.state}")
@@ -1468,6 +1471,7 @@ class AudioRecorderManager(
1468
1471
  accumulatedAudioData.toByteArray(),
1469
1472
  accumulatedAudioData.size()
1470
1473
  )
1474
+ streamPosition += accumulatedAudioData.size() // Update stream position
1471
1475
  lastEmitTime = currentTime
1472
1476
  accumulatedAudioData.reset() // Clear the accumulator
1473
1477
  }
@@ -1549,9 +1553,15 @@ class AudioRecorderManager(
1549
1553
  val from = lastEmittedSize
1550
1554
  lastEmittedSize = fileSize
1551
1555
 
1552
- // Calculate position in milliseconds
1553
- val positionInMs =
1554
- (from * 1000) / (recordingConfig.sampleRate * recordingConfig.channels * (if (recordingConfig.encoding == "pcm_8bit") 8 else 16) / 8)
1556
+ // Calculate position in milliseconds using stream position
1557
+ val bytesPerSample = when (recordingConfig.encoding) {
1558
+ "pcm_8bit" -> 1
1559
+ "pcm_16bit" -> 2
1560
+ "pcm_32bit" -> 4
1561
+ else -> 2
1562
+ }
1563
+ val byteRate = recordingConfig.sampleRate * recordingConfig.channels * bytesPerSample
1564
+ val positionInMs = (streamPosition * 1000) / byteRate
1555
1565
 
1556
1566
  val compressionBundle = if (recordingConfig.output.compressed.enabled) {
1557
1567
  // For compressed files, we need to get actual size as MediaRecorder handles the writing
@@ -1700,6 +1710,7 @@ class AudioRecorderManager(
1700
1710
  totalRecordedTime = 0
1701
1711
  pausedDuration = 0
1702
1712
  lastEmittedSize = 0
1713
+ streamPosition = 0
1703
1714
  recordingStartTime = 0
1704
1715
 
1705
1716
  // Update the WAV header if needed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siteed/expo-audio-studio",
3
- "version": "2.16.2",
3
+ "version": "2.17.0",
4
4
  "description": "Comprehensive audio processing library for React Native and Expo with recording, analysis, visualization, and streaming capabilities across iOS, Android, and web",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",