react-native-audio-api 0.6.4-nightly-b9b41c3-20250714 → 0.6.4-nightly-c1e4367-20250715
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/android/src/main/cpp/audioapi/android/core/AudioDecoder.cpp +12 -14
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +0 -6
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.cpp +13 -12
- package/common/cpp/audioapi/jsi/JsiPromise.cpp +1 -0
- package/common/cpp/test/CMakeLists.txt +7 -24
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#define MINIAUDIO_IMPLEMENTATION
|
|
8
8
|
#include <audioapi/libs/miniaudio/miniaudio.h>
|
|
9
9
|
|
|
10
|
-
#include <android/log.h>
|
|
10
|
+
// #include <android/log.h>
|
|
11
11
|
|
|
12
12
|
namespace audioapi {
|
|
13
13
|
|
|
@@ -18,12 +18,11 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithFilePath(
|
|
|
18
18
|
ma_decoder_config_init(ma_format_f32, 2, static_cast<int>(sampleRate_));
|
|
19
19
|
ma_result result = ma_decoder_init_file(path.c_str(), &config, &decoder);
|
|
20
20
|
if (result != MA_SUCCESS) {
|
|
21
|
-
__android_log_print(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
// __android_log_print(
|
|
22
|
+
// ANDROID_LOG_ERROR,
|
|
23
|
+
// "AudioDecoder",
|
|
24
|
+
// "Failed to initialize decoder for file: %s",
|
|
25
|
+
// path.c_str());
|
|
27
26
|
ma_decoder_uninit(&decoder);
|
|
28
27
|
|
|
29
28
|
return nullptr;
|
|
@@ -40,7 +39,7 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithFilePath(
|
|
|
40
39
|
ma_decoder_read_pcm_frames(&decoder, buffer, totalFrameCount, &framesDecoded);
|
|
41
40
|
|
|
42
41
|
if (framesDecoded == 0) {
|
|
43
|
-
__android_log_print(ANDROID_LOG_ERROR, "AudioDecoder", "Failed to decode");
|
|
42
|
+
// __android_log_print(ANDROID_LOG_ERROR, "AudioDecoder", "Failed to decode");
|
|
44
43
|
|
|
45
44
|
delete[] buffer;
|
|
46
45
|
ma_decoder_uninit(&decoder);
|
|
@@ -70,11 +69,10 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(
|
|
|
70
69
|
ma_decoder_config_init(ma_format_f32, 2, static_cast<int>(sampleRate_));
|
|
71
70
|
ma_result result = ma_decoder_init_memory(data, size, &config, &decoder);
|
|
72
71
|
if (result != MA_SUCCESS) {
|
|
73
|
-
__android_log_print(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
// __android_log_print(
|
|
73
|
+
// ANDROID_LOG_ERROR,
|
|
74
|
+
// "AudioDecoder",
|
|
75
|
+
// "Failed to initialize decoder for memory block");
|
|
78
76
|
ma_decoder_uninit(&decoder);
|
|
79
77
|
|
|
80
78
|
return nullptr;
|
|
@@ -90,7 +88,7 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(
|
|
|
90
88
|
ma_uint64 framesDecoded;
|
|
91
89
|
ma_decoder_read_pcm_frames(&decoder, buffer, totalFrameCount, &framesDecoded);
|
|
92
90
|
if (framesDecoded == 0) {
|
|
93
|
-
__android_log_print(ANDROID_LOG_ERROR, "AudioDecoder", "Failed to decode");
|
|
91
|
+
// __android_log_print(ANDROID_LOG_ERROR, "AudioDecoder", "Failed to decode");
|
|
94
92
|
|
|
95
93
|
delete[] buffer;
|
|
96
94
|
ma_decoder_uninit(&decoder);
|
|
@@ -119,7 +119,6 @@ std::shared_ptr<AnalyserNode> BaseAudioContext::createAnalyser() {
|
|
|
119
119
|
|
|
120
120
|
std::shared_ptr<AudioBuffer> BaseAudioContext::decodeAudioDataSource(
|
|
121
121
|
const std::string &path) {
|
|
122
|
-
#ifndef AUDIO_API_TEST_SUITE
|
|
123
122
|
auto audioBus = audioDecoder_->decodeWithFilePath(path);
|
|
124
123
|
|
|
125
124
|
if (!audioBus) {
|
|
@@ -127,13 +126,11 @@ std::shared_ptr<AudioBuffer> BaseAudioContext::decodeAudioDataSource(
|
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
return std::make_shared<AudioBuffer>(audioBus);
|
|
130
|
-
#endif // AUDIO_API_TEST_SUITE
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
std::shared_ptr<AudioBuffer> BaseAudioContext::decodeAudioData(
|
|
134
132
|
const void *data,
|
|
135
133
|
size_t size) {
|
|
136
|
-
#ifndef AUDIO_API_TEST_SUITE
|
|
137
134
|
auto audioBus = audioDecoder_->decodeWithMemoryBlock(data, size);
|
|
138
135
|
|
|
139
136
|
if (!audioBus) {
|
|
@@ -141,12 +138,10 @@ std::shared_ptr<AudioBuffer> BaseAudioContext::decodeAudioData(
|
|
|
141
138
|
}
|
|
142
139
|
|
|
143
140
|
return std::make_shared<AudioBuffer>(audioBus);
|
|
144
|
-
#endif // AUDIO_API_TEST_SUITE
|
|
145
141
|
}
|
|
146
142
|
|
|
147
143
|
std::shared_ptr<AudioBuffer> BaseAudioContext::decodeWithPCMInBase64(
|
|
148
144
|
const std::string &data) {
|
|
149
|
-
#ifndef AUDIO_API_TEST_SUITE
|
|
150
145
|
auto audioBus = audioDecoder_->decodeWithPCMInBase64(data);
|
|
151
146
|
|
|
152
147
|
if (!audioBus) {
|
|
@@ -154,7 +149,6 @@ std::shared_ptr<AudioBuffer> BaseAudioContext::decodeWithPCMInBase64(
|
|
|
154
149
|
}
|
|
155
150
|
|
|
156
151
|
return std::make_shared<AudioBuffer>(audioBus);
|
|
157
|
-
#endif // AUDIO_API_TEST_SUITE
|
|
158
152
|
}
|
|
159
153
|
|
|
160
154
|
AudioNodeManager *BaseAudioContext::getNodeManager() {
|
|
@@ -136,19 +136,20 @@ jsi::Object AudioEventHandlerRegistry::createEventObject(
|
|
|
136
136
|
const auto name = pair.first.data();
|
|
137
137
|
const auto &value = pair.second;
|
|
138
138
|
|
|
139
|
-
if (holds_alternative<int>(value)) {
|
|
140
|
-
eventObject.setProperty(*runtime_, name, get<int>(value));
|
|
141
|
-
} else if (holds_alternative<double>(value)) {
|
|
142
|
-
eventObject.setProperty(*runtime_, name, get<double>(value));
|
|
143
|
-
} else if (holds_alternative<float>(value)) {
|
|
144
|
-
eventObject.setProperty(*runtime_, name, get<float>(value));
|
|
145
|
-
} else if (holds_alternative<bool>(value)) {
|
|
146
|
-
eventObject.setProperty(*runtime_, name, get<bool>(value));
|
|
147
|
-
} else if (holds_alternative<std::string>(value)) {
|
|
148
|
-
eventObject.setProperty(*runtime_, name, get<std::string>(value));
|
|
149
|
-
} else if (holds_alternative<std::shared_ptr<jsi::HostObject>>(
|
|
139
|
+
if (std::holds_alternative<int>(value)) {
|
|
140
|
+
eventObject.setProperty(*runtime_, name, std::get<int>(value));
|
|
141
|
+
} else if (std::holds_alternative<double>(value)) {
|
|
142
|
+
eventObject.setProperty(*runtime_, name, std::get<double>(value));
|
|
143
|
+
} else if (std::holds_alternative<float>(value)) {
|
|
144
|
+
eventObject.setProperty(*runtime_, name, std::get<float>(value));
|
|
145
|
+
} else if (std::holds_alternative<bool>(value)) {
|
|
146
|
+
eventObject.setProperty(*runtime_, name, std::get<bool>(value));
|
|
147
|
+
} else if (std::holds_alternative<std::string>(value)) {
|
|
148
|
+
eventObject.setProperty(*runtime_, name, std::get<std::string>(value));
|
|
149
|
+
} else if (std::holds_alternative<std::shared_ptr<jsi::HostObject>>(
|
|
150
|
+
value)) {
|
|
150
151
|
auto hostObject = jsi::Object::createFromHostObject(
|
|
151
|
-
*runtime_, get<std::shared_ptr<jsi::HostObject>>(value));
|
|
152
|
+
*runtime_, std::get<std::shared_ptr<jsi::HostObject>>(value));
|
|
152
153
|
eventObject.setProperty(*runtime_, name, hostObject);
|
|
153
154
|
}
|
|
154
155
|
}
|
|
@@ -7,46 +7,29 @@ set(ROOT ${CMAKE_SOURCE_DIR}/../../../../..)
|
|
|
7
7
|
set(REACT_NATIVE_DIR "${ROOT}/node_modules/react-native")
|
|
8
8
|
set(JSI_DIR "${REACT_NATIVE_DIR}/ReactCommon/jsi")
|
|
9
9
|
|
|
10
|
-
include(CMakePrintHelpers)
|
|
11
|
-
cmake_print_variables(ROOT)
|
|
12
|
-
|
|
13
10
|
include(FetchContent)
|
|
14
11
|
FetchContent_Declare(
|
|
15
12
|
googletest
|
|
16
|
-
URL https://github.com/google/googletest/archive/
|
|
13
|
+
URL https://github.com/google/googletest/archive/3983f67e32fb3e9294487b9d4f9586efa6e5d088.zip
|
|
17
14
|
)
|
|
18
15
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
19
16
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
20
17
|
FetchContent_MakeAvailable(googletest)
|
|
21
18
|
|
|
22
|
-
message(STATUS "Using C++ compiler: ${CMAKE_CXX_COMPILER}")
|
|
23
|
-
|
|
24
19
|
enable_testing()
|
|
25
|
-
add_compile_definitions(AUDIO_API_TEST_SUITE)
|
|
26
20
|
|
|
27
21
|
file(GLOB_RECURSE RNAUDIOAPI_SRC
|
|
28
22
|
CONFIGURE_DEPENDS
|
|
29
|
-
"${ROOT}/
|
|
30
|
-
"${ROOT}/
|
|
31
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/BaseAudioContext.cpp"
|
|
32
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/OfflineAudioContext.cpp"
|
|
33
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/analysis/*.cpp"
|
|
34
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/destinations/*.cpp"
|
|
35
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/effects/*.cpp"
|
|
36
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/inputs/*.cpp"
|
|
37
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/sources/*.cpp"
|
|
38
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/types/*.cpp"
|
|
39
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/core/utils/*.cpp"
|
|
40
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/dsp/*.cpp"
|
|
41
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/utils/*.cpp"
|
|
23
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/*.cpp"
|
|
24
|
+
"${ROOT}/node_modules/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AudioDecoder.cpp"
|
|
42
25
|
)
|
|
43
26
|
|
|
27
|
+
list(REMOVE_ITEM RNAUDIOAPI_SRC "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/AudioContext.cpp")
|
|
28
|
+
|
|
44
29
|
file(GLOB_RECURSE RNAUDIOAPI_LIBS
|
|
45
30
|
CONFIGURE_DEPENDS
|
|
46
|
-
"${ROOT}/
|
|
47
|
-
"${ROOT}/
|
|
48
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/libs/pffft/*.c"
|
|
49
|
-
"${ROOT}/packages/react-native-audio-api/common/cpp/audioapi/libs/signalsmith-stretch/*.h"
|
|
31
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/*.c"
|
|
32
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/*.h"
|
|
50
33
|
)
|
|
51
34
|
|
|
52
35
|
add_library(rnaudioapi STATIC ${RNAUDIOAPI_SRC})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.6.4-nightly-
|
|
3
|
+
"version": "0.6.4-nightly-c1e4367-20250715",
|
|
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"
|