File: mixer.hpp

package info (click to toggle)
polybar 3.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,108 kB
  • sloc: cpp: 30,424; python: 3,750; sh: 284; makefile: 83
file content (50 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once

#include <mutex>

#include "common.hpp"
#include "settings.hpp"

// fwd
struct _snd_mixer;
struct _snd_mixer_elem;
struct _snd_mixer_selem_id;
typedef struct _snd_mixer snd_mixer_t;
typedef struct _snd_mixer_elem snd_mixer_elem_t;
typedef struct _snd_mixer_selem_id snd_mixer_selem_id_t;

POLYBAR_NS

namespace alsa {
  class mixer {
   public:
    explicit mixer(string&& mixer_selem_name, string&& soundcard_name);
    ~mixer();

    mixer(const mixer& o) = delete;
    mixer& operator=(const mixer& o) = delete;

    const string& get_name();
    const string& get_sound_card();

    bool wait(int timeout = -1);
    int process_events();

    int get_volume();
    int get_normalized_volume();
    void set_volume(float percentage);
    void set_normalized_volume(float percentage);
    void set_mute(bool mode);
    void toggle_mute();
    bool is_muted();

   private:
    snd_mixer_t* m_mixer{nullptr};
    snd_mixer_elem_t* m_elem{nullptr};

    string m_name;
    string s_name;
  };
}

POLYBAR_NS_END