]> code.delx.au - pulseaudio/blob - polyp/polyplib-internal.h
daemon auto spawn
[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 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 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
37 #define DEFAULT_TLENGTH (10240*8)
38 #define DEFAULT_MAXLENGTH ((DEFAULT_TLENGTH*3)/2)
39 #define DEFAULT_PREBUF DEFAULT_TLENGTH
40 #define DEFAULT_MINREQ 512
41 #define DEFAULT_FRAGSIZE 1024
42
43 #define DEFAULT_TIMEOUT (5*60)
44 #define DEFAULT_SERVER "/tmp/polypaudio/native"
45 #define DEFAULT_PORT "4713"
46
47 #define ENV_DEFAULT_SINK "POLYP_SINK"
48 #define ENV_DEFAULT_SOURCE "POLYP_SOURCE"
49 #define ENV_DEFAULT_SERVER "POLYP_SERVER"
50 #define ENV_DEFAULT_BINARY "POLYP_BINARY"
51
52 struct pa_context {
53 int ref;
54
55 char *name;
56 struct pa_mainloop_api* mainloop;
57
58 struct pa_socket_client *client;
59 struct pa_pstream *pstream;
60 struct pa_pdispatch *pdispatch;
61
62 struct pa_dynarray *record_streams, *playback_streams;
63 PA_LLIST_HEAD(struct pa_stream, streams);
64 PA_LLIST_HEAD(struct pa_operation, operations);
65
66 uint32_t ctag;
67 uint32_t error;
68 enum pa_context_state state;
69
70 uint8_t auth_cookie[PA_NATIVE_COOKIE_LENGTH];
71
72 void (*state_callback)(struct pa_context*c, void *userdata);
73 void *state_userdata;
74
75 void (*subscribe_callback)(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata);
76 void *subscribe_userdata;
77
78 struct pa_memblock_stat *memblock_stat;
79 };
80
81 struct pa_stream {
82 int ref;
83 struct pa_context *context;
84 PA_LLIST_FIELDS(struct pa_stream);
85
86 char *name;
87 struct pa_buffer_attr buffer_attr;
88 struct pa_sample_spec sample_spec;
89 uint32_t channel;
90 int channel_valid;
91 uint32_t device_index;
92 enum pa_stream_direction direction;
93 uint32_t requested_bytes;
94 enum pa_stream_state state;
95
96 void (*state_callback)(struct pa_stream*c, void *userdata);
97 void *state_userdata;
98
99 void (*read_callback)(struct pa_stream *p, const void*data, size_t length, void *userdata);
100 void *read_userdata;
101
102 void (*write_callback)(struct pa_stream *p, size_t length, void *userdata);
103 void *write_userdata;
104 };
105
106 struct pa_operation {
107 int ref;
108 struct pa_context *context;
109 struct pa_stream *stream;
110 PA_LLIST_FIELDS(struct pa_operation);
111
112 enum pa_operation_state state;
113 void *userdata;
114 void (*callback)();
115 };
116
117 void pa_command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
118 void pa_command_stream_killed(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
119 void pa_command_subscribe_event(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
120
121 struct pa_operation *pa_operation_new(struct pa_context *c, struct pa_stream *s);
122 void pa_operation_done(struct pa_operation *o);
123
124 void pa_create_stream_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
125 void pa_stream_disconnect_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
126 void pa_context_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
127 void pa_stream_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
128
129 void pa_context_fail(struct pa_context *c, int error);
130 void pa_context_set_state(struct pa_context *c, enum pa_context_state st);
131 int pa_context_handle_error(struct pa_context *c, uint32_t command, struct pa_tagstruct *t);
132 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);
133
134 void pa_stream_set_state(struct pa_stream *s, enum pa_stream_state st);
135
136 #endif