Lines Matching defs:sink

29 #include <pulsecore/sink-input.h>
40 PA_MODULE_DESCRIPTION("Loopback from source to sink");
45 "sink=<sink to connect to> "
151 /* Used for sink input and source output snapshots */
194 "sink",
247 /* Handling the asyncmsgq between the source output and the sink input
250 * end. But when the sink input is unlinked, we should ensure that the
252 * to the sink input. Also, we need to ensure that new messages won't be
256 * sink input, when the new state is "unlinked".
259 * by unlinking the source output before unlinking the sink input. There
323 /* Calculate rate difference between source and sink. Skip calculation
324 * after a source/sink change, an underrun or latency offset change */
330 /* Calculate frequency difference between source and sink */
334 * sink is 1% of the base rate. If the result is larger, something
358 * latency that module-loopback can deliver with a given source and sink.
362 * source and sink latency are not reported correctly (USB) the result will
364 static void update_minimum_latency(struct userdata *u, pa_sink *sink, bool print_msg) {
383 * Make sure there is enough data available that the sink can keep on playing until new
400 /* If the sink is valid, send a message to update the minimum latency to
402 if (sink)
403 pa_asyncmsgq_send(sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_UPDATE_MIN_LATENCY, NULL, u->minimum_latency, NULL);
427 /* Runtime and counters since last change of source or sink
428 * or source/sink latency */
447 update_minimum_latency(u, u->sink_input->sink, false);
457 /* Calculate real adjust time if source or sink did not change and if the system has
460 * calculation for this iteration. When source or sink changed or the system has been
500 /* Do not filter or calculate error if source or sink changed or if there was an underrun */
528 pa_asyncmsgq_send(u->sink_input->sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_FAST_ADJUST, NULL, current_source_sink_latency, NULL);
548 u->sink_input->sink->name,
621 /* Get sink and source latency snapshot */
622 pa_asyncmsgq_send(u->sink_input->sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_LATENCY_SNAPSHOT, NULL, 0, NULL);
629 * When source or sink changes, give it a third of a second to settle down, then call adjust_rates for the first time */
656 * Calculates minimum and maximum possible latency for source and sink */
657 static void update_latency_boundaries(struct userdata *u, pa_source *source, pa_sink *sink) {
683 if (sink) {
685 if (sink->flags & PA_SINK_DYNAMIC_LATENCY)
686 pa_sink_get_latency_range(sink, &u->min_sink_latency, &u->max_sink_latency);
688 u->min_sink_latency = pa_sink_get_fixed_latency(sink);
692 u->sink_latency_offset = sink->port_latency_offset;
694 /* Latencies below 2.5 ms cause problems, limit sink latency if possible */
701 update_minimum_latency(u, sink, true);
713 /* If source or sink have some large negative latency offset, we might want to
717 /* Keep at least one sink latency in the queue to make sure that the sink
719 requested_sink_latency = pa_sink_get_requested_latency_within_thread(u->sink_input->sink);
802 static void update_effective_source_latency(struct userdata *u, pa_source *source, pa_sink *sink) {
813 /* If the sink is valid, send a message to the output thread, else set the variable directly */
814 if (sink)
815 pa_asyncmsgq_send(sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_SET_EFFECTIVE_SOURCE_LATENCY, NULL, (int64_t)effective_source_latency, NULL);
830 /* Normally we try to configure sink and source latency equally. If the
831 * sink latency cannot match the requested source latency try to set the
892 if (!u->sink_input || !u->sink_input->sink)
895 return dest != u->sink_input->sink->monitor_source;
923 update_latency_boundaries(u, dest, u->sink_input->sink);
925 update_effective_source_latency(u, dest, u->sink_input->sink);
927 /* Uncork the sink input unless the destination is suspended for other
949 * If the sink is invalid here during a profile switching situation
951 if (u->sink_input->sink)
952 pa_asyncmsgq_send(u->sink_input->sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_SOURCE_CHANGED, NULL, 0, NULL);
957 * recovering from a previous source or sink change, so reset rate to
980 if (u->sink_input->sink)
981 pa_asyncmsgq_send(u->sink_input->sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_SOURCE_CHANGED, NULL, 0, NULL);
987 update_effective_source_latency(u, u->source_output->source, u->sink_input->sink);
1026 * the first pop may be called before the sink is actually started. */
1092 /* Add the sink and resampler latency */
1093 time_delta += pa_sink_get_latency_within_thread(u->sink_input->sink, true);
1137 if (u->sink_input->sink->thread_info.state != PA_SINK_SUSPENDED &&
1173 /* Add content of render memblockq to sink latency */
1174 u->latency_snapshot.sink_latency = pa_sink_get_latency_within_thread(u->sink_input->sink, true) +
1175 pa_bytes_to_usec(length, &u->sink_input->sink->sample_spec);
1212 * Set sink input latency to one third of the overall latency if possible.
1216 static void set_sink_input_latency(struct userdata *u, pa_sink *sink) {
1221 /* Normally we try to configure sink and source latency equally. If the
1222 * source latency cannot match the requested sink latency try to set the
1223 * sink latency to a smaller value to avoid underruns */
1240 pa_log_warn("Cannot set requested sink latency of %0.2f ms, adjusting to %0.2f ms", (double)requested_latency / PA_USEC_PER_MSEC, (double)u->configured_sink_latency / PA_USEC_PER_MSEC);
1252 i->sink->thread_info.rtpoll,
1374 * recovering from a previous source or sink change, so reset rate to
1375 * default before moving the sink. */
1403 if (old_state == i->sink->state)
1406 suspended = (i->sink->state == PA_SINK_SUSPENDED);
1408 /* If the sink has been suspended, we need to handle this like
1409 * a sink change when the sink is resumed. Because the sink
1417 update_effective_source_latency(u, u->source_output->source, u->sink_input->sink);
1458 update_effective_source_latency(u, u->source_output->source, u->sink_input->sink);
1467 update_latency_boundaries(u, u->source_output->source, u->sink_input->sink);
1477 current_latency = pa_sink_get_requested_latency(u->sink_input->sink);
1480 * the sink latency has been increased. The case that the minimum latency changes back
1481 * to a smaller value is not handled because this never happens with the current sink
1485 update_latency_boundaries(u, u->source_output->source, u->sink_input->sink);
1514 static pa_hook_result_t sink_port_latency_offset_changed_cb(pa_core *core, pa_sink *sink, struct userdata *u) {
1516 if (sink != u->sink_input->sink)
1522 u->sink_latency_offset = sink->port_latency_offset;
1523 update_minimum_latency(u, sink, true);
1541 update_minimum_latency(u, u->sink_input->sink, true);
1552 pa_sink *sink = NULL;
1586 n = pa_modargs_get_value(ma, "sink", NULL);
1587 if (n && !(sink = pa_namereg_get(m->core, n, PA_NAMEREG_SINK))) {
1588 pa_log("No such sink.");
1603 } else if (sink) {
1604 ss = sink->sample_spec;
1605 map = sink->channel_map;
1804 if (sink)
1805 pa_sink_input_new_data_set_sink(&sink_input_data, sink, false, true);
1855 u->last_sink_latency_offset = u->sink_input->sink->port_latency_offset;
1856 update_latency_boundaries(u, u->source_output->source, u->sink_input->sink);
1857 set_sink_input_latency(u, u->sink_input->sink);
1883 pa_strnull(pa_proplist_gets(u->sink_input->sink->proplist, PA_PROP_DEVICE_DESCRIPTION)));
1886 && (n = pa_proplist_gets(u->sink_input->sink->proplist, PA_PROP_DEVICE_ICON_NAME)))
1918 if (u->sink_input->sink->state != PA_SINK_SUSPENDED)