Skip to content

Commit

Permalink
feat: implement wrappers for getDefaultInputDevice and getDefaultOutp…
Browse files Browse the repository at this point in the history
…utDevice
  • Loading branch information
almoghamdani committed Dec 16, 2019
1 parent 3692ba5 commit 3643bc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/rt_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ Napi::Object RtAudioWrap::Init(Napi::Env env, Napi::Object exports)
InstanceMethod("getStreamSampleRate", &RtAudioWrap::getStreamSampleRate),
InstanceMethod("getStreamTime", &RtAudioWrap::getStreamTime),
InstanceMethod("setStreamTime", &RtAudioWrap::setStreamTime),
InstanceMethod("getDevices", &RtAudioWrap::getDevices)});
InstanceMethod("getDevices", &RtAudioWrap::getDevices),
InstanceMethod("getDefaultInputDevice", &RtAudioWrap::getDefaultInputDevice),
InstanceMethod("getDefaultOutputDevice", &RtAudioWrap::getDefaultOutputDevice)});

// Set the class's ctor function as a persistent object to keep it in memory
constructor = Napi::Persistent(ctor_func);
Expand Down Expand Up @@ -137,6 +139,16 @@ Napi::Value RtAudioWrap::getDevices(const Napi::CallbackInfo &info)
return devicesArray;
}

Napi::Value RtAudioWrap::getDefaultInputDevice(const Napi::CallbackInfo &info)
{
return Napi::Number::New(info.Env(), _rtAudio->getDefaultInputDevice());
}

Napi::Value RtAudioWrap::getDefaultOutputDevice(const Napi::CallbackInfo &info)
{
return Napi::Number::New(info.Env(), _rtAudio->getDefaultOutputDevice());
}

void RtAudioWrap::openStream(const Napi::CallbackInfo &info)
{
RtAudio::StreamParameters outputParams = info[0].IsNull() || info[0].IsUndefined() ? RtAudio::StreamParameters() : RtAudioConverter::ConvertStreamParameters(info[0].As<Napi::Object>());
Expand Down
2 changes: 2 additions & 0 deletions src/rt_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class RtAudioWrap : public Napi::ObjectWrap<RtAudioWrap>
~RtAudioWrap();

Napi::Value getDevices(const Napi::CallbackInfo &info);
Napi::Value getDefaultInputDevice(const Napi::CallbackInfo& info);
Napi::Value getDefaultOutputDevice(const Napi::CallbackInfo& info);

void openStream(const Napi::CallbackInfo &info);
void closeStream(const Napi::CallbackInfo &info);
Expand Down

0 comments on commit 3643bc1

Please sign in to comment.