Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/VLC/src/misc/   (VLC Media Plyer ©)  Datei vom 23.9.2026 mit Größe 4 kB image not shown  

Quelle  picture_fifo.c   Sprache: C

 

/*****************************************************************************
 * picture_fifo.c : picture fifo functions
 *****************************************************************************
 * Copyright (C) 2009 VLC authors and VideoLAN
 * Copyright (C) 2009 Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
 *
 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/


/*****************************************************************************
 * Preamble
 *****************************************************************************/


#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>

#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_picture_fifo.h>

/*****************************************************************************
 *
 *****************************************************************************/

struct picture_fifo_t {
    vlc_mutex_t lock;
    vlc_picture_chain_t pics;
    size_t count;
};

static void PictureFifoReset(picture_fifo_t *fifo)
{
    vlc_picture_chain_Init( &fifo->pics );
    fifo->count = 0;
}
static void PictureFifoPush(picture_fifo_t *fifo, picture_t *picture)
{
    assert(!picture_HasChainedPics(picture));
    vlc_picture_chain_Append( &fifo->pics, picture );
    fifo->count++;
}

picture_fifo_t *picture_fifo_New(void)
{
    picture_fifo_t *fifo = malloc(sizeof(*fifo));
    if (!fifo)
        return NULL;

    vlc_mutex_init(&fifo->lock);
    PictureFifoReset(fifo);
    return fifo;
}

void picture_fifo_Push(picture_fifo_t *fifo, picture_t *picture)
{
    vlc_mutex_assert(&fifo->lock);
    PictureFifoPush(fifo, picture);
}
picture_t *picture_fifo_Pop(picture_fifo_t *fifo)
{
    vlc_mutex_assert(&fifo->lock);
    picture_t *pic = vlc_picture_chain_PopFront( &fifo->pics );
    if (pic != NULL)
        fifo->count--;
    return pic;
}
bool picture_fifo_IsEmpty(picture_fifo_t *fifo)
{
    vlc_mutex_assert(&fifo->lock);
    return vlc_picture_chain_IsEmpty( &fifo->pics );
}
VLC_API size_t picture_fifo_GetCount(picture_fifo_t *fifo)
{
    vlc_mutex_assert(&fifo->lock);
    return fifo->count;
}
void picture_fifo_Flush(picture_fifo_t *fifo, vlc_tick_t date, bool flush_before)
{
    vlc_mutex_assert(&fifo->lock);
    picture_t *picture;

    vlc_picture_chain_t flush_chain;

    vlc_picture_chain_Init(&flush_chain);
    fifo->count = 0;

    if (date == VLC_TICK_INVALID)
        vlc_picture_chain_GetAndClear(&fifo->pics, &flush_chain);
    else {
        vlc_picture_chain_t filter_chain;
        vlc_picture_chain_GetAndClear(&fifo->pics, &filter_chain);

        while ( !vlc_picture_chain_IsEmpty( &filter_chain ) ) {
            picture = vlc_picture_chain_PopFront( &filter_chain );

            if (( flush_before && picture->date <= date) ||
                (!flush_before && picture->date >= date))
                vlc_picture_chain_Append( &flush_chain, picture );
            else
                PictureFifoPush(fifo, picture);
        }
    }

    while ((picture = vlc_picture_chain_PopFront(&flush_chain)) != NULL)
        picture_Release(picture);
}
void picture_fifo_Delete(picture_fifo_t *fifo)
{
    vlc_mutex_lock(&fifo->lock);
    picture_fifo_Flush(fifo, VLC_TICK_INVALID, true);
    vlc_mutex_unlock(&fifo->lock);
    free(fifo);
}

void picture_fifo_Lock(picture_fifo_t *fifo)
{
    vlc_mutex_lock(&fifo->lock);
}

void picture_fifo_Unlock(picture_fifo_t *fifo)
{
    vlc_mutex_unlock(&fifo->lock);
}

Messung
CHZG
839710093

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.