Mercurial > sdl-ios-xcode
annotate src/audio/pulseaudio/SDL_pulseaudio.c @ 5267:b530ef003506
Happy 2011! :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Feb 2011 22:37:15 -0800 |
parents | de59e0218aa2 |
children |
rev | line source |
---|---|
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 /* |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
5267 | 3 Copyright (C) 1997-2011 Sam Lantinga |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 Sam Lantinga |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 /* |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 The PulseAudio target for SDL 1.3 is based on the 1.3 arts target, with |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 the appropriate parts replaced with the 1.2 PulseAudio target code. This |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 was the cleanest way to move it to 1.3. The 1.2 target was written by |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 Stéphan Kochen: stephan .a.t. kochen.nl |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 #include "SDL_config.h" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 /* Allow access to a raw mixing buffer */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 #ifdef HAVE_SIGNAL_H |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 #include <signal.h> |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 #endif |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 #include <unistd.h> |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 #include <sys/types.h> |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 #include <errno.h> |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
40 #include <pulse/pulseaudio.h> |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 #include <pulse/simple.h> |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 #include "SDL_timer.h" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 #include "SDL_audio.h" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 #include "../SDL_audiomem.h" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 #include "../SDL_audio_c.h" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 #include "SDL_pulseaudio.h" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 #include "SDL_loadso.h" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 /* The tag name used by pulse audio */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 #define PULSEAUDIO_DRIVER_NAME "pulseaudio" |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
53 #if (PA_API_VERSION < 12) |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
54 /** Return non-zero if the passed state is one of the connected states */ |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
55 static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
56 return |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
57 x == PA_CONTEXT_CONNECTING || |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
58 x == PA_CONTEXT_AUTHORIZING || |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
59 x == PA_CONTEXT_SETTING_NAME || |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
60 x == PA_CONTEXT_READY; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
61 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
62 /** Return non-zero if the passed state is one of the connected states */ |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
63 static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x) { |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
64 return |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
65 x == PA_STREAM_CREATING || |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
66 x == PA_STREAM_READY; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
67 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
68 #endif /* pulseaudio <= 0.9.10 */ |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
69 |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
71 static pa_simple *(*PULSEAUDIO_pa_simple_new) (const char *, const char *, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
72 pa_stream_direction_t, const char *, const char *, const pa_sample_spec *, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
73 const pa_channel_map *, const pa_buffer_attr *, int *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
74 static void (*PULSEAUDIO_pa_simple_free) (pa_simple *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
75 static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto) ( |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
76 pa_channel_map *, unsigned, pa_channel_map_def_t); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
77 static const char * (*PULSEAUDIO_pa_strerror) (int); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
78 static pa_mainloop * (*PULSEAUDIO_pa_mainloop_new) (void); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
79 static pa_mainloop_api * (*PULSEAUDIO_pa_mainloop_get_api) (pa_mainloop *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
80 static int (*PULSEAUDIO_pa_mainloop_iterate) (pa_mainloop *, int, int *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
81 static void (*PULSEAUDIO_pa_mainloop_free) (pa_mainloop *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
82 |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
83 static pa_operation_state_t (*PULSEAUDIO_pa_operation_get_state) ( |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
84 pa_operation *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
85 static void (*PULSEAUDIO_pa_operation_cancel) (pa_operation *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
86 static void (*PULSEAUDIO_pa_operation_unref) (pa_operation *); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
87 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
88 static pa_context * (*PULSEAUDIO_pa_context_new) (pa_mainloop_api *, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
89 const char *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
90 static int (*PULSEAUDIO_pa_context_connect) (pa_context *, const char *, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
91 pa_context_flags_t, const pa_spawn_api *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
92 static pa_context_state_t (*PULSEAUDIO_pa_context_get_state) (pa_context *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
93 static void (*PULSEAUDIO_pa_context_disconnect) (pa_context *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
94 static void (*PULSEAUDIO_pa_context_unref) (pa_context *); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
95 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
96 static pa_stream * (*PULSEAUDIO_pa_stream_new) (pa_context *, const char *, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
97 const pa_sample_spec *, const pa_channel_map *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
98 static int (*PULSEAUDIO_pa_stream_connect_playback) (pa_stream *, const char *, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
99 const pa_buffer_attr *, pa_stream_flags_t, pa_cvolume *, pa_stream *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
100 static pa_stream_state_t (*PULSEAUDIO_pa_stream_get_state) (pa_stream *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
101 static size_t (*PULSEAUDIO_pa_stream_writable_size) (pa_stream *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
102 static int (*PULSEAUDIO_pa_stream_write) (pa_stream *, const void *, size_t, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
103 pa_free_cb_t, int64_t, pa_seek_mode_t); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
104 static pa_operation * (*PULSEAUDIO_pa_stream_drain) (pa_stream *, |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
105 pa_stream_success_cb_t, void *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
106 static int (*PULSEAUDIO_pa_stream_disconnect) (pa_stream *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
107 static void (*PULSEAUDIO_pa_stream_unref) (pa_stream *); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
108 |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
109 static int load_pulseaudio_syms(void); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
110 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
112 #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
113 |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
114 static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC; |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
115 static void *pulseaudio_handle = NULL; |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
116 |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
117 static int |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
118 load_pulseaudio_sym(const char *fn, void **addr) |
2274 | 119 { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
120 *addr = SDL_LoadFunction(pulseaudio_handle, fn); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
121 if (*addr == NULL) { |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
122 /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
123 return 0; |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
124 } |
2274 | 125 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
126 return 1; |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
127 } |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
128 |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
129 /* cast funcs to char* first, to please GCC's strict aliasing rules. */ |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
130 #define SDL_PULSEAUDIO_SYM(x) \ |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
131 if (!load_pulseaudio_sym(#x, (void **) (char *) &PULSEAUDIO_##x)) return -1 |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 static void |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
134 UnloadPulseAudioLibrary(void) |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
136 if (pulseaudio_handle != NULL) { |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
137 SDL_UnloadObject(pulseaudio_handle); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
138 pulseaudio_handle = NULL; |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
140 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 static int |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
143 LoadPulseAudioLibrary(void) |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
145 int retval = 0; |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
146 if (pulseaudio_handle == NULL) { |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
147 pulseaudio_handle = SDL_LoadObject(pulseaudio_library); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
148 if (pulseaudio_handle == NULL) { |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
149 retval = -1; |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
150 /* Don't call SDL_SetError(): SDL_LoadObject already did. */ |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
151 } else { |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
152 retval = load_pulseaudio_syms(); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
153 if (retval < 0) { |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
154 UnloadPulseAudioLibrary(); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 return retval; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
159 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 #else |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
163 #define SDL_PULSEAUDIO_SYM(x) PULSEAUDIO_##x = x |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
164 |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 static void |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
166 UnloadPulseAudioLibrary(void) |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 static int |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
171 LoadPulseAudioLibrary(void) |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
173 load_pulseaudio_syms(); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 return 0; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 #endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
179 |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
180 static int |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
181 load_pulseaudio_syms(void) |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
182 { |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
183 SDL_PULSEAUDIO_SYM(pa_simple_new); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
184 SDL_PULSEAUDIO_SYM(pa_simple_free); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
185 SDL_PULSEAUDIO_SYM(pa_mainloop_new); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
186 SDL_PULSEAUDIO_SYM(pa_mainloop_get_api); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
187 SDL_PULSEAUDIO_SYM(pa_mainloop_iterate); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
188 SDL_PULSEAUDIO_SYM(pa_mainloop_free); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
189 SDL_PULSEAUDIO_SYM(pa_operation_get_state); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
190 SDL_PULSEAUDIO_SYM(pa_operation_cancel); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
191 SDL_PULSEAUDIO_SYM(pa_operation_unref); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
192 SDL_PULSEAUDIO_SYM(pa_context_new); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
193 SDL_PULSEAUDIO_SYM(pa_context_connect); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
194 SDL_PULSEAUDIO_SYM(pa_context_get_state); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
195 SDL_PULSEAUDIO_SYM(pa_context_disconnect); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
196 SDL_PULSEAUDIO_SYM(pa_context_unref); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
197 SDL_PULSEAUDIO_SYM(pa_stream_new); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
198 SDL_PULSEAUDIO_SYM(pa_stream_connect_playback); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
199 SDL_PULSEAUDIO_SYM(pa_stream_get_state); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
200 SDL_PULSEAUDIO_SYM(pa_stream_writable_size); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
201 SDL_PULSEAUDIO_SYM(pa_stream_write); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
202 SDL_PULSEAUDIO_SYM(pa_stream_drain); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
203 SDL_PULSEAUDIO_SYM(pa_stream_disconnect); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
204 SDL_PULSEAUDIO_SYM(pa_stream_unref); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
205 SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
206 SDL_PULSEAUDIO_SYM(pa_strerror); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
207 return 0; |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
208 } |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
209 |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
210 |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 /* This function waits until it is possible to write a full sound buffer */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 static void |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
213 PULSEAUDIO_WaitDevice(_THIS) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 { |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
215 struct SDL_PrivateAudioData *h = this->hidden; |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
216 |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
217 while(1) { |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
218 if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY || |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
219 PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY || |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
220 PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
221 this->enabled = 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
222 return; |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
223 } |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
224 if (PULSEAUDIO_pa_stream_writable_size(h->stream) >= h->mixlen) { |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
225 return; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
226 } |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
227 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
228 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 static void |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 PULSEAUDIO_PlayDevice(_THIS) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 /* Write the audio data */ |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
234 struct SDL_PrivateAudioData *h = this->hidden; |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
235 if (PULSEAUDIO_pa_stream_write(h->stream, h->mixbuf, h->mixlen, NULL, 0LL, |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
236 PA_SEEK_RELATIVE) < 0) { |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
237 this->enabled = 0; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
238 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
239 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
240 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 static void |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
242 stream_drain_complete(pa_stream *s, int success, void *userdata) |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
243 { |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
244 /* no-op for pa_stream_drain() to use for callback. */ |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
245 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
246 |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
247 static void |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 PULSEAUDIO_WaitDone(_THIS) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 { |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
250 struct SDL_PrivateAudioData *h = this->hidden; |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
251 pa_operation *o; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
252 |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
253 o = PULSEAUDIO_pa_stream_drain(h->stream, stream_drain_complete, NULL); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
254 if (!o) { |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
255 return; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
256 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
257 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
258 while (PULSEAUDIO_pa_operation_get_state(o) != PA_OPERATION_DONE) { |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
259 if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY || |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
260 PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY || |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
261 PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
262 PULSEAUDIO_pa_operation_cancel(o); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
263 break; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
264 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
265 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
266 |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
267 PULSEAUDIO_pa_operation_unref(o); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
271 |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 static Uint8 * |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
273 PULSEAUDIO_GetDeviceBuf(_THIS) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 return (this->hidden->mixbuf); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
279 static void |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
280 PULSEAUDIO_CloseDevice(_THIS) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
281 { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
282 if (this->hidden != NULL) { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
283 if (this->hidden->mixbuf != NULL) { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
284 SDL_FreeAudioMem(this->hidden->mixbuf); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
285 this->hidden->mixbuf = NULL; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
286 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
287 if (this->hidden->stream) { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
288 PULSEAUDIO_pa_stream_disconnect(this->hidden->stream); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
289 PULSEAUDIO_pa_stream_unref(this->hidden->stream); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
290 this->hidden->stream = NULL; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
291 } |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
292 if (this->hidden->context != NULL) { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
293 PULSEAUDIO_pa_context_disconnect(this->hidden->context); |
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
294 PULSEAUDIO_pa_context_unref(this->hidden->context); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
295 this->hidden->context = NULL; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
296 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
297 if (this->hidden->mainloop != NULL) { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
298 PULSEAUDIO_pa_mainloop_free(this->hidden->mainloop); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
299 this->hidden->mainloop = NULL; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
300 } |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
301 SDL_free(this->hidden); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
302 this->hidden = NULL; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
303 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
304 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
305 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
306 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
307 static int |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
308 PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
309 { |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
310 struct SDL_PrivateAudioData *h = NULL; |
2272
25a87553a59d
Minor PulseAudio fixes: corrected OpenDevice return code, human-readable
Ryan C. Gordon <icculus@icculus.org>
parents:
2271
diff
changeset
|
311 Uint16 test_format = 0; |
25a87553a59d
Minor PulseAudio fixes: corrected OpenDevice return code, human-readable
Ryan C. Gordon <icculus@icculus.org>
parents:
2271
diff
changeset
|
312 pa_sample_spec paspec; |
25a87553a59d
Minor PulseAudio fixes: corrected OpenDevice return code, human-readable
Ryan C. Gordon <icculus@icculus.org>
parents:
2271
diff
changeset
|
313 pa_buffer_attr paattr; |
25a87553a59d
Minor PulseAudio fixes: corrected OpenDevice return code, human-readable
Ryan C. Gordon <icculus@icculus.org>
parents:
2271
diff
changeset
|
314 pa_channel_map pacmap; |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
315 pa_stream_flags_t flags = 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
316 int state = 0; |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
317 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
318 /* Initialize all variables that we clean on shutdown */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
319 this->hidden = (struct SDL_PrivateAudioData *) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
320 SDL_malloc((sizeof *this->hidden)); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
321 if (this->hidden == NULL) { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
322 SDL_OutOfMemory(); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
323 return 0; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
324 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
325 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
326 h = this->hidden; |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
327 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
328 paspec.format = PA_SAMPLE_INVALID; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
329 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
330 /* Try for a closest match on audio format */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
331 for (test_format = SDL_FirstAudioFormat(this->spec.format); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
332 (paspec.format == PA_SAMPLE_INVALID) && test_format;) { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
333 #ifdef DEBUG_AUDIO |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
334 fprintf(stderr, "Trying format 0x%4.4x\n", test_format); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
335 #endif |
2274 | 336 switch (test_format) { |
337 case AUDIO_U8: | |
338 paspec.format = PA_SAMPLE_U8; | |
339 break; | |
340 case AUDIO_S16LSB: | |
341 paspec.format = PA_SAMPLE_S16LE; | |
342 break; | |
343 case AUDIO_S16MSB: | |
344 paspec.format = PA_SAMPLE_S16BE; | |
345 break; | |
346 default: | |
347 paspec.format = PA_SAMPLE_INVALID; | |
348 break; | |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
349 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
350 if (paspec.format == PA_SAMPLE_INVALID) { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
351 test_format = SDL_NextAudioFormat(); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
352 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
353 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
354 if (paspec.format == PA_SAMPLE_INVALID) { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
355 PULSEAUDIO_CloseDevice(this); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
356 SDL_SetError("Couldn't find any hardware audio formats"); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
357 return 0; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
358 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
359 this->spec.format = test_format; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
360 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
361 /* Calculate the final parameters for this audio specification */ |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
362 #ifdef PA_STREAM_ADJUST_LATENCY |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
363 this->spec.samples /= 2; /* Mix in smaller chunck to avoid underruns */ |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
364 #endif |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
365 SDL_CalculateAudioSpec(&this->spec); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
366 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
367 /* Allocate mixing buffer */ |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
368 h->mixlen = this->spec.size; |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
369 h->mixbuf = (Uint8 *) SDL_AllocAudioMem(h->mixlen); |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
370 if (h->mixbuf == NULL) { |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
371 PULSEAUDIO_CloseDevice(this); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
372 SDL_OutOfMemory(); |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
373 return 0; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
374 } |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
375 SDL_memset(h->mixbuf, this->spec.silence, this->spec.size); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
376 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
377 paspec.channels = this->spec.channels; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
378 paspec.rate = this->spec.freq; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
379 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
380 /* Reduced prebuffering compared to the defaults. */ |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
381 #ifdef PA_STREAM_ADJUST_LATENCY |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
382 /* 2x original requested bufsize */ |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
383 paattr.tlength = h->mixlen * 4; |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
384 paattr.prebuf = -1; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
385 paattr.maxlength = -1; |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
386 /* -1 can lead to pa_stream_writable_size() >= mixlen never being true */ |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
387 paattr.minreq = h->mixlen; |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
388 flags = PA_STREAM_ADJUST_LATENCY; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
389 #else |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
390 paattr.tlength = h->mixlen*2; |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
391 paattr.prebuf = h->mixlen*2; |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
392 paattr.maxlength = h->mixlen*2; |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
393 paattr.minreq = h->mixlen; |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
394 #endif |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
395 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
396 /* The SDL ALSA output hints us that we use Windows' channel mapping */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
397 /* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */ |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
398 PULSEAUDIO_pa_channel_map_init_auto(&pacmap, this->spec.channels, |
2274 | 399 PA_CHANNEL_MAP_WAVEEX); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
400 |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
401 /* Set up a new main loop */ |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
402 if (!(h->mainloop = PULSEAUDIO_pa_mainloop_new())) { |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
403 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
404 SDL_SetError("pa_mainloop_new() failed"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
405 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
406 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
407 |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
408 h->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(h->mainloop); |
5082 | 409 h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, NULL); |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
410 if (!h->context) { |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
411 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
412 SDL_SetError("pa_context_new() failed"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
413 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
414 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
415 |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
416 /* Connect to the PulseAudio server */ |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
417 if (PULSEAUDIO_pa_context_connect(h->context, NULL, 0, NULL) < 0) { |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
418 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
419 SDL_SetError("Could not setup connection to PulseAudio"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
420 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
421 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
422 |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
423 do { |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
424 if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
425 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
426 SDL_SetError("pa_mainloop_iterate() failed"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
427 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
428 } |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
429 state = PULSEAUDIO_pa_context_get_state(h->context); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
430 if (!PA_CONTEXT_IS_GOOD(state)) { |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
431 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
432 SDL_SetError("Could not connect to PulseAudio"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
433 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
434 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
435 } while (state != PA_CONTEXT_READY); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
436 |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
437 h->stream = PULSEAUDIO_pa_stream_new( |
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
438 h->context, |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
439 "Simple DirectMedia Layer", /* stream description */ |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
440 &paspec, /* sample format spec */ |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
441 &pacmap /* channel map */ |
2274 | 442 ); |
2272
25a87553a59d
Minor PulseAudio fixes: corrected OpenDevice return code, human-readable
Ryan C. Gordon <icculus@icculus.org>
parents:
2271
diff
changeset
|
443 |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
444 if (h->stream == NULL) { |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
445 PULSEAUDIO_CloseDevice(this); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
446 SDL_SetError("Could not set up PulseAudio stream"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
447 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
448 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
449 |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
450 if (PULSEAUDIO_pa_stream_connect_playback(h->stream, NULL, &paattr, flags, |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
451 NULL, NULL) < 0) { |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
452 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
453 SDL_SetError("Could not connect PulseAudio stream"); |
2272
25a87553a59d
Minor PulseAudio fixes: corrected OpenDevice return code, human-readable
Ryan C. Gordon <icculus@icculus.org>
parents:
2271
diff
changeset
|
454 return 0; |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
455 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
456 |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
457 do { |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
458 if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
459 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
460 SDL_SetError("pa_mainloop_iterate() failed"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
461 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
462 } |
3674
7b597182d06b
Minor cleanups in PulseAudio code, to keep this 80-column-friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
3673
diff
changeset
|
463 state = PULSEAUDIO_pa_stream_get_state(h->stream); |
3672
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
464 if (!PA_STREAM_IS_GOOD(state)) { |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
465 PULSEAUDIO_CloseDevice(this); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
466 SDL_SetError("Could not create to PulseAudio stream"); |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
467 return 0; |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
468 } |
878d8adf2fde
Merged r4210:5510 from branches/SDL-1.2/src/audio/pulse: PulseAudio updates.
Ryan C. Gordon <icculus@icculus.org>
parents:
3068
diff
changeset
|
469 } while (state != PA_STREAM_READY); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
470 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
471 /* We're ready to rock and roll. :-) */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
472 return 1; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
473 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
474 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
475 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
476 static void |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
477 PULSEAUDIO_Deinitialize(void) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
478 { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
479 UnloadPulseAudioLibrary(); |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
480 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
481 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
482 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
483 static int |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
484 PULSEAUDIO_Init(SDL_AudioDriverImpl * impl) |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
485 { |
3673
c9d5bd1b4e18
Attempt to clean up PulseAudio dynamic loading support.
Ryan C. Gordon <icculus@icculus.org>
parents:
3672
diff
changeset
|
486 if (LoadPulseAudioLibrary() < 0) { |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
487 return 0; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
488 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
489 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
490 /* Set the function pointers */ |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
491 impl->OpenDevice = PULSEAUDIO_OpenDevice; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
492 impl->PlayDevice = PULSEAUDIO_PlayDevice; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
493 impl->WaitDevice = PULSEAUDIO_WaitDevice; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
494 impl->GetDeviceBuf = PULSEAUDIO_GetDeviceBuf; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
495 impl->CloseDevice = PULSEAUDIO_CloseDevice; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
496 impl->WaitDone = PULSEAUDIO_WaitDone; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
497 impl->Deinitialize = PULSEAUDIO_Deinitialize; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
498 impl->OnlyHasDefaultOutputDevice = 1; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
499 |
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
|
500 return 1; /* this audio target is available. */ |
2271
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
501 } |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
502 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
503 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
504 AudioBootStrap PULSEAUDIO_bootstrap = { |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
505 PULSEAUDIO_DRIVER_NAME, "PulseAudio", PULSEAUDIO_Init, 0 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
506 }; |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
507 |
60b4c52a7906
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
508 /* vi: set ts=4 sw=4 expandtab: */ |