mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
Remove SpaQueue, use SpaList instead
This commit is contained in:
parent
89bc235924
commit
d0f95fc323
20 changed files with 153 additions and 237 deletions
85
spa/include/spa/list.h
Normal file
85
spa/include/spa/list.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_LIST_H__
|
||||
#define __SPA_LIST_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaList SpaList;
|
||||
|
||||
#include <spa/defs.h>
|
||||
|
||||
struct _SpaList {
|
||||
SpaList *next;
|
||||
SpaList *prev;
|
||||
};
|
||||
|
||||
static inline void
|
||||
spa_list_init (SpaList *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
static inline void
|
||||
spa_list_insert (SpaList *list,
|
||||
SpaList *elem)
|
||||
{
|
||||
elem->prev = list;
|
||||
elem->next = list->next;
|
||||
list->next = elem;
|
||||
elem->next->prev = elem;
|
||||
}
|
||||
|
||||
static inline void
|
||||
spa_list_remove (SpaList *elem)
|
||||
{
|
||||
elem->prev->next = elem->next;
|
||||
elem->next->prev = elem->prev;
|
||||
}
|
||||
|
||||
#define spa_list_is_empty(l) ((l)->next == (l))
|
||||
|
||||
#define spa_list_first(head, type, member) \
|
||||
SPA_CONTAINER_OF((head)->next, type, member)
|
||||
|
||||
#define spa_list_last(item, type, member) \
|
||||
SPA_CONTAINER_OF((head)->prev, type, member)
|
||||
|
||||
#define spa_list_for_each(pos, head, member) \
|
||||
for (pos = SPA_CONTAINER_OF((head)->next, __typeof__(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = SPA_CONTAINER_OF(pos->member.next, __typeof__(*pos), member))
|
||||
|
||||
#define spa_list_for_each_safe(pos, tmp, head, member) \
|
||||
for (pos = SPA_CONTAINER_OF((head)->next, __typeof__(*pos), member), \
|
||||
tmp = SPA_CONTAINER_OF((pos)->member.next, __typeof__(*tmp), member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = SPA_CONTAINER_OF(pos->member.next, __typeof__(*tmp), member))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_LIST_H__ */
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_QUEUE_H__
|
||||
#define __SPA_QUEUE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaQueue SpaQueue;
|
||||
|
||||
#define SPA_QUEUE_URI "http://spaplug.in/ns/queue"
|
||||
#define SPA_QUEUE_PREFIX SPA_QUEUE_URI "#"
|
||||
|
||||
#include <spa/defs.h>
|
||||
|
||||
struct _SpaQueue {
|
||||
void *head, *tail;
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
#define SPA_QUEUE_INIT(q) \
|
||||
do { \
|
||||
(q)->head = (q)->tail = NULL; \
|
||||
(q)->length = 0; \
|
||||
} while (0);
|
||||
|
||||
#define SPA_QUEUE_PUSH_TAIL(q,t,next,i) \
|
||||
do { \
|
||||
if ((q)->tail) \
|
||||
((t*)(q)->tail)->next = (i); \
|
||||
(q)->tail = (i); \
|
||||
if ((q)->head == NULL) \
|
||||
(q)->head = (i); \
|
||||
(q)->length++; \
|
||||
} while (0);
|
||||
|
||||
#define SPA_QUEUE_PEEK_HEAD(q,t,i) \
|
||||
((i) = (t*)((q)->head));
|
||||
|
||||
#define SPA_QUEUE_POP_HEAD(q,t,next,i) \
|
||||
do { \
|
||||
if (((i) = (t*)((q)->head)) == NULL) \
|
||||
break; \
|
||||
(q)->head = (i)->next; \
|
||||
if ((q)->head == NULL) \
|
||||
(q)->tail = NULL; \
|
||||
(q)->length--; \
|
||||
} while (0);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_QUEUE_H__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue