Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4275)

Unified Diff: chromecast/media/cma/backend/alsa/stream_mixer_alsa.h

Issue 2738873002: [Chromecast] Implement new volume control API (Closed)
Patch Set: slan comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromecast/media/cma/backend/alsa/stream_mixer_alsa.h
diff --git a/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h b/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h
index b522f09024cb274daf1aea6adfe5a1775ded5788..879b7d0b3f4c6a5b0110c660a2fe0b49b339c3f9 100644
--- a/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h
+++ b/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h
@@ -8,6 +8,7 @@
#include <alsa/asoundlib.h>
#include <stdint.h>
+#include <map>
#include <memory>
#include <string>
#include <vector>
@@ -20,6 +21,7 @@
#include "chromecast/media/cma/backend/alsa/media_pipeline_backend_alsa.h"
#include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input.h"
#include "chromecast/public/cast_media_shlib.h"
+#include "chromecast/public/volume_control.h"
namespace media {
class AudioBus;
@@ -73,6 +75,9 @@ class StreamMixerAlsa {
// or media/audio/audio_device_description.h
virtual std::string device_id() const = 0;
+ // Returns the content type for volume control.
+ virtual AudioContentType content_type() const = 0;
+
// Returns true if PrepareToDelete() has been called.
virtual bool IsDeleting() const = 0;
@@ -129,6 +134,14 @@ class StreamMixerAlsa {
// Once the input is ready to be removed, it should call the supplied
// |delete_cb|; this should only happen once per input.
virtual void PrepareToDelete(const OnReadyToDeleteCb& delete_cb) = 0;
+
+ // Sets the multiplier based on this stream's content type. The resulting
+ // output volume should be the content type volume * the per-stream volume
+ // multiplier.
+ virtual void SetContentTypeVolume(float volume) = 0;
+
+ // Sets whether or not this stream should be muted.
+ virtual void SetMuted(bool muted) = 0;
};
enum State {
@@ -169,11 +182,29 @@ class StreamMixerAlsa {
void RemoveLoopbackAudioObserver(
CastMediaShlib::LoopbackAudioObserver* observer);
+ // Sets the volume multiplier for the given content |type|.
+ void SetVolume(AudioContentType type, float level);
+
+ // Sets the mute state for the given content |type|.
+ void SetMuted(AudioContentType type, bool muted);
+
+ // Sets the volume multiplier limit for the given content |type|.
+ void SetOutputLimit(AudioContentType type, float limit);
+
protected:
StreamMixerAlsa();
virtual ~StreamMixerAlsa();
private:
+ // Contains volume control information for an audio content type.
+ struct VolumeInfo {
+ float GetEffectiveVolume();
+
+ float volume = 0.0f;
+ float limit = 1.0f;
+ bool muted = false;
+ };
+
void ResetTaskRunnerForTest();
void FinalizeOnMixerThread();
void FinishFinalize();
@@ -232,7 +263,6 @@ class StreamMixerAlsa {
// only has to interact with the command line parameters once.
std::string alsa_device_name_;
snd_pcm_uframes_t alsa_buffer_size_;
- bool alsa_period_explicitly_set;
snd_pcm_uframes_t alsa_period_size_;
snd_pcm_uframes_t alsa_start_threshold_;
snd_pcm_uframes_t alsa_avail_min_;
@@ -251,6 +281,8 @@ class StreamMixerAlsa {
std::vector<std::unique_ptr<FilterGroup>> filter_groups_;
std::vector<CastMediaShlib::LoopbackAudioObserver*> loopback_observers_;
+ std::map<AudioContentType, VolumeInfo> volume_info_;
+
DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsa);
};
« no previous file with comments | « chromecast/media/cma/backend/alsa/slew_volume.cc ('k') | chromecast/media/cma/backend/alsa/stream_mixer_alsa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698