annotate src/audio/nas/SDL_nasaudio.c @ 3822:748707e2ddd1 SDL-ryan-multiple-audio-device

Minor NAS tweak.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 07 Oct 2006 06:17:54 +0000
parents 18393b045759
children 76c5a414b996
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
6 modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
13 Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22 This driver was written by:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 Erik Inge Bolsų
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 knan@mo.himolde.no
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
26 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 /* Allow access to a raw mixing buffer */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include <signal.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include <unistd.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
33 #include "SDL_timer.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 #include "SDL_audio.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
35 #include "../SDL_audiomem.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
36 #include "../SDL_audio_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 #include "SDL_nasaudio.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
39 /* The tag name used by nas audio */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 #define NAS_DRIVER_NAME "nas"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 static struct SDL_PrivateAudioData *this2 = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
44 /* !!! FIXME: dynamic loading? */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
46 static int
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
47 NAS_Available(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
49 AuServer *aud = AuOpenServer("", 0, NULL, 0, NULL, NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
50 if (!aud)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
51 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
53 AuCloseServer(aud);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
54 return 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 /* This function waits until it is possible to write a full sound buffer */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
58 static void
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
59 NAS_WaitDevice(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
61 while (this->hidden->buf_free < this->hidden->mixlen) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
62 AuEvent ev;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
63 AuNextEvent(this->hidden->aud, AuTrue, &ev);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
64 AuDispatchEvent(this->hidden->aud, &ev);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
65 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
68 static void
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
69 NAS_PlayDevice(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 {
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
71 while (this->hidden->mixlen > this->hidden->buf_free) {
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
72 /*
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
73 * We think the buffer is full? Yikes! Ask the server for events,
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
74 * in the hope that some of them is LowWater events telling us more
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
75 * of the buffer is free now than what we think.
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
76 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
77 AuEvent ev;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
78 AuNextEvent(this->hidden->aud, AuTrue, &ev);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
79 AuDispatchEvent(this->hidden->aud, &ev);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
80 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
81 this->hidden->buf_free -= this->hidden->mixlen;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
83 /* Write the audio data */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
84 AuWriteElement(this->hidden->aud, this->hidden->flow, 0,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
85 this->hidden->mixlen, this->hidden->mixbuf, AuFalse, NULL);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
87 this->hidden->written += this->hidden->mixlen;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
88
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 #ifdef DEBUG_AUDIO
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
90 fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
94 static Uint8 *
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
95 NAS_GetDeviceBuf(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
97 return (this->hidden->mixbuf);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
100 static void
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
101 NAS_CloseDevice(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 {
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
103 if (this->hidden != NULL) {
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
104 if (this->hidden->mixbuf != NULL) {
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
105 SDL_FreeAudioMem(this->hidden->mixbuf);
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
106 this->hidden->mixbuf = NULL;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
107 }
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
108 if (this->hidden->aud) {
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
109 AuCloseServer(this->hidden->aud);
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
110 this->hidden->aud = 0;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
111 }
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
112 SDL_free(this->hidden);
3822
748707e2ddd1 Minor NAS tweak.
Ryan C. Gordon <icculus@icculus.org>
parents: 3821
diff changeset
113 this2 = this->hidden = NULL;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
114 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
117 static unsigned char
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
118 sdlformat_to_auformat(unsigned int fmt)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
120 switch (fmt) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 case AUDIO_U8:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
122 return AuFormatLinearUnsigned8;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 case AUDIO_S8:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
124 return AuFormatLinearSigned8;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 case AUDIO_U16LSB:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
126 return AuFormatLinearUnsigned16LSB;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 case AUDIO_U16MSB:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
128 return AuFormatLinearUnsigned16MSB;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 case AUDIO_S16LSB:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
130 return AuFormatLinearSigned16LSB;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 case AUDIO_S16MSB:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
132 return AuFormatLinearSigned16MSB;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
134 return AuNone;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 static AuBool
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
138 event_handler(AuServer * aud, AuEvent * ev, AuEventHandlerRec * hnd)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
140 switch (ev->type) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
141 case AuEventTypeElementNotify:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
142 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
143 AuElementNotifyEvent *event = (AuElementNotifyEvent *) ev;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
145 switch (event->kind) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
146 case AuElementNotifyKindLowWater:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
147 if (this2->buf_free >= 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
148 this2->really += event->num_bytes;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
149 gettimeofday(&this2->last_tv, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
150 this2->buf_free += event->num_bytes;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
151 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
152 this2->buf_free = event->num_bytes;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
153 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
154 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
155 case AuElementNotifyKindState:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
156 switch (event->cur_state) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
157 case AuStatePause:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
158 if (event->reason != AuReasonUser) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
159 if (this2->buf_free >= 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
160 this2->really += event->num_bytes;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
161 gettimeofday(&this2->last_tv, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
162 this2->buf_free += event->num_bytes;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
163 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
164 this2->buf_free = event->num_bytes;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
165 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
166 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
167 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
168 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
169 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
170 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
171 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
172 return AuTrue;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 static AuDeviceID
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 find_device(_THIS, int nch)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
178 int i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
179 for (i = 0; i < AuServerNumDevices(this->hidden->aud); i++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
180 if ((AuDeviceKind(AuServerDevice(this->hidden->aud, i)) ==
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
181 AuComponentKindPhysicalOutput) &&
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
182 AuDeviceNumTracks(AuServerDevice(this->hidden->aud, i)) == nch) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
183 return AuDeviceIdentifier(AuServerDevice(this->hidden->aud, i));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
184 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
185 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
186 return AuNone;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
189 static int
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
190 NAS_OpenDevice(_THIS, const char *devname, int iscapture)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
192 AuElement elms[3];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
193 int buffer_size;
1982
3b4ce57c6215 First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
194 SDL_AudioFormat test_format, format;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
195
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
196 /* Initialize all variables that we clean on shutdown */
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
197 this->hidden = (struct SDL_PrivateAudioData *)
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
198 SDL_malloc((sizeof *this->hidden));
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
199 if (this->hidden == NULL) {
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
200 SDL_OutOfMemory();
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
201 return 0;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
202 }
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
203 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
205 /* Try for a closest match on audio format */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
206 format = 0;
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
207 for (test_format = SDL_FirstAudioFormat(this->spec.format);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
208 !format && test_format;) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
209 format = sdlformat_to_auformat(test_format);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
210 if (format == AuNone) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
211 test_format = SDL_NextAudioFormat();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
212 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
213 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
214 if (format == 0) {
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
215 NAS_CloseDevice(this);
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
216 SDL_SetError("NAS: Couldn't find any hardware audio formats");
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
217 return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
218 }
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
219 this->spec.format = test_format;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
221 this->hidden->aud = AuOpenServer("", 0, NULL, 0, NULL, NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
222 if (this->hidden->aud == 0) {
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
223 NAS_CloseDevice(this);
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
224 SDL_SetError("NAS: Couldn't open connection to NAS server");
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
225 return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
226 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
227
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
228 this->hidden->dev = find_device(this, this->spec.channels);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
229 if ((this->hidden->dev == AuNone)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
230 || (!(this->hidden->flow = AuCreateFlow(this->hidden->aud, NULL)))) {
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
231 NAS_CloseDevice(this);
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
232 SDL_SetError("NAS: Couldn't find a fitting device on NAS server");
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
233 return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
234 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
235
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
236 buffer_size = this->spec.freq;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
237 if (buffer_size < 4096)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
238 buffer_size = 4096;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
240 if (buffer_size > 32768)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
241 buffer_size = 32768; /* So that the buffer won't get unmanageably big. */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
243 /* Calculate the final parameters for this audio specification */
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
244 SDL_CalculateAudioSpec(&this->spec);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
245
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
246 this2 = this->hidden;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
248 AuMakeElementImportClient(elms,this->spec.freq,format,this->spec.channels,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
249 AuTrue, buffer_size, buffer_size / 4, 0, NULL);
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
250 AuMakeElementExportDevice(elms + 1, 0, this->hidden->dev, this->spec.freq,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
251 AuUnlimitedSamples, 0, NULL);
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
252 AuSetElements(this->hidden->aud, this->hidden->flow, AuTrue, 2, elms, NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
253 AuRegisterEventHandler(this->hidden->aud, AuEventHandlerIDMask, 0,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
254 this->hidden->flow, event_handler,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
255 (AuPointer) NULL);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
257 AuStartFlow(this->hidden->aud, this->hidden->flow, NULL);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
259 /* Allocate mixing buffer */
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
260 this->hidden->mixlen = this->spec.size;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
261 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
262 if (this->hidden->mixbuf == NULL) {
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
263 NAS_CloseDevice(this);
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
264 SDL_OutOfMemory();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
265 return (-1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
266 }
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
267 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
269 /* We're ready to rock and roll. :-) */
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
270 return 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
272
3821
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
273 static int
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
274 NAS_Init(SDL_AudioDriverImpl *impl)
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
275 {
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
276 /* Set the function pointers */
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
277 impl->OpenDevice = NAS_OpenDevice;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
278 impl->PlayDevice = NAS_PlayDevice;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
279 impl->WaitDevice = NAS_WaitDevice;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
280 impl->GetDeviceBuf = NAS_GetDeviceBuf;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
281 impl->CloseDevice = NAS_CloseDevice;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
282 impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this true? */
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
283
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
284 return 1;
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
285 }
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
286
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
287 AudioBootStrap NAS_bootstrap = {
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
288 NAS_DRIVER_NAME, "Network Audio System",
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
289 NAS_Available, NAS_Init, 0
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
290 };
18393b045759 Moved NAS audio driver to 1.3 API.
Ryan C. Gordon <icculus@icculus.org>
parents: 3809
diff changeset
291
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
292 /* vi: set ts=4 sw=4 expandtab: */