]> code.delx.au - pulseaudio/blob - polyp/polyplib-internal.h
Make the whole stuff LGPL only
[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
39 #define DEFAULT_TLENGTH (44100*2*2/2) //(10240*8)
40 #define DEFAULT_MAXLENGTH ((DEFAULT_TLENGTH*3)/2)
41 #define DEFAULT_MINREQ 512
42 #define DEFAULT_PREBUF (DEFAULT_TLENGTH-DEFAULT_MINREQ)
43 #define DEFAULT_FRAGSIZE 1024
44
45 #define DEFAULT_TIMEOUT (10)
46
47 struct pa_context {
48 int ref;
49
50 char *name;
51 struct pa_mainloop_api* mainloop;
52
53 struct pa_socket_client *client;
54 struct pa_pstream *pstream;
55 struct pa_pdispatch *pdispatch;
56
57 struct pa_dynarray *record_streams, *playback_streams;
58 PA_LLIST_HEAD(struct pa_stream, streams);
59 PA_LLIST_HEAD(struct pa_operation, operations);
60
61 uint32_t ctag;
62 uint32_t error;
63 enum pa_context_state state;
64
65 void (*state_callback)(struct pa_context*c, void *userdata);
66 void *state_userdata;
67
68 void (*subscribe_callback)(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata);
69 void *subscribe_userdata;
70
71 struct pa_memblock_stat *memblock_stat;
72
73 int local;
74 int do_autospawn;
75 int autospawn_lock_fd;
76 struct pa_spawn_api spawn_api;
77
78 struct pa_strlist *server_list;
79
80 struct pa_client_conf *conf;
81 };
82
83 struct pa_stream {
84 int ref;
85 struct pa_context *context;
86 struct pa_mainloop_api *mainloop;
87 PA_LLIST_FIELDS(struct pa_stream);
88
89 char *name;
90 struct pa_buffer_attr buffer_attr;
91 struct pa_sample_spec sample_spec;
92 uint32_t channel;
93 int channel_valid;
94 uint32_t device_index;
95 enum pa_stream_direction direction;
96 uint32_t requested_bytes;
97 uint64_t counter;
98 pa_usec_t previous_time;
99 enum pa_stream_state state;
100
101 int interpolate;
102 int corked;
103
104 uint32_t ipol_usec;
105 struct timeval ipol_timestamp;
106 struct pa_time_event *ipol_event;
107
108 void (*state_callback)(struct pa_stream*c, void *userdata);
109 void *state_userdata;
110
111 void (*read_callback)(struct pa_stream *p, const void*data, size_t length, void *userdata);
112 void *read_userdata;
113
114 void (*write_callback)(struct pa_stream *p, size_t length, void *userdata);
115 void *write_userdata;
116 };
117
118 struct pa_operation {
119 int ref;
120 struct pa_context *context;
121 struct pa_stream *stream;
122 PA_LLIST_FIELDS(struct pa_operation);
123
124 enum pa_operation_state state;
125 void *userdata;
126 void (*callback)();
127 };
128
129 void pa_command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
130 void pa_command_stream_killed(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
131 void pa_command_subscribe_event(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
132
133 struct pa_operation *pa_operation_new(struct pa_context *c, struct pa_stream *s);
134 void pa_operation_done(struct pa_operation *o);
135
136 void pa_create_stream_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
137 void pa_stream_disconnect_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
138 void pa_context_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
139 void pa_stream_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
140
141 void pa_context_fail(struct pa_context *c, int error);
142 void pa_context_set_state(struct pa_context *c, enum pa_context_state st);
143 int pa_context_handle_error(struct pa_context *c, uint32_t command, struct pa_tagstruct *t);
144 struct pa_operation* pa_context_send_simple_command(struct pa_context *c, uint32_t command, void (*internal_callback)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata), void (*cb)(), void *userdata);
145
146 void pa_stream_set_state(struct pa_stream *s, enum pa_stream_state st);
147
148 void pa_stream_trash_ipol(struct pa_stream *s);
149
150
151 #endif