Mercurial > audlegacy-plugins
annotate src/alsa-ng/alsa-core.c @ 3176:dca77b467ea2
Fix a race condition which can occur when flushing the output buffer, causing
two locking g_conds to occur at unexpected order, halting the execution.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 05 Jun 2009 02:32:48 +0300 |
parents | 1bb4cad57923 |
children | 1117166277f7 |
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 |
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 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
|
30 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
|
31 |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
32 static gint flush_request, paused; |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
33 |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
34 static GMutex *pcm_pause_mutex, *pcm_state_mutex; |
3176
dca77b467ea2
Fix a race condition which can occur when flushing the output buffer, causing
Matti Hamalainen <ccr@tnsp.org>
parents:
3175
diff
changeset
|
35 static GCond *pcm_pause_cond, *pcm_state_cond, *pcm_flush_cond; |
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
|
36 |
3164
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
37 /******************************************************************************** |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
38 * ALSA Mixer setting functions. * |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
39 ********************************************************************************/ |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
40 |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
41 /******************************************************************************** |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
42 * ALSA PCM I/O functions. * |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
43 ********************************************************************************/ |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
44 |
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
|
45 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
|
46 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
|
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 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
|
49 |
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 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
|
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 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
|
53 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
|
54 |
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 (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
|
56 { |
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 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
|
58 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
|
59 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
|
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 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
|
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 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
|
64 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
|
65 _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
|
66 |
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 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
|
68 } |
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 } |
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 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
|
73 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
|
74 { |
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 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
|
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 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
|
78 { |
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 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
|
80 { |
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 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
|
82 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
|
83 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
|
84 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
|
85 |
3176
dca77b467ea2
Fix a race condition which can occur when flushing the output buffer, causing
Matti Hamalainen <ccr@tnsp.org>
parents:
3175
diff
changeset
|
86 g_cond_broadcast(pcm_flush_cond); |
3165
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
87 } |
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
88 |
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
|
89 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
|
90 { |
3164
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
91 /* less than 2048 bytes to go...? */ |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
92 gint remain = alsaplug_ringbuffer_used(&pcm_ringbuf); |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
93 if (remain <= 2048 && remain > 0) |
3164
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
94 { |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
95 alsaplug_ringbuffer_read(&pcm_ringbuf, buf, remain); |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
96 alsaplug_write_buffer(buf, remain); |
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
97 } |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
98 else |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
99 { |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
100 g_mutex_lock(pcm_state_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
101 g_cond_wait(pcm_state_cond, pcm_state_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
102 g_mutex_unlock(pcm_state_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
103 } |
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
|
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 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
|
106 } |
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 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
|
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 |
3164
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
111 snd_pcm_drain(pcm_handle); |
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
|
112 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
|
113 pcm_handle = NULL; |
3168
7e58928783b3
alsa-ng: Set thread handles to NULL when threads exit.
William Pitcock <nenolod@atheme.org>
parents:
3167
diff
changeset
|
114 audio_thread = NULL; |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
115 alsaplug_ringbuffer_destroy(&pcm_ringbuf); |
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
|
116 |
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 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
|
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 |
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 /******************************************************************************** |
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 * 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
|
122 ********************************************************************************/ |
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 |
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 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
|
125 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
|
126 { |
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 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
|
128 |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
129 pcm_pause_mutex = g_mutex_new(); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
130 pcm_pause_cond = g_cond_new(); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
131 |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
132 pcm_state_mutex = g_mutex_new(); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
133 pcm_state_cond = g_cond_new(); |
3176
dca77b467ea2
Fix a race condition which can occur when flushing the output buffer, causing
Matti Hamalainen <ccr@tnsp.org>
parents:
3175
diff
changeset
|
134 pcm_flush_cond = g_cond_new(); |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
135 |
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
|
136 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
|
137 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
|
138 |
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 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
|
140 } |
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 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
|
143 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
|
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 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
|
146 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
|
147 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
|
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 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
|
150 |
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 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
|
152 { |
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 _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
|
154 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
|
155 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
|
156 } |
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 |
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 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 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
|
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 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
|
166 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
|
167 { |
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 _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
|
169 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
|
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 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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
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 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
|
180 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
|
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 |
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 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
|
184 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
|
185 { |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
186 g_mutex_lock(pcm_state_mutex); |
3172
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
187 |
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
|
188 pcm_going = FALSE; |
3172
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
189 wr_total = 0; |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
190 wr_hwframes = 0; |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
191 bps = 0; |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
192 |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
193 g_mutex_unlock(pcm_state_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
194 g_cond_broadcast(pcm_state_cond); |
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
|
195 |
3167
9739ba93fd79
alsa-ng: Don't try to join threads that have already exited.
William Pitcock <nenolod@atheme.org>
parents:
3166
diff
changeset
|
196 if (audio_thread != NULL) |
9739ba93fd79
alsa-ng: Don't try to join threads that have already exited.
William Pitcock <nenolod@atheme.org>
parents:
3166
diff
changeset
|
197 g_thread_join(audio_thread); |
9739ba93fd79
alsa-ng: Don't try to join threads that have already exited.
William Pitcock <nenolod@atheme.org>
parents:
3166
diff
changeset
|
198 |
3164
adec82db531c
alsa-ng: Everything but mixer (and custom output settings) should be working now.
William Pitcock <nenolod@atheme.org>
parents:
3163
diff
changeset
|
199 audio_thread = NULL; |
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
|
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 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
|
203 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
|
204 { |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
205 if (paused) |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
206 { |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
207 g_mutex_lock(pcm_pause_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
208 g_cond_wait(pcm_pause_cond, pcm_pause_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
209 g_mutex_unlock(pcm_pause_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
210 } |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
211 |
3172
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
212 g_mutex_lock(pcm_state_mutex); |
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
|
213 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
|
214 alsaplug_ringbuffer_write(&pcm_ringbuf, data, length); |
3172
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
215 g_mutex_unlock(pcm_state_mutex); |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
216 g_cond_broadcast(pcm_state_cond); |
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
|
217 } |
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 |
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 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
|
220 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
|
221 { |
3174
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
222 gint ret = 0; |
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
|
223 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
|
224 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
|
225 |
3174
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
226 g_mutex_lock(pcm_state_mutex); |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
227 |
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
|
228 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
|
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 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
|
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 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 } |
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 |
3174
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
239 ret = (bytes * 1000) / bps; |
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
|
240 } |
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 |
3174
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
242 g_mutex_unlock(pcm_state_mutex); |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
243 |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
244 return ret; |
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
|
245 } |
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 |
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 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
|
248 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
|
249 { |
3174
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
250 gint ret = 0; |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
251 |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
252 g_mutex_lock(pcm_state_mutex); |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
253 |
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
|
254 if (pcm_going) |
3174
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
255 ret = (wr_total * 1000) / bps; |
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
|
256 |
3174
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
257 g_mutex_unlock(pcm_state_mutex); |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
258 |
8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
William Pitcock <nenolod@atheme.org>
parents:
3173
diff
changeset
|
259 return ret; |
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
|
260 } |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
261 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
262 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
|
263 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
|
264 { |
3173
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
265 gint ret; |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
266 |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
267 g_mutex_lock(pcm_state_mutex); |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
268 |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
269 if (pcm_going == FALSE) |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
270 ret = 0; |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
271 else |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
272 ret = alsaplug_ringbuffer_free(&pcm_ringbuf); |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
273 |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
274 g_mutex_unlock(pcm_state_mutex); |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
275 |
3fd0d762371c
alsa-ng: alsaplug_buffer_free(): Make sure we don't try to access the ringbuffer when it's not yet allocated.
William Pitcock <nenolod@atheme.org>
parents:
3172
diff
changeset
|
276 return ret; |
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
|
277 } |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
278 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
279 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
|
280 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
|
281 { |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
282 /* make the request... */ |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
283 g_mutex_lock(pcm_state_mutex); |
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
|
284 flush_request = time; |
3175
1bb4cad57923
alsa-ng: alsaplug_flush(): It is good practise to lock the same mutex as the waiting threads while calling g_cond_broadcast.
Tomasz Mon <desowin@gmail.com>
parents:
3174
diff
changeset
|
285 g_cond_broadcast(pcm_state_cond); |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
286 |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
287 /* ...then wait for the transaction to complete. */ |
3176
dca77b467ea2
Fix a race condition which can occur when flushing the output buffer, causing
Matti Hamalainen <ccr@tnsp.org>
parents:
3175
diff
changeset
|
288 g_cond_wait(pcm_flush_cond, pcm_state_mutex); |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
289 g_mutex_unlock(pcm_state_mutex); |
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
|
290 } |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
291 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
292 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
|
293 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
|
294 { |
3172
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
295 gint ret; |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
296 |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
297 g_mutex_lock(pcm_state_mutex); |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
298 |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
299 if (pcm_going == FALSE) |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
300 ret = 0; |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
301 else |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
302 ret = alsaplug_ringbuffer_used(&pcm_ringbuf) != 0; |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
303 |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
304 g_mutex_unlock(pcm_state_mutex); |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
305 |
1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
William Pitcock <nenolod@atheme.org>
parents:
3168
diff
changeset
|
306 return ret; |
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
|
307 } |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
308 |
3165
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
309 static void |
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
310 alsaplug_pause(short p) |
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
311 { |
3166
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
312 g_mutex_lock(pcm_pause_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
313 paused = p; |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
314 g_mutex_unlock(pcm_pause_mutex); |
8cbf077ba5d0
alsa-ng: Software pause, so we don't have to use snd_pcm_pause(), which is not part of the safe ALSA subset.
William Pitcock <nenolod@atheme.org>
parents:
3165
diff
changeset
|
315 g_cond_broadcast(pcm_pause_cond); |
3165
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
316 } |
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
317 |
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
|
318 /******************************************************************************** |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
319 * 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
|
320 ********************************************************************************/ |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
321 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
322 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
|
323 .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
|
324 .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
|
325 .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
|
326 .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
|
327 .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
|
328 .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
|
329 .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
|
330 .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
|
331 .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
|
332 .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
|
333 .flush = alsaplug_flush, |
3165
087abc78516e
alsa-ng: implement pause stuff. not perfect yet.
William Pitcock <nenolod@atheme.org>
parents:
3164
diff
changeset
|
334 .pause = alsaplug_pause, |
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
|
335 }; |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
336 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
337 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
|
338 SIMPLE_OUTPUT_PLUGIN(alsa, alsa_oplist); |