aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ponymix.cc48
-rw-r--r--pulse.cc68
-rw-r--r--pulse.h10
3 files changed, 63 insertions, 63 deletions
diff --git a/ponymix.cc b/ponymix.cc
index 1f124df..a6ce950 100644
--- a/ponymix.cc
+++ b/ponymix.cc
@@ -102,7 +102,7 @@ static enum DeviceType string_to_devtype_or_die(const char* str) {
}
}
-static Device* string_to_device(Pulse& ponymix, string arg, enum DeviceType type) {
+static Device* string_to_device(PulseClient& ponymix, string arg, enum DeviceType type) {
switch (type) {
case DEVTYPE_SINK:
return ponymix.GetSink(arg);
@@ -117,7 +117,7 @@ static Device* string_to_device(Pulse& ponymix, string arg, enum DeviceType type
}
}
-static Device* string_to_device_or_die(Pulse& ponymix,
+static Device* string_to_device_or_die(PulseClient& ponymix,
string arg,
enum DeviceType type) {
Device* device = string_to_device(ponymix, arg, type);
@@ -146,14 +146,14 @@ static void Print(const Profile& profile, bool active) {
profile.name.c_str(), profile.desc.c_str(), active ? " [active]" : "");
}
-static int ShowDefaults(Pulse& ponymix, int, char*[]) {
+static int ShowDefaults(PulseClient& ponymix, int, char*[]) {
const auto& info = ponymix.GetDefaults();
Print(*ponymix.GetSink(info.sink));
Print(*ponymix.GetSource(info.source));
return 0;
}
-static int List(Pulse& ponymix, int argc, char*[]) {
+static int List(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: list requires 0 arguments");
const auto& sinks = ponymix.GetSinks();
@@ -171,7 +171,7 @@ static int List(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int ListCards(Pulse& ponymix, int argc, char*[]) {
+static int ListCards(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: list-cards requires 0 arguments");
const auto& cards = ponymix.GetCards();
@@ -180,7 +180,7 @@ static int ListCards(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int ListProfiles(Pulse& ponymix, int argc, char*[]) {
+static int ListProfiles(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: list-profiles requires 0 arguments");
// TODO: figure out how to get a list of cards?
@@ -193,7 +193,7 @@ static int ListProfiles(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int GetVolume(Pulse& ponymix, int argc, char*[]) {
+static int GetVolume(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: get-volume requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -201,7 +201,7 @@ static int GetVolume(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int SetVolume(Pulse& ponymix, int argc, char* argv[]) {
+static int SetVolume(PulseClient& ponymix, int argc, char* argv[]) {
if (argc != 1) errx(1, "error: set-volume requires exactly 1 argument");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -220,7 +220,7 @@ static int SetVolume(Pulse& ponymix, int argc, char* argv[]) {
return 0;
}
-static int GetBalance(Pulse& ponymix, int argc, char*[]) {
+static int GetBalance(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: get-balance requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -228,7 +228,7 @@ static int GetBalance(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int SetBalance(Pulse& ponymix, int argc, char* argv[]) {
+static int SetBalance(PulseClient& ponymix, int argc, char* argv[]) {
if (argc != 1) errx(1, "error: set-balance requires exactly 1 argument");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -247,7 +247,7 @@ static int SetBalance(Pulse& ponymix, int argc, char* argv[]) {
return 0;
}
-static int AdjBalance(Pulse& ponymix, int argc, char* argv[]) {
+static int AdjBalance(PulseClient& ponymix, int argc, char* argv[]) {
if (argc != 1) errx(1, "error: adj-balance requires exactly 1 argument");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -266,7 +266,7 @@ static int AdjBalance(Pulse& ponymix, int argc, char* argv[]) {
return 0;
}
-static int IncreaseVolume(Pulse& ponymix, int argc, char* argv[]) {
+static int IncreaseVolume(PulseClient& ponymix, int argc, char* argv[]) {
if (argc != 1) errx(1, "error: increase requires exactly 1 argument");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -285,7 +285,7 @@ static int IncreaseVolume(Pulse& ponymix, int argc, char* argv[]) {
return 0;
}
-static int DecreaseVolume(Pulse& ponymix, int argc, char* argv[]) {
+static int DecreaseVolume(PulseClient& ponymix, int argc, char* argv[]) {
if (argc != 1) errx(1, "error: decrease requires exactly 1 argument");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -304,7 +304,7 @@ static int DecreaseVolume(Pulse& ponymix, int argc, char* argv[]) {
return 0;
}
-static int Mute(Pulse& ponymix, int argc, char*[]) {
+static int Mute(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: mute requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -316,7 +316,7 @@ static int Mute(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int Unmute(Pulse& ponymix, int argc, char*[]) {
+static int Unmute(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: unmute requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -328,7 +328,7 @@ static int Unmute(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int ToggleMute(Pulse& ponymix, int argc, char*[]) {
+static int ToggleMute(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: toggle requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -340,14 +340,14 @@ static int ToggleMute(Pulse& ponymix, int argc, char*[]) {
return 0;
}
-static int IsMuted(Pulse& ponymix, int argc, char*[]) {
+static int IsMuted(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: is-muted requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
return !ponymix.IsMuted(*device);
}
-static int SetDefault(Pulse& ponymix, int argc, char*[]) {
+static int SetDefault(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: set-default requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -355,7 +355,7 @@ static int SetDefault(Pulse& ponymix, int argc, char*[]) {
return !ponymix.SetDefault(*device);
}
-static int GetProfile(Pulse& ponymix, int argc, char*[]) {
+static int GetProfile(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: get-profile requires 0 arguments");
auto card = ponymix.GetCard(opt_card);
@@ -366,7 +366,7 @@ static int GetProfile(Pulse& ponymix, int argc, char*[]) {
return true;
}
-static int SetProfile(Pulse& ponymix, int argc, char* argv[]) {
+static int SetProfile(PulseClient& ponymix, int argc, char* argv[]) {
if (argc != 1) errx(1, "error: set-profile requires 1 argument");
auto card = ponymix.GetCard(opt_card);
@@ -375,7 +375,7 @@ static int SetProfile(Pulse& ponymix, int argc, char* argv[]) {
return !ponymix.SetProfile(*card, argv[0]);
}
-static int Move(Pulse& ponymix, int argc, char* argv[]) {
+static int Move(PulseClient& ponymix, int argc, char* argv[]) {
if (argc != 1) errx(1, "error: move requires 1 argument");
// this assignment is a lie. stfu g++
@@ -400,7 +400,7 @@ static int Move(Pulse& ponymix, int argc, char* argv[]) {
return !ponymix.Move(*source, *target);
}
-static int Kill(Pulse& ponymix, int argc, char*[]) {
+static int Kill(PulseClient& ponymix, int argc, char*[]) {
if (argc != 0) errx(1, "error: set-default requires 0 arguments");
auto device = string_to_device_or_die(ponymix, opt_device, opt_devtype);
@@ -408,7 +408,7 @@ static int Kill(Pulse& ponymix, int argc, char*[]) {
return !ponymix.Kill(*device);
}
-static int (*fn[])(Pulse& ponymix, int argc, char* argv[]) = {
+static int (*fn[])(PulseClient& ponymix, int argc, char* argv[]) = {
[ACTION_DEFAULTS] = ShowDefaults,
[ACTION_LIST] = List,
[ACTION_LISTCARDS] = ListCards,
@@ -533,7 +533,7 @@ bool parse_options(int argc, char** argv) {
}
int main(int argc, char* argv[]) {
- Pulse ponymix("ponymix");
+ PulseClient ponymix("ponymix");
ponymix.Populate();
// defaults
diff --git a/pulse.cc b/pulse.cc
index 77a1568..cbbe405 100644
--- a/pulse.cc
+++ b/pulse.cc
@@ -95,7 +95,7 @@ static int xstrtol(const char *str, long *out) {
} // anonymous namespace
-Pulse::Pulse(string client_name) :
+PulseClient::PulseClient(string client_name) :
client_name_(client_name),
volume_range_(0, 150),
balance_range_(-100, 100) {
@@ -129,40 +129,40 @@ Pulse::Pulse(string client_name) :
//
// Pulse Client
//
-Pulse::~Pulse() {
+PulseClient::~PulseClient() {
pa_context_unref(context_);
pa_mainloop_free(mainloop_);
}
-void Pulse::Populate() {
+void PulseClient::Populate() {
populate_server_info();
populate_sinks();
populate_sources();
populate_cards();
}
-Card* Pulse::GetCard(const uint32_t& index) {
+Card* PulseClient::GetCard(const uint32_t& index) {
for (Card& card : cards_) {
if (card.index_ == index) return &card;
}
return nullptr;
}
-Card* Pulse::GetCard(const string& name) {
+Card* PulseClient::GetCard(const string& name) {
for (Card& card : cards_) {
if (card.name_ == name) return &card;
}
return nullptr;
}
-Device* Pulse::get_device(vector<Device>& devices, const uint32_t& index) {
+Device* PulseClient::get_device(vector<Device>& devices, const uint32_t& index) {
for (Device& device : devices) {
if (device.index_ == index) return &device;
}
return nullptr;
}
-Device* Pulse::get_device(vector<Device>& devices, const string& name) {
+Device* PulseClient::get_device(vector<Device>& devices, const string& name) {
long val;
if (xstrtol(name.c_str(), &val) == 0) return get_device(devices, val);
@@ -172,46 +172,46 @@ Device* Pulse::get_device(vector<Device>& devices, const string& name) {
return nullptr;
}
-Device* Pulse::GetSink(const uint32_t& index) {
+Device* PulseClient::GetSink(const uint32_t& index) {
return get_device(sinks_, index);
}
-Device* Pulse::GetSink(const string& name) {
+Device* PulseClient::GetSink(const string& name) {
return get_device(sinks_, name);
}
-Device* Pulse::GetSource(const uint32_t& index) {
+Device* PulseClient::GetSource(const uint32_t& index) {
return get_device(sources_, index);
}
-Device* Pulse::GetSource(const string& name) {
+Device* PulseClient::GetSource(const string& name) {
return get_device(sources_, name);
}
-Device* Pulse::GetSinkInput(const uint32_t& index) {
+Device* PulseClient::GetSinkInput(const uint32_t& index) {
return get_device(sink_inputs_, index);
}
-Device* Pulse::GetSinkInput(const string& name) {
+Device* PulseClient::GetSinkInput(const string& name) {
return get_device(sink_inputs_, name);
}
-Device* Pulse::GetSourceOutput(const uint32_t& index) {
+Device* PulseClient::GetSourceOutput(const uint32_t& index) {
return get_device(source_outputs_, index);
}
-Device* Pulse::GetSourceOutput(const string& name) {
+Device* PulseClient::GetSourceOutput(const string& name) {
return get_device(source_outputs_, name);
}
-void Pulse::mainloop_iterate(pa_operation* op) {
+void PulseClient::mainloop_iterate(pa_operation* op) {
int r;
while (pa_operation_get_state(op) == PA_OPERATION_RUNNING) {
pa_mainloop_iterate(mainloop_, 1, &r);
}
}
-void Pulse::populate_cards() {
+void PulseClient::populate_cards() {
cards_.clear();
pa_operation* op = pa_context_get_card_info_list(context_,
card_info_cb,
@@ -220,7 +220,7 @@ void Pulse::populate_cards() {
pa_operation_unref(op);
}
-void Pulse::populate_server_info() {
+void PulseClient::populate_server_info() {
pa_operation* op = pa_context_get_server_info(context_,
server_info_cb,
&defaults_);
@@ -228,7 +228,7 @@ void Pulse::populate_server_info() {
pa_operation_unref(op);
}
-void Pulse::populate_sinks() {
+void PulseClient::populate_sinks() {
sinks_.clear();
pa_operation* op = pa_context_get_sink_info_list(context_,
device_info_cb,
@@ -244,7 +244,7 @@ void Pulse::populate_sinks() {
pa_operation_unref(op);
}
-void Pulse::populate_sources() {
+void PulseClient::populate_sources() {
sources_.clear();
pa_operation* op = pa_context_get_source_info_list(context_,
device_info_cb,
@@ -260,7 +260,7 @@ void Pulse::populate_sources() {
pa_operation_unref(op);
}
-bool Pulse::SetMute(Device& device, bool mute) {
+bool PulseClient::SetMute(Device& device, bool mute) {
int success;
if (device.ops_.Mute == nullptr) {
@@ -281,7 +281,7 @@ bool Pulse::SetMute(Device& device, bool mute) {
return success;
}
-bool Pulse::SetVolume(Device& device, long volume) {
+bool PulseClient::SetVolume(Device& device, long volume) {
int success;
if (device.ops_.SetVolume == nullptr) {
@@ -303,17 +303,17 @@ bool Pulse::SetVolume(Device& device, long volume) {
return success;
}
-bool Pulse::IncreaseVolume(Device& device, long increment) {
+bool PulseClient::IncreaseVolume(Device& device, long increment) {
return SetVolume(device,
volume_range_.clamp(device.volume_percent_ + increment));
}
-bool Pulse::DecreaseVolume(Device& device, long increment) {
+bool PulseClient::DecreaseVolume(Device& device, long increment) {
return SetVolume(device,
volume_range_.clamp(device.volume_percent_ - increment));
}
-bool Pulse::SetBalance(Device& device, long balance) {
+bool PulseClient::SetBalance(Device& device, long balance) {
int success;
if (device.ops_.SetVolume == nullptr) {
@@ -337,25 +337,25 @@ bool Pulse::SetBalance(Device& device, long balance) {
return success;
}
-bool Pulse::IncreaseBalance(Device& device, long increment) {
+bool PulseClient::IncreaseBalance(Device& device, long increment) {
return SetBalance(device,
balance_range_.clamp(device.balance_ + increment));
}
-bool Pulse::DecreaseBalance(Device& device, long increment) {
+bool PulseClient::DecreaseBalance(Device& device, long increment) {
return SetBalance(device,
balance_range_.clamp(device.balance_ - increment));
}
-int Pulse::GetVolume(const Device& device) const {
+int PulseClient::GetVolume(const Device& device) const {
return device.Volume();
}
-int Pulse::GetBalance(const Device& device) const {
+int PulseClient::GetBalance(const Device& device) const {
return device.Balance();
}
-bool Pulse::SetProfile(Card& card, const string& profile) {
+bool PulseClient::SetProfile(Card& card, const string& profile) {
int success;
pa_operation* op =
pa_context_set_card_profile_by_index(context_,
@@ -379,7 +379,7 @@ bool Pulse::SetProfile(Card& card, const string& profile) {
return success;
}
-bool Pulse::Move(Device& source, Device& dest) {
+bool PulseClient::Move(Device& source, Device& dest) {
int success;
if (source.ops_.Move == nullptr) {
@@ -398,7 +398,7 @@ bool Pulse::Move(Device& source, Device& dest) {
return success;
}
-bool Pulse::Kill(Device& device) {
+bool PulseClient::Kill(Device& device) {
int success;
if (device.ops_.Kill == nullptr) {
@@ -418,7 +418,7 @@ bool Pulse::Kill(Device& device) {
return success;
}
-bool Pulse::SetDefault(Device& device) {
+bool PulseClient::SetDefault(Device& device) {
int success;
if (device.ops_.SetDefault == nullptr) {
@@ -450,7 +450,7 @@ bool Pulse::SetDefault(Device& device) {
return success;
}
-void Pulse::remove_device(Device& device) {
+void PulseClient::remove_device(Device& device) {
vector<Device>* devlist;
switch (device.type_) {
diff --git a/pulse.h b/pulse.h
index 1e91352..9a61108 100644
--- a/pulse.h
+++ b/pulse.h
@@ -55,7 +55,7 @@ class Device {
enum DeviceType Type() const { return type_; }
private:
- friend class Pulse;
+ friend class PulseClient;
void update_volume(const pa_cvolume& newvol);
@@ -83,7 +83,7 @@ class Card {
const Profile& ActiveProfile() const { return active_profile_; }
private:
- friend class Pulse;
+ friend class PulseClient;
uint32_t index_;
string name_;
@@ -110,10 +110,10 @@ struct Range {
T max;
};
-class Pulse {
+class PulseClient {
public:
- Pulse(string client_name);
- ~Pulse();
+ PulseClient(string client_name);
+ ~PulseClient();
// Populates all known devices and cards. Any currently known
// devices and cards are cleared before the new data is stored.