annotate src/audio/nto/SDL_nto_audio.c @ 3825:76c5a414b996 SDL-ryan-multiple-audio-device

Dynamic loading for NAS audio driver.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 07 Oct 2006 07:25:30 +0000
parents c8b3d3d13ed1
children d3171647e661
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
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 718
diff changeset
3 Copyright (C) 1997-2004 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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #include <errno.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 #include <unistd.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #include <fcntl.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include <signal.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include <sys/types.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include <sys/time.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include <sched.h>
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
31 #include <sys/select.h>
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
32 #include <sys/neutrino.h>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include <sys/asoundlib.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
35 #include "SDL_timer.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 #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
37 #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
38 #include "../SDL_audio_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 #include "SDL_nto_audio.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 /* The tag name used by NTO audio */
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
42 #define DRIVER_NAME "qsa-nto"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 /* default channel communication parameters */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 #define DEFAULT_CPARAMS_RATE 22050
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 #define DEFAULT_CPARAMS_VOICES 1
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
47 /* FIXME: need to add in the near future flexible logic with frag_size and frags count */
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
48 #define DEFAULT_CPARAMS_FRAG_SIZE 4096
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 #define DEFAULT_CPARAMS_FRAGS_MIN 1
283
3d8b6b9f1e18 Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
50 #define DEFAULT_CPARAMS_FRAGS_MAX 1
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 /* Open the audio device for playback, and don't block if busy */
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
53 #define OPEN_FLAGS SND_PCM_OPEN_PLAYBACK
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
55 #define QSA_NO_WORKAROUNDS 0x00000000
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
56 #define QSA_MMAP_WORKAROUND 0x00000001
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
57
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
58 struct BuggyCards
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
59 {
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
60 char *cardname;
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 unsigned long bugtype;
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
62 };
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
63
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
64 #define QSA_WA_CARDS 3
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
65
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
66 struct BuggyCards buggycards[QSA_WA_CARDS] = {
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
67 {"Sound Blaster Live!", QSA_MMAP_WORKAROUND},
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 {"Vortex 8820", QSA_MMAP_WORKAROUND},
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
69 {"Vortex 8830", QSA_MMAP_WORKAROUND},
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
70 };
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
71
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 /* Audio driver functions */
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
73 static void NTO_ThreadInit(_THIS);
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
74 static int NTO_OpenAudio(_THIS, SDL_AudioSpec * spec);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 static void NTO_WaitAudio(_THIS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 static void NTO_PlayAudio(_THIS);
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 static Uint8 *NTO_GetAudioBuf(_THIS);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 static void NTO_CloseAudio(_THIS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
80 /* card names check to apply the workarounds */
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
81 static int
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
82 NTO_CheckBuggyCards(_THIS, unsigned long checkfor)
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
83 {
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
84 char scardname[33];
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
85 int it;
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
86
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 if (snd_card_get_name(cardno, scardname, 32) < 0) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
88 return 0;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
89 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
90
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
91 for (it = 0; it < QSA_WA_CARDS; it++) {
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
92 if (SDL_strcmp(buggycards[it].cardname, scardname) == 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
93 if (buggycards[it].bugtype == checkfor) {
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 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
95 }
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
96 }
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
97 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
98
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
99 return 0;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
100 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
101
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
102 static void
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
103 NTO_ThreadInit(_THIS)
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
104 {
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
105 int status;
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
106 struct sched_param param;
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
107
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
108 /* increasing default 10 priority to 25 to avoid jerky sound */
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
109 status = SchedGet(0, 0, &param);
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
110 param.sched_priority = param.sched_curpriority + 15;
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
111 status = SchedSet(0, 0, SCHED_NOCHANGE, &param);
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
112 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 /* PCM transfer channel parameters initialize function */
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
115 static void
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
116 NTO_InitAudioParams(snd_pcm_channel_params_t * cpars)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
118 SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
120 cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
121 cpars->mode = SND_PCM_MODE_BLOCK;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
122 cpars->start_mode = SND_PCM_START_DATA;
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
123 cpars->stop_mode = SND_PCM_STOP_STOP;
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
124 cpars->format.format = SND_PCM_SFMT_S16_LE;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
125 cpars->format.interleave = 1;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
126 cpars->format.rate = DEFAULT_CPARAMS_RATE;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
127 cpars->format.voices = DEFAULT_CPARAMS_VOICES;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
128 cpars->buf.block.frag_size = DEFAULT_CPARAMS_FRAG_SIZE;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
129 cpars->buf.block.frags_min = DEFAULT_CPARAMS_FRAGS_MIN;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
130 cpars->buf.block.frags_max = DEFAULT_CPARAMS_FRAGS_MAX;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132
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
133 static int
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 NTO_AudioAvailable(void)
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
135 {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
136 /* See if we can open a nonblocking channel.
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
137 Return value '1' means we can.
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 Return value '0' means we cannot. */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
140 int available;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
141 int rval;
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
142 snd_pcm_t *handle;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
144 available = 0;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
145 handle = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
147 rval = snd_pcm_open_preferred(&handle, NULL, NULL, OPEN_FLAGS);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148
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
149 if (rval >= 0) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
150 available = 1;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
151
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
152 if ((rval = snd_pcm_close(handle)) < 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
153 SDL_SetError
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 ("NTO_AudioAvailable(): snd_pcm_close failed: %s\n",
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 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
156 available = 0;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
157 }
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
158 } 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
159 SDL_SetError
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 ("NTO_AudioAvailable(): there are no available audio devices.\n");
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
161 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
162
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
163 return (available);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165
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
166 static void
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 NTO_DeleteAudioDevice(SDL_AudioDevice * device)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 {
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
169 if ((device) && (device->hidden)) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
170 SDL_free(device->hidden);
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
171 }
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
172 if (device) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
173 SDL_free(device);
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
174 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176
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
177 static SDL_AudioDevice *
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 NTO_CreateAudioDevice(int devindex)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
180 SDL_AudioDevice *this;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
181
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
182 /* Initialize all variables that we clean on shutdown */
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
183 this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
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 if (this) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
185 SDL_memset(this, 0, sizeof(SDL_AudioDevice));
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
186 this->hidden = (struct SDL_PrivateAudioData *)
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
187 SDL_malloc(sizeof(struct SDL_PrivateAudioData));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
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 if ((this == NULL) || (this->hidden == NULL)) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
190 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
191 if (this) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
192 SDL_free(this);
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
193 }
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
194 return (0);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
195 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
196 SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
197 audio_handle = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
199 /* Set the function pointers */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
200 this->ThreadInit = NTO_ThreadInit;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
201 this->OpenAudio = NTO_OpenAudio;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
202 this->WaitAudio = NTO_WaitAudio;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
203 this->PlayAudio = NTO_PlayAudio;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
204 this->GetAudioBuf = NTO_GetAudioBuf;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
205 this->CloseAudio = NTO_CloseAudio;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
207 this->free = NTO_DeleteAudioDevice;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
209 return this;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211
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
212 AudioBootStrap QNXNTOAUDIO_bootstrap = {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
213 DRIVER_NAME, "QNX6 QSA-NTO Audio",
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
214 NTO_AudioAvailable,
3798
c8b3d3d13ed1 Audio bootstraps can now specify that a driver is only to be used if
Ryan C. Gordon <icculus@icculus.org>
parents: 2007
diff changeset
215 NTO_CreateAudioDevice,
c8b3d3d13ed1 Audio bootstraps can now specify that a driver is only to be used if
Ryan C. Gordon <icculus@icculus.org>
parents: 2007
diff changeset
216 0
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 /* 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
220 static void
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 NTO_WaitAudio(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222 {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
223 fd_set wfds;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
224 int selectret;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
225
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
226 FD_ZERO(&wfds);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
227 FD_SET(audio_fd, &wfds);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
229 do {
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
230 selectret = select(audio_fd + 1, NULL, &wfds, 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
231 switch (selectret) {
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
232 case -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
233 case 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
234 SDL_SetError("NTO_WaitAudio(): select() failed: %s\n",
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
235 strerror(errno));
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
236 return;
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 default:
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 if (FD_ISSET(audio_fd, &wfds)) {
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
239 return;
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 }
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 break;
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
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 }
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
244 while (1);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246
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
247 static void
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
248 NTO_PlayAudio(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
250 int written, rval;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
251 int towrite;
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
252 void *pcmbuffer;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253
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
254 if (!this->enabled) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
255 return;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
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
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
258 towrite = this->spec.size;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
259 pcmbuffer = pcm_buf;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
261 /* Write the audio data, checking for EAGAIN (buffer full) and underrun */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
262 do {
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
263 written = snd_pcm_plugin_write(audio_handle, pcm_buf, towrite);
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
264 if (written != towrite) {
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 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
266 /* Let a little CPU time go by and try to write again */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
267 SDL_Delay(1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
268 /* if we wrote some data */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
269 towrite -= written;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
270 pcmbuffer += written * this->spec.channels;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
271 continue;
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 } 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
273 if ((errno == EINVAL) || (errno == EIO)) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
274 SDL_memset(&cstatus, 0, sizeof(cstatus));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
275 cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
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
276 if ((rval =
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
277 snd_pcm_plugin_status(audio_handle, &cstatus)) < 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
278 SDL_SetError
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
279 ("NTO_PlayAudio(): snd_pcm_plugin_status failed: %s\n",
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
280 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
281 return;
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
282 }
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
283 if ((cstatus.status == SND_PCM_STATUS_UNDERRUN)
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
284 || (cstatus.status == SND_PCM_STATUS_READY)) {
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
285 if ((rval =
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
286 snd_pcm_plugin_prepare(audio_handle,
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
287 SND_PCM_CHANNEL_PLAYBACK))
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
288 < 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
289 SDL_SetError
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
290 ("NTO_PlayAudio(): snd_pcm_plugin_prepare failed: %s\n",
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
291 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
292 return;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
293 }
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
294 }
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
295 continue;
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
296 } else {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
297 return;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
298 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
299 }
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
300 } else {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
301 /* we wrote all remaining data */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
302 towrite -= written;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
303 pcmbuffer += written * this->spec.channels;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
304 }
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
305 }
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
306 while ((towrite > 0) && (this->enabled));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
308 /* If we couldn't write, assume fatal error for now */
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
309 if (towrite != 0) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
310 this->enabled = 0;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
311 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
312
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
313 return;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315
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
316 static Uint8 *
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
317 NTO_GetAudioBuf(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318 {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
319 return pcm_buf;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
321
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
322 static void
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
323 NTO_CloseAudio(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324 {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
325 int rval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
327 this->enabled = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328
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
329 if (audio_handle != 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
330 if ((rval =
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
331 snd_pcm_plugin_flush(audio_handle,
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
332 SND_PCM_CHANNEL_PLAYBACK)) < 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
333 SDL_SetError
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
334 ("NTO_CloseAudio(): snd_pcm_plugin_flush failed: %s\n",
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
335 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
336 return;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
337 }
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
338 if ((rval = snd_pcm_close(audio_handle)) < 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
339 SDL_SetError("NTO_CloseAudio(): snd_pcm_close failed: %s\n",
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
340 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
341 return;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
342 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
343 audio_handle = NULL;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
344 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
346
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
347 static int
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
348 NTO_OpenAudio(_THIS, SDL_AudioSpec * spec)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
349 {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
350 int rval;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
351 int format;
1982
3b4ce57c6215 First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
352 SDL_AudioFormat test_format;
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
353 int found;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
354
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
355 audio_handle = NULL;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
356 this->enabled = 0;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
357
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
358 if (pcm_buf != 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
359 SDL_FreeAudioMem(pcm_buf);
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
360 pcm_buf = NULL;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
361 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
363 /* initialize channel transfer parameters to default */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
364 NTO_InitAudioParams(&cparams);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
365
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
366 /* Open the audio device */
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
367 rval =
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
368 snd_pcm_open_preferred(&audio_handle, &cardno, &deviceno, OPEN_FLAGS);
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
369 if (rval < 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
370 SDL_SetError("NTO_OpenAudio(): snd_pcm_open failed: %s\n",
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
371 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
372 return (-1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
373 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
374
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
375 if (!NTO_CheckBuggyCards(this, QSA_MMAP_WORKAROUND)) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
376 /* enable count status parameter */
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
377 if ((rval =
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
378 snd_pcm_plugin_set_disable(audio_handle,
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
379 PLUGIN_DISABLE_MMAP)) < 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
380 SDL_SetError("snd_pcm_plugin_set_disable failed: %s\n",
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
381 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
382 return (-1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
383 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
384 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
385
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
386 /* Try for a closest match on audio format */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
387 format = 0;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
388 /* can't use format as SND_PCM_SFMT_U8 = 0 in nto */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
389 found = 0;
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
390
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
391 for (test_format = SDL_FirstAudioFormat(spec->format); !found;) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
392 /* if match found set format to equivalent ALSA 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
393 switch (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
394 case AUDIO_U8:
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
395 format = SND_PCM_SFMT_U8;
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
396 found = 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
397 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
398 case AUDIO_S8:
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
399 format = SND_PCM_SFMT_S8;
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
400 found = 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
401 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
402 case AUDIO_S16LSB:
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
403 format = SND_PCM_SFMT_S16_LE;
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
404 found = 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
405 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
406 case AUDIO_S16MSB:
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
407 format = SND_PCM_SFMT_S16_BE;
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
408 found = 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
409 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
410 case AUDIO_U16LSB:
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
411 format = SND_PCM_SFMT_U16_LE;
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
412 found = 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
413 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
414 case AUDIO_U16MSB:
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
415 format = SND_PCM_SFMT_U16_BE;
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
416 found = 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
417 break;
2007
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
418 case AUDIO_S32LSB:
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
419 format = SND_PCM_SFMT_S32_LE;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
420 found = 1;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
421 break;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
422 case AUDIO_S32MSB:
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
423 format = SND_PCM_SFMT_S32_BE;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
424 found = 1;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
425 break;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
426 case AUDIO_F32LSB:
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
427 format = SND_PCM_SFMT_FLOAT_LE;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
428 found = 1;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
429 break;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
430 case AUDIO_F32MSB:
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
431 format = SND_PCM_SFMT_FLOAT_BE;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
432 found = 1;
cff63f857ff3 QNX6 support for int32/float32 (isn't this just ALSA?!)
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
433 break;
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
434 default:
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
435 break;
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
436 }
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
437
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
438 if (!found) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
439 test_format = SDL_NextAudioFormat();
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
440 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
441 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
442
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
443 /* assumes test_format not 0 on success */
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
444 if (test_format == 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
445 SDL_SetError
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
446 ("NTO_OpenAudio(): Couldn't find any hardware audio formats");
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
447 return (-1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
448 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
449
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
450 spec->format = test_format;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
451
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
452 /* Set the audio format */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
453 cparams.format.format = format;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
454
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
455 /* Set mono or stereo audio (currently only two channels supported) */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
456 cparams.format.voices = 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
457
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
458 /* Set rate */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
459 cparams.format.rate = spec->freq;
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
460
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
461 /* Setup the transfer parameters according to cparams */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
462 rval = snd_pcm_plugin_params(audio_handle, &cparams);
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
463 if (rval < 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
464 SDL_SetError
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
465 ("NTO_OpenAudio(): snd_pcm_channel_params failed: %s\n",
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
466 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
467 return (-1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
468 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
469
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
470 /* Make sure channel is setup right one last time */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
471 SDL_memset(&csetup, 0x00, sizeof(csetup));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
472 csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
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
473 if (snd_pcm_plugin_setup(audio_handle, &csetup) < 0) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
474 SDL_SetError("NTO_OpenAudio(): Unable to setup playback channel\n");
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
475 return -1;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
476 }
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
477
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
478
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
479 /* Calculate the final parameters for this audio specification */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
480 SDL_CalculateAudioSpec(spec);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
481
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
482 pcm_len = spec->size;
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
483
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
484 if (pcm_len == 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
485 pcm_len =
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
486 csetup.buf.block.frag_size * spec->channels *
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
487 (snd_pcm_format_width(format) / 8);
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
488 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
489
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
490 /* Allocate memory to the audio buffer and initialize with silence (Note that
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
491 buffer size must be a multiple of fragment size, so find closest multiple)
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
492 */
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
493 pcm_buf = (Uint8 *) SDL_AllocAudioMem(pcm_len);
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
494 if (pcm_buf == NULL) {
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
495 SDL_SetError("NTO_OpenAudio(): pcm buffer allocation failed\n");
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
496 return (-1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
497 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
498 SDL_memset(pcm_buf, spec->silence, pcm_len);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
499
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
500 /* get the file descriptor */
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
501 if ((audio_fd =
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
502 snd_pcm_file_descriptor(audio_handle,
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
503 SND_PCM_CHANNEL_PLAYBACK)) < 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
504 SDL_SetError
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
505 ("NTO_OpenAudio(): snd_pcm_file_descriptor failed with error code: %s\n",
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
506 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
507 return (-1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
508 }
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
509
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
510 /* Trigger audio playback */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
511 rval = snd_pcm_plugin_prepare(audio_handle, SND_PCM_CHANNEL_PLAYBACK);
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
512 if (rval < 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
513 SDL_SetError("snd_pcm_plugin_prepare failed: %s\n",
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
514 snd_strerror(rval));
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
515 return (-1);
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
516 }
418
337f3ec4c385 Updated the QNX audio code for QNX 6.2 (thanks Travis!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
517
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
518 this->enabled = 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
519
718
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
520 /* Get the parent process id (we're the parent of the audio thread) */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
521 parent = getpid();
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
522
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
523 /* We're really ready to rock and roll. :-) */
cbc0f7fabd1c Date: Sat, 13 Sep 2003 15:50:43 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
524 return (0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
525 }
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
526
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
527 /* vi: set ts=4 sw=4 expandtab: */