RSDK-13419 Add stop playing audio do command#27
RSDK-13419 Add stop playing audio do command#27oliviamiller merged 2 commits intoviam-modules:mainfrom
Conversation
|
|
||
| The speaker supports the following DoCommands: | ||
|
|
||
| **`set_volume`** — Set the speaker output volume. |
There was a problem hiding this comment.
forgot to document this before so adding now
| // Advance playback position to write position so no more audio is played. | ||
| std::lock_guard<std::mutex> lock(stream_mu_); | ||
| if (audio_context_) { | ||
| audio_context_->playback_position.store(audio_context_->get_write_position(), std::memory_order_relaxed); |
There was a problem hiding this comment.
I don't think using memory_order_relaxed is correct here. Unless we truly don't care what the value is. If the reader of playback_position also happened to acquire the stream_mu_, this could be accidentally right (using a mutex + atomic variables is awkward, I don't believe we're intentionally trying to rely on some memory ordering relationship there).
In general, one shouldn't need to play with the default memory_order_seq_cst that these stores and loads use.
There was a problem hiding this comment.
oops sorry I merged before I saw this, ill make a ticket to remove the memory_order usages and verify there's no performance regression in the audio callback.
Summary
Adds a do command to stop playing audio from the speaker. (requested by gambit).
Testing
Added unit test for successful stop, manually tested on mac and linux that audio stopped playing.
Reviews
1 Approval.