@@ -99,7 +99,7 @@ struct Device { | |||||
/** Returns a list of all valid (user-selectable) sample rates. | /** Returns a list of all valid (user-selectable) sample rates. | ||||
The device may accept sample rates not in this list, but it *must* accept sample rates in the list. | The device may accept sample rates not in this list, but it *must* accept sample rates in the list. | ||||
*/ | */ | ||||
virtual std::vector<int> getSampleRates() { | |||||
virtual std::set<int> getSampleRates() { | |||||
return {}; | return {}; | ||||
} | } | ||||
/** Returns the current sample rate. */ | /** Returns the current sample rate. */ | ||||
@@ -112,7 +112,7 @@ struct Device { | |||||
/** Returns a list of all valid (user-selectable) block sizes. | /** Returns a list of all valid (user-selectable) block sizes. | ||||
The device may accept block sizes not in this list, but it *must* accept block sizes in the list. | The device may accept block sizes not in this list, but it *must* accept block sizes in the list. | ||||
*/ | */ | ||||
virtual std::vector<int> getBlockSizes() { | |||||
virtual std::set<int> getBlockSizes() { | |||||
return {}; | return {}; | ||||
} | } | ||||
/** Returns the current block size. */ | /** Returns the current block size. */ | ||||
@@ -169,11 +169,11 @@ struct Port { | |||||
std::string getDeviceName(int deviceId); | std::string getDeviceName(int deviceId); | ||||
std::string getDeviceDetail(int deviceId, int offset); | std::string getDeviceDetail(int deviceId, int offset); | ||||
std::vector<int> getSampleRates(); | |||||
std::set<int> getSampleRates(); | |||||
int getSampleRate(); | int getSampleRate(); | ||||
void setSampleRate(int sampleRate); | void setSampleRate(int sampleRate); | ||||
std::vector<int> getBlockSizes(); | |||||
std::set<int> getBlockSizes(); | |||||
int getBlockSize(); | int getBlockSize(); | ||||
void setBlockSize(int blockSize); | void setBlockSize(int blockSize); | ||||
@@ -154,15 +154,14 @@ static void appendAudioSampleRateMenu(ui::Menu* menu, audio::Port* port) { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
std::vector<int> sampleRates = port->getSampleRates(); | |||||
std::set<int> sampleRatesSet(sampleRates.begin(), sampleRates.end()); | |||||
std::set<int> sampleRates = port->getSampleRates(); | |||||
// Add current sample rate in case it's not in the list | // Add current sample rate in case it's not in the list | ||||
sampleRatesSet.insert(port->getSampleRate()); | |||||
sampleRates.insert(port->getSampleRate()); | |||||
if (sampleRatesSet.empty()) { | |||||
if (sampleRates.empty()) { | |||||
menu->addChild(createMenuLabel("(Locked by device)")); | menu->addChild(createMenuLabel("(Locked by device)")); | ||||
} | } | ||||
for (int sampleRate : sampleRatesSet) { | |||||
for (int sampleRate : sampleRates) { | |||||
if (sampleRate <= 0) | if (sampleRate <= 0) | ||||
continue; | continue; | ||||
AudioSampleRateValueItem* item = new AudioSampleRateValueItem; | AudioSampleRateValueItem* item = new AudioSampleRateValueItem; | ||||
@@ -220,15 +219,14 @@ static void appendAudioBlockSizeMenu(ui::Menu* menu, audio::Port* port) { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
std::vector<int> blockSizes = port->getBlockSizes(); | |||||
std::set<int> blockSizesSet(blockSizes.begin(), blockSizes.end()); | |||||
std::set<int> blockSizes = port->getBlockSizes(); | |||||
// Add current block size in case it's not in the list | // Add current block size in case it's not in the list | ||||
blockSizesSet.insert(port->getBlockSize()); | |||||
blockSizes.insert(port->getBlockSize()); | |||||
if (blockSizesSet.empty()) { | |||||
if (blockSizes.empty()) { | |||||
menu->addChild(createMenuLabel("(Locked by device)")); | menu->addChild(createMenuLabel("(Locked by device)")); | ||||
} | } | ||||
for (int blockSize : blockSizesSet) { | |||||
for (int blockSize : blockSizes) { | |||||
if (blockSize <= 0) | if (blockSize <= 0) | ||||
continue; | continue; | ||||
AudioBlockSizeValueItem* item = new AudioBlockSizeValueItem; | AudioBlockSizeValueItem* item = new AudioBlockSizeValueItem; | ||||
@@ -242,7 +242,7 @@ std::string Port::getDeviceDetail(int deviceId, int offset) { | |||||
} | } | ||||
} | } | ||||
std::vector<int> Port::getSampleRates() { | |||||
std::set<int> Port::getSampleRates() { | |||||
if (!device) | if (!device) | ||||
return {}; | return {}; | ||||
try { | try { | ||||
@@ -277,7 +277,7 @@ void Port::setSampleRate(int sampleRate) { | |||||
} | } | ||||
} | } | ||||
std::vector<int> Port::getBlockSizes() { | |||||
std::set<int> Port::getBlockSizes() { | |||||
if (!device) | if (!device) | ||||
return {}; | return {}; | ||||
try { | try { | ||||
@@ -146,8 +146,8 @@ struct RtAudioDevice : audio::Device { | |||||
return outputParameters.nChannels; | return outputParameters.nChannels; | ||||
} | } | ||||
std::vector<int> getSampleRates() override { | |||||
std::vector<int> sampleRates(deviceInfo.sampleRates.begin(), deviceInfo.sampleRates.end()); | |||||
std::set<int> getSampleRates() override { | |||||
std::set<int> sampleRates(deviceInfo.sampleRates.begin(), deviceInfo.sampleRates.end()); | |||||
return sampleRates; | return sampleRates; | ||||
} | } | ||||
int getSampleRate() override { | int getSampleRate() override { | ||||
@@ -159,11 +159,11 @@ struct RtAudioDevice : audio::Device { | |||||
openStream(); | openStream(); | ||||
} | } | ||||
std::vector<int> getBlockSizes() override { | |||||
std::vector<int> blockSizes; | |||||
std::set<int> getBlockSizes() override { | |||||
std::set<int> blockSizes; | |||||
// 32 to 4096 | // 32 to 4096 | ||||
for (int i = 5; i <= 12; i++) { | for (int i = 5; i <= 12; i++) { | ||||
blockSizes.push_back(1 << i); | |||||
blockSizes.insert(1 << i); | |||||
} | } | ||||
return blockSizes; | return blockSizes; | ||||
} | } | ||||