[pulseaudio-discuss] userdata not being relayed in callback method

Forwind info forward at forwind.net
Tue Oct 13 14:36:04 PDT 2009


Hi folks,

I have made considerable progress from earlier on. I have almost completed
my task but it looks as if there may be a bug or more than likely I'm being
a bit stupid ?

I'm on 0.9.1.4 on Jaunty.

Scenario:

On a PA_SUBSCRIPTION_EVENT_SINK_INPUT my subscription callback method is
called with the relevant userdata obj which was passed in at the main method
stage. All fine so far.

After receiving this event, I then call

pa_context_get_sink_input_info(c, index,
context_get_sink_input_info_callback, userdata));  //please note  at this
point the userdata obj is as it should be.

But when the callback is called the userdata obj is NULL !

Any ideas ?

Code is pasted below

Conor

static void context_get_sink_input_info_callback(pa_context *c, const
pa_sink_input_info *info, void *userdata){
    if (!info) {
        printf("Failed to get sink input info");
        return;
    }
    else{
        printf("\n SINK INPUT INFO Name : %s \n", info->name);
        printf("\n SINK INPUT INFO sink index : %d \n", info->sink);
        pa_operation_unref(pa_context_get_sink_info_by_index(c, info->sink,
context_get_sink_info_by_index_callback, userdata));

        // From here userdata is NULL !
        if (userdata == NULL) {
            printf("userdata is null in the events callback");
        }
        else{
            update_GUI((GtkLabel*)userdata);
        }
    }
}

static void subscribed_events_callback(pa_context *c, enum
pa_subscription_event_type t, uint32_t index, void *userdata){
    GtkLabel *label = (GtkLabel*) userdata
    switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
        case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
            g_message("in the event callback - type = sink input and index =
%d", index);
            pa_operation_unref(pa_context_get_sink_input_info(c, index,
context_get_sink_input_info_callback, userdata));
        // from the userdata is fine!
        if (userdata == NULL) {
            printf("userdata is null in the events callback");
        }
        else{
            // this works fine
            update_GUI((GtkLabel*)userdata);
        }
        break;
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20091013/327698df/attachment.htm>


More information about the pulseaudio-discuss mailing list