diff options
| author | jacqueline <me@jacqueline.id.au> | 2022-11-16 11:13:21 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2022-11-16 11:13:21 +1100 |
| commit | 8c51280bc68e51b76243e83b84762e33c52510ca (patch) | |
| tree | 7871ce5bca24c9b9f42a437763d7f1411ddbcd94 /src/drivers/include | |
| parent | e802b8583f58a2be366f24b72afeb050550dbc7e (diff) | |
| download | tangara-fw-8c51280bc68e51b76243e83b84762e33c52510ca.tar.gz | |
Fix playback and console issues
Diffstat (limited to 'src/drivers/include')
| -rw-r--r-- | src/drivers/include/audio_output.hpp | 4 | ||||
| -rw-r--r-- | src/drivers/include/audio_playback.hpp | 26 | ||||
| -rw-r--r-- | src/drivers/include/i2s_audio_output.hpp | 2 |
3 files changed, 18 insertions, 14 deletions
diff --git a/src/drivers/include/audio_output.hpp b/src/drivers/include/audio_output.hpp index 739dddfe..916ee906 100644 --- a/src/drivers/include/audio_output.hpp +++ b/src/drivers/include/audio_output.hpp @@ -15,10 +15,14 @@ class IAudioOutput { auto GetAudioElement() -> audio_element_handle_t { return element_; } virtual auto SetVolume(uint8_t volume) -> void = 0; + virtual auto GetVolume() const -> uint8_t { return volume_; } + virtual auto Configure(audio_element_info_t& info) -> void = 0; + virtual auto SetSoftMute(bool enabled) -> void = 0; protected: audio_element_handle_t element_; + uint8_t volume_; }; } // namespace drivers diff --git a/src/drivers/include/audio_playback.hpp b/src/drivers/include/audio_playback.hpp index d26fcda2..8224d4bf 100644 --- a/src/drivers/include/audio_playback.hpp +++ b/src/drivers/include/audio_playback.hpp @@ -44,14 +44,14 @@ class AudioPlayback { * * Any value set in `set_next_file` is cleared by this method. */ - void Play(const std::string& filename); + auto Play(const std::string& filename) -> void; /* Toogle between resumed and paused. */ - void Toggle(); - void Resume(); - void Pause(); + auto Toggle() -> void; + auto Resume() -> void; + auto Pause() -> void; enum PlaybackState { PLAYING, PAUSED, STOPPED }; - auto GetPlaybackState() -> PlaybackState; + auto GetPlaybackState() const -> PlaybackState; /* * Handles any pending events from the underlying audio pipeline. This must @@ -59,34 +59,32 @@ class AudioPlayback { * different audio types (e.g. sample rate, bit depth), and for gapless * playback. */ - void ProcessEvents(uint16_t max_time_ms); + auto ProcessEvents(uint16_t max_time_ms) -> void; /* * Sets the file that should be played immediately after the current file * finishes. This is used for gapless playback */ - void set_next_file(const std::string& filename); + auto SetNextFile(const std::string& filename) -> void; - void set_volume(uint8_t volume); - auto volume() -> uint8_t; + auto SetVolume(uint8_t volume) -> void; + auto GetVolume() const -> uint8_t; // Not copyable or movable. AudioPlayback(const AudioPlayback&) = delete; AudioPlayback& operator=(const AudioPlayback&) = delete; private: - PlaybackState current_state_; + PlaybackState playback_state_; enum Decoder { NONE, MP3, AMR, OPUS, OGG, FLAC, WAV, AAC }; - auto GetDecoderForFilename(std::string filename) -> Decoder; - auto CreateDecoder(Decoder decoder) -> audio_element_handle_t; + auto GetDecoderForFilename(std::string filename) const -> Decoder; + auto CreateDecoder(Decoder decoder) const -> audio_element_handle_t; auto ReconfigurePipeline(Decoder decoder) -> void; std::unique_ptr<IAudioOutput> output_; - std::mutex playback_lock_; std::string next_filename_ = ""; - uint8_t volume_; audio_pipeline_handle_t pipeline_; audio_element_handle_t source_element_; diff --git a/src/drivers/include/i2s_audio_output.hpp b/src/drivers/include/i2s_audio_output.hpp index 1ec97307..d4f6dae1 100644 --- a/src/drivers/include/i2s_audio_output.hpp +++ b/src/drivers/include/i2s_audio_output.hpp @@ -24,9 +24,11 @@ class I2SAudioOutput : public IAudioOutput { virtual auto SetVolume(uint8_t volume) -> void; virtual auto Configure(audio_element_info_t& info) -> void; + virtual auto SetSoftMute(bool enabled) -> void; private: std::unique_ptr<AudioDac> dac_; + bool is_soft_muted_ = false; }; } // namespace drivers |
