Browse Source

Allow RtAudio device name to be empty, gets default value

tags/v1.9.11
falkTX FilipeCSnuk 6 years ago
parent
commit
e0477b1683
2 changed files with 34 additions and 19 deletions
  1. +1
    -1
      source/backend/CarlaStandalone.cpp
  2. +33
    -18
      source/backend/engine/CarlaEngineRtAudio.cpp

+ 1
- 1
source/backend/CarlaStandalone.cpp View File

@@ -209,7 +209,7 @@ const char* const* carla_get_engine_driver_device_names(uint index)

const EngineDriverDeviceInfo* carla_get_engine_driver_device_info(uint index, const char* name)
{
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr);
CARLA_SAFE_ASSERT_RETURN(name != nullptr, nullptr);

static EngineDriverDeviceInfo retDevInfo;
static const uint32_t nullBufferSizes[] = { 0 };


+ 33
- 18
source/backend/engine/CarlaEngineRtAudio.cpp View File

@@ -1193,7 +1193,34 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const uint index
if (index >= gRtAudioApis.size())
return nullptr;

static EngineDriverDeviceInfo devInfo = { 0x0, nullptr, nullptr };
static uint32_t dummyBufferSizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 };
static double dummySampleRates[] = { 22050.0, 32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, 0.0 };

// reset
devInfo.hints = 0x0;

// cleanup
if (devInfo.bufferSizes != nullptr && devInfo.bufferSizes != dummyBufferSizes)
{
delete[] devInfo.bufferSizes;
devInfo.bufferSizes = nullptr;
}
if (devInfo.sampleRates != nullptr && devInfo.sampleRates != dummySampleRates)
{
delete[] devInfo.sampleRates;
devInfo.sampleRates = nullptr;
}

const RtAudio::Api& api(gRtAudioApis[index]);

if (api == RtAudio::UNIX_JACK)
{
devInfo.bufferSizes = nullptr;
devInfo.sampleRates = nullptr;
return &devInfo;
}

RtAudio::DeviceInfo rtAudioDevInfo;

try {
@@ -1214,25 +1241,10 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const uint index
}

if (i == devCount)
return nullptr;
rtAudioDevInfo = rtAudio.getDeviceInfo(rtAudio.getDefaultOutputDevice());

} CARLA_SAFE_EXCEPTION_RETURN("RtAudio device discovery", nullptr);

static EngineDriverDeviceInfo devInfo = { 0x0, nullptr, nullptr };
static uint32_t dummyBufferSizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 };
static double dummySampleRates[] = { 22050.0, 32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, 0.0 };

// reset
devInfo.hints = 0x0;
devInfo.bufferSizes = dummyBufferSizes;

// cleanup
if (devInfo.sampleRates != nullptr && devInfo.sampleRates != dummySampleRates)
{
delete[] devInfo.sampleRates;
devInfo.sampleRates = nullptr;
}

// a few APIs can do triple buffer
switch (api)
{
@@ -1245,13 +1257,16 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const uint index
break;
}

// always use default buffer sizes
devInfo.bufferSizes = dummyBufferSizes;

// valid sample rates
if (const size_t sampleRatesCount = rtAudioDevInfo.sampleRates.size())
{
double* const sampleRates(new double[sampleRatesCount+1]);

for (size_t j=0; j < sampleRatesCount; ++j)
sampleRates[j] = rtAudioDevInfo.sampleRates[j];
for (size_t i=0; i < sampleRatesCount; ++i)
sampleRates[i] = rtAudioDevInfo.sampleRates[i];
sampleRates[sampleRatesCount] = 0.0;

devInfo.sampleRates = sampleRates;


Loading…
Cancel
Save