diff --git a/plugins/linux-pulseaudio/pulse-wrapper.c b/plugins/linux-pulseaudio/pulse-wrapper.c index 44820e40ef55f9f45c5b6e6375e38cde2d07bd3b..6af459a178393af2a83f7e506339b69812c2523e 100644 --- a/plugins/linux-pulseaudio/pulse-wrapper.c +++ b/plugins/linux-pulseaudio/pulse-wrapper.c @@ -181,6 +181,25 @@ int_fast32_t pulse_get_source_info_list(pa_source_info_cb_t cb, void* userdata) return 0; } +int_fast32_t pulse_get_source_info(pa_source_info_cb_t cb, const char *name, + void *userdata) +{ + if (pulse_context_ready() < 0) + return -1; + + pulse_lock(); + + pa_operation *op = pa_context_get_source_info_by_name( + pulse_context, name, cb, userdata); + while (pa_operation_get_state(op) == PA_OPERATION_RUNNING) + pulse_wait(); + pa_operation_unref(op); + + pulse_unlock(); + + return 0; +} + int_fast32_t pulse_get_server_info(pa_server_info_cb_t cb, void* userdata) { if (pulse_context_ready() < 0) diff --git a/plugins/linux-pulseaudio/pulse-wrapper.h b/plugins/linux-pulseaudio/pulse-wrapper.h index 493fc3de8e567bd92769a030b41dc6cf4bb1db8b..9c2a8807d5c2b20be5e898b5516f8095ad8e5c9a 100644 --- a/plugins/linux-pulseaudio/pulse-wrapper.h +++ b/plugins/linux-pulseaudio/pulse-wrapper.h @@ -93,6 +93,25 @@ void pulse_accept(); */ int_fast32_t pulse_get_source_info_list(pa_source_info_cb_t cb, void *userdata); +/** + * Request source information from a specific source + * + * The function will block until the operation was executed and the mainloop + * called the provided callback function. + * + * @param cb pointer to the callback function + * @param name the source name to get information for + * @param userdata pointer to userdata the callback will be called with + * + * @return negative on error + * + * @note The function will block until the server context is ready. + * + * @warning call without active locks + */ +int_fast32_t pulse_get_source_info(pa_source_info_cb_t cb, const char *name, + void *userdata); + /** * Request server information *