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