annotate src/alsa-ng/alsa-core.c @ 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 26a2c237ef53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 * Audacious ALSA Plugin (-ng)
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 * Copyright (c) 2009 William Pitcock <nenolod@dereferenced.org>
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 *
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 * 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
6 * 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
7 * 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
8 * (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
9 *
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 * 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
11 * 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
12 * 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
13 * 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
14 *
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 * 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
16 * 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
17 * 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
18 */
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 #define ALSA_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
21 #include "alsa-stdinc.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
22
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 static snd_pcm_t *pcm_handle = NULL;
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 static alsaplug_ringbuf_t pcm_ringbuf;
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 static gboolean pcm_going = FALSE;
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 static GThread *audio_thread = NULL;
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 static gint bps;
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 static GMutex *pcm_mutex;
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 static GCond *pcm_cond;
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
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 static gsize wr_total = 0;
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 static gsize wr_hwframes = 0;
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 static gint flush_request;
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
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 static void
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 alsaplug_write_buffer(gpointer data, gint length)
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 {
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 snd_pcm_sframes_t wr_frames;
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
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 while (length > 0)
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 {
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 gint frames = snd_pcm_bytes_to_frames(pcm_handle, length);
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 wr_frames = snd_pcm_writei(pcm_handle, data, frames);
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 if (wr_frames > 0)
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 {
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 gint written = snd_pcm_frames_to_bytes(pcm_handle, wr_frames);
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 length -= written;
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 data += written;
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 }
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 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
53 {
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 gint err = snd_pcm_recover(pcm_handle, wr_frames, 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
55 if (err < 0)
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 _ERROR("(write) snd_pcm_recover: %s", snd_strerror(err));
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 return;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
59 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
60 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
61 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 static gpointer
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 alsaplug_loop(gpointer unused)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 gchar buf[2048];
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
68 while (pcm_going)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
69 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
70 if (flush_request != -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
71 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
72 snd_pcm_drop(pcm_handle);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
73 snd_pcm_prepare(pcm_handle);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
74 wr_total = flush_request * (bps / 1000);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
75 flush_request = -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
76 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
77
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 if (alsaplug_ringbuffer_read(&pcm_ringbuf, buf, 2048) == -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
79 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
80 GTimeVal pcm_abs_time;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
81
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82 g_get_current_time(&pcm_abs_time);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83 g_time_val_add(&pcm_abs_time, 10000);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
84
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
85 g_mutex_lock(pcm_mutex);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
86 g_cond_timed_wait(pcm_cond, pcm_mutex, &pcm_abs_time);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
87 g_mutex_unlock(pcm_mutex);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
88
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89 continue;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
90 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
91
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
92 alsaplug_write_buffer(buf, 2048);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
93 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
94
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
95 snd_pcm_close(pcm_handle);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96 pcm_handle = NULL;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
97
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
98 return NULL;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
101 /********************************************************************************
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
102 * Output Plugin API implementation. *
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
103 ********************************************************************************/
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
104
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105 static OutputPluginInitStatus
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
106 alsaplug_init(void)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
107 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108 gint card = -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
109
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 pcm_mutex = g_mutex_new();
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111 pcm_cond = g_cond_new();
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113 if (snd_card_next(&card) != 0)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114 return OUTPUT_PLUGIN_INIT_NO_DEVICES;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
115
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116 return OUTPUT_PLUGIN_INIT_FOUND_DEVICES;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 static gint
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 alsaplug_open_audio(AFormat fmt, gint rate, gint nch)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 gint err, bitwidth, ringbuf_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
123 snd_pcm_format_t afmt;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124 snd_pcm_hw_params_t *hwparams = NULL;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126 afmt = alsaplug_format_convert(fmt);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128 if ((err = snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 _ERROR("snd_pcm_open: %s", snd_strerror(err));
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131 pcm_handle = NULL;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 return -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
133 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
134
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135 snd_pcm_hw_params_alloca(&hwparams);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 snd_pcm_hw_params_any(pcm_handle, hwparams);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137 snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
138 snd_pcm_hw_params_set_format(pcm_handle, hwparams, afmt);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139 snd_pcm_hw_params_set_channels(pcm_handle, hwparams, nch);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140 snd_pcm_hw_params_set_rate(pcm_handle, hwparams, rate, 0);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 err = snd_pcm_hw_params(pcm_handle, hwparams);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143 if (err < 0)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145 _ERROR("snd_pcm_hw_params failed: %s", snd_strerror(err));
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146 return -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
147 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149 bitwidth = snd_pcm_format_physical_width(afmt);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 bps = (rate * bitwidth * nch) >> 3;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151 ringbuf_size = aud_cfg->output_buffer_size * bps / 1000;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 alsaplug_ringbuffer_init(&pcm_ringbuf, ringbuf_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
153 pcm_going = TRUE;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154 flush_request = -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
155
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156 audio_thread = g_thread_create(alsaplug_loop, NULL, TRUE, NULL);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157 return 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
158 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
159
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160 static void
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 alsaplug_close_audio(void)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163 pcm_going = FALSE;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165 g_thread_join(audio_thread);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
166
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 wr_total = 0;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
168 wr_hwframes = 0;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
169 bps = 0;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
170 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
171
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172 static void
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173 alsaplug_write_audio(gpointer data, gint length)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
174 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
175 wr_total += length;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
176 alsaplug_ringbuffer_write(&pcm_ringbuf, data, length);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
179 static gint
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
180 alsaplug_output_time(void)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
181 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
182 snd_pcm_sframes_t delay;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
183 gsize bytes = wr_total;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
184
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
185 if (pcm_going && pcm_handle != NULL)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
186 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
187 if (!snd_pcm_delay(pcm_handle, &delay))
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
188 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
189 guint d = snd_pcm_frames_to_bytes(pcm_handle, delay);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
190 if (bytes < d)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
191 bytes = 0;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
192 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
193 bytes -= d;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
194 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
195
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
196 return (bytes * 1000) / bps;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
197 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
198
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
199 return 0;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
200 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
201
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
202 static gint
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
203 alsaplug_written_time(void)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
204 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
205 if (pcm_going)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
206 return (wr_total * 1000) / bps;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
207
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
208 return 0;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
209 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
210
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
211 static gint
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
212 alsaplug_buffer_free(void)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
213 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
214 return alsaplug_ringbuffer_free(&pcm_ringbuf);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
215 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
216
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
217 static void
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
218 alsaplug_flush(gint time)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
219 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
220 flush_request = time;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
221 while (flush_request != -1 && pcm_going)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
222 g_usleep(10000);
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
223 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
224
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
225 static gint
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
226 alsaplug_buffer_playing(void)
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
227 {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
228 return pcm_going;
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
229 }
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
230
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
231 /********************************************************************************
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
232 * Plugin glue. *
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
233 ********************************************************************************/
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
234
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
235 static OutputPlugin alsa_op = {
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
236 .description = "ALSA Output Plugin (-ng)",
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
237 .probe_priority = 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
238 .init = alsaplug_init,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
239 .open_audio = alsaplug_open_audio,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
240 .close_audio = alsaplug_close_audio,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
241 .write_audio = alsaplug_write_audio,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
242 .output_time = alsaplug_output_time,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
243 .written_time = alsaplug_written_time,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
244 .buffer_free = alsaplug_buffer_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
245 .buffer_playing = alsaplug_buffer_playing,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
246 .flush = alsaplug_flush,
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
247 };
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
248
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
249 OutputPlugin *alsa_oplist[] = { &alsa_op, NULL };
e387614b9be9 alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
250 SIMPLE_OUTPUT_PLUGIN(alsa, alsa_oplist);