diff options
author | Dave Reisner <dreisner@archlinux.org> | 2013-01-02 15:27:14 -0500 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-01-02 15:27:14 -0500 |
commit | 4292241040661f4b9b042b24d2f0773de0eb1366 (patch) | |
tree | bb251a4c06b5590b06076e10f4d439d1aefa7821 /pulse.h | |
parent | e35ce0069094c135ed9065f2bda945fdf4b6d83e (diff) | |
download | mirror-ponymix-4292241040661f4b9b042b24d2f0773de0eb1366.tar.gz mirror-ponymix-4292241040661f4b9b042b24d2f0773de0eb1366.tar.bz2 mirror-ponymix-4292241040661f4b9b042b24d2f0773de0eb1366.zip |
Derive the card from the targetted device
Unless explicitly specified, target a card based on the selected device.
Note that not all devices will be tied to a card.
falconindy » put differently, if i have multiple cards, what determines which
card is used by pulse for a given app?
tanuk » In theory, the logic can be anything (it depends on what
policy-implementing modules are loaded). By default, routing is mostly
handled by module-stream-restore, which chooses the sink based on the
user's previous routing choices.
tanuk » If the user hasn't done any routing choices, the fallback logic is to
select the current "default sink".
tanuk » I don't recommend trying to guess the routing policy.
falconindy » i guess my understanding of pulse internals is lacking
falconindy » but that's rather enlightening
falconindy » is there any way to figure out the connection between a sink and a card?
tanuk » Yes... (One moment, I'll look up things.)
falconindy » ah. uint32_t card
falconindy » appears to be in pa_sink_info
falconindy » so that ties the sink to the index of a card?
tanuk » Yep.
falconindy » awesome, that's good enough for what i need to do
tanuk » Not all sinks are part of a card, though, but those that are will have
the card index set.
falconindy » also good to know
Diffstat (limited to 'pulse.h')
-rw-r--r-- | pulse.h | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -68,6 +68,7 @@ class Device { pa_channel_map channels_; int mute_; int balance_; + uint32_t card_idx_; Operations ops_; }; @@ -96,6 +97,17 @@ class Card { struct ServerInfo { string sink; string source; + + const string GetDefault(enum DeviceType type) { + switch (type) { + case DEVTYPE_SINK: + return sink; + case DEVTYPE_SOURCE: + return source; + default: + return ""; + } + } }; template<typename T> @@ -127,6 +139,11 @@ class PulseClient { // devices and cards are cleared before the new data is stored. void Populate(); + // Get a device by index or name and type, or all devices by type. + Device* GetDevice(const uint32_t& index, enum DeviceType type); + Device* GetDevice(const string& name, enum DeviceType type); + const vector<Device>& GetDevices(enum DeviceType type) const; + // Get a sink by index or name, or all sinks. Device* GetSink(const uint32_t& index); Device* GetSink(const string& name); @@ -147,9 +164,11 @@ class PulseClient { Device* GetSourceOutput(const string& name); const vector<Device>& GetSourceOutputs() const { return source_outputs_; } - // Get a card by index or name, or all cards. + // Get a card by index or name, all cards, or get the card which + // a sink is attached to. Card* GetCard(const uint32_t& index); Card* GetCard(const string& name); + Card* GetCard(const Device& device); const vector<Card>& GetCards() const { return cards_; } // Get or set the volume of a device. |