1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/drivers/audio_pulse.c Wed Apr 16 10:12:12 2008 +0000
1.5 + * $Id: audio_pulse.c 661 2008-02-26 01:10:48Z bhaal22 $
1.7 + * The pulseaudio sound driver
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.22 +#include <unistd.h>
1.23 +#include <pulse/simple.h>
1.24 +#include "aica/audio.h"
1.25 +#include "lxdream.h"
1.27 +static pa_simple *pulse_server = NULL;
1.29 +gboolean audio_pulse_init()
1.34 +gboolean audio_pulse_set_format( uint32_t rate, uint32_t format )
1.36 + pa_sample_spec ss;
1.38 + if( pulse_server != NULL ) {
1.39 + pa_simple_free(pulse_server);
1.43 + if( format & AUDIO_FMT_16BIT ) {
1.44 + ss.format = PA_SAMPLE_S16NE;
1.46 + ss.format = PA_SAMPLE_U8;
1.49 + if( format & AUDIO_FMT_STEREO ) {
1.55 + pulse_server = pa_simple_new(NULL, APP_NAME, PA_STREAM_PLAYBACK,
1.56 + NULL, "Audio", &ss, NULL, NULL, NULL);
1.57 + if( pulse_server == NULL ) {
1.58 + ERROR( "Unable to open audio output (pulseaudio)" );
1.64 +gboolean audio_pulse_process_buffer( audio_buffer_t buffer )
1.66 + if( pulse_server != NULL ) {
1.68 + pa_simple_write( pulse_server, buffer->data, buffer->length, &error );
1.71 + ERROR( "Pulseaudio not initialized" );
1.76 +gboolean audio_pulse_close()
1.78 + pa_simple_free(pulse_server);
1.79 + pulse_server = NULL;
1.83 +struct audio_driver audio_pulse_driver = { "pulse",
1.85 + audio_pulse_set_format,
1.86 + audio_pulse_process_buffer,
1.87 + audio_pulse_close};