mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
Provide support to query the active port on PulseAudio's default sink (#405)
* Provide support to query the active port on PA's default sink This commit exposes 2 objects: - pa_sink_active_port_name (example value: "analog-output-headphones") - pa_sink_active_port_description (example value: "Headphones") that give respectively the name and description strings for the active port on the default sink provided by PulseAudio. * Reflect 9ed28f2a in the documentation
This commit is contained in:
parent
c712d67884
commit
e1a19b3093
@ -3072,6 +3072,24 @@
|
||||
<listitem>Pulseaudio's default sink description.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>pa_sink_active_port_name</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>Pulseaudio's default sink active port name.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>pa_sink_active_port_description</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>Pulseaudio's default sink active port description.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
|
@ -1888,6 +1888,14 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
obj->callbacks.print = &print_puau_sink_description;
|
||||
obj->callbacks.free = &free_pulseaudio;
|
||||
init_pulseaudio(obj);
|
||||
END OBJ(pa_sink_active_port_name, 0)
|
||||
obj->callbacks.print = &print_puau_sink_active_port_name;
|
||||
obj->callbacks.free = &free_pulseaudio;
|
||||
init_pulseaudio(obj);
|
||||
END OBJ(pa_sink_active_port_description, 0)
|
||||
obj->callbacks.print = &print_puau_sink_active_port_description;
|
||||
obj->callbacks.free = &free_pulseaudio;
|
||||
init_pulseaudio(obj);
|
||||
END OBJ(pa_sink_volume, 0)
|
||||
obj->callbacks.percentage = &puau_vol;
|
||||
obj->callbacks.free = &free_pulseaudio;
|
||||
|
@ -43,7 +43,7 @@ struct pulseaudio_default_results get_result_copy();
|
||||
|
||||
|
||||
const struct pulseaudio_default_results pulseaudio_result0 =
|
||||
{ std::string(), std::string(), 0, 0, 0, 0, std::string(), std::string(), 0 };
|
||||
{ std::string(), std::string(), std::string(), std::string(), 0, 0, 0, 0, std::string(), std::string(), 0 };
|
||||
pulseaudio_c *pulseaudio = NULL;
|
||||
|
||||
void pa_sink_info_callback(pa_context *c, const pa_sink_info *i, int eol, void *data) {
|
||||
@ -53,6 +53,8 @@ void pa_sink_info_callback(pa_context *c, const pa_sink_info *i, int eol, void *
|
||||
pdr->sink_mute = i->mute;
|
||||
pdr->sink_card = i->card;
|
||||
pdr->sink_index = i->index;
|
||||
pdr->sink_active_port_name.assign(i->active_port->name);
|
||||
pdr->sink_active_port_description.assign(i->active_port->description);
|
||||
pdr->sink_volume = round_to_int(100.0f * (float)pa_cvolume_avg(&(i->volume)) / (float)PA_VOLUME_NORM);
|
||||
pa_threaded_mainloop_signal(pulseaudio->mainloop, 0);
|
||||
}
|
||||
@ -284,6 +286,14 @@ void print_puau_sink_description(struct text_object *obj, char *p, int p_max_siz
|
||||
snprintf(p, p_max_size, "%s", get_pulseaudio(obj).sink_description.c_str());
|
||||
}
|
||||
|
||||
void print_puau_sink_active_port_name(struct text_object *obj, char *p, int p_max_size) {
|
||||
snprintf(p, p_max_size, "%s", get_pulseaudio(obj).sink_active_port_name.c_str());
|
||||
}
|
||||
|
||||
void print_puau_sink_active_port_description(struct text_object *obj, char *p, int p_max_size) {
|
||||
snprintf(p, p_max_size, "%s", get_pulseaudio(obj).sink_active_port_description.c_str());
|
||||
}
|
||||
|
||||
void print_puau_card_active_profile(struct text_object *obj, char *p, int p_max_size) {
|
||||
snprintf(p, p_max_size, "%s", get_pulseaudio(obj).card_active_profile_description.c_str());
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ void init_pulseaudio(struct text_object *obj);
|
||||
void free_pulseaudio(struct text_object *obj);
|
||||
uint8_t puau_vol(struct text_object *); // preserve pa_* for libpulse
|
||||
void print_puau_sink_description(struct text_object *obj, char *p, int p_max_size);
|
||||
void print_puau_sink_active_port_name(struct text_object *obj, char *p, int p_max_size);
|
||||
void print_puau_sink_active_port_description(struct text_object *obj, char *p, int p_max_size);
|
||||
void print_puau_card_name(struct text_object *obj, char *p, int p_max_size);
|
||||
void print_puau_card_active_profile(struct text_object *obj, char *p, int p_max_size);
|
||||
double puau_volumebarval(struct text_object *obj);
|
||||
@ -47,6 +49,8 @@ struct pulseaudio_default_results {
|
||||
// default sink
|
||||
std::string sink_name;
|
||||
std::string sink_description;
|
||||
std::string sink_active_port_name;
|
||||
std::string sink_active_port_description;
|
||||
uint32_t sink_card;
|
||||
int sink_mute;
|
||||
uint32_t sink_index;
|
||||
@ -77,7 +81,7 @@ class pulseaudio_c {
|
||||
context(NULL),
|
||||
cstate(PULSE_CONTEXT_INITIALIZING),
|
||||
ninits(0),
|
||||
result({ std::string(), std::string(), 0, 0, 0, 0, std::string(), std::string(), 0 }){};
|
||||
result({ std::string(), std::string(), std::string(), std::string(), 0, 0, 0, 0, std::string(), std::string(), 0 }){};
|
||||
};
|
||||
|
||||
#endif /* _PULSEAUDIO_H */
|
||||
|
Loading…
Reference in New Issue
Block a user