| 236 | }; |
| 237 | |
| 238 | static void appendAudioBlockSizeMenu(ui::Menu* menu, audio::Port* port) { |
| 239 | if (!port) |
| 240 | return; |
| 241 | |
| 242 | std::set<int> blockSizes = port->getBlockSizes(); |
| 243 | // Add current block size in case it's not in the list |
| 244 | blockSizes.insert(port->getBlockSize()); |
| 245 | |
| 246 | if (blockSizes.empty()) { |
| 247 | menu->addChild(createMenuLabel("(" + string::translate("AudioDisplay.lockedByDevice") + ")")); |
| 248 | } |
| 249 | for (int blockSize : blockSizes) { |
| 250 | if (blockSize <= 0) |
| 251 | continue; |
| 252 | AudioBlockSizeValueItem* item = new AudioBlockSizeValueItem; |
| 253 | item->port = port; |
| 254 | item->blockSize = blockSize; |
| 255 | float latency = (float) blockSize / port->getSampleRate() * 1000.0; |
| 256 | item->text = string::f("%d (%.1f ms)", blockSize, latency); |
| 257 | item->rightText = CHECKMARK(item->blockSize == port->getBlockSize()); |
| 258 | menu->addChild(item); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | void AudioBlockSizeChoice::onAction(const ActionEvent& e) { |
| 263 | ui::Menu* menu = createMenu(); |
no test coverage detected