@siteed/expo-audio-studio 2.14.0 → 2.14.1

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,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
 
10
10
 
11
+ ## [2.14.1] - 2025-06-11
12
+ ### Changed
13
+ - fix(android): Fix duration returning 0 when primary output is disabled (#244) ([38d6f50](https://github.com/deeeed/expo-audio-stream/commit/38d6f50c084a10329be33a0f1c123aa9f457c371))
11
14
  ## [2.14.0] - 2025-06-11
12
15
  ### Changed
13
16
  - feat(expo-audio-studio): comprehensive cross-platform stop recording performance optimization ([b3ed474](https://github.com/deeeed/expo-audio-stream/commit/b3ed474d91994698fe082354621adc98e758557e))
@@ -319,7 +322,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
319
322
  - Feature: Audio features extraction during recording.
320
323
  - Feature: Consistent WAV PCM recording format across all platforms.
321
324
 
322
- [unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.14.0...HEAD
325
+ [unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.14.1...HEAD
326
+ [2.14.1]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.14.0...@siteed/expo-audio-studio@2.14.1
323
327
  [2.14.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.13.2...@siteed/expo-audio-studio@2.14.0
324
328
  [2.13.2]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.13.1...@siteed/expo-audio-studio@2.13.2
325
329
  [2.13.1]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.13.0...@siteed/expo-audio-studio@2.13.1
@@ -928,6 +928,10 @@ class AudioRecorderManager(
928
928
  return
929
929
  }
930
930
 
931
+ // Declare variables at the synchronized block level to ensure they're accessible in both try blocks
932
+ var duration: Long = 0
933
+ var fileSize: Long = 0
934
+
931
935
  try {
932
936
  if (isPaused.get()) {
933
937
  val remainingData = ByteArray(bufferSizeInBytes)
@@ -971,24 +975,11 @@ class AudioRecorderManager(
971
975
  audioRecord!!.stop()
972
976
  }
973
977
 
974
- cleanup()
975
- } catch (e: IllegalStateException) {
976
- LogUtils.e(CLASS_NAME, "Error reading from AudioRecord", e)
977
- } finally {
978
- releaseWakeLock()
979
- audioRecord?.release()
980
- }
981
-
982
- try {
983
- AudioProcessor.resetUniqueIdCounter()
984
- audioProcessor.resetCumulativeAmplitudeRange()
985
-
986
- // Use cached file size to avoid file system call
987
- val fileSize = if (recordingConfig.output.primary.enabled) cachedPrimaryFileSize else 0L
978
+ // Calculate duration BEFORE cleanup (which resets recordingStartTime)
979
+ fileSize = if (recordingConfig.output.primary.enabled) cachedPrimaryFileSize else 0L
988
980
  LogUtils.d(CLASS_NAME, "WAV File validation - Size: $fileSize bytes (cached), Path: ${audioFile?.absolutePath}")
989
981
 
990
- // Calculate duration based on context - use actual recording time for streaming-only mode
991
- val duration = if (!recordingConfig.output.primary.enabled) {
982
+ duration = if (!recordingConfig.output.primary.enabled) {
992
983
  // For streaming-only mode, calculate duration from actual recording time
993
984
  val actualRecordingTime = if (recordingStartTime > 0) {
994
985
  System.currentTimeMillis() - recordingStartTime - pausedDuration
@@ -1012,6 +1003,18 @@ class AudioRecorderManager(
1012
1003
  fileDuration
1013
1004
  }
1014
1005
 
1006
+ cleanup()
1007
+ } catch (e: IllegalStateException) {
1008
+ LogUtils.e(CLASS_NAME, "Error reading from AudioRecord", e)
1009
+ } finally {
1010
+ releaseWakeLock()
1011
+ audioRecord?.release()
1012
+ }
1013
+
1014
+ try {
1015
+ AudioProcessor.resetUniqueIdCounter()
1016
+ audioProcessor.resetCumulativeAmplitudeRange()
1017
+
1015
1018
  compressedRecorder?.apply {
1016
1019
  stop()
1017
1020
  release()
@@ -1221,14 +1224,25 @@ class AudioRecorderManager(
1221
1224
 
1222
1225
  // Use cached file size instead of file system call
1223
1226
  val fileSize = if (recordingConfig.output.primary.enabled) cachedPrimaryFileSize else 0L
1224
- val duration = when (mimeType) {
1225
- "audio/wav" -> {
1226
- val dataFileSize = fileSize - Constants.WAV_HEADER_SIZE
1227
- val byteRate = recordingConfig.sampleRate * recordingConfig.channels *
1228
- (if (recordingConfig.encoding == "pcm_8bit") 8 else 16) / 8
1229
- if (byteRate > 0) dataFileSize * 1000 / byteRate else 0
1227
+ val duration = if (!recordingConfig.output.primary.enabled) {
1228
+ // For streaming-only mode, calculate duration from actual recording time
1229
+ val actualRecordingTime = if (recordingStartTime > 0) {
1230
+ System.currentTimeMillis() - recordingStartTime - pausedDuration
1231
+ } else {
1232
+ 0L
1233
+ }
1234
+ actualRecordingTime
1235
+ } else {
1236
+ // For file-based recording, calculate duration from file size
1237
+ when (mimeType) {
1238
+ "audio/wav" -> {
1239
+ val dataFileSize = fileSize - Constants.WAV_HEADER_SIZE
1240
+ val byteRate = recordingConfig.sampleRate * recordingConfig.channels *
1241
+ (if (recordingConfig.encoding == "pcm_8bit") 8 else 16) / 8
1242
+ if (byteRate > 0) dataFileSize * 1000 / byteRate else 0
1243
+ }
1244
+ else -> totalRecordedTime
1230
1245
  }
1231
- else -> totalRecordedTime
1232
1246
  }
1233
1247
 
1234
1248
  val compressionBundle = if (recordingConfig.output.compressed.enabled) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siteed/expo-audio-studio",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
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",