react-native-audio-api 0.11.0-nightly-95f9c99-20251215 → 0.11.0-nightly-dd83923-20251216

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.
Files changed (138) hide show
  1. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +382 -39
  2. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +45 -18
  3. package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
  4. package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +33 -0
  5. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +170 -0
  6. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +46 -0
  7. package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -1
  8. package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.cpp +83 -0
  9. package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.h +22 -0
  10. package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +8 -0
  11. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +493 -0
  12. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +70 -0
  13. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/ptrs.hpp +56 -0
  14. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/utils.cpp +114 -0
  15. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/utils.h +34 -0
  16. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +296 -0
  17. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +40 -0
  18. package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +32 -0
  19. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +2 -0
  20. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +7 -3
  21. package/android/src/main/java/com/swmansion/audioapi/system/CentralizedForegroundService.kt +1 -0
  22. package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
  23. package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotification.kt +1 -0
  24. package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotificationReceiver.kt +2 -0
  25. package/android/src/oldarch/NativeAudioAPIModuleSpec.java +100 -80
  26. package/common/cpp/audioapi/AudioAPIModuleInstaller.h +3 -11
  27. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +145 -16
  28. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +21 -6
  29. package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +43 -60
  30. package/common/cpp/audioapi/core/inputs/AudioRecorder.h +53 -33
  31. package/common/cpp/audioapi/core/sources/RecorderAdapterNode.cpp +42 -14
  32. package/common/cpp/audioapi/core/sources/RecorderAdapterNode.h +12 -9
  33. package/common/cpp/audioapi/core/utils/AudioFileWriter.cpp +41 -0
  34. package/common/cpp/audioapi/core/utils/AudioFileWriter.h +44 -0
  35. package/common/cpp/audioapi/core/utils/AudioRecorderCallback.cpp +101 -0
  36. package/common/cpp/audioapi/core/utils/AudioRecorderCallback.h +52 -0
  37. package/common/cpp/audioapi/utils/AudioFileProperties.cpp +92 -0
  38. package/common/cpp/audioapi/utils/AudioFileProperties.h +76 -0
  39. package/common/cpp/audioapi/utils/Result.hpp +323 -0
  40. package/common/cpp/audioapi/utils/UnitConversion.h +9 -0
  41. package/ios/audioapi/ios/AudioAPIModule.mm +9 -14
  42. package/ios/audioapi/ios/core/IOSAudioPlayer.h +1 -1
  43. package/ios/audioapi/ios/core/IOSAudioPlayer.mm +7 -6
  44. package/ios/audioapi/ios/core/IOSAudioRecorder.h +39 -13
  45. package/ios/audioapi/ios/core/IOSAudioRecorder.mm +302 -26
  46. package/ios/audioapi/ios/core/NativeAudioPlayer.m +7 -11
  47. package/ios/audioapi/ios/core/NativeAudioRecorder.h +8 -9
  48. package/ios/audioapi/ios/core/NativeAudioRecorder.m +70 -76
  49. package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -0
  50. package/ios/audioapi/ios/core/utils/FileOptions.h +33 -0
  51. package/ios/audioapi/ios/core/utils/FileOptions.mm +195 -0
  52. package/ios/audioapi/ios/core/utils/IOSFileWriter.h +53 -0
  53. package/ios/audioapi/ios/core/utils/IOSFileWriter.mm +239 -0
  54. package/ios/audioapi/ios/core/utils/IOSRecorderCallback.h +47 -0
  55. package/ios/audioapi/ios/core/utils/IOSRecorderCallback.mm +185 -0
  56. package/ios/audioapi/ios/system/AudioEngine.h +21 -16
  57. package/ios/audioapi/ios/system/AudioEngine.mm +138 -130
  58. package/ios/audioapi/ios/system/AudioSessionManager.h +19 -9
  59. package/ios/audioapi/ios/system/AudioSessionManager.mm +250 -215
  60. package/ios/audioapi/ios/system/NotificationManager.mm +24 -42
  61. package/lib/commonjs/api.js +82 -109
  62. package/lib/commonjs/api.js.map +1 -1
  63. package/lib/commonjs/core/AudioRecorder.js +159 -13
  64. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  65. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  66. package/lib/commonjs/system/notification/PlaybackNotificationManager.js +17 -14
  67. package/lib/commonjs/system/notification/PlaybackNotificationManager.js.map +1 -1
  68. package/lib/commonjs/system/notification/RecordingNotificationManager.js +22 -19
  69. package/lib/commonjs/system/notification/RecordingNotificationManager.js.map +1 -1
  70. package/lib/commonjs/system/notification/SimpleNotificationManager.js +16 -13
  71. package/lib/commonjs/system/notification/SimpleNotificationManager.js.map +1 -1
  72. package/lib/commonjs/types.js +39 -0
  73. package/lib/commonjs/types.js.map +1 -1
  74. package/lib/commonjs/utils/filePresets.js +43 -0
  75. package/lib/commonjs/utils/filePresets.js.map +1 -0
  76. package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js +6 -3
  77. package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js.map +1 -1
  78. package/lib/commonjs/web-system/notification/RecordingNotificationManager.js +6 -3
  79. package/lib/commonjs/web-system/notification/RecordingNotificationManager.js.map +1 -1
  80. package/lib/module/api.js +5 -4
  81. package/lib/module/api.js.map +1 -1
  82. package/lib/module/core/AudioRecorder.js +159 -13
  83. package/lib/module/core/AudioRecorder.js.map +1 -1
  84. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  85. package/lib/module/system/notification/PlaybackNotificationManager.js +17 -14
  86. package/lib/module/system/notification/PlaybackNotificationManager.js.map +1 -1
  87. package/lib/module/system/notification/RecordingNotificationManager.js +22 -19
  88. package/lib/module/system/notification/RecordingNotificationManager.js.map +1 -1
  89. package/lib/module/system/notification/SimpleNotificationManager.js +16 -13
  90. package/lib/module/system/notification/SimpleNotificationManager.js.map +1 -1
  91. package/lib/module/types.js +38 -1
  92. package/lib/module/types.js.map +1 -1
  93. package/lib/module/utils/filePresets.js +39 -0
  94. package/lib/module/utils/filePresets.js.map +1 -0
  95. package/lib/module/web-system/notification/PlaybackNotificationManager.js +6 -3
  96. package/lib/module/web-system/notification/PlaybackNotificationManager.js.map +1 -1
  97. package/lib/module/web-system/notification/RecordingNotificationManager.js +6 -3
  98. package/lib/module/web-system/notification/RecordingNotificationManager.js.map +1 -1
  99. package/lib/typescript/api.d.ts +5 -4
  100. package/lib/typescript/api.d.ts.map +1 -1
  101. package/lib/typescript/core/AudioRecorder.d.ts +69 -7
  102. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  103. package/lib/typescript/events/types.d.ts +36 -2
  104. package/lib/typescript/events/types.d.ts.map +1 -1
  105. package/lib/typescript/interfaces.d.ts +24 -4
  106. package/lib/typescript/interfaces.d.ts.map +1 -1
  107. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -1
  108. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  109. package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts +4 -3
  110. package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts.map +1 -1
  111. package/lib/typescript/system/notification/RecordingNotificationManager.d.ts +4 -3
  112. package/lib/typescript/system/notification/RecordingNotificationManager.d.ts.map +1 -1
  113. package/lib/typescript/system/notification/SimpleNotificationManager.d.ts +3 -2
  114. package/lib/typescript/system/notification/SimpleNotificationManager.d.ts.map +1 -1
  115. package/lib/typescript/system/notification/types.d.ts.map +1 -1
  116. package/lib/typescript/types.d.ts +79 -3
  117. package/lib/typescript/types.d.ts.map +1 -1
  118. package/lib/typescript/utils/filePresets.d.ts +9 -0
  119. package/lib/typescript/utils/filePresets.d.ts.map +1 -0
  120. package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts +4 -3
  121. package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts.map +1 -1
  122. package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts +4 -3
  123. package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts.map +1 -1
  124. package/package.json +4 -4
  125. package/src/AudioAPIModule/globals.d.ts +1 -2
  126. package/src/api.ts +8 -29
  127. package/src/core/AudioRecorder.ts +195 -23
  128. package/src/events/types.ts +40 -2
  129. package/src/interfaces.ts +34 -5
  130. package/src/specs/NativeAudioAPIModule.ts +2 -2
  131. package/src/system/notification/PlaybackNotificationManager.ts +20 -16
  132. package/src/system/notification/RecordingNotificationManager.ts +26 -21
  133. package/src/system/notification/SimpleNotificationManager.ts +18 -13
  134. package/src/system/notification/types.ts +1 -0
  135. package/src/types.ts +89 -3
  136. package/src/utils/filePresets.ts +47 -0
  137. package/src/web-system/notification/PlaybackNotificationManager.ts +9 -5
  138. package/src/web-system/notification/RecordingNotificationManager.ts +9 -5
