00001
00002
00003
00004
00005
00006
00007 #ifdef HAVE_PULSE_AUDIO
00008
00009 #include <pulse/context.h>
00010 #include <pulse/thread-mainloop.h>
00011 #include <pulse/introspect.h>
00012 #include <pulse/stream.h>
00013 #include <pulse/proplist.h>
00014 #include <pulse/error.h>
00015
00016 #include "audio.h"
00017
00018
00019 #define PULSE_MAX_OUTPUT_CHANS PA_CHANNEL_POSITION_MAX
00020
00021 #define LIVES_PA_BUFF_MAXLEN 16384
00022 #define LIVES_PA_BUFF_TARGET 4096
00023
00024 typedef struct {
00025 size_t size;
00026 void *data;
00027 } audio_buffer_t;
00028
00029
00030 typedef struct {
00031 pa_threaded_mainloop *mloop;
00032 pa_context *con;
00033 pa_stream *pstream;
00034 pa_proplist *pa_props;
00035
00036 int str_idx;
00037
00038 pa_context_state_t state;
00039
00040
00041 glong in_arate;
00042 gulong in_achans;
00043 gulong in_asamps;
00044
00045
00046 glong out_arate;
00047 gulong out_achans;
00048 gulong out_asamps;
00049
00050 gulong out_chans_available;
00051
00052 int in_signed;
00053 int in_endian;
00054
00055 int out_signed;
00056 int out_endian;
00057
00058 gulong num_calls;
00060 audio_buffer_t* aPlayPtr;
00061 lives_audio_loop_t loop;
00062
00063 guchar* sound_buffer;
00064
00065 float volume[PULSE_MAX_OUTPUT_CHANS];
00066
00067 gboolean in_use;
00068 gboolean mute;
00069
00071 volatile aserver_message_t *msgq;
00072
00073 gulong frames_written;
00074
00075 gboolean is_paused;
00076
00077 gint64 audio_ticks;
00078
00079 int fd;
00080 gboolean is_opening;
00081 volatile off_t seek_pos;
00082 off_t seek_end;
00083 gboolean usigned;
00084 gboolean reverse_endian;
00085
00086 lives_whentostop_t *whentostop;
00087 volatile lives_cancel_t *cancelled;
00088
00089
00090 gboolean pulsed_died;
00091 struct timeval last_reconnect_attempt;
00092
00093 gboolean is_output;
00094
00095 gint playing_file;
00096
00097 lives_audio_buf_t **abufs;
00098 volatile gint read_abuf;
00099
00100 gulong chunk_size;
00101
00102
00103 } pulse_driver_t;
00104
00105
00106
00107
00108
00109 gboolean lives_pulse_init (short startup_phase);
00110
00111 int pulse_audio_init(void);
00112 int pulse_audio_read_init(void);
00113
00114 pulse_driver_t *pulse_get_driver(gboolean is_output);
00115
00116 int pulse_driver_activate(pulse_driver_t *);
00117 void pulse_close_client(pulse_driver_t *);
00118
00119 void pulse_shutdown(void);
00120
00121 void pulse_flush_read_data(pulse_driver_t *, size_t rbytes, void *data);
00122
00123 void pulse_driver_uncork(pulse_driver_t *);
00124
00125
00126 volatile aserver_message_t *pulse_get_msgq(pulse_driver_t *);
00127
00128 long pulse_audio_seek_bytes (pulse_driver_t *, long bytes);
00129
00130 gint64 lives_pulse_get_time(pulse_driver_t *, gboolean absolute);
00131
00132 gdouble lives_pulse_get_pos(pulse_driver_t *);
00133
00134
00136
00137 void pulse_audio_seek_frame (pulse_driver_t *, gint frame);
00138
00139 void pulse_get_rec_avals(pulse_driver_t *);
00140
00141
00142
00143 #endif