Logo Search packages:      
Sourcecode: pulseaudio version File versions  Download package

pa_browser* pa_browser_new_full ( pa_mainloop_api mainloop,
pa_browse_flags_t  flags,
const char **  error_string 
)

Same pa_browser_new, but pass additional flags parameter.

Definition at line 320 of file browser.c.

References PA_BROWSE_FOR_SERVERS, PA_BROWSE_FOR_SINKS, and pa_xnew.

                                                                                                               {
    pa_browser *b;
    int error;

    pa_assert(mainloop);

    if (flags & ~(PA_BROWSE_FOR_SERVERS|PA_BROWSE_FOR_SINKS|PA_BROWSE_FOR_SOURCES) || flags == 0)
        return NULL;

    b = pa_xnew(pa_browser, 1);
    b->mainloop = mainloop;
    PA_REFCNT_INIT(b);
    b->callback = NULL;
    b->userdata = NULL;
    b->error_callback = NULL;
    b->error_userdata = NULL;
    b->sink_browser = b->source_browser = b->server_browser = NULL;

    b->avahi_poll = pa_avahi_poll_new(mainloop);

    if (!(b->client = avahi_client_new(b->avahi_poll, 0, client_callback, b, &error))) {
        if (error_string)
            *error_string = avahi_strerror(error);
        goto fail;
    }

    if ((flags & PA_BROWSE_FOR_SERVERS) &&
        !(b->server_browser = avahi_service_browser_new(
                  b->client,
                  AVAHI_IF_UNSPEC,
                  AVAHI_PROTO_INET,
                  SERVICE_TYPE_SERVER,
                  NULL,
                  0,
                  browse_callback,
                  b))) {

        if (error_string)
            *error_string = avahi_strerror(avahi_client_errno(b->client));
        goto fail;
    }

    if ((flags & PA_BROWSE_FOR_SINKS) &&
        !(b->sink_browser = avahi_service_browser_new(
                  b->client,
                  AVAHI_IF_UNSPEC,
                  AVAHI_PROTO_UNSPEC,
                  SERVICE_TYPE_SINK,
                  NULL,
                  0,
                  browse_callback,
                  b))) {

        if (error_string)
            *error_string = avahi_strerror(avahi_client_errno(b->client));
        goto fail;
    }

    if ((flags & PA_BROWSE_FOR_SOURCES) &&
        !(b->source_browser = avahi_service_browser_new(
                  b->client,
                  AVAHI_IF_UNSPEC,
                  AVAHI_PROTO_UNSPEC,
                  SERVICE_TYPE_SOURCE,
                  NULL,
                  0,
                  browse_callback,
                  b))) {

        if (error_string)
            *error_string = avahi_strerror(avahi_client_errno(b->client));
        goto fail;
    }

    return b;

fail:
    if (b)
        browser_free(b);

    return NULL;
}


Generated by  Doxygen 1.6.0   Back to index