diff options
Diffstat (limited to 'src/audio/include')
| -rw-r--r-- | src/audio/include/audio_decoder.hpp | 2 | ||||
| -rw-r--r-- | src/audio/include/audio_element_handle.hpp | 41 | ||||
| -rw-r--r-- | src/audio/include/fatfs_audio_input.hpp | 2 |
3 files changed, 43 insertions, 2 deletions
diff --git a/src/audio/include/audio_decoder.hpp b/src/audio/include/audio_decoder.hpp index 9c0626db..0a2df76d 100644 --- a/src/audio/include/audio_decoder.hpp +++ b/src/audio/include/audio_decoder.hpp @@ -43,7 +43,7 @@ class AudioDecoder : public IAudioElement { std::unique_ptr<codecs::ICodec> current_codec_; std::optional<StreamInfo> stream_info_; - ChunkWriter chunk_writer_; + std::unique_ptr<ChunkWriter> chunk_writer_; }; } // namespace audio 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 diff --git a/src/audio/include/fatfs_audio_input.hpp b/src/audio/include/fatfs_audio_input.hpp index 040b2b54..f3704f1d 100644 --- a/src/audio/include/fatfs_audio_input.hpp +++ b/src/audio/include/fatfs_audio_input.hpp @@ -47,7 +47,7 @@ class FatfsAudioInput : public IAudioElement { FIL current_file_; bool is_file_open_; - ChunkWriter chunk_writer_; + std::unique_ptr<ChunkWriter> chunk_writer_; }; } // namespace audio |
