Mercurial > sdl-ios-xcode
annotate src/audio/alsa/SDL_alsa_audio.c @ 3699:4160ba33b597
Removed test for "driver is valid, but doesn't see any audio devices."
It was causing problems, and it really doesn't make sense to do it that way.
Fixes Bugzilla #834.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 26 Jan 2010 06:01:33 +0000 |
parents | f7b03b6838cb |
children | 9bc9ff36eb8f |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
3697 | 6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
3697 | 8 version 2.1 of the License, or (at your option) any later version. |
0 | 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 | |
3697 | 13 Lesser General Public License for more details. |
0 | 14 |
3697 | 15 You should have received a copy of the GNU Lesser General Public |
16 License along with this library; if not, write to the Free Software | |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
0 | 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() */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
28 #include <errno.h> |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
29 #include <string.h> |
0 | 30 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
31 #include "SDL_timer.h" |
0 | 32 #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
|
33 #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
|
34 #include "../SDL_audio_c.h" |
0 | 35 #include "SDL_alsa_audio.h" |
36 | |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
37 #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
38 #include "SDL_loadso.h" |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
39 #endif |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
40 |
0 | 41 /* The tag name used by ALSA audio */ |
42 #define DRIVER_NAME "alsa" | |
43 | |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
44 static int (*ALSA_snd_pcm_open) |
2060 | 45 (snd_pcm_t **, const char *, snd_pcm_stream_t, int); |
46 static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm); | |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
47 static snd_pcm_sframes_t(*ALSA_snd_pcm_writei) |
2060 | 48 (snd_pcm_t *, const void *, snd_pcm_uframes_t); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
49 static int (*ALSA_snd_pcm_recover) (snd_pcm_t *, int, int); |
2060 | 50 static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *); |
51 static int (*ALSA_snd_pcm_drain) (snd_pcm_t *); | |
52 static const char *(*ALSA_snd_strerror) (int); | |
53 static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void); | |
54 static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void); | |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
55 static void (*ALSA_snd_pcm_hw_params_copy) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
56 (snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *); |
2060 | 57 static int (*ALSA_snd_pcm_hw_params_any) (snd_pcm_t *, snd_pcm_hw_params_t *); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
58 static int (*ALSA_snd_pcm_hw_params_set_access) |
2060 | 59 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
60 static int (*ALSA_snd_pcm_hw_params_set_format) |
2060 | 61 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
62 static int (*ALSA_snd_pcm_hw_params_set_channels) |
2060 | 63 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
64 static int (*ALSA_snd_pcm_hw_params_get_channels) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
65 (const snd_pcm_hw_params_t *, unsigned int *); |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
66 static int (*ALSA_snd_pcm_hw_params_set_rate_near) |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
67 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
68 static int (*ALSA_snd_pcm_hw_params_set_period_size_near) |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
69 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
70 static int (*ALSA_snd_pcm_hw_params_get_period_size) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
71 (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *); |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
72 static int (*ALSA_snd_pcm_hw_params_set_periods_near) |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
73 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
74 static int (*ALSA_snd_pcm_hw_params_get_periods) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
75 (const snd_pcm_hw_params_t *, unsigned int *, int *); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
76 static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
77 (snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
78 static int (*ALSA_snd_pcm_hw_params_get_buffer_size) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
79 (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *); |
2060 | 80 static int (*ALSA_snd_pcm_hw_params) (snd_pcm_t *, snd_pcm_hw_params_t *); |
81 static int (*ALSA_snd_pcm_sw_params_current) (snd_pcm_t *, | |
82 snd_pcm_sw_params_t *); | |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
83 static int (*ALSA_snd_pcm_sw_params_set_start_threshold) |
2060 | 84 (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); |
85 static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *); | |
86 static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int); | |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
87 static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
88 #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
89 #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
90 |
0 | 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; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
96 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
97 static int |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
98 load_alsa_sym(const char *fn, void **addr) |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
99 { |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
100 *addr = SDL_LoadFunction(alsa_handle, fn); |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
101 if (*addr == NULL) { |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
102 /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
103 return 0; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
104 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
105 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
106 return 1; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
107 } |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
108 |
1161
05d4b93b911e
Placate gcc's strict aliasing rules with an extra cast.
Ryan C. Gordon <icculus@icculus.org>
parents:
942
diff
changeset
|
109 /* cast funcs to char* first, to please GCC's strict aliasing rules. */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
110 #define SDL_ALSA_SYM(x) \ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
111 if (!load_alsa_sym(#x, (void **) (char *) &ALSA_##x)) return -1 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
112 #else |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
113 #define SDL_ALSA_SYM(x) ALSA_##x = x |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
114 #endif |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
115 |
2060 | 116 static int |
117 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
|
118 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
119 SDL_ALSA_SYM(snd_pcm_open); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
120 SDL_ALSA_SYM(snd_pcm_close); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
121 SDL_ALSA_SYM(snd_pcm_writei); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
122 SDL_ALSA_SYM(snd_pcm_recover); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
123 SDL_ALSA_SYM(snd_pcm_prepare); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
124 SDL_ALSA_SYM(snd_pcm_drain); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
125 SDL_ALSA_SYM(snd_strerror); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
126 SDL_ALSA_SYM(snd_pcm_hw_params_sizeof); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
127 SDL_ALSA_SYM(snd_pcm_sw_params_sizeof); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
128 SDL_ALSA_SYM(snd_pcm_hw_params_copy); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
129 SDL_ALSA_SYM(snd_pcm_hw_params_any); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
130 SDL_ALSA_SYM(snd_pcm_hw_params_set_access); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
131 SDL_ALSA_SYM(snd_pcm_hw_params_set_format); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
132 SDL_ALSA_SYM(snd_pcm_hw_params_set_channels); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
133 SDL_ALSA_SYM(snd_pcm_hw_params_get_channels); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
134 SDL_ALSA_SYM(snd_pcm_hw_params_set_rate_near); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
135 SDL_ALSA_SYM(snd_pcm_hw_params_set_period_size_near); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
136 SDL_ALSA_SYM(snd_pcm_hw_params_get_period_size); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
137 SDL_ALSA_SYM(snd_pcm_hw_params_set_periods_near); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
138 SDL_ALSA_SYM(snd_pcm_hw_params_get_periods); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
139 SDL_ALSA_SYM(snd_pcm_hw_params_set_buffer_size_near); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
140 SDL_ALSA_SYM(snd_pcm_hw_params_get_buffer_size); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
141 SDL_ALSA_SYM(snd_pcm_hw_params); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
142 SDL_ALSA_SYM(snd_pcm_sw_params_current); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
143 SDL_ALSA_SYM(snd_pcm_sw_params_set_start_threshold); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
144 SDL_ALSA_SYM(snd_pcm_sw_params); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
145 SDL_ALSA_SYM(snd_pcm_nonblock); |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
146 SDL_ALSA_SYM(snd_pcm_wait); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
147 return 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
148 } |
2060 | 149 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
150 #undef SDL_ALSA_SYM |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
151 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
152 #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
|
153 |
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
|
154 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
|
155 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
|
156 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
157 if (alsa_handle != NULL) { |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
158 SDL_UnloadObject(alsa_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
|
159 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
|
160 } |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
161 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
162 |
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
|
163 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
|
164 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
|
165 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
166 int retval = 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
167 if (alsa_handle == NULL) { |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
168 alsa_handle = SDL_LoadObject(alsa_library); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
169 if (alsa_handle == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
170 retval = -1; |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
171 /* Don't call SDL_SetError(): SDL_LoadObject already did. */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
172 } else { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
173 retval = load_alsa_syms(); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
174 if (retval < 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
|
175 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
|
176 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
177 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
178 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
179 return retval; |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
180 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
181 |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
182 #else |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
183 |
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
|
184 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
|
185 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
|
186 { |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
187 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
188 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
189 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
|
190 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
|
191 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
192 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
|
193 return 0; |
865
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
194 } |
92615154bb68
Date: Sun, 29 Feb 2004 15:14:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
195 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
196 #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
|
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 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
|
199 get_audio_device(int channels) |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
200 { |
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
|
201 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
|
202 |
c121d94672cb
SDL 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 = 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
|
204 if (device == NULL) { |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
205 switch (channels) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
206 case 6: |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
207 device = "plug:surround51"; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
208 break; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
209 case 4: |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
210 device = "plug:surround40"; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
211 break; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
212 default: |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
213 device = "default"; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
214 break; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
215 } |
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
|
216 } |
c121d94672cb
SDL 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 return device; |
0 | 218 } |
219 | |
220 | |
221 /* 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
|
222 static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
223 ALSA_WaitDevice(_THIS) |
0 | 224 { |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
225 /* We're in blocking mode, so there's nothing to do here */ |
0 | 226 } |
227 | |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
228 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
229 /* !!! FIXME: is there a channel swizzler in alsalib instead? */ |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
230 /* |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
231 * 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
|
232 * "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
|
233 * 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
|
234 */ |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
235 #define SWIZ6(T) \ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
236 T *ptr = (T *) this->hidden->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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 } |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
244 |
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
|
245 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
|
246 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
|
247 { |
c121d94672cb
SDL 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 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
|
249 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2060
diff
changeset
|
250 |
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
|
251 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
|
252 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
|
253 { |
c121d94672cb
SDL 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 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
|
255 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2060
diff
changeset
|
256 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
257 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
|
258 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
|
259 { |
c121d94672cb
SDL 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 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
|
261 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2060
diff
changeset
|
262 |
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
|
263 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
|
264 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
|
265 { |
c121d94672cb
SDL 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 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
|
267 } |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
268 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
269 #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
|
270 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
271 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
272 /* |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
273 * Called right before feeding this->hidden->mixbuf to the hardware. Swizzle |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
274 * channels from Windows/Mac order to the format alsalib will want. |
1878
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
275 */ |
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
|
276 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
|
277 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
|
278 { |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 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
|
289 } |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
290 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
291 /* !!! 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
|
292 } |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
293 |
d7c9d7f42881
Swizzle ALSA channels for 5.1 output to match DirectSound and CoreAudio.
Ryan C. Gordon <icculus@icculus.org>
parents:
1553
diff
changeset
|
294 |
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
|
295 static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
296 ALSA_PlayDevice(_THIS) |
0 | 297 { |
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
|
298 int status; |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
299 const Uint8 *sample_buf = (const Uint8 *) this->hidden->mixbuf; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
300 const int frame_size = (((int) (this->spec.format & 0xFF)) / 8) * |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
301 this->spec.channels; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
302 snd_pcm_uframes_t frames_left = ((snd_pcm_uframes_t) this->spec.samples); |
765
4c2ba6161939
Editors Note: The original patch was modified to use SDL_Delay() instead of
Sam Lantinga <slouken@libsdl.org>
parents:
547
diff
changeset
|
303 |
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
|
304 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
|
305 |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
306 while ( frames_left > 0 && this->enabled ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
307 /* !!! FIXME: This works, but needs more testing before going live */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
308 /*ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1);*/ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
309 status = ALSA_snd_pcm_writei(this->hidden->pcm_handle, |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
310 sample_buf, frames_left); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
311 |
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
|
312 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
|
313 if (status == -EAGAIN) { |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
314 /* Apparently snd_pcm_recover() doesn't handle this case - |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
315 does it assume snd_pcm_wait() above? */ |
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 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
|
317 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
|
318 } |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
319 status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 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
|
320 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
|
321 /* Hmm, not much we can do - abort */ |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
322 fprintf(stderr, "ALSA write failed (unrecoverable): %s\n", |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
323 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
|
324 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
|
325 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
|
326 } |
c121d94672cb
SDL 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 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
|
328 } |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
329 sample_buf += status * frame_size; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
330 frames_left -= 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
|
331 } |
0 | 332 } |
333 | |
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
|
334 static Uint8 * |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
335 ALSA_GetDeviceBuf(_THIS) |
0 | 336 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
337 return (this->hidden->mixbuf); |
0 | 338 } |
339 | |
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
|
340 static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
341 ALSA_CloseDevice(_THIS) |
0 | 342 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
343 if (this->hidden != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
344 if (this->hidden->mixbuf != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
345 SDL_FreeAudioMem(this->hidden->mixbuf); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
346 this->hidden->mixbuf = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
347 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
348 if (this->hidden->pcm_handle) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
349 ALSA_snd_pcm_drain(this->hidden->pcm_handle); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
350 ALSA_snd_pcm_close(this->hidden->pcm_handle); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
351 this->hidden->pcm_handle = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
352 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
353 SDL_free(this->hidden); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
354 this->hidden = NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
355 } |
0 | 356 } |
357 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
358 static int |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
359 ALSA_finalize_hardware(_THIS, snd_pcm_hw_params_t *hwparams, int override) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
360 { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
361 int status; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
362 snd_pcm_uframes_t bufsize; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
363 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
364 /* "set" the hardware with the desired parameters */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
365 status = ALSA_snd_pcm_hw_params(this->hidden->pcm_handle, hwparams); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
366 if ( status < 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
367 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
368 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
369 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
370 /* Get samples for the actual buffer size */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
371 status = ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
372 if ( status < 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
373 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
374 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
375 if ( !override && bufsize != this->spec.samples * 2 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
376 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
377 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
378 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
379 /* !!! FIXME: Is this safe to do? */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
380 this->spec.samples = bufsize / 2; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
381 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
382 /* This is useful for debugging */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
383 if ( SDL_getenv("SDL_AUDIO_ALSA_DEBUG") ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
384 snd_pcm_uframes_t persize = 0; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
385 unsigned int periods = 0; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
386 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
387 ALSA_snd_pcm_hw_params_get_period_size(hwparams, &persize, NULL); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
388 ALSA_snd_pcm_hw_params_get_periods(hwparams, &periods, NULL); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
389 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
390 fprintf(stderr, |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
391 "ALSA: period size = %ld, periods = %u, buffer size = %lu\n", |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
392 persize, periods, bufsize); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
393 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
394 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
395 return(0); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
396 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
397 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
398 static int |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
399 ALSA_set_period_size(_THIS, snd_pcm_hw_params_t *params, int override) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
400 { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
401 const char *env; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
402 int status; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
403 snd_pcm_hw_params_t *hwparams; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
404 snd_pcm_uframes_t frames; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
405 unsigned int periods; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
406 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
407 /* Copy the hardware parameters for this setup */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
408 snd_pcm_hw_params_alloca(&hwparams); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
409 ALSA_snd_pcm_hw_params_copy(hwparams, params); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
410 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
411 if ( !override ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
412 env = SDL_getenv("SDL_AUDIO_ALSA_SET_PERIOD_SIZE"); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
413 if ( env ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
414 override = SDL_atoi(env); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
415 if ( override == 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
416 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
417 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
418 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
419 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
420 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
421 frames = this->spec.samples; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
422 status = ALSA_snd_pcm_hw_params_set_period_size_near( |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
423 this->hidden->pcm_handle, hwparams, &frames, NULL); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
424 if ( status < 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
425 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
426 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
427 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
428 periods = 2; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
429 status = ALSA_snd_pcm_hw_params_set_periods_near( |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
430 this->hidden->pcm_handle, hwparams, &periods, NULL); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
431 if ( status < 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
432 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
433 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
434 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
435 return ALSA_finalize_hardware(this, hwparams, override); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
436 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
437 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
438 static int |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
439 ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params, int override) |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
440 { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
441 const char *env; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
442 int status; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
443 snd_pcm_hw_params_t *hwparams; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
444 snd_pcm_uframes_t frames; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
445 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
446 /* Copy the hardware parameters for this setup */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
447 snd_pcm_hw_params_alloca(&hwparams); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
448 ALSA_snd_pcm_hw_params_copy(hwparams, params); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
449 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
450 if ( !override ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
451 env = SDL_getenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE"); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
452 if ( env ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
453 override = SDL_atoi(env); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
454 if ( override == 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
455 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
456 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
457 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
458 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
459 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
460 frames = this->spec.samples * 2; |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
461 status = ALSA_snd_pcm_hw_params_set_buffer_size_near( |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
462 this->hidden->pcm_handle, hwparams, &frames); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
463 if ( status < 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
464 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
465 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
466 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
467 return ALSA_finalize_hardware(this, hwparams, override); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
468 } |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
469 |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
470 static int |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
471 ALSA_OpenDevice(_THIS, const char *devname, int iscapture) |
0 | 472 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
473 int status = 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
474 snd_pcm_t *pcm_handle = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
475 snd_pcm_hw_params_t *hwparams = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
476 snd_pcm_sw_params_t *swparams = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
477 snd_pcm_format_t format = 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
478 SDL_AudioFormat test_format = 0; |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
479 unsigned int rate = 0; |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
480 unsigned int channels = 0; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
481 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
482 /* Initialize all variables that we clean on shutdown */ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
483 this->hidden = (struct SDL_PrivateAudioData *) |
2060 | 484 SDL_malloc((sizeof *this->hidden)); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
485 if (this->hidden == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
486 SDL_OutOfMemory(); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
487 return 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
488 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
489 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
0 | 490 |
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
|
491 /* 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
|
492 /* Name of device should depend on # channels in spec */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
493 status = ALSA_snd_pcm_open(&pcm_handle, |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
494 get_audio_device(this->spec.channels), |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
495 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
|
496 |
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
|
497 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
498 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
499 SDL_SetError("ALSA: Couldn't open audio device: %s", |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
500 ALSA_snd_strerror(status)); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
501 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
502 } |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
503 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
504 this->hidden->pcm_handle = pcm_handle; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
505 |
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
|
506 /* 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
|
507 snd_pcm_hw_params_alloca(&hwparams); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
508 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
|
509 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
510 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
511 SDL_SetError("ALSA: Couldn't get hardware config: %s", |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
512 ALSA_snd_strerror(status)); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
513 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
514 } |
354
30935e76acb5
Updated ALSA audio support for ALSA 0.9
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
515 |
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
|
516 /* SDL only uses interleaved sample output */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
517 status = ALSA_snd_pcm_hw_params_set_access(pcm_handle, hwparams, |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
518 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
|
519 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
520 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
521 SDL_SetError("ALSA: Couldn't set interleaved access: %s", |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
522 ALSA_snd_strerror(status)); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
523 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
524 } |
0 | 525 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
526 /* 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
|
527 status = -1; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
528 for (test_format = SDL_FirstAudioFormat(this->spec.format); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
529 test_format && (status < 0);) { |
2060 | 530 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
|
531 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
|
532 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
|
533 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
|
534 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
|
535 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 break; |
1995
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
550 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
|
551 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
|
552 break; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
553 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
|
554 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
|
555 break; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
556 case AUDIO_F32LSB: |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
557 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
|
558 break; |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
559 case AUDIO_F32MSB: |
0ca6ba107642
ALSA backend can handle int32 and float32 data directly.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
560 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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 } |
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
|
566 if (status >= 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
567 status = ALSA_snd_pcm_hw_params_set_format(pcm_handle, |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
568 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
|
569 } |
c121d94672cb
SDL 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 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
|
571 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
|
572 } |
c121d94672cb
SDL 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 } |
c121d94672cb
SDL 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 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
575 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
576 SDL_SetError("ALSA: Couldn't find any hardware audio formats"); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
577 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
578 } |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
579 this->spec.format = test_format; |
0 | 580 |
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
|
581 /* Set the number of channels */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
582 status = ALSA_snd_pcm_hw_params_set_channels(pcm_handle, hwparams, |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
583 this->spec.channels); |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
584 channels = this->spec.channels; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
585 if (status < 0) { |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
586 status = ALSA_snd_pcm_hw_params_get_channels(hwparams, &channels); |
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
587 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
588 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
589 SDL_SetError("ALSA: Couldn't set audio channels"); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
590 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
591 } |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
592 this->spec.channels = 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
|
593 } |
0 | 594 |
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
|
595 /* Set the audio rate */ |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
596 rate = this->spec.freq; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
597 status = ALSA_snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
598 &rate, 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
|
599 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
600 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
601 SDL_SetError("ALSA: Couldn't set audio frequency: %s", |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
602 ALSA_snd_strerror(status)); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
603 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
604 } |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
605 this->spec.freq = rate; |
0 | 606 |
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
|
607 /* Set the buffer size, in samples */ |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
608 if ( ALSA_set_period_size(this, hwparams, 0) < 0 && |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
609 ALSA_set_buffer_size(this, hwparams, 0) < 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
610 /* Failed to set desired buffer size, do the best you can... */ |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
611 if ( ALSA_set_period_size(this, hwparams, 1) < 0 ) { |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
612 ALSA_CloseDevice(this); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
613 SDL_SetError("Couldn't set hardware audio parameters: %s", ALSA_snd_strerror(status)); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
614 return(-1); |
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
615 } |
3362
4e83cdb58134
Merged r4990:4991 from branches/SDL-1.2: ALSA 1.0 API and dlvsym() removal.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
616 } |
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
|
617 /* 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
|
618 snd_pcm_sw_params_alloca(&swparams); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
619 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
|
620 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
621 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
622 SDL_SetError("ALSA: Couldn't get software config: %s", |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
623 ALSA_snd_strerror(status)); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
624 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
625 } |
2060 | 626 status = |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
627 ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
628 if (status < 0) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
629 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
630 SDL_SetError("ALSA: Couldn't set start threshold: %s", |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
631 ALSA_snd_strerror(status)); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
632 return 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
633 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
634 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
|
635 if (status < 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
636 ALSA_CloseDevice(this); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
637 SDL_SetError("Couldn't set software audio parameters: %s", |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
638 ALSA_snd_strerror(status)); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
639 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
640 } |
0 | 641 |
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
|
642 /* Calculate the final parameters for this audio specification */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
643 SDL_CalculateAudioSpec(&this->spec); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
644 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
645 /* Allocate mixing buffer */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
646 this->hidden->mixlen = this->spec.size; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
647 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
648 if (this->hidden->mixbuf == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
649 ALSA_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
650 SDL_OutOfMemory(); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
651 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1878
diff
changeset
|
652 } |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
653 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); |
0 | 654 |
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
|
655 /* Switch to blocking mode for playback */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
656 ALSA_snd_pcm_nonblock(pcm_handle, 0); |
0 | 657 |
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
|
658 /* We're ready to rock and roll. :-) */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
659 return 1; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
660 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
661 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
662 static void |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
663 ALSA_Deinitialize(void) |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
664 { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
665 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
|
666 } |
0 | 667 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
668 static int |
2060 | 669 ALSA_Init(SDL_AudioDriverImpl * impl) |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
670 { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
671 if (LoadALSALibrary() < 0) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
672 return 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
673 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
674 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
675 /* Set the function pointers */ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
676 impl->OpenDevice = ALSA_OpenDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
677 impl->WaitDevice = ALSA_WaitDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
678 impl->GetDeviceBuf = ALSA_GetDeviceBuf; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
679 impl->PlayDevice = ALSA_PlayDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
680 impl->CloseDevice = ALSA_CloseDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
681 impl->Deinitialize = ALSA_Deinitialize; |
2060 | 682 impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Add device enum! */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
683 |
3699
4160ba33b597
Removed test for "driver is valid, but doesn't see any audio devices."
Ryan C. Gordon <icculus@icculus.org>
parents:
3697
diff
changeset
|
684 return 1; /* this audio target is available. */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
685 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
686 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
687 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
688 AudioBootStrap ALSA_bootstrap = { |
3627
631173ffd68f
Merged r4991:5154 from branches/SDL-1.2/src/audio/alsa: many 1.2.14 ALSA fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
3362
diff
changeset
|
689 DRIVER_NAME, "ALSA PCM audio", ALSA_Init, 0 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
690 }; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
691 |
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
|
692 /* vi: set ts=4 sw=4 expandtab: */ |