Mercurial > sdl-ios-xcode
annotate src/audio/alsa/SDL_alsa_audio.c @ 3818:49eadd6e8962 SDL-ryan-multiple-audio-device
Mangled ALSA dynamic loading...static loading will still work if you have the
right libraries, but this is expected to break in general cases as we start
dealing with different symbol versions, etc (but may work with, say,
distro-specific packages, etc).
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 06 Oct 2006 19:45:11 +0000 |
parents | c8b3d3d13ed1 |
children | b225d9820ee3 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
765
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
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 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* Allow access to a raw mixing buffer */ | |
25 | |
26 #include <sys/types.h> | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
27 #include <signal.h> /* For kill() */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
28 #include <dlfcn.h> |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
29 #include <errno.h> |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
30 #include <string.h> |
0 | 31 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
32 #include "SDL_timer.h" |
0 | 33 #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
|
34 #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
|
35 #include "../SDL_audio_c.h" |
0 | 36 #include "SDL_alsa_audio.h" |
37 | |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
38 |
0 | 39 /* The tag name used by ALSA audio */ |
40 #define DRIVER_NAME "alsa" | |
41 | |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
42 /* The default ALSA audio driver */ |
765
4c2ba6161939
Editors Note: The original patch was modified to use SDL_Delay() instead of
Sam Lantinga <slouken@libsdl.org>
parents:
547
diff
changeset
|
43 #define DEFAULT_DEVICE "default" |
0 | 44 |
45 /* Audio driver functions */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
46 static int ALSA_OpenAudio(_THIS, SDL_AudioSpec * spec); |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
47 static void ALSA_WaitAudio(_THIS); |
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
48 static void ALSA_PlayAudio(_THIS); |
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
49 static Uint8 *ALSA_GetAudioBuf(_THIS); |
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
50 static void ALSA_CloseAudio(_THIS); |
0 | 51 |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
52 static int (*ALSA_snd_pcm_open) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
53 (snd_pcm_t **, const char *, snd_pcm_stream_t, int); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
54 static int (*ALSA_snd_pcm_close)(snd_pcm_t * pcm); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
55 static snd_pcm_sframes_t(*ALSA_snd_pcm_writei) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
56 (snd_pcm_t *,const void *, snd_pcm_uframes_t); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
57 static int (*ALSA_snd_pcm_resume)(snd_pcm_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
58 static int (*ALSA_snd_pcm_prepare)(snd_pcm_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
59 static int (*ALSA_snd_pcm_drain)(snd_pcm_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
60 static const char *(*ALSA_snd_strerror)(int); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
61 static size_t(*ALSA_snd_pcm_hw_params_sizeof)(void); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
62 static size_t(*ALSA_snd_pcm_sw_params_sizeof)(void); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
63 static int (*ALSA_snd_pcm_hw_params_any)(snd_pcm_t *, snd_pcm_hw_params_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
64 static int (*ALSA_snd_pcm_hw_params_set_access) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
65 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
66 static int (*ALSA_snd_pcm_hw_params_set_format) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
67 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
68 static int (*ALSA_snd_pcm_hw_params_set_channels) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
69 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
70 static int (*ALSA_snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
71 static unsigned int (*ALSA_snd_pcm_hw_params_set_rate_near) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
72 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int, int *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
73 static snd_pcm_uframes_t (*ALSA_snd_pcm_hw_params_set_period_size_near) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
74 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t, int *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
75 static snd_pcm_sframes_t (*ALSA_snd_pcm_hw_params_get_period_size) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
76 (const snd_pcm_hw_params_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
77 static unsigned int (*ALSA_snd_pcm_hw_params_set_periods_near) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
78 (snd_pcm_t *,snd_pcm_hw_params_t *, unsigned int, int *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
79 static int (*ALSA_snd_pcm_hw_params_get_periods)(snd_pcm_hw_params_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
80 static int (*ALSA_snd_pcm_hw_params)(snd_pcm_t *, snd_pcm_hw_params_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
81 static int (*ALSA_snd_pcm_sw_params_current)(snd_pcm_t*, snd_pcm_sw_params_t*); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
82 static int (*ALSA_snd_pcm_sw_params_set_start_threshold) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
83 (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
84 static int (*ALSA_snd_pcm_sw_params_set_avail_min) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
85 (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
86 static int (*ALSA_snd_pcm_sw_params)(snd_pcm_t *, snd_pcm_sw_params_t *); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
87 static int (*ALSA_snd_pcm_nonblock)(snd_pcm_t *, int); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
88 #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
89 #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
90 |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
91 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
92 #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
93 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
94 static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC; |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
95 static void *alsa_handle = NULL; |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
96 |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
97 static int |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
98 load_alsa_sym(const char *fn, void **addr) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
99 { |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
100 #if HAVE_DLVSYM |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
101 *addr = dlvsym(alsa_handle, fn, "ALSA_0.9"); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
102 if (*addr == NULL) |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
103 #endif |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
104 { |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
105 *addr = dlsym(alsa_handle, fn); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
106 if (*addr == NULL) { |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
107 return 0; |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
108 } |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
109 } |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
110 |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
111 return 1; |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
112 } |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
113 |
1161
05d4b93b911e
Placate gcc's strict aliasing rules with an extra cast.
Ryan C. Gordon <icculus@icculus.org>
parents:
942
diff
changeset
|
114 /* cast funcs to char* first, to please GCC's strict aliasing rules. */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
115 #define SDL_ALSA_SYM(x) \ |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
116 if (!load_alsa_sym(#x, (void **) (char *) &ALSA_##x)) return -1 |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
117 #else |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
118 #define SDL_ALSA_SYM(x) ALSA_##x = x |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
119 #endif |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
120 |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
121 static int load_alsa_syms(void) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
122 { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
123 SDL_ALSA_SYM(snd_pcm_open); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
124 SDL_ALSA_SYM(snd_pcm_close); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
125 SDL_ALSA_SYM(snd_pcm_writei); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
126 SDL_ALSA_SYM(snd_pcm_resume); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
127 SDL_ALSA_SYM(snd_pcm_prepare); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
128 SDL_ALSA_SYM(snd_pcm_drain); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
129 SDL_ALSA_SYM(snd_strerror); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
130 SDL_ALSA_SYM(snd_pcm_hw_params_sizeof); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
131 SDL_ALSA_SYM(snd_pcm_sw_params_sizeof); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
132 SDL_ALSA_SYM(snd_pcm_hw_params_any); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
133 SDL_ALSA_SYM(snd_pcm_hw_params_set_access); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
134 SDL_ALSA_SYM(snd_pcm_hw_params_set_format); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
135 SDL_ALSA_SYM(snd_pcm_hw_params_set_channels); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
136 SDL_ALSA_SYM(snd_pcm_hw_params_get_channels); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
137 SDL_ALSA_SYM(snd_pcm_hw_params_set_rate_near); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
138 SDL_ALSA_SYM(snd_pcm_hw_params_set_period_size_near); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
139 SDL_ALSA_SYM(snd_pcm_hw_params_get_period_size); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
140 SDL_ALSA_SYM(snd_pcm_hw_params_set_periods_near); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
141 SDL_ALSA_SYM(snd_pcm_hw_params_get_periods); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
142 SDL_ALSA_SYM(snd_pcm_hw_params); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
143 SDL_ALSA_SYM(snd_pcm_sw_params_current); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
144 SDL_ALSA_SYM(snd_pcm_sw_params_set_start_threshold); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
145 SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
146 SDL_ALSA_SYM(snd_pcm_sw_params); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
147 SDL_ALSA_SYM(snd_pcm_nonblock); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
148 return 0; |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
149 } |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
150 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
151 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:
1878
diff
changeset
|
152 UnloadALSALibrary(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
153 { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
154 if (alsa_handle != NULL) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
155 dlclose(alsa_handle); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
156 alsa_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:
1878
diff
changeset
|
157 } |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
158 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
159 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
160 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:
1878
diff
changeset
|
161 LoadALSALibrary(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
162 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
163 int i, retval = -1; |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
164 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
165 alsa_handle = dlopen(alsa_library, RTLD_NOW); |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
166 if (alsa_handle == NULL) { |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
167 SDL_SetError("ALSA: dlopen('%s') failed: %s\n", |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
168 alsa_library, strerror(errno)); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
169 } else { |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
170 retval = load_alsa_syms(); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
171 if (retval < 0) { |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
172 UnloadALSALibrary(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
173 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
174 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
175 return retval; |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
176 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
177 |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
178 #else |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
179 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
180 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:
1878
diff
changeset
|
181 UnloadALSALibrary(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
182 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
183 return; |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
184 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
185 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
186 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:
1878
diff
changeset
|
187 LoadALSALibrary(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
188 { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
189 load_alsa_syms(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
190 return 0; |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
191 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
192 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
193 #endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
194 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
195 static const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
196 get_audio_device(int channels) |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
197 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
198 const char *device; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
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:
1878
diff
changeset
|
200 device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
201 if (device == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
202 if (channels == 6) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
203 device = "surround51"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
204 else if (channels == 4) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
205 device = "surround40"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
206 else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
207 device = DEFAULT_DEVICE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
208 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
209 return device; |
0 | 210 } |
211 | |
212 /* Audio driver bootstrap functions */ | |
213 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
214 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:
1878
diff
changeset
|
215 Audio_Available(void) |
0 | 216 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
217 int available; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
218 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:
1878
diff
changeset
|
219 snd_pcm_t *handle; |
0 | 220 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
221 available = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
222 if (LoadALSALibrary() < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
223 return available; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
224 } |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
225 status = ALSA_snd_pcm_open(&handle, get_audio_device(2), |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
226 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
227 if (status >= 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
228 available = 1; |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
229 ALSA_snd_pcm_close(handle); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
230 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
231 UnloadALSALibrary(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
232 return (available); |
0 | 233 } |
234 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
235 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:
1878
diff
changeset
|
236 Audio_DeleteDevice(SDL_AudioDevice * device) |
0 | 237 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
238 SDL_free(device->hidden); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
239 SDL_free(device); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
240 UnloadALSALibrary(); |
0 | 241 } |
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:
1878
diff
changeset
|
243 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:
1878
diff
changeset
|
244 Audio_CreateDevice(int devindex) |
0 | 245 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
246 SDL_AudioDevice *this; |
0 | 247 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
248 /* Initialize all variables that we clean on shutdown */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
249 LoadALSALibrary(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
250 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:
1878
diff
changeset
|
251 if (this) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
252 SDL_memset(this, 0, (sizeof *this)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
253 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:
1878
diff
changeset
|
254 SDL_malloc((sizeof *this->hidden)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
255 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
256 if ((this == NULL) || (this->hidden == NULL)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
257 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
258 if (this) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
259 SDL_free(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
260 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
261 return (0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
262 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
263 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
0 | 264 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
265 /* Set the function pointers */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
266 this->OpenAudio = ALSA_OpenAudio; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
267 this->WaitAudio = ALSA_WaitAudio; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
268 this->PlayAudio = ALSA_PlayAudio; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
269 this->GetAudioBuf = ALSA_GetAudioBuf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
270 this->CloseAudio = ALSA_CloseAudio; |
0 | 271 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
272 this->free = Audio_DeleteDevice; |
0 | 273 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
274 return this; |
0 | 275 } |
276 | |
277 AudioBootStrap ALSA_bootstrap = { | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
278 DRIVER_NAME, "ALSA 0.9 PCM audio", |
3798
c8b3d3d13ed1
Audio bootstraps can now specify that a driver is only to be used if
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
279 Audio_Available, Audio_CreateDevice, 0 |
0 | 280 }; |
281 | |
282 /* 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:
1878
diff
changeset
|
283 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:
1878
diff
changeset
|
284 ALSA_WaitAudio(_THIS) |
0 | 285 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
286 /* Check to see if the thread-parent process is still alive */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
287 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
288 static int cnt = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
289 /* Note that this only works with thread implementations |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
290 that use a different process id for each thread. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
291 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
292 if (parent && (((++cnt) % 10) == 0)) { /* Check every 10 loops */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
293 if (kill(parent, 0) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
294 this->enabled = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
295 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
296 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
297 } |
0 | 298 } |
299 | |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
300 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
301 /* |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
302 * http://bugzilla.libsdl.org/show_bug.cgi?id=110 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
303 * "For Linux ALSA, this is FL-FR-RL-RR-C-LFE |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
304 * and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-RL-RR" |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
305 */ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
306 #define SWIZ6(T) \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
307 T *ptr = (T *) mixbuf; \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
308 const Uint32 count = (this->spec.samples / 6); \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
309 Uint32 i; \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
310 for (i = 0; i < count; i++, ptr += 6) { \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
311 T tmp; \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
312 tmp = ptr[2]; ptr[2] = ptr[4]; ptr[4] = tmp; \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
313 tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
314 } |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
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:
1878
diff
changeset
|
316 static __inline__ void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
317 swizzle_alsa_channels_6_64bit(_THIS) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
318 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
319 SWIZ6(Uint64); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
320 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
321 static __inline__ void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
322 swizzle_alsa_channels_6_32bit(_THIS) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
323 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
324 SWIZ6(Uint32); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
325 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
326 static __inline__ void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
327 swizzle_alsa_channels_6_16bit(_THIS) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
328 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
329 SWIZ6(Uint16); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
330 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
331 static __inline__ void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
332 swizzle_alsa_channels_6_8bit(_THIS) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
333 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
334 SWIZ6(Uint8); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
335 } |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
336 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
337 #undef SWIZ6 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
338 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
339 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
340 /* |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
341 * Called right before feeding this->mixbuf to the hardware. Swizzle channels |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
342 * from Windows/Mac order to the format alsalib will want. |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
343 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
344 static __inline__ void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
345 swizzle_alsa_channels(_THIS) |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
346 { |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
347 if (this->spec.channels == 6) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
348 const Uint16 fmtsize = (this->spec.format & 0xFF); /* bits/channel. */ |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
349 if (fmtsize == 16) |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
350 swizzle_alsa_channels_6_16bit(this); |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
351 else if (fmtsize == 8) |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
352 swizzle_alsa_channels_6_8bit(this); |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
353 else if (fmtsize == 32) |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
354 swizzle_alsa_channels_6_32bit(this); |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
355 else if (fmtsize == 64) |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
356 swizzle_alsa_channels_6_64bit(this); |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
357 } |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
358 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
359 /* !!! FIXME: update this for 7.1 if needed, later. */ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
360 } |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
361 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
362 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
363 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:
1878
diff
changeset
|
364 ALSA_PlayAudio(_THIS) |
0 | 365 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
366 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:
1878
diff
changeset
|
367 int sample_len; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
368 signed short *sample_buf; |
765
4c2ba6161939
Editors Note: The original patch was modified to use SDL_Delay() instead of
Sam Lantinga <slouken@libsdl.org>
parents:
547
diff
changeset
|
369 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
370 swizzle_alsa_channels(this); |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
371 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
372 sample_len = this->spec.samples; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
373 sample_buf = (signed short *) mixbuf; |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
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:
1878
diff
changeset
|
375 while (sample_len > 0) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
376 status = ALSA_snd_pcm_writei(pcm_handle, sample_buf, sample_len); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
377 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
378 if (status == -EAGAIN) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
379 SDL_Delay(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
380 continue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
381 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
382 if (status == -ESTRPIPE) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
383 do { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
384 SDL_Delay(1); |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
385 status = ALSA_snd_pcm_resume(pcm_handle); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
386 } while (status == -EAGAIN); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
387 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
388 if (status < 0) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
389 status = ALSA_snd_pcm_prepare(pcm_handle); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
390 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
391 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
392 /* Hmm, not much we can do - abort */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
393 this->enabled = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
394 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
395 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
396 continue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
397 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
398 sample_buf += status * this->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:
1878
diff
changeset
|
399 sample_len -= status; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
400 } |
0 | 401 } |
402 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
403 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:
1878
diff
changeset
|
404 ALSA_GetAudioBuf(_THIS) |
0 | 405 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
406 return (mixbuf); |
0 | 407 } |
408 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
409 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:
1878
diff
changeset
|
410 ALSA_CloseAudio(_THIS) |
0 | 411 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
412 if (mixbuf != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
413 SDL_FreeAudioMem(mixbuf); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
414 mixbuf = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
415 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
416 if (pcm_handle) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
417 ALSA_snd_pcm_drain(pcm_handle); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
418 ALSA_snd_pcm_close(pcm_handle); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
419 pcm_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:
1878
diff
changeset
|
420 } |
0 | 421 } |
422 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
423 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:
1878
diff
changeset
|
424 ALSA_OpenAudio(_THIS, SDL_AudioSpec * spec) |
0 | 425 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
426 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:
1878
diff
changeset
|
427 snd_pcm_hw_params_t *hwparams; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
428 snd_pcm_sw_params_t *swparams; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
429 snd_pcm_format_t format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
430 snd_pcm_uframes_t frames; |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
431 SDL_AudioFormat test_format; |
0 | 432 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
433 /* Open the audio device */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
434 /* Name of device should depend on # channels in spec */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
435 status = ALSA_snd_pcm_open(&pcm_handle, |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
436 get_audio_device(spec->channels), |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
437 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
939
diff
changeset
|
438 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
439 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
440 SDL_SetError("Couldn't open audio device: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
441 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
442 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:
1878
diff
changeset
|
443 } |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
444 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
445 /* Figure out what the hardware is capable of */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
446 snd_pcm_hw_params_alloca(&hwparams); |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
447 status = ALSA_snd_pcm_hw_params_any(pcm_handle, hwparams); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
448 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
449 SDL_SetError("Couldn't get hardware config: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
450 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
451 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
452 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:
1878
diff
changeset
|
453 } |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
454 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
455 /* SDL only uses interleaved sample output */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
456 status = ALSA_snd_pcm_hw_params_set_access(pcm_handle, hwparams, |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
457 SND_PCM_ACCESS_RW_INTERLEAVED); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
458 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
459 SDL_SetError("Couldn't set interleaved access: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
460 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
461 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
462 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:
1878
diff
changeset
|
463 } |
0 | 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:
1878
diff
changeset
|
465 /* Try for a closest match on audio format */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
466 status = -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
467 for (test_format = SDL_FirstAudioFormat(spec->format); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
468 test_format && (status < 0);) { |
2043 | 469 status = 0; /* if we can't support a format, it'll become -1. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
470 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:
1878
diff
changeset
|
471 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:
1878
diff
changeset
|
472 format = SND_PCM_FORMAT_U8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
473 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
474 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:
1878
diff
changeset
|
475 format = SND_PCM_FORMAT_S8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
476 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
477 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:
1878
diff
changeset
|
478 format = SND_PCM_FORMAT_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:
1878
diff
changeset
|
479 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
480 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:
1878
diff
changeset
|
481 format = SND_PCM_FORMAT_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:
1878
diff
changeset
|
482 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
483 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:
1878
diff
changeset
|
484 format = SND_PCM_FORMAT_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:
1878
diff
changeset
|
485 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
486 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:
1878
diff
changeset
|
487 format = SND_PCM_FORMAT_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:
1878
diff
changeset
|
488 break; |
1995
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
489 case AUDIO_S32LSB: |
2010
39897da56f63
Whoops, wrong tokens for int32 support in ALSA driver (specified unsigned
Ryan C. Gordon <icculus@icculus.org>
parents:
2009
diff
changeset
|
490 format = SND_PCM_FORMAT_S32_LE; |
1995
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
491 break; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
492 case AUDIO_S32MSB: |
2010
39897da56f63
Whoops, wrong tokens for int32 support in ALSA driver (specified unsigned
Ryan C. Gordon <icculus@icculus.org>
parents:
2009
diff
changeset
|
493 format = SND_PCM_FORMAT_S32_BE; |
1995
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
494 break; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
495 case AUDIO_F32LSB: |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
496 format = SND_PCM_FORMAT_FLOAT_LE; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
497 break; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
498 case AUDIO_F32MSB: |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
499 format = SND_PCM_FORMAT_FLOAT_BE; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
500 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:
1878
diff
changeset
|
501 default: |
2009
f2058fb367e4
ALSA was testing if (format) was set to zero as an error condition, but
Ryan C. Gordon <icculus@icculus.org>
parents:
1995
diff
changeset
|
502 status = -1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
503 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
504 } |
2009
f2058fb367e4
ALSA was testing if (format) was set to zero as an error condition, but
Ryan C. Gordon <icculus@icculus.org>
parents:
1995
diff
changeset
|
505 if (status >= 0) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
506 status = ALSA_snd_pcm_hw_params_set_format(pcm_handle, |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
507 hwparams, 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:
1878
diff
changeset
|
508 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
509 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
510 test_format = SDL_NextAudioFormat(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
511 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
512 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
513 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
514 SDL_SetError("Couldn't find any hardware audio formats"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
515 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
516 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:
1878
diff
changeset
|
517 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
518 spec->format = test_format; |
0 | 519 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
520 /* Set the number of channels */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
521 status = ALSA_snd_pcm_hw_params_set_channels(pcm_handle, hwparams, |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
522 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:
1878
diff
changeset
|
523 if (status < 0) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
524 status = ALSA_snd_pcm_hw_params_get_channels(hwparams); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
525 if ((status <= 0) || (status > 2)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
526 SDL_SetError("Couldn't set audio channels"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
527 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
528 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:
1878
diff
changeset
|
529 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
530 spec->channels = status; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
531 } |
0 | 532 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
533 /* Set the audio rate */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
534 status = ALSA_snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
535 spec->freq, NULL); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
536 if (status < 0) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
537 ALSA_CloseAudio(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:
1878
diff
changeset
|
538 SDL_SetError("Couldn't set audio frequency: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
539 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
540 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:
1878
diff
changeset
|
541 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
542 spec->freq = status; |
0 | 543 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
544 /* Set the buffer size, in samples */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
545 frames = spec->samples; |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
546 frames = ALSA_snd_pcm_hw_params_set_period_size_near(pcm_handle, hwparams, |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
547 frames, NULL); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
548 spec->samples = frames; |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
549 ALSA_snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, 2, NULL); |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
550 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
551 /* "set" the hardware with the desired parameters */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
552 status = ALSA_snd_pcm_hw_params(pcm_handle, hwparams); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
553 if (status < 0) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
554 ALSA_CloseAudio(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:
1878
diff
changeset
|
555 SDL_SetError("Couldn't set hardware audio parameters: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
556 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
557 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:
1878
diff
changeset
|
558 } |
1552 | 559 |
1553
63fa37538842
Left the debug code more explicit
Sam Lantinga <slouken@libsdl.org>
parents:
1552
diff
changeset
|
560 /* This is useful for debugging... */ |
1552 | 561 /* |
1553
63fa37538842
Left the debug code more explicit
Sam Lantinga <slouken@libsdl.org>
parents:
1552
diff
changeset
|
562 { snd_pcm_sframes_t bufsize; int fragments; |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
563 bufsize = ALSA_snd_pcm_hw_params_get_period_size(hwparams); |
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
564 fragments = ALSA_snd_pcm_hw_params_get_periods(hwparams); |
1552 | 565 |
566 fprintf(stderr, "ALSA: bufsize = %ld, fragments = %d\n", bufsize, fragments); | |
567 } | |
568 */ | |
569 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
570 /* Set the software parameters */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
571 snd_pcm_sw_params_alloca(&swparams); |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
572 status = ALSA_snd_pcm_sw_params_current(pcm_handle, swparams); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
573 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
574 SDL_SetError("Couldn't get software config: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
575 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
576 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
577 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:
1878
diff
changeset
|
578 } |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
579 status = ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle,swparams,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:
1878
diff
changeset
|
580 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
581 SDL_SetError("Couldn't set start threshold: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
582 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
583 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
584 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:
1878
diff
changeset
|
585 } |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
586 status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, frames); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
587 if (status < 0) { |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
588 SDL_SetError("Couldn't set avail min: %s", ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
589 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
590 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:
1878
diff
changeset
|
591 } |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
592 status = ALSA_snd_pcm_sw_params(pcm_handle, swparams); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
593 if (status < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
594 SDL_SetError("Couldn't set software audio parameters: %s", |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
595 ALSA_snd_strerror(status)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
596 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
597 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:
1878
diff
changeset
|
598 } |
0 | 599 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
600 /* Calculate the final parameters for this audio specification */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
601 SDL_CalculateAudioSpec(spec); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
602 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
603 /* Allocate mixing buffer */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
604 mixlen = spec->size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
605 mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
606 if (mixbuf == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
607 ALSA_CloseAudio(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
608 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:
1878
diff
changeset
|
609 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
610 SDL_memset(mixbuf, spec->silence, spec->size); |
0 | 611 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
612 /* Get the parent process id (we're the parent of the audio thread) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
613 parent = getpid(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
614 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
615 /* Switch to blocking mode for playback */ |
3818
49eadd6e8962
Mangled ALSA dynamic loading...static loading will still work if you have the
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
616 ALSA_snd_pcm_nonblock(pcm_handle, 0); |
0 | 617 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
618 /* We're ready to rock and roll. :-) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
619 return (0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
620 } |
0 | 621 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
622 /* vi: set ts=4 sw=4 expandtab: */ |