#include "sink-input.h"
+/* #define SINK_INPUT_DEBUG */
+
#define MEMBLOCKQ_MAXLENGTH (32*1024*1024)
#define CONVERT_BUFFER_LENGTH (PA_PAGE_SIZE)
pa_log_info("Trying to change sample rate");
if (pa_sink_update_rate(data->sink, data->sample_spec.rate, pa_sink_input_new_data_is_passthrough(data)) == TRUE)
- pa_log_info("Rate changed to %u kHz",
+ pa_log_info("Rate changed to %u Hz",
data->sink->sample_spec.rate);
else
- pa_log_info("Resampling enabled to %u kHz", data->sink->sample_spec.rate);
+ pa_log_info("Resampling enabled to %u Hz", data->sink->sample_spec.rate);
}
/* Due to the fixing of the sample spec the volume might not match anymore */
if (i->state == state)
return;
+ if (i->state == PA_SINK_INPUT_CORKED && state == PA_SINK_INPUT_RUNNING && pa_sink_used_by(i->sink) == 0) {
+ /* We were uncorked and the sink was not playing anything -- let's try
+ * to update the sample rate to avoid resampling */
+ pa_sink_update_rate(i->sink, i->sample_spec.rate, pa_sink_input_is_passthrough(i));
+ }
+
pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) == 0);
update_n_corked(i, state);
pa_assert(chunk);
pa_assert(volume);
-/* pa_log_debug("peek"); */
+#ifdef SINK_INPUT_DEBUG
+ pa_log_debug("peek");
+#endif
block_size_max_sink_input = i->thread_info.resampler ?
pa_resampler_max_block_size(i->thread_info.resampler) :
pa_memchunk rchunk;
pa_resampler_run(i->thread_info.resampler, &wchunk, &rchunk);
-/* pa_log_debug("pushing %lu", (unsigned long) rchunk.length); */
+#ifdef SINK_INPUT_DEBUG
+ pa_log_debug("pushing %lu", (unsigned long) rchunk.length);
+#endif
if (rchunk.memblock) {
pa_assert(chunk->length > 0);
pa_assert(chunk->memblock);
-/* pa_log_debug("peeking %lu", (unsigned long) chunk->length); */
+#ifdef SINK_INPUT_DEBUG
+ pa_log_debug("peeking %lu", (unsigned long) chunk->length);
+#endif
if (chunk->length > block_size_max_sink)
chunk->length = block_size_max_sink;
pa_assert(pa_frame_aligned(nbytes, &i->sink->sample_spec));
pa_assert(nbytes > 0);
-/* pa_log_debug("dropping %lu", (unsigned long) nbytes); */
+#ifdef SINK_INPUT_DEBUG
+ pa_log_debug("dropping %lu", (unsigned long) nbytes);
+#endif
pa_memblockq_drop(i->thread_info.render_memblockq, nbytes);
}
pa_assert(PA_SINK_INPUT_IS_LINKED(i->thread_info.state));
pa_assert(pa_frame_aligned(nbytes, &i->sink->sample_spec));
-/* pa_log_debug("rewind(%lu, %lu)", (unsigned long) nbytes, (unsigned long) i->thread_info.rewrite_nbytes); */
+#ifdef SINK_INPUT_DEBUG
+ pa_log_debug("rewind(%lu, %lu)", (unsigned long) nbytes, (unsigned long) i->thread_info.rewrite_nbytes);
+#endif
lbq = pa_memblockq_get_length(i->thread_info.render_memblockq);
pa_log_info("Trying to change sample rate");
if (pa_sink_update_rate(dest, i->sample_spec.rate, pa_sink_input_is_passthrough(i)) == TRUE)
- pa_log_info("Rate changed to %u kHz",
+ pa_log_info("Rate changed to %u Hz",
dest->sample_spec.rate);
else
- pa_log_info("Resampling enabled to %u kHz",
+ pa_log_info("Resampling enabled to %u Hz",
dest->sample_spec.rate);
}
nbytes = PA_MAX(i->thread_info.rewrite_nbytes, nbytes);
- /* pa_log_debug("request rewrite %zu", nbytes); */
+#ifdef SINK_INPUT_DEBUG
+ pa_log_debug("request rewrite %zu", nbytes);
+#endif
/* Calculate how much we can rewind locally without having to
* touch the sink */
i->actual_resample_method = new_resampler ? pa_resampler_get_method(new_resampler) : PA_RESAMPLER_INVALID;
- pa_log_debug("Updated resmpler for sink input %d", i->index);
+ pa_log_debug("Updated resampler for sink input %d", i->index);
return 0;
}