Mercurial > sdl-ios-xcode
annotate src/audio/bsd/SDL_bsdaudio.c @ 3820:1f156fd874fa SDL-ryan-multiple-audio-device
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
some other tweaks in already-converted drivers.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 07 Oct 2006 05:36:36 +0000 |
parents | 9d070c1a45fa |
children | 66fb40445587 |
rev | line source |
---|---|
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 * Driver for native OpenBSD/NetBSD audio(4). |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 * vedge@vedge.com.ar. |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include <errno.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include <unistd.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #include <fcntl.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include <sys/time.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #include <sys/ioctl.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include <sys/stat.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #include <sys/types.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #include <sys/audioio.h> |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #include "SDL_timer.h" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #include "SDL_audio.h" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 #include "../SDL_audiomem.h" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 #include "../SDL_audio_c.h" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 #include "../SDL_audiodev_c.h" |
1583
95451df282c3
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1567
diff
changeset
|
43 #include "SDL_bsdaudio.h" |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 /* The tag name used by NetBSD/OpenBSD audio */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 #ifdef __NetBSD__ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 #define BSD_AUDIO_DRIVER_NAME "netbsd" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 #define BSD_AUDIO_DRIVER_DESC "Native NetBSD audio" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 #else |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 #define BSD_AUDIO_DRIVER_NAME "openbsd" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 #define BSD_AUDIO_DRIVER_DESC "Native OpenBSD audio" |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 #endif |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 /* Open the audio device for playback, and don't block if busy */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 /* #define USE_BLOCKING_WRITES */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 /* Use timer for synchronization */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 /* #define USE_TIMER_SYNC */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 /* #define DEBUG_AUDIO */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 /* #define DEBUG_AUDIO_STREAM */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 #ifdef USE_BLOCKING_WRITES |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
64 #define OPEN_FLAGS_OUTPUT O_WRONLY |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
65 #define OPEN_FLAGS_INPUT O_RDONLY |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 #else |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
67 #define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
68 #define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK) |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 #endif |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
71 /* !!! FIXME: so much cut and paste with dsp/dma drivers... */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
72 static char **outputDevices = NULL; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
73 static int outputDeviceCount = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
74 static char **inputDevices = NULL; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
75 static int inputDeviceCount = 0; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
77 static inline void |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
78 free_device_list(char ***devs, int *count) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
79 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
80 SDL_FreeUnixAudioDevices(devs, count); |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
83 static inline void |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
84 build_device_list(int iscapture, char ***devs, int *count) |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
86 const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
87 free_device_list(devs, count); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
88 SDL_EnumUnixAudioDevices(flags, 0, NULL, devs, count); |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
91 static inline void |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
92 build_device_lists(void) |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
94 build_device_list(0, &outputDevices, &outputDeviceCount); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
95 build_device_list(1, &inputDevices, &inputDeviceCount); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
96 } |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
99 static inline void |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
100 free_device_lists(void) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
101 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
102 free_device_list(&outputDevices, &outputDeviceCount); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
103 free_device_list(&inputDevices, &inputDeviceCount); |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
107 static int |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
108 BSDAUDIO_Available(void) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
109 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
110 int available = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
111 build_device_lists(); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
112 available = ((outputDeviceCount > 0) || (inputDeviceCount > 0)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
113 free_device_lists(); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
114 return available; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
117 |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 static void |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
119 BSDAUDIO_Deinitialize(void) |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
121 free_device_lists(); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
122 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
123 |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
125 static int |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
126 BSDAUDIO_DetectDevices(int iscapture) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
127 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
128 if (iscapture) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
129 build_device_list(1, &inputDevices, &inputDeviceCount); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
130 return inputDeviceCount; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
131 } else { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
132 build_device_list(0, &outputDevices, &outputDeviceCount); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
133 return outputDeviceCount; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
134 } |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
136 return 0; /* shouldn't ever hit this. */ |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
139 static const char * |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
140 BSDAUDIO_GetDeviceName(int index, int iscapture) |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
142 if ((iscapture) && (index < inputDeviceCount)) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
143 return inputDevices[index]; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
144 } else if ((!iscapture) && (index < outputDeviceCount)) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
145 return outputDevices[index]; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
146 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
147 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
148 SDL_SetError("No such device"); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
149 return NULL; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
152 |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 static void |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
154 BSDAUDIO_Status(_THIS) |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 { |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 #ifdef DEBUG_AUDIO |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 audio_info_t info; |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
159 if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 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:
1583
diff
changeset
|
160 fprintf(stderr, "AUDIO_GETINFO failed.\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
161 return; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
164 fprintf(stderr, "\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
165 "[play/record info]\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
166 "buffer size : %d bytes\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
167 "sample rate : %i Hz\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
168 "channels : %i\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
169 "precision : %i-bit\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
170 "encoding : 0x%x\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
171 "seek : %i\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
172 "sample count : %i\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
173 "EOF count : %i\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
174 "paused : %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:
1583
diff
changeset
|
175 "error occured : %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:
1583
diff
changeset
|
176 "waiting : %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:
1583
diff
changeset
|
177 "active : %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:
1583
diff
changeset
|
178 "", |
3816
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
179 info.play.buffer_size, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
180 info.play.sample_rate, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
181 info.play.channels, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
182 info.play.precision, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
183 info.play.encoding, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
184 info.play.seek, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
185 info.play.samples, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
186 info.play.eof, |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
187 info.play.pause ? "yes" : "no", |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
188 info.play.error ? "yes" : "no", |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
189 info.play.waiting ? "yes" : "no", |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
190 info.play.active ? "yes" : "no"); |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
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:
1583
diff
changeset
|
192 fprintf(stderr, "\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
193 "[audio info]\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
194 "monitor_gain : %i\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
195 "hw block size : %d bytes\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
196 "hi watermark : %i\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
197 "lo watermark : %i\n" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
198 "audio mode : %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:
1583
diff
changeset
|
199 "", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
200 info.monitor_gain, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
201 info.blocksize, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
202 info.hiwat, info.lowat, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
203 (info.mode == AUMODE_PLAY) ? "PLAY" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
204 : (info.mode = AUMODE_RECORD) ? "RECORD" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
205 : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?")); |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
206 #endif /* DEBUG_AUDIO */ |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 } |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
208 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
209 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
210 /* This function waits until it is possible to write a full sound buffer */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
211 static void |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
212 BSDAUDIO_WaitDevice(_THIS) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
213 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
214 #ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
215 /* See if we need to use timed audio synchronization */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
216 if (this->hidden->frame_ticks) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
217 /* Use timer for general audio synchronization */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
218 Sint32 ticks; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
219 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
220 ticks = ((Sint32)(this->hidden->next_frame-SDL_GetTicks()))-FUDGE_TICKS; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
221 if (ticks > 0) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
222 SDL_Delay(ticks); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
223 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
224 } else { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
225 /* Use select() for audio synchronization */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
226 fd_set fdset; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
227 struct timeval timeout; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
228 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
229 FD_ZERO(&fdset); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
230 FD_SET(this->hidden->audio_fd, &fdset); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
231 timeout.tv_sec = 10; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
232 timeout.tv_usec = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
233 #ifdef DEBUG_AUDIO |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
234 fprintf(stderr, "Waiting for audio to get ready\n"); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
235 #endif |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
236 if (select(this->hidden->audio_fd+1,NULL,&fdset,NULL,&timeout) <= 0) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
237 const char *message = |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
238 "Audio timeout - buggy audio driver? (disabled)"; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
239 /* In general we should never print to the screen, |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
240 but in this case we have no other way of letting |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
241 the user know what happened. |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
242 */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
243 fprintf(stderr, "SDL: %s\n", message); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
244 this->enabled = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
245 /* Don't try to close - may hang */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
246 this->hidden->audio_fd = -1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
247 #ifdef DEBUG_AUDIO |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
248 fprintf(stderr, "Done disabling audio\n"); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
249 #endif |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
250 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
251 #ifdef DEBUG_AUDIO |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
252 fprintf(stderr, "Ready!\n"); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
253 #endif |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
254 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
255 #endif /* !USE_BLOCKING_WRITES */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
256 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
257 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
258 static void |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
259 BSDAUDIO_PlayDevice(_THIS) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
260 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
261 int written, p = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
262 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
263 /* Write the audio data, checking for EAGAIN on broken audio drivers */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
264 do { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
265 written = write(this->hidden->audio_fd, |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
266 &this->hidden->mixbuf[p], |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
267 this->hidden->mixlen - p); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
268 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
269 if (written > 0) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
270 p += written; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
271 if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
272 /* Non recoverable error has occurred. It should be reported!!! */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
273 perror("audio"); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
274 break; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
275 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
276 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
277 if (p < written |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
278 || ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
279 SDL_Delay(1); /* Let a little CPU time go by */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
280 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
281 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
282 while (p < written); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
283 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
284 /* If timer synchronization is enabled, set the next write frame */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
285 if (this->hidden->frame_ticks) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
286 this->hidden->next_frame += this->hidden->frame_ticks; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
287 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
288 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
289 /* If we couldn't write, assume fatal error for now */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
290 if (written < 0) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
291 this->enabled = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
292 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
293 #ifdef DEBUG_AUDIO |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
294 fprintf(stderr, "Wrote %d bytes of audio data\n", written); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
295 #endif |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
296 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
297 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
298 static Uint8 * |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
299 BSDAUDIO_GetDeviceBuf(_THIS) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
300 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
301 return (this->hidden->mixbuf); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
302 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
303 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
304 static void |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
305 BSDAUDIO_CloseDevice(_THIS) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
306 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
307 if (this->hidden != NULL) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
308 if (this->hidden->mixbuf != NULL) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
309 SDL_FreeAudioMem(this->hidden->mixbuf); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
310 this->hidden->mixbuf = NULL; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
311 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
312 if (this->hidden->audio_fd >= 0) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
313 close(this->hidden->audio_fd); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
314 this->hidden->audio_fd = -1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
315 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
316 SDL_free(this->hidden); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
317 this->hidden = NULL; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
318 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
319 } |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 static int |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
322 BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
324 const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
325 SDL_AudioFormat format = 0; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 audio_info_t info; |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
328 /* We don't care what the devname is...we'll try to open anything. */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
329 /* ...but default to first name in the list... */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
330 if (devname == NULL) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
331 if ( ((iscapture) && (inputDeviceCount == 0)) || |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
332 ((!iscapture) && (outputDeviceCount == 0)) ) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
333 SDL_SetError("No such audio device"); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
334 return 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
335 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
336 devname = ((iscapture) ? inputDevices[0] : outputDevices[0]); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
337 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
338 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
339 /* Initialize all variables that we clean on shutdown */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
340 this->hidden = (struct SDL_PrivateAudioData *) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
341 SDL_malloc((sizeof *this->hidden)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
342 if (this->hidden == NULL) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
343 SDL_OutOfMemory(); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
344 return 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
345 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
346 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
347 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
348 /* Open the audio device */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
349 this->hidden->audio_fd = open(devname, flags, 0); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
350 if (this->hidden->audio_fd < 0) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
351 SDL_SetError("Couldn't open %s: %s", devname, strerror(errno)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
352 return 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
353 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
354 |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 AUDIO_INITINFO(&info); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
356 |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 /* Calculate the final parameters for this audio specification */ |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
358 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:
1583
diff
changeset
|
359 |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 /* Set to play mode */ |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 info.mode = AUMODE_PLAY; |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
362 if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) < 0) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
363 BSDAUDIO_CloseDevice(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:
1583
diff
changeset
|
364 SDL_SetError("Couldn't put device into play mode"); |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
365 return 0; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
367 |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 AUDIO_INITINFO(&info); |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
369 for (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:
1583
diff
changeset
|
370 format; 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:
1583
diff
changeset
|
371 switch (format) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
372 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:
1583
diff
changeset
|
373 info.play.encoding = AUDIO_ENCODING_ULINEAR; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
374 info.play.precision = 8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
375 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
376 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:
1583
diff
changeset
|
377 info.play.encoding = AUDIO_ENCODING_SLINEAR; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
378 info.play.precision = 8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
379 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
380 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:
1583
diff
changeset
|
381 info.play.encoding = AUDIO_ENCODING_SLINEAR_LE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
382 info.play.precision = 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
383 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
384 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:
1583
diff
changeset
|
385 info.play.encoding = AUDIO_ENCODING_SLINEAR_BE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
386 info.play.precision = 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
387 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
388 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:
1583
diff
changeset
|
389 info.play.encoding = AUDIO_ENCODING_ULINEAR_LE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
390 info.play.precision = 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
391 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
392 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:
1583
diff
changeset
|
393 info.play.encoding = AUDIO_ENCODING_ULINEAR_BE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
394 info.play.precision = 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
395 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
396 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
397 continue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
398 } |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
399 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
400 if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) == 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:
1583
diff
changeset
|
401 break; |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
402 } |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
405 if (!format) { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
406 BSDAUDIO_CloseDevice(this); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
407 SDL_SetError("No supported encoding for 0x%x", this->spec.format); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
408 return 0; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 } |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
411 this->spec.format = format; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 AUDIO_INITINFO(&info); |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
414 info.play.channels = this->spec.channels; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
415 if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) == -1) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
416 this->spec.channels = 1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
417 } |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 AUDIO_INITINFO(&info); |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
419 info.play.sample_rate = this->spec.freq; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
420 info.blocksize = this->spec.size; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 info.hiwat = 5; |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 info.lowat = 3; |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
423 (void) ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
424 (void) ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
425 this->spec.freq = info.play.sample_rate; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 /* Allocate mixing buffer */ |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
427 this->hidden->mixlen = this->spec.size; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
428 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
429 if (this->hidden->mixbuf == NULL) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
430 BSDAUDIO_CloseDevice(this); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
431 SDL_OutOfMemory(); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
432 return 0; |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 } |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
434 SDL_memset(this->hidden->mixbuf, this->spec.silence, 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:
1583
diff
changeset
|
435 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
436 BSDAUDIO_Status(this); |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 |
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 /* We're ready to rock and roll. :-) */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
439 return (0); |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
441 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
442 static int |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
443 BSDAUDIO_Init(SDL_AudioDriverImpl *impl) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
444 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
445 /* Set the function pointers */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
446 impl->DetectDevices = DSP_DetectDevices; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
447 impl->GetDeviceName = DSP_GetDeviceName; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
448 impl->OpenDevice = DSP_OpenDevice; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
449 impl->PlayDevice = DSP_PlayDevice; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
450 impl->WaitDevice = DSP_WaitDevice; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
451 impl->GetDeviceBuf = DSP_GetDeviceBuf; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
452 impl->CloseDevice = DSP_CloseDevice; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
453 impl->Deinitialize = DSP_Deinitialize; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
454 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
455 build_device_lists(); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
456 return 1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
457 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
458 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
459 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
460 AudioBootStrap BSD_AUDIO_bootstrap = { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
461 BSD_AUDIO_DRIVER_NAME, BSD_AUDIO_DRIVER_DESC, |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
462 BSDAUDIO_Available, BSDAUDIO_Init, 0 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
463 }; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3816
diff
changeset
|
464 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1583
diff
changeset
|
465 /* vi: set ts=4 sw=4 expandtab: */ |