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 /ponymix.cc | |
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 'ponymix.cc')
-rw-r--r-- | ponymix.cc | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -146,7 +146,8 @@ static int ListCards(PulseClient& ponymix, int, char*[]) { } static int ListProfiles(PulseClient& ponymix, int, char*[]) { - // TODO: Is there any sense of a "default card" ? + if (opt_card == nullptr) errx(1, "error: no card selected"); + auto card = ponymix.GetCard(opt_card); if (card == nullptr) errx(1, "error: no match found for card: %s", opt_card); @@ -500,15 +501,24 @@ int main(int argc, char* argv[]) { ponymix.Populate(); // defaults + ServerInfo defaults = ponymix.GetDefaults(); opt_action = "defaults"; opt_devtype = DEVTYPE_SINK; - opt_device = ponymix.GetDefaults().sink.c_str(); - opt_card = ponymix.GetCards()[0].Name().c_str(); + opt_device = defaults.sink.c_str(); if (!parse_options(argc, argv)) return 1; argc -= optind; argv += optind; + // cards are tricky... find the one that belongs to the chosen sink. + if (opt_card == nullptr) { + const Device* device = ponymix.GetDevice(opt_device, opt_devtype); + if (device) { + const Card* card = ponymix.GetCard(*device); + if (card) opt_card = card->Name().c_str(); + } + } + return CommandDispatch(ponymix, argc, argv); } |