@@ -0,0 +1,170 @@
1
+ #include <android/log.h>
2
+ #include <audioapi/HostObjects/sources/AudioBufferHostObject.h>
3
+ #include <audioapi/android/core/utils/AndroidRecorderCallback.h>
4
+ #include <audioapi/events/AudioEventHandlerRegistry.h>
5
+ #include <audioapi/libs/miniaudio/miniaudio.h>
6
+ #include <audioapi/utils/AudioArray.h>
7
+ #include <audioapi/utils/AudioBus.h>
8
+ #include <audioapi/utils/CircularAudioArray.h>
9
+
10
+ #include <algorithm>
11
+ #include <memory>
12
+ #include <string>
13
+ #include <unordered_map>
14
+
15
+ namespace audioapi {
16
+
17
+ /// @brief Constructor
18
+ /// Allocates circular buffer (as every property to do so is already known at this point).
19
+ /// @param audioEventHandlerRegistry The audio event handler registry
20
+ /// @param sampleRate The user desired sample rate
21
+ /// @param bufferLength The user desired buffer length
22
+ /// @param channelCount The user desired channel count
23
+ /// @param callbackId The callback identifier
24
+ AndroidRecorderCallback::AndroidRecorderCallback(
25
+ const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
26
+ float sampleRate,
27
+ size_t bufferLength,
28
+ int channelCount,
29
+ uint64_t callbackId)
30
+ : AudioRecorderCallback(
31
+ audioEventHandlerRegistry,
32
+ sampleRate,
33
+ bufferLength,
34
+ channelCount,
35
+ callbackId) {}
36
+
37
+ AndroidRecorderCallback::~AndroidRecorderCallback() {
38
+ if (converter_ != nullptr) {
39
+ ma_data_converter_uninit(converter_.get(), NULL);
40
+ converter_.reset();
41
+ }
42
+
43
+ if (processingBuffer_ != nullptr) {
44
+ ma_free(processingBuffer_, NULL);
45
+ processingBuffer_ = nullptr;
46
+ processingBufferLength_ = 0;
47
+ }
48
+
49
+ for (size_t i = 0; i < circularBus_.size(); ++i) {
50
+ circularBus_[i]->zero();
51
+ }
52
+ }
53
+
54
+ /// @brief Prepares the recorder callback by initializing the data converter and allocating necessary buffers.
55
+ /// @param streamSampleRate The sample rate of the incoming audio stream.
56
+ /// @param streamChannelCount The channel count of the incoming audio stream.
57
+ /// @param maxInputBufferLength The maximum buffer length of the incoming audio stream.
58
+ Result<NoneType, std::string> AndroidRecorderCallback::prepare(
59
+ float streamSampleRate,
60
+ int32_t streamChannelCount,
61
+ size_t maxInputBufferLength) {
62
+ ma_result result;
63
+
64
+ streamSampleRate_ = streamSampleRate;
65
+ streamChannelCount_ = streamChannelCount;
66
+ maxInputBufferLength_ = maxInputBufferLength;
67
+
68
+ ma_data_converter_config converterConfig = ma_data_converter_config_init(
69
+ ma_format_f32,
70
+ ma_format_f32,
71
+ streamChannelCount_,
72
+ channelCount_,
73
+ streamSampleRate_,
74
+ static_cast<int32_t>(sampleRate_));
75
+
76
+ converter_ = std::make_unique<ma_data_converter>();
77
+ result = ma_data_converter_init(&converterConfig, NULL, converter_.get());
78
+
79
+ if (result != MA_SUCCESS) {
80
+ return Result<NoneType, std::string>::Err(
81
+ "Failed to initialize miniaudio data converter" +
82
+ std::string(ma_result_description(result)));
83
+ }
84
+
85
+ if (streamSampleRate_ <= 0 || streamChannelCount_ <= 0) {
86
+ return Result<NoneType, std::string>::Err("Invalid stream sample rate or channel count");
87
+ }
88
+
89
+ if (sampleRate_ <= 0 || channelCount_ <= 0) {
90
+ return Result<NoneType, std::string>::Err("Invalid callback sample rate or channel count");
91
+ }
92
+
93
+ ma_data_converter_get_expected_output_frame_count(
94
+ converter_.get(), maxInputBufferLength_, &processingBufferLength_);
95
+
96
+ processingBufferLength_ = std::max(processingBufferLength_, (ma_uint64)maxInputBufferLength_);
97
+
98
+ deinterleavingArray_ = std::make_shared<AudioArray>(processingBufferLength_);
99
+ processingBuffer_ = ma_malloc(
100
+ processingBufferLength_ * channelCount_ * ma_get_bytes_per_sample(ma_format_f32), NULL);
101
+
102
+ return Result<NoneType, std::string>::Ok(None);
103
+ }
104
+
105
+ void AndroidRecorderCallback::cleanup() {
106
+ emitAudioData(true);
107
+
108
+ if (converter_ != nullptr) {
109
+ ma_data_converter_uninit(converter_.get(), NULL);
110
+ converter_.reset();
111
+ }
112
+
113
+ if (processingBuffer_ != nullptr) {
114
+ ma_free(processingBuffer_, NULL);
115
+ processingBuffer_ = nullptr;
116
+ processingBufferLength_ = 0;
117
+ }
118
+
119
+ for (size_t i = 0; i < circularBus_.size(); ++i) {
120
+ circularBus_[i]->zero();
121
+ }
122
+ }
123
+
124
+ /// @brief Receives audio data from the recorder, processes it (resampling and deinterleaving if necessary),
125
+ /// and pushes it into the circular buffer.
126
+ /// @param data Pointer to the incoming audio data.
127
+ /// @param numFrames Number of frames in the incoming audio data.
128
+ void AndroidRecorderCallback::receiveAudioData(void *data, int numFrames) {
129
+ if (!isInitialized_.load(std::memory_order_acquire)) {
130
+ return;
131
+ }
132
+
133
+ ma_uint64 inputFrameCount = numFrames;
134
+ ma_uint64 outputFrameCount = 0;
135
+
136
+ if (static_cast<float>(streamSampleRate_) == sampleRate_ &&
137
+ streamChannelCount_ == channelCount_) {
138
+ deinterleaveAndPushAudioData(data, numFrames);
139
+ emitAudioData();
140
+ return;
141
+ }
142
+
143
+ ma_data_converter_get_expected_output_frame_count(
144
+ converter_.get(), inputFrameCount, &outputFrameCount);
145
+
146
+ ma_data_converter_process_pcm_frames(
147
+ converter_.get(), data, &inputFrameCount, processingBuffer_, &outputFrameCount);
148
+
149
+ deinterleaveAndPushAudioData(processingBuffer_, static_cast<int>(outputFrameCount));
150
+ emitAudioData();
151
+ }
152
+
153
+ /// @brief Deinterleaves the audio data and pushes it into the circular buffer.
154
+ /// @param data Pointer to the interleaved audio data.
155
+ /// @param numFrames Number of frames in the audio data.
156
+ void AndroidRecorderCallback::deinterleaveAndPushAudioData(void *data, int numFrames) {
157
+ auto *inputData = static_cast<float *>(data);
158
+
159
+ for (int channel = 0; channel < channelCount_; ++channel) {
160
+ float *channelData = deinterleavingArray_->getData();
161
+
162
+ for (int frame = 0; frame < numFrames; ++frame) {
163
+ channelData[frame] = inputData[frame * channelCount_ + channel];
164
+ }
165
+
166
+ circularBus_[channel]->push_back(channelData, numFrames);
167
+ }
168
+ }
169
+
170
+ } // namespace audioapi
@@ -0,0 +1,46 @@
1
+ #pragma once
2
+
3
+
4
+ #include <audioapi/libs/miniaudio/miniaudio.h>
5
+ #include <audioapi/core/utils/AudioRecorderCallback.h>
6
+ #include <memory>
7
+ #include <vector>
8
+ #include <string>
9
+
10
+ namespace audioapi {
11
+
12
+ class AudioBus;
13
+ class AudioArray;
14
+ class CircularAudioArray;
15
+ class AudioEventHandlerRegistry;
16
+
17
+ class AndroidRecorderCallback : public AudioRecorderCallback {
18
+ public:
19
+ AndroidRecorderCallback(
20
+ const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
21
+ float sampleRate,
22
+ size_t bufferLength,
23
+ int channelCount,
24
+ uint64_t callbackId);
25
+ ~AndroidRecorderCallback();
26
+
27
+ Result<NoneType, std::string> prepare(float streamSampleRate, int streamChannelCount, size_t maxInputBufferLength);
28
+ void cleanup() override;
29
+
30
+ void receiveAudioData(void *data, int numFrames);
31
+
32
+ protected:
33
+ float streamSampleRate_{0.0};
34
+ int streamChannelCount_{0};
35
+ size_t maxInputBufferLength_{0};
36
+
37
+ void *processingBuffer_{nullptr};
38
+ ma_uint64 processingBufferLength_{0};
39
+ std::unique_ptr<ma_data_converter> converter_{nullptr};
40
+
41
+ std::shared_ptr<AudioArray> deinterleavingArray_;
42
+
43
+ void deinterleaveAndPushAudioData(void *data, int numFrames);
44
+ };
45
+
46
+ } // namespace audioapi
@@ -5,7 +5,6 @@
5
5
  #include <audioapi/utils/AudioArray.h>
