react-native-audio-api 0.8.1-nightly-fc8149e-20250904 → 0.8.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.
@@ -67,8 +67,8 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithFilePath(
67
67
  #ifndef AUDIO_API_TEST_SUITE
68
68
  std::vector<int16_t> buffer;
69
69
  if (AudioDecoder::pathHasExtension(path, {".mp4", ".m4a", ".aac"})) {
70
- buffer =
71
- ffmpegdecoding::decodeWithFilePath(path, static_cast<int>(sampleRate_));
70
+ buffer = ffmpegdecoding::decodeWithFilePath(
71
+ path, numChannels_, static_cast<int>(sampleRate_));
72
72
  if (buffer.empty()) {
73
73
  __android_log_print(
74
74
  ANDROID_LOG_ERROR,
@@ -122,7 +122,8 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(
122
122
  const AudioFormat format = AudioDecoder::detectAudioFormat(data, size);
123
123
  if (format == AudioFormat::MP4 || format == AudioFormat::M4A ||
124
124
  format == AudioFormat::AAC) {
125
- buffer = ffmpegdecoding::decodeWithMemoryBlock(data, size, sampleRate_);
125
+ buffer = ffmpegdecoding::decodeWithMemoryBlock(
126
+ data, size, numChannels_, sampleRate_);
126
127
  if (buffer.empty()) {
127
128
  __android_log_print(
128
129
  ANDROID_LOG_ERROR, "AudioDecoder", "Failed to decode with FFmpeg");
@@ -218,7 +218,7 @@ std::vector<int16_t> readAllPcmFrames(
218
218
  return buffer;
219
219
  }
220
220
 
221
- std::vector<int16_t> decodeWithMemoryBlock(const void *data, size_t size, int sample_rate) {
221
+ std::vector<int16_t> decodeWithMemoryBlock(const void *data, size_t size, const int channel_count, int sample_rate) {
222
222
  if (data == nullptr || size == 0) {
223
223
  return {};
224
224
  }
@@ -325,7 +325,7 @@ std::vector<int16_t> decodeWithMemoryBlock(const void *data, size_t size, int sa
325
325
  // Decode all frames
326
326
  size_t framesRead = 0;
327
327
  std::vector<int16_t> decoded_buffer = readAllPcmFrames(
328
- fmt_ctx, codec_ctx, sample_rate, audio_stream_index, actual_channels, framesRead);
328
+ fmt_ctx, codec_ctx, sample_rate, audio_stream_index, channel_count, framesRead);
329
329
 
330
330
  // Cleanup - Note: avio_context_free will free the io_buffer
331
331
  avcodec_free_context(&codec_ctx);
@@ -339,7 +339,7 @@ std::vector<int16_t> decodeWithMemoryBlock(const void *data, size_t size, int sa
339
339
  return decoded_buffer;
340
340
  }
341
341
 
342
- std::vector<int16_t> decodeWithFilePath(const std::string &path, int sample_rate) {
342
+ std::vector<int16_t> decodeWithFilePath(const std::string &path, const int channel_count, int sample_rate) {
343
343
  if (path.empty()) {
344
344
  return {};
345
345
  }
@@ -388,16 +388,9 @@ std::vector<int16_t> decodeWithFilePath(const std::string &path, int sample_rate
388
388
  return {};
389
389
  }
390
390
 
391
- int actual_channels = codec_ctx->ch_layout.nb_channels;
392
- if (actual_channels <= 0 || actual_channels > 8) {
393
- avcodec_free_context(&codec_ctx);
394
- avformat_close_input(&fmt_ctx);
395
- return {};
396
- }
397
-
398
391
  size_t framesRead = 0;
399
392
  std::vector<int16_t> decoded_buffer = readAllPcmFrames(
400
- fmt_ctx, codec_ctx, sample_rate, audio_stream_index, actual_channels, framesRead);
393
+ fmt_ctx, codec_ctx, sample_rate, audio_stream_index, channel_count, framesRead);
401
394
 
402
395
  avcodec_free_context(&codec_ctx);
403
396
  avformat_close_input(&fmt_ctx);
@@ -31,7 +31,7 @@ struct MemoryIOContext {
31
31
  int read_packet(void *opaque, uint8_t *buf, int buf_size);
32
32
  int64_t seek_packet(void *opaque, int64_t offset, int whence);
33
33
  std::vector<int16_t> readAllPcmFrames(AVFormatContext *fmt_ctx, AVCodecContext *codec_ctx, int out_sample_rate, int audio_stream_index, int channels, size_t &framesRead);
34
- std::vector<int16_t> decodeWithMemoryBlock(const void *data, size_t size, int sample_rate);
35
- std::vector<int16_t> decodeWithFilePath(const std::string &path, int sample_rate);
34
+ std::vector<int16_t> decodeWithMemoryBlock(const void *data, size_t size, const int channel_count, int sample_rate);
35
+ std::vector<int16_t> decodeWithFilePath(const std::string &path, const int channel_count, int sample_rate);
36
36
 
37
37
  } // namespace audioapi::ffmpegdecoder
@@ -56,7 +56,7 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithFilePath(const std::string &pa
56
56
  {
57
57
  std::vector<int16_t> buffer;
58
58
  if (AudioDecoder::pathHasExtension(path, {".mp4", ".m4a", ".aac"})) {
59
- buffer = ffmpegdecoding::decodeWithFilePath(path, static_cast<int>(sampleRate_));
59
+ buffer = ffmpegdecoding::decodeWithFilePath(path, numChannels_, static_cast<int>(sampleRate_));
60
60
  if (buffer.empty()) {
61
61
  NSLog(@"Failed to decode with FFmpeg: %s", path.c_str());
62
62
  return nullptr;
@@ -93,7 +93,7 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(const void *data,
93
93
  std::vector<int16_t> buffer;
94
94
  const AudioFormat format = AudioDecoder::detectAudioFormat(data, size);
95
95
  if (format == AudioFormat::MP4 || format == AudioFormat::M4A || format == AudioFormat::AAC) {
96
- buffer = ffmpegdecoding::decodeWithMemoryBlock(data, size, static_cast<int>(sampleRate_));
96
+ buffer = ffmpegdecoding::decodeWithMemoryBlock(data, size, numChannels_, static_cast<int>(sampleRate_));
97
97
  if (buffer.empty()) {
98
98
  NSLog(@"Failed to decode with FFmpeg");
99
99
  return nullptr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-audio-api",
3
- "version": "0.8.1-nightly-fc8149e-20250904",
3
+ "version": "0.8.1",
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"