[PATCH resend 2/2] winegstreamer: Move broad callback handling code to gst_cbs.

Zebediah Figura zfigura at codeweavers.com
Thu Mar 19 12:30:43 CDT 2020


On 3/17/20 12:07 PM, Derek Lesho wrote:
> +BOOL is_wine_thread(void)
> +{
> +    return pthread_getspecific(wine_gst_key) != NULL;
> +}
> +
> +pthread_mutex_t cb_list_lock = PTHREAD_MUTEX_INITIALIZER;
> +pthread_cond_t cb_list_cond = PTHREAD_COND_INITIALIZER;
> +struct list cb_list = LIST_INIT(cb_list);
> +
> +void CALLBACK perform_cb(TP_CALLBACK_INSTANCE *instance, void *user)
> +{
> +    struct cb_data *cbdata = user;
> +
> +    if (cbdata->type < GSTDEMUX_MAX)
> +        perform_cb_gstdemux(cbdata);
> +
> +    pthread_mutex_lock(&cbdata->lock);
> +    cbdata->finished = 1;
> +    pthread_cond_broadcast(&cbdata->cond);
> +    pthread_mutex_unlock(&cbdata->lock);
> +}

I think these can be static now.

> +
> +static DWORD WINAPI dispatch_thread(void *user)
> +{
> +    struct cb_data *cbdata;
> +
> +    CoInitializeEx(NULL, COINIT_MULTITHREADED);
> +
> +    pthread_mutex_lock(&cb_list_lock);
> +
> +    while(1){
> +        pthread_cond_wait(&cb_list_cond, &cb_list_lock);
> +
> +        while(!list_empty(&cb_list)){
> +            cbdata = LIST_ENTRY(list_head(&cb_list), struct cb_data, entry);
> +            list_remove(&cbdata->entry);
> +
> +            TrySubmitThreadpoolCallback(&perform_cb, cbdata, NULL);
> +        }
> +    }
> +
> +    pthread_mutex_unlock(&cb_list_lock);
> +
> +    CoUninitialize();
> +
> +    return 0;
> +}

As long as you're moving code here, can you please improve the
formatting a little? (i.e. space after "while", opening brace on a new
line.)

> +    default:
> +        {
> +            ERR("Wrong callback forwarder called\n");
> +            assert(0);

I think this belongs in a separate patch. Also, the ERR() seems
unnecessary; the assert() gives you just as much information.



More information about the wine-devel mailing list