2006-02-16 23:11:28 +00:00
|
|
|
#ifndef foointernalhfoo
|
|
|
|
|
#define foointernalhfoo
|
2004-08-14 20:25:32 +00:00
|
|
|
|
2004-08-13 13:24:48 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2004-11-14 14:58:54 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2004-08-13 13:24:48 +00:00
|
|
|
by the Free Software Foundation; either version 2 of the License,
|
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2004-08-13 13:24:48 +00:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
2004-11-14 14:58:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2006-06-19 21:53:48 +00:00
|
|
|
along with PulseAudio; if not, write to the Free Software
|
2004-08-13 13:24:48 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/mainloop-api.h>
|
|
|
|
|
#include <pulse/context.h>
|
|
|
|
|
#include <pulse/stream.h>
|
|
|
|
|
#include <pulse/operation.h>
|
|
|
|
|
#include <pulse/subscribe.h>
|
2006-02-17 12:10:58 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/socket-client.h>
|
|
|
|
|
#include <pulsecore/pstream.h>
|
|
|
|
|
#include <pulsecore/pdispatch.h>
|
|
|
|
|
#include <pulsecore/dynarray.h>
|
|
|
|
|
#include <pulsecore/llist.h>
|
|
|
|
|
#include <pulsecore/native-common.h>
|
|
|
|
|
#include <pulsecore/strlist.h>
|
|
|
|
|
#include <pulsecore/mcalign.h>
|
|
|
|
|
#include <pulsecore/memblockq.h>
|
|
|
|
|
#include <pulsecore/hashmap.h>
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-02-17 12:10:58 +00:00
|
|
|
#include "client-conf.h"
|
|
|
|
|
|
2006-08-27 13:04:56 +00:00
|
|
|
#define DEFAULT_TIMEOUT (30)
|
2004-08-13 13:24:48 +00:00
|
|
|
|
|
|
|
|
struct pa_context {
|
2004-08-14 20:25:32 +00:00
|
|
|
int ref;
|
|
|
|
|
|
2004-08-13 13:24:48 +00:00
|
|
|
char *name;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_mainloop_api* mainloop;
|
2004-08-14 20:25:32 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_socket_client *client;
|
|
|
|
|
pa_pstream *pstream;
|
|
|
|
|
pa_pdispatch *pdispatch;
|
2004-08-14 20:25:32 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_dynarray *record_streams, *playback_streams;
|
|
|
|
|
PA_LLIST_HEAD(pa_stream, streams);
|
|
|
|
|
PA_LLIST_HEAD(pa_operation, operations);
|
2006-02-20 04:05:16 +00:00
|
|
|
|
2006-03-02 21:56:15 +00:00
|
|
|
uint32_t version;
|
2004-08-13 13:24:48 +00:00
|
|
|
uint32_t ctag;
|
2006-02-20 04:05:16 +00:00
|
|
|
uint32_t csyncid;
|
2004-08-13 13:24:48 +00:00
|
|
|
uint32_t error;
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_context_state_t state;
|
2006-02-20 16:01:53 +00:00
|
|
|
|
|
|
|
|
pa_context_notify_cb_t state_callback;
|
2004-08-14 20:25:32 +00:00
|
|
|
void *state_userdata;
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-02-20 17:09:39 +00:00
|
|
|
pa_context_subscribe_cb_t subscribe_callback;
|
2004-08-13 13:24:48 +00:00
|
|
|
void *subscribe_userdata;
|
2004-08-17 19:37:29 +00:00
|
|
|
|
2006-08-18 19:55:18 +00:00
|
|
|
pa_mempool *mempool;
|
2004-09-15 19:16:57 +00:00
|
|
|
|
2006-08-18 23:45:23 +00:00
|
|
|
int is_local;
|
2004-11-11 21:18:33 +00:00
|
|
|
int do_autospawn;
|
|
|
|
|
int autospawn_lock_fd;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_spawn_api spawn_api;
|
2004-11-11 21:18:33 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_strlist *server_list;
|
2004-09-17 19:45:44 +00:00
|
|
|
|
2004-11-17 00:05:25 +00:00
|
|
|
char *server;
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_client_conf *conf;
|
2004-08-13 13:24:48 +00:00
|
|
|
};
|
|
|
|
|
|
2006-04-12 17:17:23 +00:00
|
|
|
#define PA_MAX_WRITE_INDEX_CORRECTIONS 10
|
2006-04-07 00:24:48 +00:00
|
|
|
|
2006-04-12 17:17:23 +00:00
|
|
|
typedef struct pa_index_correction {
|
2006-04-07 00:24:48 +00:00
|
|
|
uint32_t tag;
|
|
|
|
|
int valid;
|
|
|
|
|
int64_t value;
|
|
|
|
|
int absolute, corrupt;
|
2006-04-12 17:17:23 +00:00
|
|
|
} pa_index_correction;
|
2006-04-07 00:24:48 +00:00
|
|
|
|
2004-08-13 13:24:48 +00:00
|
|
|
struct pa_stream {
|
2004-08-14 20:25:32 +00:00
|
|
|
int ref;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_context *context;
|
|
|
|
|
pa_mainloop_api *mainloop;
|
|
|
|
|
PA_LLIST_FIELDS(pa_stream);
|
2004-08-13 13:24:48 +00:00
|
|
|
|
|
|
|
|
char *name;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_buffer_attr buffer_attr;
|
|
|
|
|
pa_sample_spec sample_spec;
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_channel_map channel_map;
|
2006-04-07 00:24:48 +00:00
|
|
|
pa_stream_flags_t flags;
|
2004-08-13 13:24:48 +00:00
|
|
|
uint32_t channel;
|
2006-02-20 04:05:16 +00:00
|
|
|
uint32_t syncid;
|
2004-08-13 13:24:48 +00:00
|
|
|
int channel_valid;
|
|
|
|
|
uint32_t device_index;
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_stream_direction_t direction;
|
|
|
|
|
pa_stream_state_t state;
|
2006-04-07 00:24:48 +00:00
|
|
|
|
|
|
|
|
uint32_t requested_bytes;
|
|
|
|
|
|
2006-02-17 15:42:47 +00:00
|
|
|
pa_memchunk peek_memchunk;
|
|
|
|
|
pa_memblockq *record_memblockq;
|
2004-08-14 20:25:32 +00:00
|
|
|
|
2004-10-27 00:10:12 +00:00
|
|
|
int corked;
|
|
|
|
|
|
2006-04-07 00:24:48 +00:00
|
|
|
/* Store latest latency info */
|
2006-04-07 01:29:33 +00:00
|
|
|
pa_timing_info timing_info;
|
|
|
|
|
int timing_info_valid;
|
2006-04-07 00:24:48 +00:00
|
|
|
|
|
|
|
|
/* Use to make sure that time advances monotonically */
|
|
|
|
|
pa_usec_t previous_time;
|
|
|
|
|
|
2006-04-12 17:17:23 +00:00
|
|
|
/* time updates with tags older than these are invalid */
|
|
|
|
|
uint32_t write_index_not_before;
|
|
|
|
|
uint32_t read_index_not_before;
|
|
|
|
|
|
|
|
|
|
/* Data about individual timing update correctoins */
|
|
|
|
|
pa_index_correction write_index_corrections[PA_MAX_WRITE_INDEX_CORRECTIONS];
|
|
|
|
|
int current_write_index_correction;
|
2006-04-07 00:24:48 +00:00
|
|
|
|
|
|
|
|
/* Latency interpolation stuff */
|
2006-04-12 17:17:23 +00:00
|
|
|
pa_time_event *auto_timing_update_event;
|
|
|
|
|
int auto_timing_update_requested;
|
|
|
|
|
|
2006-06-19 12:37:43 +00:00
|
|
|
pa_usec_t cached_time;
|
|
|
|
|
int cached_time_valid;
|
2006-04-07 00:24:48 +00:00
|
|
|
|
|
|
|
|
/* Callbacks */
|
2006-02-20 04:05:16 +00:00
|
|
|
pa_stream_notify_cb_t state_callback;
|
2004-08-14 20:25:32 +00:00
|
|
|
void *state_userdata;
|
2006-02-20 04:05:16 +00:00
|
|
|
pa_stream_request_cb_t read_callback;
|
2004-08-13 13:24:48 +00:00
|
|
|
void *read_userdata;
|
2006-02-20 04:05:16 +00:00
|
|
|
pa_stream_request_cb_t write_callback;
|
2004-08-13 13:24:48 +00:00
|
|
|
void *write_userdata;
|
2006-02-20 04:05:16 +00:00
|
|
|
pa_stream_notify_cb_t overflow_callback;
|
|
|
|
|
void *overflow_userdata;
|
|
|
|
|
pa_stream_notify_cb_t underflow_callback;
|
|
|
|
|
void *underflow_userdata;
|
2006-05-15 20:17:11 +00:00
|
|
|
pa_stream_notify_cb_t latency_update_callback;
|
|
|
|
|
void *latency_update_userdata;
|
2004-08-13 13:24:48 +00:00
|
|
|
};
|
|
|
|
|
|
2006-02-20 22:41:02 +00:00
|
|
|
typedef void (*pa_operation_cb_t)(void);
|
2006-01-11 01:17:39 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
struct pa_operation {
|
|
|
|
|
int ref;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_context *context;
|
|
|
|
|
pa_stream *stream;
|
2006-04-24 19:29:15 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
PA_LLIST_FIELDS(pa_operation);
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_operation_state_t state;
|
2004-08-14 20:25:32 +00:00
|
|
|
void *userdata;
|
2006-02-20 22:41:02 +00:00
|
|
|
pa_operation_cb_t callback;
|
2004-08-13 13:24:48 +00:00
|
|
|
};
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
|
|
|
|
void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
|
|
|
|
void pa_command_subscribe_event(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
2006-02-20 04:05:16 +00:00
|
|
|
void pa_command_overflow_or_underflow(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-02-20 22:41:02 +00:00
|
|
|
pa_operation *pa_operation_new(pa_context *c, pa_stream *s, pa_operation_cb_t callback, void *userdata);
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_operation_done(pa_operation *o);
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
|
|
|
|
void pa_stream_disconnect_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
|
|
|
|
void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
|
|
|
|
void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_context_fail(pa_context *c, int error);
|
2006-02-20 04:05:16 +00:00
|
|
|
int pa_context_set_error(pa_context *c, int error);
|
2006-01-27 16:25:31 +00:00
|
|
|
void pa_context_set_state(pa_context *c, pa_context_state_t st);
|
2006-01-11 01:17:39 +00:00
|
|
|
int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t);
|
|
|
|
|
pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, void (*internal_callback)(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata), void (*cb)(void), void *userdata);
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-01-27 16:25:31 +00:00
|
|
|
void pa_stream_set_state(pa_stream *s, pa_stream_state_t st);
|
2004-08-13 13:24:48 +00:00
|
|
|
|
2006-02-23 01:24:16 +00:00
|
|
|
pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *tag);
|
|
|
|
|
|
2006-02-20 04:05:16 +00:00
|
|
|
#define PA_CHECK_VALIDITY(context, expression, error) do { \
|
|
|
|
|
if (!(expression)) \
|
|
|
|
|
return -pa_context_set_error((context), (error)); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define PA_CHECK_VALIDITY_RETURN_ANY(context, expression, error, value) do { \
|
|
|
|
|
if (!(expression)) { \
|
|
|
|
|
pa_context_set_error((context), (error)); \
|
|
|
|
|
return value; \
|
|
|
|
|
} \
|
|
|
|
|
} while(0)
|
2004-10-27 00:10:12 +00:00
|
|
|
|
2006-02-20 22:41:02 +00:00
|
|
|
#define PA_CHECK_VALIDITY_RETURN_NULL(context, expression, error) PA_CHECK_VALIDITY_RETURN_ANY(context, expression, error, NULL)
|
|
|
|
|
|
|
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
#endif
|