1 /*****************************************************************************
2 * dynamicoverlay_commands.c : dynamic overlay plugin commands
3 *****************************************************************************
4 * Copyright (C) 2008 the VideoLAN team
7 * Author: Søren Bøg <avacore@videolan.org>
8 * Jean-Paul Saman <jpsaman@videolan.org>
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.
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.
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 *****************************************************************************/
31 #include "dynamicoverlay.h"
33 /*****************************************************************************
34 * queue_t: Command queue
35 *****************************************************************************/
37 int QueueInit( queue_t *p_queue )
39 memset( p_queue, 0, sizeof( queue_t ) );
40 p_queue->p_head = NULL;
41 p_queue->p_tail = NULL;
46 int QueueDestroy( queue_t *p_queue )
48 command_t *p_cur = p_queue->p_head, *p_temp;
49 while( p_cur != NULL )
52 p_cur = p_cur->p_next;
55 p_queue->p_head = NULL;
56 p_queue->p_tail = NULL;
61 int QueueEnqueue( queue_t *p_queue, command_t *p_cmd )
63 if( p_queue->p_tail != NULL )
65 p_queue->p_tail->p_next = p_cmd;
67 if( p_queue->p_head == NULL )
69 p_queue->p_head = p_cmd;
71 p_queue->p_tail = p_cmd;
77 command_t *QueueDequeue( queue_t *p_queue )
79 if( p_queue->p_head == NULL )
85 command_t *p_ret = p_queue->p_head;
86 if( p_queue->p_head == p_queue->p_tail )
88 p_queue->p_head = p_queue->p_tail = NULL;
92 p_queue->p_head = p_queue->p_head->p_next;
98 int QueueTransfer( queue_t *p_sink, queue_t *p_source )
100 if( p_source->p_head == NULL ) {
104 if( p_sink->p_head == NULL ) {
105 p_sink->p_head = p_source->p_head;
106 p_sink->p_tail = p_source->p_tail;
108 p_sink->p_tail->p_next = p_source->p_head;
109 p_sink->p_tail = p_source->p_tail;
111 p_source->p_head = p_source->p_tail = NULL;