]> code.delx.au - pulseaudio/blob - src/pulsecore/sink-input.h
allow hooking into the process of creating playback streams. To implement this I...
[pulseaudio] / src / pulsecore / sink-input.h
1 #ifndef foosinkinputhfoo
2 #define foosinkinputhfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of PulseAudio.
8
9 PulseAudio 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 PulseAudio 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 PulseAudio; 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 <inttypes.h>
26
27 typedef struct pa_sink_input pa_sink_input;
28
29 #include <pulse/sample.h>
30 #include <pulsecore/hook-list.h>
31 #include <pulsecore/memblockq.h>
32 #include <pulsecore/resampler.h>
33 #include <pulsecore/module.h>
34 #include <pulsecore/client.h>
35 #include <pulsecore/sink.h>
36 #include <pulsecore/core.h>
37
38 typedef enum pa_sink_input_state {
39 PA_SINK_INPUT_RUNNING, /*< The stream is alive and kicking */
40 PA_SINK_INPUT_DRAINED, /*< The stream stopped playing because there was no data to play */
41 PA_SINK_INPUT_CORKED, /*< The stream was corked on user request */
42 PA_SINK_INPUT_DISCONNECTED /*< The stream is dead */
43 } pa_sink_input_state_t;
44
45 typedef enum pa_sink_input_flags {
46 PA_SINK_INPUT_VARIABLE_RATE = 1,
47 PA_SINK_INPUT_NO_HOOKS = 2
48 } pa_sink_input_flags_t;
49
50 struct pa_sink_input {
51 int ref;
52 uint32_t index;
53 pa_sink_input_state_t state;
54 pa_sink_input_flags_t flags;
55
56 char *name, *driver; /* may be NULL */
57 pa_module *module; /* may be NULL */
58 pa_client *client; /* may be NULL */
59
60 pa_sink *sink;
61
62 pa_sample_spec sample_spec;
63 pa_channel_map channel_map;
64 pa_cvolume volume;
65
66 /* Some silence to play before the actual data. This is used to
67 * compensate for latency differences when moving a sink input
68 * "hot" between sinks. */
69 size_t move_silence;
70
71 int (*peek) (pa_sink_input *i, pa_memchunk *chunk);
72 void (*drop) (pa_sink_input *i, const pa_memchunk *chunk, size_t length);
73 void (*kill) (pa_sink_input *i); /* may be NULL */
74 pa_usec_t (*get_latency) (pa_sink_input *i); /* may be NULL */
75 void (*underrun) (pa_sink_input *i); /* may be NULL */
76
77 void *userdata;
78
79 pa_memchunk resampled_chunk;
80 pa_resampler *resampler; /* may be NULL */
81
82 int variable_rate;
83 pa_resample_method_t resample_method;
84
85 pa_memblock *silence_memblock; /* may be NULL */
86 };
87
88 typedef struct pa_sink_input_new_data {
89 const char *name, *driver;
90 pa_module *module;
91 pa_client *client;
92
93 pa_sink *sink;
94
95 pa_sample_spec sample_spec;
96 int sample_spec_is_set;
97 pa_channel_map channel_map;
98 int channel_map_is_set;
99 pa_cvolume volume;
100 int volume_is_set;
101
102 pa_resample_method_t resample_method;
103 } pa_sink_input_new_data;
104
105 pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data);
106 void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const pa_sample_spec *spec);
107 void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map);
108 void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
109
110 pa_sink_input* pa_sink_input_new(pa_core *core, pa_sink_input_new_data *data, pa_sink_input_flags_t flags);
111
112 void pa_sink_input_unref(pa_sink_input* i);
113 pa_sink_input* pa_sink_input_ref(pa_sink_input* i);
114
115 /* To be called by the implementing module only */
116 void pa_sink_input_disconnect(pa_sink_input* i);
117
118 /* External code may request disconnection with this funcion */
119 void pa_sink_input_kill(pa_sink_input*i);
120
121 pa_usec_t pa_sink_input_get_latency(pa_sink_input *i);
122
123 int pa_sink_input_peek(pa_sink_input *i, pa_memchunk *chunk, pa_cvolume *volume);
124 void pa_sink_input_drop(pa_sink_input *i, const pa_memchunk *chunk, size_t length);
125
126 void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume);
127 const pa_cvolume * pa_sink_input_get_volume(pa_sink_input *i);
128
129 void pa_sink_input_cork(pa_sink_input *i, int b);
130
131 void pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate);
132
133 void pa_sink_input_set_name(pa_sink_input *i, const char *name);
134
135 pa_resample_method_t pa_sink_input_get_resample_method(pa_sink_input *i);
136
137 int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, int immediately);
138
139 #endif