Lines Matching refs:pd
109 PulseData *pd = s->priv_data;
111 if (pd->mainloop)
112 pa_threaded_mainloop_stop(pd->mainloop);
114 if (pd->stream)
115 pa_stream_unref(pd->stream);
116 pd->stream = NULL;
118 if (pd->context) {
119 pa_context_disconnect(pd->context);
120 pa_context_unref(pd->context);
122 pd->context = NULL;
124 if (pd->mainloop)
125 pa_threaded_mainloop_free(pd->mainloop);
126 pd->mainloop = NULL;
128 ff_timefilter_destroy(pd->timefilter);
129 pd->timefilter = NULL;
136 PulseData *pd = s->priv_data;
143 pd->sample_rate,
144 pd->channels };
155 attr.fragsize = pd->fragment_size;
160 if (!(pd->mainloop = pa_threaded_mainloop_new())) {
165 if (!(pd->context = pa_context_new(pa_threaded_mainloop_get_api(pd->mainloop), pd->name))) {
170 pa_context_set_state_callback(pd->context, context_state_cb, pd);
172 if (pa_context_connect(pd->context, pd->server, 0, NULL) < 0) {
174 return AVERROR(pa_context_errno(pd->context));
177 pa_threaded_mainloop_lock(pd->mainloop);
179 if (pa_threaded_mainloop_start(pd->mainloop) < 0) {
187 state = pa_context_get_state(pd->context);
193 ret = AVERROR(pa_context_errno(pd->context));
198 pa_threaded_mainloop_wait(pd->mainloop);
201 if (!(pd->stream = pa_stream_new(pd->context, pd->stream_name, &ss, NULL))) {
202 ret = AVERROR(pa_context_errno(pd->context));
206 pa_stream_set_state_callback(pd->stream, stream_state_cb, pd);
207 pa_stream_set_read_callback(pd->stream, stream_request_cb, pd);
208 pa_stream_set_write_callback(pd->stream, stream_request_cb, pd);
209 pa_stream_set_latency_update_callback(pd->stream, stream_latency_update_cb, pd);
211 ret = pa_stream_connect_record(pd->stream, device, &attr,
217 ret = AVERROR(pa_context_errno(pd->context));
224 state = pa_stream_get_state(pd->stream);
230 ret = AVERROR(pa_context_errno(pd->context));
235 pa_threaded_mainloop_wait(pd->mainloop);
238 pa_threaded_mainloop_unlock(pd->mainloop);
243 st->codec->sample_rate = pd->sample_rate;
244 st->codec->channels = pd->channels;
247 pd->timefilter = ff_timefilter_new(1000000.0 / pd->sample_rate,
250 if (!pd->timefilter) {
258 pa_threaded_mainloop_unlock(pd->mainloop);
266 PulseData *pd = s->priv_data;
274 pa_threaded_mainloop_lock(pd->mainloop);
276 CHECK_DEAD_GOTO(pd, ret, unlock_and_fail);
281 r = pa_stream_peek(pd->stream, &read_data, &read_length);
285 pa_threaded_mainloop_wait(pd->mainloop);
286 CHECK_DEAD_GOTO(pd, ret, unlock_and_fail);
290 r = pa_stream_drop(pd->stream);
301 pa_operation_unref(pa_stream_update_timing_info(pd->stream, NULL, NULL));
303 if (pa_stream_get_latency(pd->stream, &latency, &negative) >= 0) {
306 int frame_size = ((av_get_bits_per_sample(codec_id) >> 3) * pd->channels);
314 pkt->pts = ff_timefilter_update(pd->timefilter, dts, pd->last_period);
316 pd->last_period = frame_duration;
322 pa_stream_drop(pd->stream);
324 pa_threaded_mainloop_unlock(pd->mainloop);
328 pa_threaded_mainloop_unlock(pd->mainloop);