6
6
  #include <audioapi/utils/AudioBus.h>
7
7
 
8
- #define MINIAUDIO_IMPLEMENTATION
9
8
  #include <audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h>
10
9
  #include <audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h>
11
10
  #include <audioapi/libs/miniaudio/miniaudio.h>
@@ -0,0 +1,83 @@
1
+ #include <android/log.h>
2
+ #include <audioapi/android/core/utils/FileOptions.h>
3
+ #include <audioapi/android/system/NativeFileInfo.hpp>
4
+ #include <audioapi/utils/AudioFileProperties.h>
5
+ #include <chrono>
6
+ #include <filesystem>
7
+ #include <format>
8
+ #include <iostream>
9
+ #include <memory>
10
+ #include <string>
11
+
12
+ namespace audioapi::android::fileoptions {
13
+
14
+ Result<NoneType, std::string> createDirectoryIfNotExists(const std::string &directoryPath) {
15
+ std::error_code ec;
16
+
17
+ if (std::filesystem::exists(directoryPath, ec)) {
18
+ return Result<NoneType, std::string>::Ok(None);
19
+ }
20
+
21
+ bool created = std::filesystem::create_directories(directoryPath, ec);
22
+
23
+ if (!created) {
24
+ return Result<NoneType, std::string>::Err("Failed to create directory: " + directoryPath);
25
+ }
26
+
27
+ if (ec) {
28
+ return Result<NoneType, std::string>::Err(ec.message());
29
+ }
30
+
31
+ return Result<NoneType, std::string>::Ok(None);
32
+ }
33
+
34
+ std::string getTimestampString() {
35
+ auto tNow = std::chrono::system_clock::now();
36
+ return std::format("{:%Y%m%d_%H%M%S}", std::chrono::floor<std::chrono::seconds>(tNow));
37
+ }
38
+
39
+ std::string getDirectory(const std::shared_ptr<AudioFileProperties> &properties) {
40
+ switch (properties->directory) {
41
+ case AudioFileProperties::FileDirectory::Document:
42
+ return NativeFileInfo::getFilesDir();
43
+ case AudioFileProperties::FileDirectory::Cache:
44
+ return NativeFileInfo::getCacheDir();
45
+ default:
46
+ return NativeFileInfo::getCacheDir();
47
+ }
48
+ }
49
+
50
+ std::string getFileExtension(const std::shared_ptr<AudioFileProperties> &properties) {
51
+ switch (properties->format) {
52
+ case AudioFileProperties::Format::WAV:
53
+ return "wav";
54
+ case AudioFileProperties::Format::CAF:
55
+ return "caf";
56
+ case AudioFileProperties::Format::M4A:
57
+ return "m4a";
58
+ case AudioFileProperties::Format::FLAC:
59
+ return "flac";
60
+ default:
61
+ return "m4a";
62
+ }
63
+ }
64
+
65
+ Result<std::string, std::string> getFilePath(
66
+ const std::shared_ptr<AudioFileProperties> &properties) {
67
+ std::string directory = getDirectory(properties);
68
+ std::string subDirectory = std::format("{}/{}", directory, properties->subDirectory);
69
+ std::string fileTimestamp = getTimestampString();
70
+ std::string extension = getFileExtension(properties);
71
+
72
+ auto result = createDirectoryIfNotExists(subDirectory);
73
+
74
+ if (!result.is_ok()) {
75
+ return Result<std::string, std::string>::Err(result.unwrap_err());
76
+ }
77
+
78
+ auto filePath = std::format(
79
+ "{}/{}_{}.{}", subDirectory, properties->fileNamePrefix, fileTimestamp, extension);
80
+ return Result<std::string, std::string>::Ok(filePath);
81
+ }
82
+
83
+ } // namespace audioapi::android::fileoptions
@@ -0,0 +1,22 @@
1
+ #pragma once
2
+
3
+ #include <string>
4
+ #include <memory>
5
+ #include <audioapi/utils/Result.hpp>
6
+
7
+ namespace audioapi {
8
+
9
+ class AudioFileProperties;
10
+
11
+ namespace android::fileoptions {
12
+
13
+ Result<NoneType, std::string> createDirectoryIfNotExists(const std::string &directoryPath);
14
+ std::string getTimestampString();
15
+
16
+ std::string getDirectory(const std::shared_ptr<AudioFileProperties> &properties);
17
+ std::string getFileExtension(const std::shared_ptr<AudioFileProperties> &properties);
18
+ Result<std::string, std::string> getFilePath(const std::shared_ptr<AudioFileProperties> &properties);
19
+
20
+ } // namespace android::fileoptions
21
+
22
+ } // namespace audioapi
@@ -0,0 +1,8 @@
1
+ /// Miniaudio implementation for Android platform.
2
+ /// this define tells the miniaudio to also include the definitions and not only declarations.
3
+ /// Which should be done only once in the whole project.
4
+ /// This make its safe to include the header file in multiple places, without causing multiple definition errors.
5
+ /// TODO: Consider moving this file to common scope to re-use the miniaudio also for iOS platform.
6
+ #define MINIAUDIO_IMPLEMENTATION
7
+ #define MA_DEBUG_OUTPUT
8
+ #include <audioapi/libs/miniaudio/miniaudio.h>