| 184 | } |
| 185 | |
| 186 | void AudioPage::AudioProvider::SetRowValue(int row, int v) |
| 187 | { |
| 188 | // Volume changes apply live with StartPreview() so the user hears |
| 189 | // the new level immediately (legacy DisplayOptionsAudio behaviour). |
| 190 | // UI 0..100 maps to internal 0..10 (the IAudioSystem volume scale). |
| 191 | if (GSoundsys) |
| 192 | { |
| 193 | float vf = AudioPage::PercentToVolume(v); |
| 194 | switch (row) |
| 195 | { |
| 196 | case kRowMusic: |
| 197 | // Music: long-form sample. Don't restart on volume |
| 198 | // change — UpdateMixer (called from SetCDVolume) updates |
| 199 | // the running wave's _volumeAdjustMusic which feeds |
| 200 | // WaveOAL::ApplyVolume on the next render tick, so the |
| 201 | // user hears the new level live without the wave |
| 202 | // cutting and restarting from the head. StartCategoryPreview |
| 203 | // only fires from the focus-dwell path in TickPreviewLoop. |
| 204 | GSoundsys->SetCDVolume(vf); |
| 205 | return; |
| 206 | case kRowEffects: |
| 207 | GSoundsys->SetWaveVolume(vf); |
| 208 | GSoundsys->StartCategoryPreview(WaveEffect); |
| 209 | return; |
| 210 | case kRowSpeech: |
| 211 | GSoundsys->SetSpeechVolume(vf); |
| 212 | GSoundsys->StartCategoryPreview(WaveSpeech); |
| 213 | return; |
| 214 | case kRowOutputDev: |
| 215 | { |
| 216 | if (m_outputDevs.empty()) |
| 217 | RebuildOutputDeviceList(); |
| 218 | if (v < 0 || v >= (int)m_outputDevs.size()) |
| 219 | return; |
| 220 | |
| 221 | const int count = (int)m_outputDevs.size(); |
| 222 | const int curr = RowValue(row); |
| 223 | int direction = 1; |
| 224 | if (count > 1) |
| 225 | { |
| 226 | if (v == (curr + count - 1) % count) |
| 227 | direction = -1; |
| 228 | else if (v == (curr + 1) % count) |
| 229 | direction = 1; |
| 230 | else |
| 231 | direction = (v > curr) ? 1 : -1; |
| 232 | } |
| 233 | |
| 234 | bool filteredAny = false; |
| 235 | for (int offset = 0; offset < count; ++offset) |
| 236 | { |
| 237 | int candidate = curr + direction * (offset + 1); |
| 238 | while (candidate < 0) |
| 239 | candidate += count; |
| 240 | candidate %= count; |
| 241 | |
| 242 | if (candidate != 0 && m_unavailableOutputDevs.count(m_outputDevs[candidate])) |
| 243 | continue; |
nothing calls this directly
no test coverage detected