#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <pulse/utf8.h>
#include <pulse/xmalloc.h>
* to using the sample spec and channel map after all decisions w.r.t.
* routing are complete. */
pa_idxset *tmp = pa_idxset_new(NULL, NULL);
- pa_format_info *f = pa_format_info_from_sample_spec(&data->sample_spec, &data->channel_map);
+ pa_format_info *f = pa_format_info_from_sample_spec(&data->sample_spec,
+ data->channel_map_is_set ? &data->channel_map : NULL);
pa_idxset_put(tmp, f, NULL);
pa_sink_input_new_data_set_formats(data, tmp);
}
pa_return_val_if_fail(!data->driver || pa_utf8_valid(data->driver), -PA_ERR_INVALID);
- if (!data->sink)
- pa_sink_input_new_data_set_sink(data, pa_namereg_get(core, NULL, PA_NAMEREG_SINK), FALSE);
-
+ if (!data->sink) {
+ pa_sink *sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK);
+ pa_return_val_if_fail(sink, -PA_ERR_NOENTITY);
+ pa_sink_input_new_data_set_sink(data, sink, FALSE);
+ }
/* Routing's done, we have a sink. Now let's fix the format and set up the
* sample spec */
pa_sink_input_new_data_set_sample_spec(data, &ss);
}
- pa_return_val_if_fail(data->sink, -PA_ERR_NOENTITY);
pa_return_val_if_fail(PA_SINK_IS_LINKED(pa_sink_get_state(data->sink)), -PA_ERR_BADSTATE);
pa_return_val_if_fail(!data->sync_base || (data->sync_base->sink == data->sink && pa_sink_input_get_state(data->sync_base) == PA_SINK_INPUT_CORKED), -PA_ERR_INVALID);
pa_return_val_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec), -PA_ERR_INVALID);
/* Don't restore (or save) stream volume for passthrough streams */
- if (!pa_format_info_is_pcm(data->format)) {
+ if (pa_sink_input_new_data_is_passthrough(data)) {
data->volume_is_set = FALSE;
data->volume_factor_is_set = FALSE;
}
/* pa_log_debug("peek"); */
- pa_assert(i->thread_info.state == PA_SINK_INPUT_RUNNING ||
- i->thread_info.state == PA_SINK_INPUT_CORKED ||
- i->thread_info.state == PA_SINK_INPUT_DRAINED);
-
block_size_max_sink_input = i->thread_info.resampler ?
pa_resampler_max_block_size(i->thread_info.resampler) :
pa_frame_align(pa_mempool_block_size_max(i->core->mempool), &i->sample_spec);
!pa_sample_spec_equal(&i->sample_spec, &dest->sample_spec) ||
!pa_channel_map_equal(&i->channel_map, &dest->channel_map)) {
- /* Okey, we need a new resampler for the new sink */
+ /* Okay, we need a new resampler for the new sink */
if (!(new_resampler = pa_resampler_new(
i->core->mempool,
1,
0,
&i->sink->silence);
+ i->actual_resample_method = new_resampler ? pa_resampler_get_method(new_resampler) : PA_RESAMPLER_INVALID;
}
+
pa_sink_update_status(dest);
update_volume_due_to_moving(i, dest);
/* Notify everyone */
pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], i);
-
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
return 0;
if (i->state_change)
i->state_change(i, state);
- i->thread_info.state = state;
-
if (corking) {
pa_log_debug("Requesting rewind due to corking");
* so that the unplayed already mixed data is not lost */
pa_sink_input_request_rewind(i, 0, TRUE, TRUE, FALSE);
+ /* Set the corked state *after* requesting rewind */
+ i->thread_info.state = state;
+
} else if (uncorking) {
+ pa_log_debug("Requesting rewind due to uncorking");
+
i->thread_info.underrun_for = (uint64_t) -1;
i->thread_info.playing_for = 0;
- pa_log_debug("Requesting rewind due to uncorking");
+ /* Set the uncorked state *before* requesting rewind */
+ i->thread_info.state = state;
/* OK, we're being uncorked. Make sure we're not rewound when
* the hw buffer is remixed and request a remix. */
pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
- }
+ } else
+ /* We may not be corking or uncorking, but we still need to set the state. */
+ i->thread_info.state = state;
}
/* Called from thread context, except when it is not. */