mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-25 04:19:16 +02:00
added setMute
This commit is contained in:
parent
6e3a569057
commit
f1e05797a3
2 changed files with 28 additions and 0 deletions
|
@ -208,6 +208,7 @@ void Player::worker()
|
|||
}
|
||||
|
||||
|
||||
|
||||
void Player::setVolume(double volume)
|
||||
{
|
||||
long min, max;
|
||||
|
@ -233,6 +234,30 @@ void Player::setVolume(double volume)
|
|||
|
||||
|
||||
|
||||
void Player::setMute(bool mute)
|
||||
{
|
||||
snd_mixer_t *handle;
|
||||
snd_mixer_selem_id_t *sid;
|
||||
const char *selem_name = "Master";
|
||||
|
||||
snd_mixer_open(&handle, 0);
|
||||
snd_mixer_attach(handle, pcmDevice_.name.c_str());
|
||||
snd_mixer_selem_register(handle, NULL, NULL);
|
||||
snd_mixer_load(handle);
|
||||
|
||||
snd_mixer_selem_id_alloca(&sid);
|
||||
snd_mixer_selem_id_set_index(sid, 0);
|
||||
snd_mixer_selem_id_set_name(sid, selem_name);
|
||||
snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
|
||||
|
||||
if (snd_mixer_selem_has_playback_switch(elem))
|
||||
snd_mixer_selem_set_playback_switch_all(elem, mute?0:1);
|
||||
|
||||
snd_mixer_close(handle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
vector<PcmDevice> Player::pcm_list(void)
|
||||
{
|
||||
void **hints, **n;
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
Player(const PcmDevice& pcmDevice, Stream* stream);
|
||||
virtual ~Player();
|
||||
void setVolume(double volume);
|
||||
void setMute(bool mute);
|
||||
void start();
|
||||
void stop();
|
||||
static std::vector<PcmDevice> pcm_list(void);
|
||||
|
@ -42,8 +43,10 @@ private:
|
|||
void initAlsa();
|
||||
void uninitAlsa();
|
||||
void worker();
|
||||
|
||||
snd_pcm_t* handle_;
|
||||
snd_pcm_uframes_t frames_;
|
||||
|
||||
char *buff_;
|
||||
std::atomic<bool> active_;
|
||||
Stream* stream_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue