Line
Link Here
|
0 |
-- SDL-1.2.13/src/audio/pulse/SDL_pulseaudio.c |
0 |
++ SDL-1.2.13/src/audio/pulse/SDL_pulseaudio.c |
Lines 1-3
Link Here
|
|
|
1 |
/* -*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*- */ |
1 |
/* |
2 |
/* |
2 |
SDL - Simple DirectMedia Layer |
3 |
SDL - Simple DirectMedia Layer |
3 |
Copyright (C) 1997-2007 Sam Lantinga |
4 |
Copyright (C) 1997-2007 Sam Lantinga |
Lines 18-24
Link Here
|
18 |
|
19 |
|
19 |
Stéphan Kochen |
20 |
Stéphan Kochen |
20 |
stephan@kochen.nl |
21 |
stephan@kochen.nl |
21 |
|
22 |
|
22 |
Based on parts of the ALSA and ESounD output drivers. |
23 |
Based on parts of the ALSA and ESounD output drivers. |
23 |
*/ |
24 |
*/ |
24 |
#include "SDL_config.h" |
25 |
#include "SDL_config.h" |
Lines 78-91
static int (*SDL_NAME(pa_simple_write))(
Link Here
|
78 |
pa_simple *s, |
79 |
pa_simple *s, |
79 |
const void *data, |
80 |
const void *data, |
80 |
size_t length, |
81 |
size_t length, |
81 |
int *error |
82 |
int *error |
82 |
); |
83 |
); |
83 |
static pa_channel_map* (*SDL_NAME(pa_channel_map_init_auto))( |
84 |
static pa_channel_map* (*SDL_NAME(pa_channel_map_init_auto))( |
84 |
pa_channel_map *m, |
85 |
pa_channel_map *m, |
85 |
unsigned channels, |
86 |
unsigned channels, |
86 |
pa_channel_map_def_t def |
87 |
pa_channel_map_def_t def |
87 |
); |
88 |
); |
88 |
|
89 |
|
89 |
|
90 |
|
90 |
static struct { |
91 |
static struct { |
91 |
const char *name; |
92 |
const char *name; |
Lines 158-173
static int Audio_Available(void)
Link Here
|
158 |
if ( LoadPulseLibrary() < 0 ) { |
159 |
if ( LoadPulseLibrary() < 0 ) { |
159 |
return available; |
160 |
return available; |
160 |
} |
161 |
} |
161 |
|
162 |
|
162 |
/* Connect with a dummy format. */ |
163 |
/* Connect with a dummy format. */ |
163 |
paspec.format = PA_SAMPLE_U8; |
164 |
paspec.format = PA_SAMPLE_U8; |
164 |
paspec.rate = 11025; |
165 |
paspec.rate = 11025; |
165 |
paspec.channels = 1; |
166 |
paspec.channels = 1; |
166 |
connection = SDL_NAME(pa_simple_new)( |
167 |
connection = SDL_NAME(pa_simple_new)( |
167 |
SDL_getenv("PASERVER"), /* server */ |
168 |
NULL, /* server */ |
168 |
"Test stream", /* application name */ |
169 |
"Test stream", /* application name */ |
169 |
PA_STREAM_PLAYBACK, /* playback mode */ |
170 |
PA_STREAM_PLAYBACK, /* playback mode */ |
170 |
SDL_getenv("PADEVICE"), /* device on the server */ |
171 |
NULL, /* device on the server */ |
171 |
"Simple DirectMedia Layer", /* stream description */ |
172 |
"Simple DirectMedia Layer", /* stream description */ |
172 |
&paspec, /* sample format spec */ |
173 |
&paspec, /* sample format spec */ |
173 |
NULL, /* channel map */ |
174 |
NULL, /* channel map */ |
Lines 178-184
static int Audio_Available(void)
Link Here
|
178 |
available = 1; |
179 |
available = 1; |
179 |
SDL_NAME(pa_simple_free)(connection); |
180 |
SDL_NAME(pa_simple_free)(connection); |
180 |
} |
181 |
} |
181 |
|
182 |
|
182 |
UnloadPulseLibrary(); |
183 |
UnloadPulseLibrary(); |
183 |
return(available); |
184 |
return(available); |
184 |
} |
185 |
} |
Lines 233-239
static void PULSE_WaitAudio(_THIS)
Link Here
|
233 |
{ |
234 |
{ |
234 |
/* Check to see if the thread-parent process is still alive */ |
235 |
/* Check to see if the thread-parent process is still alive */ |
235 |
{ static int cnt = 0; |
236 |
{ static int cnt = 0; |
236 |
/* Note that this only works with thread implementations |
237 |
/* Note that this only works with thread implementations |
237 |
that use a different process id for each thread. |
238 |
that use a different process id for each thread. |
238 |
*/ |
239 |
*/ |
239 |
if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */ |
240 |
if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */ |
Lines 302-308
static int PULSE_OpenAudio(_THIS, SDL_Au
Link Here
|
302 |
pa_sample_spec paspec; |
303 |
pa_sample_spec paspec; |
303 |
pa_buffer_attr paattr; |
304 |
pa_buffer_attr paattr; |
304 |
pa_channel_map pacmap; |
305 |
pa_channel_map pacmap; |
305 |
|
306 |
|
306 |
paspec.format = PA_SAMPLE_INVALID; |
307 |
paspec.format = PA_SAMPLE_INVALID; |
307 |
for ( test_format = SDL_FirstAudioFormat(spec->format); test_format; ) { |
308 |
for ( test_format = SDL_FirstAudioFormat(spec->format); test_format; ) { |
308 |
switch ( test_format ) { |
309 |
switch ( test_format ) { |
Lines 324-330
static int PULSE_OpenAudio(_THIS, SDL_Au
Link Here
|
324 |
return(-1); |
325 |
return(-1); |
325 |
} |
326 |
} |
326 |
spec->format = test_format; |
327 |
spec->format = test_format; |
327 |
|
328 |
|
328 |
paspec.channels = spec->channels; |
329 |
paspec.channels = spec->channels; |
329 |
paspec.rate = spec->freq; |
330 |
paspec.rate = spec->freq; |
330 |
|
331 |
|
Lines 338-362
static int PULSE_OpenAudio(_THIS, SDL_Au
Link Here
|
338 |
return(-1); |
339 |
return(-1); |
339 |
} |
340 |
} |
340 |
SDL_memset(mixbuf, spec->silence, spec->size); |
341 |
SDL_memset(mixbuf, spec->silence, spec->size); |
341 |
|
342 |
|
342 |
/* Reduced prebuffering compared to the defaults. */ |
343 |
/* Reduced prebuffering compared to the defaults. */ |
343 |
paattr.tlength = mixlen; |
344 |
paattr.tlength = mixlen*2; |
344 |
paattr.minreq = mixlen; |
345 |
paattr.minreq = mixlen; |
345 |
paattr.fragsize = mixlen; |
346 |
paattr.prebuf = mixlen*2; |
346 |
paattr.prebuf = mixlen; |
347 |
paattr.maxlength = mixlen*2; |
347 |
paattr.maxlength = mixlen * 4; |
348 |
|
348 |
|
|
|
349 |
/* The SDL ALSA output hints us that we use Windows' channel mapping */ |
349 |
/* The SDL ALSA output hints us that we use Windows' channel mapping */ |
350 |
/* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */ |
350 |
/* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */ |
351 |
SDL_NAME(pa_channel_map_init_auto)( |
351 |
SDL_NAME(pa_channel_map_init_auto)( |
352 |
&pacmap, spec->channels, PA_CHANNEL_MAP_WAVEEX); |
352 |
&pacmap, spec->channels, PA_CHANNEL_MAP_WAVEEX); |
353 |
|
353 |
|
354 |
/* Connect to the PulseAudio server */ |
354 |
/* Connect to the PulseAudio server */ |
355 |
stream = SDL_NAME(pa_simple_new)( |
355 |
stream = SDL_NAME(pa_simple_new)( |
356 |
SDL_getenv("PASERVER"), /* server */ |
356 |
NULL, /* server */ |
357 |
get_progname(), /* application name */ |
357 |
get_progname(), /* application name */ |
358 |
PA_STREAM_PLAYBACK, /* playback mode */ |
358 |
PA_STREAM_PLAYBACK, /* playback mode */ |
359 |
SDL_getenv("PADEVICE"), /* device on the server */ |
359 |
NULL, /* device on the server */ |
360 |
"Simple DirectMedia Layer", /* stream description */ |
360 |
"Simple DirectMedia Layer", /* stream description */ |
361 |
&paspec, /* sample format spec */ |
361 |
&paspec, /* sample format spec */ |
362 |
&pacmap, /* channel map */ |
362 |
&pacmap, /* channel map */ |
Lines 371-377
static int PULSE_OpenAudio(_THIS, SDL_Au
Link Here
|
371 |
|
371 |
|
372 |
/* Get the parent process id (we're the parent of the audio thread) */ |
372 |
/* Get the parent process id (we're the parent of the audio thread) */ |
373 |
parent = getpid(); |
373 |
parent = getpid(); |
374 |
|
374 |
|
375 |
return(0); |
375 |
return(0); |
376 |
} |
376 |
} |
377 |
|
|
|