Skip to content

Conversation

@michalsek
Copy link
Member

@michalsek michalsek commented Oct 20, 2025

Closes #

⚠️ Breaking changes ⚠️

  • AudioRecorder constructor no longer accepts any options
  • onAudioReady now requires additional properties passed, that define data received by the callback - desired chunk length, channel count, sample rate

Introduced changes

  • Adds option to record to files and makes audio callback optional
  • Smaller fixes around types and their exposure
  • Fixes issue with showing iOS lock screen controls while using only recorder
  • fixes eslint & ts setup
  • fixes issue with setSessionActive always resolving to true no mather if it was succesfull or not
  • slightly refactors of how session options are handled as well as how recorder communicates with the audio engine
  • fixes issue with recorder enforcing sample rate (thus audio output quality) on the playback

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage
  • Added support for web

@gabimoncha
Copy link
Contributor

big if true 🤘🏼

std::string filePath_{""};
std::atomic<size_t> framesWritten_{0};

int32_t streamSampleRate_{0};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a float/double like everywhere else

emitAudioData();
}

void AndroidRecorderCallback::deinterleaveAndWriteAudioData(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT

Suggested change
void AndroidRecorderCallback::deinterleaveAndWriteAudioData(
void AndroidRecorderCallback::deinterleaveAndPushAudioData(

}

void AndroidRecorderCallback::sendRemainingData() {
auto numberOfFrames = circularBus_[0]->getNumberOfAvailableFrames();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally circular bus should be a separate class instead of plain vector of circular arrays

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emitAudioData + sendRemainingData could be rewritten to single method with param emitRemaining: bool

Comment on lines +19 to +24
__android_log_print(
ANDROID_LOG_ERROR,
"FileOptions",
"Error creating directory at path: %s, error: %s",
directoryPath.c_str(),
ec.message().c_str());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary logs

frame_ = av_unique_ptr<AVFrame>(av_frame_alloc());
packet_ = av_unique_ptr<AVPacket>(av_packet_alloc());

int contextFrameRatio = 4;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number

using namespace facebook;
using namespace react;

class NativeFileInfo : public jni::JavaClass<NativeFileInfo> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better name?

Comment on lines +181 to +189
auto result = audioRecorder_->setOnAudioReadyCallback(
sampleRate, bufferLength, channelCount, callbackId);
auto jsResult = jsi::Object(runtime);

jsResult.setProperty(
runtime,
"status",
jsi::String::createFromUtf8(
runtime, result.isSuccess() ? "success" : "error"));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error message is not returned here

int log_level_offset;

enum AVMediaTypeFFmpeg codec_type; /* see AVMEDIA_TYPE_xxx */
enum AVMediaTypeFFMPEG codec_type; /* see AVMEDIA_TYPE_xxx */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary change

sampleRate,
bitRate,
bitDepth,
std::max(flacCompressionLevel - 1, 0),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might not be necessary anymore - with file templates and defaults we don't need to worry about absent parameter

Comment on lines +71 to +75
template<>
class ReturnStatus<void> {
public:
enum class Status {
Success = 0,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dig in, this template spec doesn't seem to be properly picked up by the compiler 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants