Added check on channels number
This commit is contained in:
parent
733c0d8b76
commit
83b02b0ec0
1 changed files with 16 additions and 8 deletions
24
src/gdpd.cpp
24
src/gdpd.cpp
|
|
@ -58,22 +58,30 @@ int Gdpd::init(int nbInputs, int nbOutputs, int sampleRate, int bufferSize) {
|
||||||
Godot::print("There are no available sound devices.");
|
Godot::print("There are no available sound devices.");
|
||||||
}
|
}
|
||||||
|
|
||||||
RtAudio::StreamParameters outParams, inParams;
|
RtAudio::StreamParameters outParams, inpParams;
|
||||||
unsigned int sr = m_audio.getDeviceInfo(outParams.deviceId).preferredSampleRate;
|
inpParams.deviceId = m_audio.getDefaultInputDevice();
|
||||||
outParams.deviceId = m_audio.getDefaultOutputDevice();
|
outParams.deviceId = m_audio.getDefaultOutputDevice();
|
||||||
inParams.deviceId = m_audio.getDefaultInputDevice();
|
RtAudio::DeviceInfo inpInfo = m_audio.getDeviceInfo(inpParams.deviceId);
|
||||||
outParams.nChannels = m_nbInputs = nbInputs;
|
RtAudio::DeviceInfo outInfo = m_audio.getDeviceInfo(outParams.deviceId);
|
||||||
inParams.nChannels = m_nbOutputs = nbOutputs;
|
|
||||||
m_bufferFrames = bufferSize;
|
unsigned int sr = outInfo.preferredSampleRate;
|
||||||
|
inpParams.nChannels = m_nbInputs
|
||||||
|
= std::min<int>(nbInputs, inpInfo.inputChannels);
|
||||||
|
outParams.nChannels = m_nbOutputs
|
||||||
|
= std::min<int>(nbOutputs, outInfo.outputChannels);
|
||||||
|
print("Output channels = "+std::to_string(outParams.nChannels));
|
||||||
|
print("Input channels = "+std::to_string(inpParams.nChannels));
|
||||||
|
m_bufferFrames = std::max<int>(64, bufferSize);
|
||||||
|
|
||||||
|
|
||||||
RtAudio::StreamOptions options;
|
RtAudio::StreamOptions options;
|
||||||
options.streamName = "gdpd";
|
options.streamName = "gdpd";
|
||||||
options.flags = RTAUDIO_SCHEDULE_REALTIME;
|
options.flags = RTAUDIO_SCHEDULE_REALTIME;
|
||||||
if(m_audio.getCurrentApi() != RtAudio::MACOSX_CORE) {
|
if(m_audio.getCurrentApi() != RtAudio::MACOSX_CORE) {
|
||||||
options.flags |= RTAUDIO_MINIMIZE_LATENCY; // CoreAudio doesn't seem to like this
|
options.flags |= RTAUDIO_MINIMIZE_LATENCY;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
m_audio.openStream(&outParams, &inParams, RTAUDIO_FLOAT32,
|
m_audio.openStream(&outParams, &inpParams, RTAUDIO_FLOAT32,
|
||||||
sr, &m_bufferFrames, &audioCallback,
|
sr, &m_bufferFrames, &audioCallback,
|
||||||
this, &options);
|
this, &options);
|
||||||
m_audio.startStream();
|
m_audio.startStream();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue