mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-01-01 11:08:36 -05:00
srbchannel: Add the shared ringbuffer object
An shm ringbuffer that is used for low overhead server-client communication. Signalling is done through eventfd semaphores - it's based on pa_fdsem to avoid syscalls if nothing is waiting on the other side. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
cb484805c1
commit
0cd4d3531a
3 changed files with 369 additions and 1 deletions
62
src/pulsecore/srbchannel.h
Normal file
62
src/pulsecore/srbchannel.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef foopulsesrbchannelhfoo
|
||||
#define foopulsesrbchannelhfoo
|
||||
|
||||
/***
|
||||
This file is part of PulseAudio.
|
||||
|
||||
Copyright 2014 David Henningsson, Canonical Ltd.
|
||||
|
||||
PulseAudio 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.
|
||||
|
||||
PulseAudio 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 PulseAudio; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA.
|
||||
***/
|
||||
|
||||
#include <pulse/mainloop-api.h>
|
||||
#include <pulsecore/fdsem.h>
|
||||
#include <pulsecore/memblock.h>
|
||||
|
||||
/* An shm ringbuffer that is used for low overhead server-client communication.
|
||||
Signaling is done through eventfd semaphores (pa_fdsem). */
|
||||
|
||||
typedef struct pa_srbchannel pa_srbchannel;
|
||||
|
||||
typedef struct pa_srbchannel_template {
|
||||
int readfd, writefd;
|
||||
pa_memblock *memblock;
|
||||
} pa_srbchannel_template;
|
||||
|
||||
pa_srbchannel* pa_srbchannel_new(pa_mainloop_api *m, pa_mempool *p);
|
||||
/* Note: this creates a srbchannel with swapped read and write. */
|
||||
pa_srbchannel* pa_srbchannel_new_from_template(pa_mainloop_api *m, pa_srbchannel_template *t);
|
||||
|
||||
void pa_srbchannel_free(pa_srbchannel *sr);
|
||||
|
||||
void pa_srbchannel_export(pa_srbchannel *sr, pa_srbchannel_template *t);
|
||||
|
||||
size_t pa_srbchannel_write(pa_srbchannel *sr, const void *data, size_t l);
|
||||
size_t pa_srbchannel_read(pa_srbchannel *sr, void *data, size_t l);
|
||||
|
||||
/* Set the callback function that is called whenever data becomes available for reading.
|
||||
It can also be called if the output buffer was full and can now be written to.
|
||||
|
||||
Return false to abort all processing (e g if the srbchannel has been freed during the callback).
|
||||
Otherwise return true.
|
||||
|
||||
Note that the callback will be called immediately, to be able to process stuff that
|
||||
might already be in the buffer.
|
||||
*/
|
||||
typedef bool (*pa_srbchannel_cb_t)(pa_srbchannel *sr, void *userdata);
|
||||
void pa_srbchannel_set_callback(pa_srbchannel *sr, pa_srbchannel_cb_t callback, void *userdata);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue