]> code.delx.au - pulseaudio/blob - polyp/polyplib-internal.h
add simple hardware auto detection module
[pulseaudio] / polyp / polyplib-internal.h
1 #ifndef foopolyplibinternalhfoo
2 #define foopolyplibinternalhfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of polypaudio.
8
9 polypaudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
13
14 polypaudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with polypaudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include "mainloop-api.h"
26 #include "socket-client.h"
27 #include "pstream.h"
28 #include "pdispatch.h"
29 #include "dynarray.h"
30
31 #include "polyplib-context.h"
32 #include "polyplib-stream.h"
33 #include "polyplib-operation.h"
34 #include "llist.h"
35 #include "native-common.h"
36 #include "client-conf.h"
37 #include "strlist.h"
38 #include "mcalign.h"
39
40 #define DEFAULT_TIMEOUT (10)
41
42 struct pa_context {
43 int ref;
44
45 char *name;
46 pa_mainloop_api* mainloop;
47
48 pa_socket_client *client;
49 pa_pstream *pstream;
50 pa_pdispatch *pdispatch;
51
52 pa_dynarray *record_streams, *playback_streams;
53 PA_LLIST_HEAD(pa_stream, streams);
54 PA_LLIST_HEAD(pa_operation, operations);
55
56 uint32_t ctag;
57 uint32_t error;
58 pa_context_state_t state;
59
60 void (*state_callback)(pa_context*c, void *userdata);
61 void *state_userdata;
62
63 void (*subscribe_callback)(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata);
64 void *subscribe_userdata;
65
66 pa_memblock_stat *memblock_stat;
67
68 int local;
69 int do_autospawn;
70 int autospawn_lock_fd;
71 pa_spawn_api spawn_api;
72
73 pa_strlist *server_list;
74
75 char *server;
76
77 pa_client_conf *conf;
78 };
79
80 struct pa_stream {
81 int ref;
82 pa_context *context;
83 pa_mainloop_api *mainloop;
84 PA_LLIST_FIELDS(pa_stream);
85
86 char *name;
87 pa_buffer_attr buffer_attr;
88 pa_sample_spec sample_spec;
89 pa_channel_map channel_map;
90 uint32_t channel;
91 int channel_valid;
92 uint32_t device_index;
93 pa_stream_direction_t direction;
94 uint32_t requested_bytes;
95 uint64_t counter;
96 pa_usec_t previous_time;
97 pa_usec_t previous_ipol_time;
98 pa_stream_state_t state;
99 pa_mcalign *mcalign;
100
101 int interpolate;
102 int corked;
103
104 uint32_t ipol_usec;
105 struct timeval ipol_timestamp;
106 pa_time_event *ipol_event;
107 int ipol_requested;
108
109 void (*state_callback)(pa_stream*c, void *userdata);
110 void *state_userdata;
111
112 void (*read_callback)(pa_stream *p, const void*data, size_t length, void *userdata);
113 void *read_userdata;
114
115 void (*write_callback)(pa_stream *p, size_t length, void *userdata);
116 void *write_userdata;
117 };
118
119 typedef void (*pa_operation_callback)(void);
120
121 struct pa_operation {
122 int ref;
123 pa_context *context;
124 pa_stream *stream;
125 PA_LLIST_FIELDS(pa_operation);
126
127 pa_operation_state_t state;
128 void *userdata;
129 pa_operation_callback callback;
130 };
131
132 void pa_command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
133 void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
134 void pa_command_subscribe_event(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
135
136 pa_operation *pa_operation_new(pa_context *c, pa_stream *s);
137 void pa_operation_done(pa_operation *o);
138
139 void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
140 void pa_stream_disconnect_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
141 void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
142 void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
143
144 void pa_context_fail(pa_context *c, int error);
145 void pa_context_set_state(pa_context *c, pa_context_state_t st);
146 int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t);
147 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);
148
149 void pa_stream_set_state(pa_stream *s, pa_stream_state_t st);
150
151 void pa_stream_trash_ipol(pa_stream *s);
152
153
154 #endif