]> code.delx.au - pulseaudio/blob - src/pulsecore/sink-input.h
51d9ec788cd6b25ec88697516abd1a431f660023
[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 Copyright 2004-2006 Lennart Poettering
10 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
11
12 PulseAudio is free software; you can redistribute it and/or modify
13 it under the terms of the GNU Lesser General Public License as published
14 by the Free Software Foundation; either version 2 of the License,
15 or (at your option) any later version.
16
17 PulseAudio is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with PulseAudio; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 USA.
26 ***/
27
28 #include <inttypes.h>
29
30 typedef struct pa_sink_input pa_sink_input;
31
32 #include <pulse/sample.h>
33 #include <pulsecore/hook-list.h>
34 #include <pulsecore/memblockq.h>
35 #include <pulsecore/resampler.h>
36 #include <pulsecore/module.h>
37 #include <pulsecore/client.h>
38 #include <pulsecore/sink.h>
39 #include <pulsecore/core.h>
40
41 typedef enum pa_sink_input_state {
42 PA_SINK_INPUT_RUNNING, /*< The stream is alive and kicking */
43 PA_SINK_INPUT_DRAINED, /*< The stream stopped playing because there was no data to play */
44 PA_SINK_INPUT_CORKED, /*< The stream was corked on user request */
45 PA_SINK_INPUT_DISCONNECTED /*< The stream is dead */
46 } pa_sink_input_state_t;
47
48 typedef enum pa_sink_input_flags {
49 PA_SINK_INPUT_VARIABLE_RATE = 1,
50 PA_SINK_INPUT_NO_HOOKS = 2
51 } pa_sink_input_flags_t;
52
53 struct pa_sink_input {
54 int ref;
55 uint32_t index;
56 pa_sink_input_state_t state;
57 pa_sink_input_flags_t flags;
58
59 char *name, *driver; /* may be NULL */
60 pa_module *module; /* may be NULL */
61 pa_client *client; /* may be NULL */
62
63 pa_sink *sink;
64
65 pa_sample_spec sample_spec;
66 pa_channel_map channel_map;
67 pa_cvolume volume;
68
69 /* Some silence to play before the actual data. This is used to
70 * compensate for latency differences when moving a sink input
71 * "hot" between sinks. */
72 size_t move_silence;
73
74 int (*peek) (pa_sink_input *i, pa_memchunk *chunk);
75 void (*drop) (pa_sink_input *i, const pa_memchunk *chunk, size_t length);
76 void (*kill) (pa_sink_input *i); /* may be NULL */
77 pa_usec_t (*get_latency) (pa_sink_input *i); /* may be NULL */
78 void (*underrun) (pa_sink_input *i); /* may be NULL */
79
80 void *userdata;
81
82 pa_memchunk resampled_chunk;
83 pa_resampler *resampler; /* may be NULL */
84
85 pa_resample_method_t resample_method;
86
87 pa_memblock *silence_memblock; /* may be NULL */
88 };
89
90 typedef struct pa_sink_input_new_data {
91 const char *name, *driver;
92 pa_module *module;
93 pa_client *client;
94
95 pa_sink *sink;
96
97 pa_sample_spec sample_spec;
98 int sample_spec_is_set;
99 pa_channel_map channel_map;
100 int channel_map_is_set;
101 pa_cvolume volume;
102 int volume_is_set;
103
104 pa_resample_method_t resample_method;
105 } pa_sink_input_new_data;
106
107 pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data);
108 void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const pa_sample_spec *spec);
109 void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map);
110 void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
111
112 pa_sink_input* pa_sink_input_new(
113 pa_core *core,
114 pa_sink_input_new_data *data,
115 pa_sink_input_flags_t flags);
116
117 void pa_sink_input_unref(pa_sink_input* i);
118 pa_sink_input* pa_sink_input_ref(pa_sink_input* i);
119
120 /* To be called by the implementing module only */
121 void pa_sink_input_disconnect(pa_sink_input* i);
122
123 /* External code may request disconnection with this funcion */
124 void pa_sink_input_kill(pa_sink_input*i);
125
126 pa_usec_t pa_sink_input_get_latency(pa_sink_input *i);
127
128 int pa_sink_input_peek(pa_sink_input *i, pa_memchunk *chunk, pa_cvolume *volume);
129 void pa_sink_input_drop(pa_sink_input *i, const pa_memchunk *chunk, size_t length);
130
131 void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume);
132 const pa_cvolume * pa_sink_input_get_volume(pa_sink_input *i);
133
134 void pa_sink_input_cork(pa_sink_input *i, int b);
135
136 void pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate);
137
138 void pa_sink_input_set_name(pa_sink_input *i, const char *name);
139
140 pa_resample_method_t pa_sink_input_get_resample_method(pa_sink_input *i);
141
142 int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, int immediately);
143
144 #endif