LiVES 1.3.11-svn
|
00001 // pulse.h 00002 // LiVES (lives-exe) 00003 // (c) G. Finch 2005 - 2009 00004 // Released under the GPL 3 or later 00005 // see file ../COPYING for licensing details 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 // app side 00041 glong in_arate; 00042 gulong in_achans; 00043 gulong in_asamps; 00044 00045 // server side 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 /* variables used for trying to restart the connection to pulse */ 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 volatile int astream_fd; 00103 00104 } pulse_driver_t; 00105 00106 00107 00108 // TODO - rationalise names 00109 00110 gboolean lives_pulse_init (short startup_phase); 00111 00112 int pulse_audio_init(void); 00113 int pulse_audio_read_init(void); // ditto 00114 00115 pulse_driver_t *pulse_get_driver(gboolean is_output); 00116 00117 int pulse_driver_activate(pulse_driver_t *); 00118 void pulse_close_client(pulse_driver_t *); 00119 00120 void pulse_shutdown(void); 00121 00122 void pulse_flush_read_data(pulse_driver_t *, size_t rbytes, void *data); 00123 00124 void pulse_driver_uncork(pulse_driver_t *); 00125 00126 // utils 00127 volatile aserver_message_t *pulse_get_msgq(pulse_driver_t *); 00128 00129 long pulse_audio_seek_bytes (pulse_driver_t *, long bytes); 00130 00131 gint64 lives_pulse_get_time(pulse_driver_t *, gboolean absolute); 00132 00133 gdouble lives_pulse_get_pos(pulse_driver_t *); 00134 00135 00137 00138 void pulse_audio_seek_frame (pulse_driver_t *, gint frame); 00139 00140 void pulse_get_rec_avals(pulse_driver_t *); 00141 00142 00143 00144 #endif