Lines Matching defs:source

42 #include "source-output.h"
137 data->source = s;
144 /* Extended API: let's see if this source supports the formats the client would like */
149 data->source = s;
178 if (data->source) {
180 return pa_source_output_new_data_set_source(data, data->source, (data->preferred_source != NULL),
278 if (!data->source) {
279 pa_source *source;
282 source = data->direct_on_input->sink->monitor_source;
283 pa_return_val_if_fail(source, -PA_ERR_INVALID);
285 source = pa_namereg_get(core, NULL, PA_NAMEREG_SOURCE);
286 pa_return_val_if_fail(source, -PA_ERR_NOENTITY);
289 pa_source_output_new_data_set_source(data, source, false, false);
298 /* We know that data->source is set, because data->format has been set.
300 * can't happen before data->source has been set. */
301 pa_assert(data->source);
315 pa_return_val_if_fail(PA_SOURCE_IS_LINKED(data->source->state), -PA_ERR_BADSTATE);
316 pa_return_val_if_fail(!data->direct_on_input || data->direct_on_input->sink == data->source->monitor_of, -PA_ERR_INVALID);
318 /* Routing is done. We have a source and a format. */
336 r = pa_format_info_to_sample_spec2(data->format, &data->sample_spec, &data->channel_map, &data->source->sample_spec,
337 &data->source->channel_map);
370 pa_cvolume_reset(&data->volume_factor_source, data->source->sample_spec.channels);
372 pa_return_val_if_fail(pa_cvolume_compatible(&data->volume_factor_source, &data->source->sample_spec), -PA_ERR_INVALID);
378 !pa_sample_spec_equal(&data->sample_spec, &data->source->sample_spec)) {
379 /* try to change source format and rate. This is done before the FIXATE hook since
380 module-suspend-on-idle can resume a source */
383 pa_source_reconfigure(data->source, &data->sample_spec, pa_source_output_new_data_is_passthrough(data));
387 !pa_sample_spec_equal(&data->sample_spec, &data->source->sample_spec)) {
390 pa_log_debug("Could not update source sample spec to match passthrough stream");
403 data->source->state == PA_SOURCE_SUSPENDED) {
404 pa_log("Failed to create source output: source is suspended.");
408 if (pa_idxset_size(data->source->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
409 pa_log("Failed to create source output: too many outputs per source.");
414 !pa_sample_spec_equal(&data->sample_spec, &data->source->sample_spec) ||
415 !pa_channel_map_equal(&data->channel_map, &data->source->channel_map)) {
420 &data->source->sample_spec, &data->source->channel_map,
445 o->source = data->source;
456 if (!data->volume_is_absolute && pa_source_flat_volume_enabled(o->source)) {
460 * as relative to the source volume even in flat volume mode */
461 remapped = data->source->reference_volume;
462 pa_cvolume_remap(&remapped, &data->source->channel_map, &data->channel_map);
494 "source output delay_memblockq",
498 &o->source->sample_spec,
502 &o->source->silence);
504 resampler_history = (uint64_t) PA_RESAMPLER_MAX_DELAY_USEC * o->source->sample_spec.rate / PA_USEC_PER_SEC;
505 resampler_history *= pa_frame_size(&o->source->sample_spec);
507 pa_memblockq_set_maxrewind(o->thread_info.delay_memblockq, resampler_history + pa_source_get_max_rewind(o->source));
510 pa_assert_se(pa_idxset_put(o->source->outputs, pa_source_output_ref(o), NULL) == 0);
522 o->source->name,
539 if (!o->source)
543 pa_assert_se(o->source->n_corked -- >= 1);
545 o->source->n_corked++;
557 if (o->source) {
558 if (o->state == PA_SOURCE_OUTPUT_CORKED && state == PA_SOURCE_OUTPUT_RUNNING && pa_source_used_by(o->source) == 0 &&
559 !pa_sample_spec_equal(&o->sample_spec, &o->source->sample_spec)) {
560 /* We were uncorked and the source was not playing anything -- let's try
562 pa_source_reconfigure(o->source, &o->sample_spec, pa_source_output_is_passthrough(o));
565 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) == 0);
567 /* If the source is not valid, pa_source_output_set_state_within_thread() must be called directly */
580 if (o->source)
581 pa_source_update_status(o->source);
606 if (o->source)
607 if (pa_idxset_remove_by_data(o->source->outputs, o, NULL))
616 if (linked && o->source) {
618 pa_source_leave_passthrough(o->source);
620 /* We might need to update the source's volume if we are in flat volume mode. */
621 if (pa_source_flat_volume_enabled(o->source))
622 pa_source_set_volume(o->source, NULL, false, false);
624 if (o->source->asyncmsgq)
625 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_REMOVE_OUTPUT, o, 0, NULL) == 0);
630 if (o->source) {
631 if (PA_SOURCE_IS_LINKED(o->source->state))
632 pa_source_update_status(o->source);
634 o->source = NULL;
696 /* We might need to update the source's volume if we are in flat volume mode. */
697 if (pa_source_flat_volume_enabled(o->source))
698 pa_source_set_volume(o->source, NULL, false, o->save_volume);
709 pa_source_enter_passthrough(o->source);
714 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_ADD_OUTPUT, o, 0, NULL) == 0);
719 pa_source_update_status(o->source);
739 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_GET_LATENCY, r, 0, NULL) == 0);
761 pa_assert(pa_frame_aligned(chunk->length, &o->source->sample_spec));
773 limit = o->process_rewind ? 0 : o->source->thread_info.max_rewind;
778 if (limit > 0 && o->source->monitor_of) {
789 latency = pa_sink_get_latency_within_thread(o->source->monitor_of, false);
791 n = pa_usec_to_bytes(latency, &o->source->sample_spec);
816 pa_silence_memchunk(&qchunk, &o->source->sample_spec);
826 pa_volume_memchunk(&qchunk, &o->source->sample_spec, &v);
830 pa_volume_memchunk(&qchunk, &o->source->sample_spec, &o->thread_info.soft_volume);
835 pa_volume_memchunk(&qchunk, &o->source->sample_spec, &o->volume_factor_source);
864 void pa_source_output_process_rewind(pa_source_output *o, size_t nbytes /* in source sample spec */) {
869 pa_assert(pa_frame_aligned(nbytes, &o->source->sample_spec));
896 resampler_bytes = (size_t) pa_resampler_get_delay(o->thread_info.resampler, false) * pa_frame_size(&o->source->sample_spec);
912 return pa_resampler_result(o->thread_info.resampler, o->source->thread_info.max_rewind);
916 void pa_source_output_update_max_rewind(pa_source_output *o, size_t nbytes /* in the source's sample spec */) {
922 pa_assert(pa_frame_aligned(nbytes, &o->source->sample_spec));
924 resampler_history = (uint64_t) PA_RESAMPLER_MAX_DELAY_USEC * o->source->sample_spec.rate / PA_USEC_PER_SEC;
925 resampler_history *= pa_frame_size(&o->source->sample_spec);
938 if (!(o->source->flags & PA_SOURCE_DYNAMIC_LATENCY))
939 usec = o->source->thread_info.fixed_latency;
942 usec = PA_CLAMP(usec, o->source->thread_info.min_latency, o->source->thread_info.max_latency);
945 pa_source_invalidate_requested_latency(o->source, true);
955 if (PA_SOURCE_OUTPUT_IS_LINKED(o->state) && o->source) {
956 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
960 /* If this source output is not realized yet or is being moved, we
963 if (o->source) {
964 if (!(o->source->flags & PA_SOURCE_DYNAMIC_LATENCY))
965 usec = pa_source_get_fixed_latency(o->source);
969 pa_source_get_latency_range(o->source, &min_latency, &max_latency);
984 if (PA_SOURCE_OUTPUT_IS_LINKED(o->state) && o->source) {
986 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_GET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
990 /* If this source output is not realized yet or is being moved, we
1008 if (!absolute && pa_source_flat_volume_enabled(o->source)) {
1009 v = o->source->reference_volume;
1010 pa_cvolume_remap(&v, &o->source->channel_map, &o->channel_map);
1031 if (pa_source_flat_volume_enabled(o->source)) {
1032 /* We are in flat volume mode, so let's update all source input
1033 * volumes and update the flat volume of the source */
1035 pa_source_set_volume(o->source, NULL, true, save);
1043 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_SOFT_VOLUME, NULL, 0, NULL) == 0);
1103 if (absolute || !pa_source_flat_volume_enabled(o->source))
1127 pa_log_debug("The mute of source output %u changed from %s to %s.", o->index, pa_yes_no(old_mute), pa_yes_no(mute));
1131 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_SOFT_MUTE, NULL, 0, NULL) == 0);
1278 pa_asyncmsgq_post(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_RATE, PA_UINT_TO_PTR(rate), 0, NULL, NULL);
1312 s = s->output_from_master->source;
1319 pa_source *source = o->source;
1321 if (!source)
1324 while (source->output_from_master) {
1325 source = source->output_from_master->source;
1327 if (!source)
1340 if (dest == o->source)
1349 /* Make sure we're not creating a filter source cycle */
1355 /* If this source output is connected to a filter source that itself is
1357 * the IO thread of the old source, and if the old source is a filter
1358 * source that is moving, there's no IO thread associated to the old
1359 * source. */
1361 pa_log_debug("Can't move output from filter source %s, because the filter source itself is currently moving.",
1362 o->source->name);
1367 pa_log_warn("Failed to move source output: too many outputs per source.");
1386 pa_assert(o->source);
1394 pa_log_debug("Starting to move source output %u from '%s'", (unsigned) o->index, o->source->name);
1396 origin = o->source;
1398 pa_idxset_remove_by_data(o->source->outputs, o, NULL);
1404 pa_source_leave_passthrough(o->source);
1406 if (pa_source_flat_volume_enabled(o->source))
1407 /* We might need to update the source's volume if we are in flat
1409 pa_source_set_volume(o->source, NULL, false, false);
1411 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_REMOVE_OUTPUT, o, 0, NULL) == 0);
1413 pa_source_update_status(o->source);
1415 pa_cvolume_remap(&o->volume_factor_source, &o->source->channel_map, &o->channel_map);
1417 o->source = NULL;
1425 /* Called from main context. If it has an origin source that uses volume sharing,
1426 * then also the origin source and all streams connected to it need to update
1433 pa_assert(o->source); /* The destination source should already be set. */
1440 root_source = pa_source_get_master(o->source);
1445 if (pa_source_flat_volume_enabled(o->source)) {
1446 /* Ok, so the origin source uses volume sharing, and flat volume is
1449 * o->volume := o->source->real_volume
1451 * o->reference_ratio := o->volume / o->source->reference_volume
1454 * (streams whose origin source uses volume sharing should
1457 * (streams whose origin source uses volume sharing should
1467 /* Ok, so the origin source uses volume sharing, and flat volume is
1473 * (streams whose origin source uses volume sharing should
1476 * (streams whose origin source uses volume sharing should
1487 /* Additionally, the origin source volume needs updating:
1511 /* Recursively update origin source outputs. */
1516 if (pa_source_flat_volume_enabled(o->source)) {
1520 * o->volume := o->reference_ratio * o->source->reference_volume
1522 * o->real_ratio := o->volume / o->source->real_volume
1527 new_volume = o->source->reference_volume;
1528 pa_cvolume_remap(&new_volume, &o->source->channel_map, &o->channel_map);
1545 /* If this is a virtual source stream, we have to apply the source volume
1546 * to the source output. */
1557 /* If o->source == dest, then recursion has finished, and we can finally call
1559 if ((o->source == dest) && pa_source_flat_volume_enabled(o->source))
1560 pa_source_set_volume(o->source, NULL, false, o->save_volume);
1584 pa_assert(!o->source);
1592 pa_log_debug("New source doesn't support stream format, sending format-changed and killing");
1603 /* try to change dest source format and rate if possible without glitches.
1604 module-suspend-on-idle resumes destination source with
1614 o->source = dest;
1624 pa_idxset_put(o->source->outputs, pa_source_output_ref(o), NULL);
1626 pa_cvolume_remap(&o->volume_factor_source, &o->channel_map, &o->source->channel_map);
1629 o->source->n_corked++;
1638 pa_source_enter_passthrough(o->source);
1640 pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_ADD_OUTPUT, o, 0, NULL) == 0);
1642 pa_log_debug("Successfully moved source output %i to %s.", o->index, dest->name);
1657 pa_assert(!o->source);
1659 /* Check if someone wants this source output? */
1663 /* Can we move the source output to the default source? */
1682 pa_assert(o->source);
1685 if (dest == o->source)
1709 /* Called from IO thread context except when cork() is called without a valid source. */
1732 r[0] += pa_bytes_to_usec(pa_memblockq_get_length(o->thread_info.delay_memblockq), &o->source->sample_spec);
1734 r[1] += pa_source_get_latency_within_thread(o->source, false);
1812 /* Updates the source output's resampler with whatever the current source
1813 * requires -- useful when the underlying source's sample spec might have changed */
1823 pa_sample_spec_equal(pa_resampler_input_sample_spec(o->thread_info.resampler), &o->source->sample_spec) &&
1824 pa_channel_map_equal(pa_resampler_input_channel_map(o->thread_info.resampler), &o->source->channel_map))
1830 !pa_sample_spec_equal(&o->sample_spec, &o->source->sample_spec) ||
1831 !pa_channel_map_equal(&o->channel_map, &o->source->channel_map))) {
1834 &o->source->sample_spec, &o->source->channel_map,
1862 memblockq_name = pa_sprintf_malloc("source output delay_memblockq [%u]", o->index);
1868 &o->source->sample_spec,
1872 &o->source->silence);
1875 resampler_history = (uint64_t) PA_RESAMPLER_MAX_DELAY_USEC * o->source->sample_spec.rate / PA_USEC_PER_SEC;
1876 resampler_history *= pa_frame_size(&o->source->sample_spec);
1878 pa_memblockq_set_maxrewind(o->thread_info.delay_memblockq, resampler_history + pa_source_get_max_rewind(o->source));
1882 pa_log_debug("Updated resampler for source output %d", o->index);
1926 pa_log_debug("The volume of source output %u changed from %s to %s.", o->index,
1964 * source. As a side effect the stream is moved to the new preferred source.
1966 * a stream, as a side effect the preferred source is changed. This could cause