153a5a1b3Sopenharmony_ci#ifndef foopulseasyncqhfoo
253a5a1b3Sopenharmony_ci#define foopulseasyncqhfoo
353a5a1b3Sopenharmony_ci
453a5a1b3Sopenharmony_ci/***
553a5a1b3Sopenharmony_ci  This file is part of PulseAudio.
653a5a1b3Sopenharmony_ci
753a5a1b3Sopenharmony_ci  Copyright 2004-2006 Lennart Poettering
853a5a1b3Sopenharmony_ci
953a5a1b3Sopenharmony_ci  PulseAudio is free software; you can redistribute it and/or modify
1053a5a1b3Sopenharmony_ci  it under the terms of the GNU Lesser General Public License as
1153a5a1b3Sopenharmony_ci  published by the Free Software Foundation; either version 2.1 of the
1253a5a1b3Sopenharmony_ci  License, or (at your option) any later version.
1353a5a1b3Sopenharmony_ci
1453a5a1b3Sopenharmony_ci  PulseAudio is distributed in the hope that it will be useful, but
1553a5a1b3Sopenharmony_ci  WITHOUT ANY WARRANTY; without even the implied warranty of
1653a5a1b3Sopenharmony_ci  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1753a5a1b3Sopenharmony_ci  Lesser General Public License for more details.
1853a5a1b3Sopenharmony_ci
1953a5a1b3Sopenharmony_ci  You should have received a copy of the GNU Lesser General Public
2053a5a1b3Sopenharmony_ci  License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
2153a5a1b3Sopenharmony_ci***/
2253a5a1b3Sopenharmony_ci
2353a5a1b3Sopenharmony_ci#include <sys/types.h>
2453a5a1b3Sopenharmony_ci#include <pulse/def.h>
2553a5a1b3Sopenharmony_ci#include <pulsecore/macro.h>
2653a5a1b3Sopenharmony_ci
2753a5a1b3Sopenharmony_ci/* A simple, asynchronous, lock-free (if requested also wait-free)
2853a5a1b3Sopenharmony_ci * queue. Not multiple-reader/multiple-writer safe. If that is
2953a5a1b3Sopenharmony_ci * required both sides can be protected by a mutex each. --- Which is
3053a5a1b3Sopenharmony_ci * not a bad thing in most cases, since this queue is intended for
3153a5a1b3Sopenharmony_ci * communication between a normal thread and a single real-time
3253a5a1b3Sopenharmony_ci * thread. Only the real-time side needs to be lock-free/wait-free.
3353a5a1b3Sopenharmony_ci *
3453a5a1b3Sopenharmony_ci * If the queue is full and another entry shall be pushed, or when the
3553a5a1b3Sopenharmony_ci * queue is empty and another entry shall be popped and the "wait"
3653a5a1b3Sopenharmony_ci * argument is non-zero, the queue will block on a UNIX FIFO object --
3753a5a1b3Sopenharmony_ci * that will probably require locking on the kernel side -- which
3853a5a1b3Sopenharmony_ci * however is probably not problematic, because we do it only on
3953a5a1b3Sopenharmony_ci * starvation or overload in which case we have to block anyway.  */
4053a5a1b3Sopenharmony_ci
4153a5a1b3Sopenharmony_citypedef struct pa_asyncq pa_asyncq;
4253a5a1b3Sopenharmony_ci
4353a5a1b3Sopenharmony_ciunsigned PaAsyncqGetNumToRead(pa_asyncq *l);
4453a5a1b3Sopenharmony_cipa_asyncq* pa_asyncq_new(unsigned size);
4553a5a1b3Sopenharmony_civoid pa_asyncq_free(pa_asyncq* q, pa_free_cb_t free_cb);
4653a5a1b3Sopenharmony_ci
4753a5a1b3Sopenharmony_civoid* pa_asyncq_pop(pa_asyncq *q, bool wait);
4853a5a1b3Sopenharmony_ciint pa_asyncq_push(pa_asyncq *q, void *p, bool wait);
4953a5a1b3Sopenharmony_ci
5053a5a1b3Sopenharmony_ci/* Similar to pa_asyncq_push(), but if the queue is full, postpone the
5153a5a1b3Sopenharmony_ci * appending of the item locally and delay until
5253a5a1b3Sopenharmony_ci * pa_asyncq_before_poll_post() is called. */
5353a5a1b3Sopenharmony_civoid pa_asyncq_post(pa_asyncq*l, void *p);
5453a5a1b3Sopenharmony_ci
5553a5a1b3Sopenharmony_ci/* For the reading side */
5653a5a1b3Sopenharmony_ciint pa_asyncq_read_fd(pa_asyncq *q);
5753a5a1b3Sopenharmony_ciint pa_asyncq_read_before_poll(pa_asyncq *a);
5853a5a1b3Sopenharmony_civoid pa_asyncq_read_after_poll(pa_asyncq *a);
5953a5a1b3Sopenharmony_ci
6053a5a1b3Sopenharmony_ci/* For the writing side */
6153a5a1b3Sopenharmony_ciint pa_asyncq_write_fd(pa_asyncq *q);
6253a5a1b3Sopenharmony_civoid pa_asyncq_write_before_poll(pa_asyncq *a);
6353a5a1b3Sopenharmony_civoid pa_asyncq_write_after_poll(pa_asyncq *a);
6453a5a1b3Sopenharmony_ci
6553a5a1b3Sopenharmony_ci#endif
66