diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-01-20 09:48:29 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-01-20 09:48:29 +1100 |
| commit | 4c88fcc4a57b1fae7b6edaf42034945d5ac24a89 (patch) | |
| tree | e44c384ba40e9eab37374b3f339c79e9bf1fde5d /src/audio/include/audio_element_handle.hpp | |
| parent | e53dfc4cc59fd0c3b01dc74762c1904f3ec9cc06 (diff) | |
| download | tangara-fw-4c88fcc4a57b1fae7b6edaf42034945d5ac24a89.tar.gz | |
fix build issues with new pipeline
Diffstat (limited to 'src/audio/include/audio_element_handle.hpp')
| -rw-r--r-- | src/audio/include/audio_element_handle.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/audio/include/audio_element_handle.hpp b/src/audio/include/audio_element_handle.hpp new file mode 100644 index 00000000..adb26baa --- /dev/null +++ b/src/audio/include/audio_element_handle.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include <memory> +#include "audio_element.hpp" + +namespace audio { + +class AudioElementHandle { + public: + AudioElementHandle(std::unique_ptr<TaskHandle_t> task, + std::shared_ptr<IAudioElement> element); + ~AudioElementHandle(); + + auto CurrentState() -> ElementState; + + // TODO: think about this contract. Would it ever make sense to pause and + // then walk away? Things could keep running for a whole loop if data comes + // through, so probably not? + enum PlayPause { + PLAY, + PAUSE, + }; + auto PlayPause(PlayPause state) -> void; + auto Quit() -> void; + + auto PauseSync() -> void; + auto QuitSync() -> void; + + AudioElementHandle(const AudioElementHandle&) = delete; + AudioElementHandle& operator=(const AudioElementHandle&) = delete; + + private: + std::unique_ptr<TaskHandle_t> task_; + std::shared_ptr<IAudioElement> element_; + + auto MonitorUtilState(eTaskState desired) -> void; + auto SetStateAndWakeUp(ElementState state) -> void; + auto WakeUpTask() -> void; +}; + +} // namespace audio |
