| 248 | } |
| 249 | |
| 250 | void audio_ringbuffer::enqueue(bool enqueue_silence, bool force) |
| 251 | { |
| 252 | AUDIT(cur_pos < cfg.num_allocated_buffers); |
| 253 | |
| 254 | // Prepare buffer |
| 255 | static float silence_buffer[u32{AUDIO_MAX_CHANNELS_COUNT} * u32{AUDIO_BUFFER_SAMPLES}]{}; |
| 256 | float* buf = silence_buffer; |
| 257 | |
| 258 | if (!enqueue_silence) |
| 259 | { |
| 260 | buf = buffer[cur_pos].get(); |
| 261 | cur_pos = (cur_pos + 1) % cfg.num_allocated_buffers; |
| 262 | } |
| 263 | |
| 264 | if (!backend_active.observe() && !force) |
| 265 | { |
| 266 | // backend is not ready yet |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | // Enqueue audio |
| 271 | if (cfg.time_stretching_enabled) |
| 272 | { |
| 273 | resampler.put_samples(buf, AUDIO_BUFFER_SAMPLES); |
| 274 | } |
| 275 | else |
| 276 | { |
| 277 | // Since time stretching step is skipped, we can commit to buffer directly |
| 278 | commit_data(buf, AUDIO_BUFFER_SAMPLES); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | void audio_ringbuffer::enqueue_silence(u32 buf_count, bool force) |
| 283 | { |
no test coverage detected