]> git.sesse.net Git - vlc/blob - modules/video_filter/dynamicoverlay/dynamicoverlay_queue.c
Fix encoding (and writing).
[vlc] / modules / video_filter / dynamicoverlay / dynamicoverlay_queue.c
1 /*****************************************************************************
2  * dynamicoverlay_commands.c : dynamic overlay plugin commands
3  *****************************************************************************
4  * Copyright (C) 2008-2009 the VideoLAN team
5  * $Id$
6  *
7  * Author: Søren Bøg <avacore@videolan.org>
8  *         Jean-Paul Saman <jpsaman@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc_common.h>
30 #include <vlc_osd.h>
31
32 #include "dynamicoverlay.h"
33
34 /*****************************************************************************
35  * queue_t: Command queue
36  *****************************************************************************/
37
38 int QueueInit( queue_t *p_queue )
39 {
40     memset( p_queue, 0, sizeof( queue_t ) );
41     p_queue->p_head = NULL;
42     p_queue->p_tail = NULL;
43
44     return VLC_SUCCESS;
45 }
46
47 int QueueDestroy( queue_t *p_queue )
48 {
49     command_t *p_cur = p_queue->p_head, *p_temp;
50     while( p_cur != NULL )
51     {
52         p_temp = p_cur;
53         p_cur = p_cur->p_next;
54         free( p_temp );
55     }
56     p_queue->p_head = NULL;
57     p_queue->p_tail = NULL;
58
59     return VLC_SUCCESS;
60 }
61
62 int QueueEnqueue( queue_t *p_queue, command_t *p_cmd )
63 {
64     if( p_queue->p_tail != NULL )
65     {
66         p_queue->p_tail->p_next = p_cmd;
67     }
68     if( p_queue->p_head == NULL )
69     {
70         p_queue->p_head = p_cmd;
71     }
72     p_queue->p_tail = p_cmd;
73     p_cmd->p_next = NULL;
74
75     return VLC_SUCCESS;
76 }
77
78 command_t *QueueDequeue( queue_t *p_queue )
79 {
80     if( p_queue->p_head == NULL )
81     {
82         return NULL;
83     }
84     else
85     {
86         command_t *p_ret = p_queue->p_head;
87         if( p_queue->p_head == p_queue->p_tail )
88         {
89             p_queue->p_head = p_queue->p_tail = NULL;
90         }
91         else
92         {
93             p_queue->p_head = p_queue->p_head->p_next;
94         }
95         return p_ret;
96     }
97 }
98
99 int QueueTransfer( queue_t *p_sink, queue_t *p_source )
100 {
101     if( p_source->p_head == NULL ) {
102         return VLC_SUCCESS;
103     }
104
105     if( p_sink->p_head == NULL ) {
106         p_sink->p_head = p_source->p_head;
107         p_sink->p_tail = p_source->p_tail;
108     } else {
109         p_sink->p_tail->p_next = p_source->p_head;
110         p_sink->p_tail = p_source->p_tail;
111     }
112     p_source->p_head = p_source->p_tail = NULL;
113
114     return VLC_SUCCESS;
115 }