@@ -2227,6 +2227,89 @@ static NTSTATUS pulse_is_format_supported(void *args)
22272227 return STATUS_SUCCESS ;
22282228}
22292229
2230+ static void sink_name_info_cb (pa_context * c , const pa_sink_info * i , int eol , void * userdata )
2231+ {
2232+ uint32_t * current_device_index = userdata ;
2233+ pulse_broadcast ();
2234+
2235+ if (!i || !i -> name || !i -> name [0 ])
2236+ return ;
2237+ * current_device_index = i -> index ;
2238+ }
2239+
2240+ struct find_monitor_of_sink_cb_param
2241+ {
2242+ struct get_loopback_capture_device_params * params ;
2243+ uint32_t current_device_index ;
2244+ };
2245+
2246+ static void find_monitor_of_sink_cb (pa_context * c , const pa_source_info * i , int eol , void * userdata )
2247+ {
2248+ struct find_monitor_of_sink_cb_param * p = userdata ;
2249+ unsigned int len ;
2250+
2251+ pulse_broadcast ();
2252+
2253+ if (!i || !i -> name || !i -> name [0 ])
2254+ return ;
2255+ if (i -> monitor_of_sink != p -> current_device_index )
2256+ return ;
2257+
2258+ len = strlen (i -> name ) + 1 ;
2259+ if (len <= p -> params -> ret_device_len )
2260+ {
2261+ memcpy (p -> params -> ret_device , i -> name , len );
2262+ p -> params -> result = STATUS_SUCCESS ;
2263+ return ;
2264+ }
2265+ p -> params -> ret_device_len = len ;
2266+ p -> params -> result = STATUS_BUFFER_TOO_SMALL ;
2267+ }
2268+
2269+ static NTSTATUS pulse_get_loopback_capture_device (void * args )
2270+ {
2271+ struct get_loopback_capture_device_params * params = args ;
2272+ uint32_t current_device_index = PA_INVALID_INDEX ;
2273+ struct find_monitor_of_sink_cb_param p ;
2274+ const char * device_name ;
2275+ char * name ;
2276+
2277+ pulse_lock ();
2278+
2279+ if (!pulse_ml )
2280+ {
2281+ pulse_unlock ();
2282+ ERR ("Called without main loop running.\n" );
2283+ params -> result = E_INVALIDARG ;
2284+ return STATUS_SUCCESS ;
2285+ }
2286+
2287+ name = wstr_to_str (params -> name );
2288+ params -> result = pulse_connect (name );
2289+ free (name );
2290+
2291+ if (FAILED (params -> result ))
2292+ {
2293+ pulse_unlock ();
2294+ return STATUS_SUCCESS ;
2295+ }
2296+
2297+ device_name = params -> device ;
2298+ if (device_name && !device_name [0 ]) device_name = NULL ;
2299+
2300+ params -> result = E_FAIL ;
2301+ wait_pa_operation_complete (pa_context_get_sink_info_by_name (pulse_ctx , device_name , & sink_name_info_cb , & current_device_index ));
2302+ if (current_device_index != PA_INVALID_INDEX )
2303+ {
2304+ p .current_device_index = current_device_index ;
2305+ p .params = params ;
2306+ wait_pa_operation_complete (pa_context_get_source_info_list (pulse_ctx , & find_monitor_of_sink_cb , & p ));
2307+ }
2308+
2309+ pulse_unlock ();
2310+ return STATUS_SUCCESS ;
2311+ }
2312+
22302313static NTSTATUS pulse_get_mix_format (void * args )
22312314{
22322315 struct get_mix_format_params * params = args ;
@@ -2580,7 +2663,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
25802663 pulse_get_capture_buffer ,
25812664 pulse_release_capture_buffer ,
25822665 pulse_is_format_supported ,
2583- pulse_not_implemented ,
2666+ pulse_get_loopback_capture_device ,
25842667 pulse_get_mix_format ,
25852668 pulse_get_device_period ,
25862669 pulse_get_buffer_size ,
@@ -2773,6 +2856,31 @@ static NTSTATUS pulse_wow64_is_format_supported(void *args)
27732856 return STATUS_SUCCESS ;
27742857}
27752858
2859+ static NTSTATUS pulse_wow64_get_loopback_capture_device (void * args )
2860+ {
2861+ struct
2862+ {
2863+ PTR32 name ;
2864+ PTR32 device ;
2865+ PTR32 ret_device ;
2866+ UINT32 ret_device_len ;
2867+ HRESULT result ;
2868+ } * params32 = args ;
2869+
2870+ struct get_loopback_capture_device_params params =
2871+ {
2872+ .name = ULongToPtr (params32 -> name ),
2873+ .device = ULongToPtr (params32 -> device ),
2874+ .ret_device = ULongToPtr (params32 -> device ),
2875+ .ret_device_len = params32 -> ret_device_len ,
2876+ };
2877+
2878+ pulse_get_loopback_capture_device (& params );
2879+ params32 -> result = params .result ;
2880+ params32 -> ret_device_len = params .ret_device_len ;
2881+ return STATUS_SUCCESS ;
2882+ }
2883+
27762884static NTSTATUS pulse_wow64_get_mix_format (void * args )
27772885{
27782886 struct
@@ -3053,7 +3161,7 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
30533161 pulse_wow64_get_capture_buffer ,
30543162 pulse_release_capture_buffer ,
30553163 pulse_wow64_is_format_supported ,
3056- pulse_not_implemented ,
3164+ pulse_wow64_get_loopback_capture_device ,
30573165 pulse_wow64_get_mix_format ,
30583166 pulse_wow64_get_device_period ,
30593167 pulse_wow64_get_buffer_size ,
0 commit comments