diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-10-05 00:56:01 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-10-05 00:56:01 -0500 |
commit | b38ed6b8403c40563f2059d4476d4482b3e29004 (patch) | |
tree | 2ab1fef74d54511ecd9249792dc664ce06be1273 | |
parent | aff78fdd73c8736114c869b84389d57b49a57bd5 (diff) | |
download | pavolctld-b38ed6b8403c40563f2059d4476d4482b3e29004.tar.xz pavolctld-b38ed6b8403c40563f2059d4476d4482b3e29004.zip |
fix default sink idx print bug and reorder a few things
-rw-r--r-- | pavolctld.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/pavolctld.c b/pavolctld.c index b266ab0..e291db5 100644 --- a/pavolctld.c +++ b/pavolctld.c @@ -14,29 +14,28 @@ static int command_sink_index; // commands will modify this sink /* output callbacks */ static void sink_info_volume_callback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { - pa_volume_t vol; + pa_volume_t vol = pa_cvolume_avg(&i->volume); if (eol) return; - vol = pa_cvolume_avg(&i->volume); printf("v%d,%d,%.02f,%d\n", i->index, ROUND_POS(vol*100.0f/PA_VOLUME_NORM), pa_sw_volume_to_dB(vol), i->mute); fflush(stdout); } -static void sink_info_default_index_callback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { +static void sink_info_sink_desc_callback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { if (eol) return; - default_sink_index = i->index; + printf("s%d,%s,%s\n", i->index, i->name, i->description); + fflush(stdout); } -static void sink_info_sink_desc_callback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { +static void sink_info_default_index_callback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { if (eol) return; - printf("s%d,%s,%s\n", i->index, i->name, i->description); + default_sink_index = i->index; + printf("f%d\n", default_sink_index); fflush(stdout); } static void server_info_default_sink_callback(pa_context *c, const pa_server_info *i, void *userdata) { pa_context_get_sink_info_by_name(c, i->default_sink_name, sink_info_default_index_callback, userdata); - printf("f%d\n", default_sink_index); - fflush(stdout); } /* subscription callback is called whenever a listened-to event occurs */ |