Skip to content

Commit

Permalink
ci: yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Makowski committed Dec 11, 2024
1 parent 146d1c9 commit 0a7feb0
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ AudioAPIInstaller::AudioAPIInstaller(
jsCallInvoker_(jsCallInvoker) {}

void AudioAPIInstaller::install() {
auto hostObject = std::make_shared<AudioAPIInstallerHostObject>(rnRuntime_, jsCallInvoker_);
auto hostObject =
std::make_shared<AudioAPIInstallerHostObject>(rnRuntime_, jsCallInvoker_);
hostObject->install();
}
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ namespace audioapi {
using namespace facebook;

AudioAPIInstallerHostObject::AudioAPIInstallerHostObject(
jsi::Runtime *runtime,
const std::shared_ptr<react::CallInvoker> &jsInvoker): rnRuntime_(runtime) {
jsi::Runtime *runtime,
const std::shared_ptr<react::CallInvoker> &jsInvoker)
: rnRuntime_(runtime) {
promiseVendor_ =
std::make_shared<JsiPromise::PromiseVendor>(runtime, jsInvoker);
}
Expand Down Expand Up @@ -33,9 +34,10 @@ jsi::Value AudioAPIInstallerHostObject::get(
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value {
auto audioContext = std::make_shared<AudioContext>();
auto audioContextHostObject = std::make_shared<AudioContextHostObject>(
audioContext, promiseVendor_);
auto audioContext = std::make_shared<AudioContext>();
auto audioContextHostObject =
std::make_shared<AudioContextHostObject>(
audioContext, promiseVendor_);
return jsi::Object::createFromHostObject(
runtime, audioContextHostObject);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,32 @@
namespace audioapi {
using namespace facebook;

class AudioAPIInstallerHostObject : public jsi::HostObject, public std::enable_shared_from_this<AudioAPIInstallerHostObject> {

public:
class AudioAPIInstallerHostObject
: public jsi::HostObject,
public std::enable_shared_from_this<AudioAPIInstallerHostObject> {
public:
explicit AudioAPIInstallerHostObject(
jsi::Runtime *runtime,
const std::shared_ptr<react::CallInvoker> &jsInvoker);

jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override;
jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override;

void set(
jsi::Runtime &runtime,
const jsi::PropNameID &name,
const jsi::Value &value) override;
void set(
jsi::Runtime &runtime,
const jsi::PropNameID &name,
const jsi::Value &value) override;

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;

void install() {
auto object = jsi::Object::createFromHostObject(*rnRuntime_, shared_from_this());
rnRuntime_->global().setProperty(
*rnRuntime_, "__AudioAPIInstaller", std::move(object));
}
void install() {
auto object =
jsi::Object::createFromHostObject(*rnRuntime_, shared_from_this());
rnRuntime_->global().setProperty(
*rnRuntime_, "__AudioAPIInstaller", std::move(object));
}

private:
std::shared_ptr<JsiPromise::PromiseVendor> promiseVendor_;
jsi::Runtime *rnRuntime_;
jsi::Runtime *rnRuntime_;
};
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ AudioBufferSourceNodeHostObject::AudioBufferSourceNodeHostObject(
const std::shared_ptr<AudioBufferSourceNode> &node)
: AudioScheduledSourceNodeHostObject(node) {}

std::shared_ptr<AudioBufferSourceNode> AudioBufferSourceNodeHostObject::
getAudioBufferSourceNodeFromAudioNode() {
std::shared_ptr<AudioBufferSourceNode>
AudioBufferSourceNodeHostObject::getAudioBufferSourceNodeFromAudioNode() {
return std::static_pointer_cast<AudioBufferSourceNode>(node_);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using namespace facebook;

AudioContextHostObject::AudioContextHostObject(
const std::shared_ptr<AudioContext> &audioContext,
const std::shared_ptr<JsiPromise::PromiseVendor>& promiseVendor)
const std::shared_ptr<JsiPromise::PromiseVendor> &promiseVendor)
: BaseAudioContextHostObject(audioContext, promiseVendor) {}

std::vector<jsi::PropNameID> AudioContextHostObject::getPropertyNames(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AudioContextHostObject : public BaseAudioContextHostObject {
public:
explicit AudioContextHostObject(
const std::shared_ptr<AudioContext> &audioContext,
const std::shared_ptr<JsiPromise::PromiseVendor>& promiseVendor);
const std::shared_ptr<JsiPromise::PromiseVendor> &promiseVendor);

jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override;

Expand All @@ -27,7 +27,6 @@ class AudioContextHostObject : public BaseAudioContextHostObject {
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;

private:
std::shared_ptr<AudioContext>
getAudioContextFromBaseAudioContext();
std::shared_ptr<AudioContext> getAudioContextFromBaseAudioContext();
};
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
namespace audioapi {
using namespace facebook;

AudioNodeHostObject::AudioNodeHostObject(
const std::shared_ptr<AudioNode> &node)
AudioNodeHostObject::AudioNodeHostObject(const std::shared_ptr<AudioNode> &node)
: node_(node) {}

std::vector<jsi::PropNameID> AudioNodeHostObject::getPropertyNames(
Expand Down Expand Up @@ -41,8 +40,7 @@ jsi::Value AudioNodeHostObject::get(
size_t count) -> jsi::Value {
auto node =
args[0].getObject(rt).getHostObject<AudioNodeHostObject>(rt);
node_->connect(
std::shared_ptr<AudioNodeHostObject>(node)->node_);
node_->connect(std::shared_ptr<AudioNodeHostObject>(node)->node_);
return jsi::Value::undefined();
});
}
Expand All @@ -59,8 +57,7 @@ jsi::Value AudioNodeHostObject::get(
size_t count) -> jsi::Value {
auto node =
args[0].getObject(rt).getHostObject<AudioNodeHostObject>(rt);
node_->disconnect(
std::shared_ptr<AudioNodeHostObject>(node)->node_);
node_->disconnect(std::shared_ptr<AudioNodeHostObject>(node)->node_);
return jsi::Value::undefined();
});
}
Expand All @@ -78,8 +75,7 @@ jsi::Value AudioNodeHostObject::get(
}

if (propName == "channelCountMode") {
return jsi::String::createFromUtf8(
runtime, node_->getChannelCountMode());
return jsi::String::createFromUtf8(runtime, node_->getChannelCountMode());
}

if (propName == "channelInterpretation") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ using namespace facebook;

class AudioNodeHostObject : public jsi::HostObject {
public:
explicit AudioNodeHostObject(
const std::shared_ptr<AudioNode> &node);
explicit AudioNodeHostObject(const std::shared_ptr<AudioNode> &node);

jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jsi::Value AudioParamHostObject::get(
const jsi::Value &thisVal,
const jsi::Value *args,
size_t count) -> jsi::Value {
auto value = static_cast<float>(args[0].getNumber());
auto value = static_cast<float>(args[0].getNumber());
double startTime = args[1].getNumber();
param_->setValueAtTime(value, startTime);
return jsi::Value::undefined();
Expand All @@ -70,7 +70,7 @@ jsi::Value AudioParamHostObject::get(
const jsi::Value &thisVal,
const jsi::Value *args,
size_t count) -> jsi::Value {
auto value = static_cast<float>(args[0].getNumber());
auto value = static_cast<float>(args[0].getNumber());
double endTime = args[1].getNumber();
param_->linearRampToValueAtTime(value, endTime);
return jsi::Value::undefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ namespace audioapi {
using namespace facebook;

std::shared_ptr<AudioScheduledSourceNode>
AudioScheduledSourceNodeHostObject::
getAudioScheduledSourceNodeFromAudioNode() {
AudioScheduledSourceNodeHostObject::getAudioScheduledSourceNodeFromAudioNode() {
return std::static_pointer_cast<AudioScheduledSourceNode>(node_);
}

Expand Down Expand Up @@ -34,8 +33,7 @@ jsi::Value AudioScheduledSourceNodeHostObject::get(
const jsi::Value *args,
size_t count) -> jsi::Value {
auto time = args[0].getNumber();
auto node =
getAudioScheduledSourceNodeFromAudioNode();
auto node = getAudioScheduledSourceNodeFromAudioNode();
node->start(time);
return jsi::Value::undefined();
});
Expand All @@ -52,8 +50,7 @@ jsi::Value AudioScheduledSourceNodeHostObject::get(
const jsi::Value *args,
size_t count) -> jsi::Value {
auto time = args[0].getNumber();
auto node =
getAudioScheduledSourceNodeFromAudioNode();
auto node = getAudioScheduledSourceNodeFromAudioNode();
node->stop(time);
return jsi::Value::undefined();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ BaseAudioContextHostObject::BaseAudioContextHostObject(
const std::shared_ptr<BaseAudioContext> &context,
const std::shared_ptr<JsiPromise::PromiseVendor> &promiseVendor)
: context_(context), promiseVendor_(promiseVendor) {
destination_ = std::make_shared<AudioDestinationNodeHostObject>(context->getDestination());
destination_ = std::make_shared<AudioDestinationNodeHostObject>(
context->getDestination());
}

std::vector<jsi::PropNameID> BaseAudioContextHostObject::getPropertyNames(
Expand Down Expand Up @@ -68,7 +69,8 @@ jsi::Value BaseAudioContextHostObject::get(
const jsi::Value *arguments,
size_t count) -> jsi::Value {
auto oscillator = context_->createOscillator();
auto oscillatorHostObject = std::make_shared<OscillatorNodeHostObject>(oscillator);
auto oscillatorHostObject =
std::make_shared<OscillatorNodeHostObject>(oscillator);
return jsi::Object::createFromHostObject(
runtime, oscillatorHostObject);
});
Expand Down Expand Up @@ -101,7 +103,8 @@ jsi::Value BaseAudioContextHostObject::get(
const jsi::Value *arguments,
size_t count) -> jsi::Value {
auto stereoPanner = context_->createStereoPanner();
auto stereoPannerHostObject = std::make_shared<StereoPannerNodeHostObject>(stereoPanner);
auto stereoPannerHostObject =
std::make_shared<StereoPannerNodeHostObject>(stereoPanner);
return jsi::Object::createFromHostObject(
runtime, stereoPannerHostObject);
});
Expand All @@ -118,7 +121,8 @@ jsi::Value BaseAudioContextHostObject::get(
const jsi::Value *arguments,
size_t count) -> jsi::Value {
auto biquadFilter = context_->createBiquadFilter();
auto biquadFilterHostObject = std::make_shared<BiquadFilterNodeHostObject>(biquadFilter);
auto biquadFilterHostObject =
std::make_shared<BiquadFilterNodeHostObject>(biquadFilter);
return jsi::Object::createFromHostObject(
runtime, biquadFilterHostObject);
});
Expand All @@ -135,7 +139,8 @@ jsi::Value BaseAudioContextHostObject::get(
const jsi::Value *arguments,
size_t count) -> jsi::Value {
auto bufferSource = context_->createBufferSource();
auto bufferSourceHostObject = std::make_shared<AudioBufferSourceNodeHostObject>(bufferSource);
auto bufferSourceHostObject =
std::make_shared<AudioBufferSourceNodeHostObject>(bufferSource);
return jsi::Object::createFromHostObject(
runtime, bufferSourceHostObject);
});
Expand All @@ -155,8 +160,9 @@ jsi::Value BaseAudioContextHostObject::get(
auto length = static_cast<int>(arguments[1].getNumber());
auto sampleRate = static_cast<int>(arguments[2].getNumber());
auto buffer =
context_->createBuffer(numberOfChannels, length, sampleRate);
auto bufferHostObject = std::make_shared<AudioBufferHostObject>(buffer);
context_->createBuffer(numberOfChannels, length, sampleRate);
auto bufferHostObject =
std::make_shared<AudioBufferHostObject>(buffer);
return jsi::Object::createFromHostObject(runtime, bufferHostObject);
});
}
Expand Down Expand Up @@ -191,7 +197,8 @@ jsi::Value BaseAudioContextHostObject::get(

auto periodicWave = context_->createPeriodicWave(
realData, imagData, disableNormalization, length);
auto periodicWaveHostObject = std::make_shared<PeriodicWaveHostObject>(periodicWave);
auto periodicWaveHostObject =
std::make_shared<PeriodicWaveHostObject>(periodicWave);
return jsi::Object::createFromHostObject(
runtime, periodicWaveHostObject);
});
Expand All @@ -213,7 +220,8 @@ jsi::Value BaseAudioContextHostObject::get(
sourcePath,
promise = std::move(promise)]() {
auto results = context_->decodeAudioDataSource(sourcePath);
auto audioBufferHostObject = std::make_shared<AudioBufferHostObject>(results);
auto audioBufferHostObject =
std::make_shared<AudioBufferHostObject>(results);

promise->resolve(jsi::Object::createFromHostObject(
runtime, audioBufferHostObject));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ BiquadFilterNodeHostObject::getBiquadFilterNodeFromAudioNode() {
BiquadFilterNodeHostObject::BiquadFilterNodeHostObject(
const std::shared_ptr<BiquadFilterNode> &node)
: AudioNodeHostObject(node) {
frequencyParam_ = std::make_shared<AudioParamHostObject>(node->getFrequencyParam());
frequencyParam_ =
std::make_shared<AudioParamHostObject>(node->getFrequencyParam());
detuneParam_ = std::make_shared<AudioParamHostObject>(node->getDetuneParam());
QParam_ = std::make_shared<AudioParamHostObject>(node->getQParam());
gainParam_ = std::make_shared<AudioParamHostObject>(node->getGainParam());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class BiquadFilterNodeHostObject : public AudioNodeHostObject {
std::shared_ptr<AudioParamHostObject> QParam_;
std::shared_ptr<AudioParamHostObject> gainParam_;

std::shared_ptr<BiquadFilterNode>
getBiquadFilterNodeFromAudioNode();
std::shared_ptr<BiquadFilterNode> getBiquadFilterNodeFromAudioNode();
};
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
namespace audioapi {
using namespace facebook;

GainNodeHostObject::GainNodeHostObject(
const std::shared_ptr<GainNode> &node)
GainNodeHostObject::GainNodeHostObject(const std::shared_ptr<GainNode> &node)
: AudioNodeHostObject(node) {
auto gainParamWrapper = node->getGainParam();
gainParam_ = std::make_shared<AudioParamHostObject>(gainParamWrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class OscillatorNodeHostObject : public AudioScheduledSourceNodeHostObject {
std::shared_ptr<AudioParamHostObject> frequencyParam_;
std::shared_ptr<AudioParamHostObject> detuneParam_;

std::shared_ptr<OscillatorNode>
getOscillatorNodeFromAudioNode();
std::shared_ptr<OscillatorNode> getOscillatorNodeFromAudioNode();
};
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AudioDestinationNode : public AudioNode {
protected:
// DestinationNode is triggered by AudioContext using renderAudio
// processNode function is not necessary and is never called.
void processNode(AudioBus *, int) final{};
void processNode(AudioBus *, int) final {};

private:
std::size_t currentSampleFrame_;
Expand Down
3 changes: 1 addition & 2 deletions packages/react-native-audio-api/ios/AudioAPIModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ @implementation AudioAPIModule

auto &runtime = *jsRuntime;

auto hostObject =
std::make_shared<audioapi::AudioAPIInstallerHostObject>(jsRuntime, cxxBridge.jsCallInvoker);
auto hostObject = std::make_shared<audioapi::AudioAPIInstallerHostObject>(jsRuntime, cxxBridge.jsCallInvoker);
hostObject->install();

NSLog(@"Successfully installed JSI bindings for react-native-audio-api!");
Expand Down
19 changes: 9 additions & 10 deletions packages/react-native-audio-api/ios/AudioDecoder/AudioDecoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ - (AVAudioPCMBuffer *)convertBuffer:(AVAudioPCMBuffer *)buffer ToFormat:(AVAudio
[[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:(AVAudioFrameCount)buffer.frameCapacity];

AVAudioConverterInputBlock inputBlock =
^AVAudioBuffer *(AVAudioPacketCount inNumberOfPackets, AVAudioConverterInputStatus *outStatus)
{
if (buffer.frameLength > 0) {
*outStatus = AVAudioConverterInputStatus_HaveData;
return buffer;
} else {
*outStatus = AVAudioConverterInputStatus_NoDataNow;
return nil;
}
};
^AVAudioBuffer *(AVAudioPacketCount inNumberOfPackets, AVAudioConverterInputStatus *outStatus) {
if (buffer.frameLength > 0) {
*outStatus = AVAudioConverterInputStatus_HaveData;
return buffer;
} else {
*outStatus = AVAudioConverterInputStatus_NoDataNow;
return nil;
}
};

[converter convertToBuffer:convertedBuffer error:&error withInputFromBlock:inputBlock];

Expand Down

0 comments on commit 0a7feb0

Please sign in to comment.