Example #1
0
static void
RemoveSource( JSDContext* jsdc, JSDSourceText* jsdsrc )
{
    PR_REMOVE_LINK(&jsdsrc->links);
    ClearText( jsdc, jsdsrc );
    DestroySource( jsdc, jsdsrc );
}
Example #2
0
File: pulse.c Project: 4udak/vlc
/**
 * Adds a source.
 */
static int AddSource (services_discovery_t *sd, const pa_source_info *info)
{
    services_discovery_sys_t *sys = sd->p_sys;

    msg_Dbg (sd, "adding %s (%s)", info->name, info->description);

    char *mrl;
    if (unlikely(asprintf (&mrl, "pulse://%s", info->name) == -1))
        return -1;

    input_item_t *item = input_item_NewWithType (mrl, info->description,
                                                 0, NULL, 0, -1,
                                                 ITEM_TYPE_CARD);
    free (mrl);
    if (unlikely(item == NULL))
        return -1;

    struct device *d = malloc (sizeof (*d));
    if (unlikely(d == NULL))
    {
        vlc_gc_decref (item);
        return -1;
    }
    d->index = info->index;
    d->item = item;
    d->sd = NULL;

    struct device **dp = tsearch (d, &sys->root, cmpsrc);
    if (dp == NULL) /* Out-of-memory */
    {
        DestroySource (d);
        return -1;
    }
    if (*dp != d) /* Replace existing source */
    {
        DestroySource (*dp);
        *dp = d;
    }

    const char *card = pa_proplist_gets(info->proplist, "device.product.name");
    services_discovery_AddItem (sd, item,
                                (card != NULL) ? card : N_("Generic"));
    d->sd = sd;
    return 0;
}
Example #3
0
File: pulse.c Project: 4udak/vlc
/**
 * Removes a source (if present) by index.
 */
static void RemoveSource (services_discovery_t *sd, uint32_t idx)
{
    services_discovery_sys_t *sys = sd->p_sys;

    struct device **dp = tfind (&idx, &sys->root, cmpsrc);
    if (dp == NULL)
        return;

    struct device *d = *dp;
    tdelete (d, &sys->root, cmpsrc);
    DestroySource (d);
}
Example #4
0
static void
RemoveSourceFromRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
{
    PR_REMOVE_LINK(&jsdsrc->links);
    DestroySource( jsdc, jsdsrc );
}