comparison src/alsa-ng/alsa-ringbuffer.h @ 3162:e387614b9be9

alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback. This driver uses the "safe" ALSA API subset, including use of blocking I/O. Right now, it is hardcoded to use "default". Do not complain about bugs in this plugin.
author William Pitcock <nenolod@atheme.org>
date Thu, 14 May 2009 21:05:11 -0500
parents
children
comparison
equal deleted inserted replaced
3161:6dd886b5c72b 3162:e387614b9be9
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 */
16
17 #ifndef _ALSAPLUG_RINGBUFFER_H
18 #define _ALSAPLUG_RINGBUFFER_H
19
20 #include <glib.h>
21
22 typedef GMutex alsaplug_ringbuffer_mutex_t;
23 #define _ALSAPLUG_RINGBUFFER_LOCK(L) g_mutex_lock(L)
24 #define _ALSAPLUG_RINGBUFFER_UNLOCK(L) g_mutex_unlock(L)
25
26 #include <stdlib.h>
27
28 #ifdef ALSAPLUG_RINGBUFFER_DEBUG
29 #define ASSERT_RB(buf) _alsaplug_ringbuffer_assert(buf)
30 #else
31 #define ASSERT_RB(buf)
32 #endif
33
34 typedef struct {
35 alsaplug_ringbuffer_mutex_t* lock;
36 char _free_lock;
37 char* buf;
38 char* end;
39 char* wp;
40 char* rp;
41 unsigned int free;
42 unsigned int used;
43 unsigned int size;
44 } alsaplug_ringbuf_t;
45
46 int alsaplug_ringbuffer_init(alsaplug_ringbuf_t* rb, unsigned int size);
47 int alsaplug_ringbuffer_init_with_lock(alsaplug_ringbuf_t* rb, unsigned int size, alsaplug_ringbuffer_mutex_t* lock);
48 int alsaplug_ringbuffer_write(alsaplug_ringbuf_t* rb, void* buf, unsigned int size);
49 int alsaplug_ringbuffer_read(alsaplug_ringbuf_t* rb, void* buf, unsigned int size);
50 int alsaplug_ringbuffer_read_locked(alsaplug_ringbuf_t* rb, void* buf, unsigned int size);
51 void alsaplug_ringbuffer_reset(alsaplug_ringbuf_t* rb);
52 unsigned int alsaplug_ringbuffer_free(alsaplug_ringbuf_t* rb);
53 unsigned int alsaplug_ringbuffer_free_locked(alsaplug_ringbuf_t* rb);
54 unsigned int alsaplug_ringbuffer_used(alsaplug_ringbuf_t* rb);
55 unsigned int alsaplug_ringbuffer_used_locked(alsaplug_ringbuf_t* rb);
56 void alsaplug_ringbuffer_destroy(alsaplug_ringbuf_t* rb);
57
58 #endif