mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
Fix a few sink/source calls when they are called in suspended state.
This commit is contained in:
parent
d6fdd71c02
commit
5fc11a0724
2 changed files with 43 additions and 16 deletions
|
|
@ -547,6 +547,9 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
|
||||||
s->thread_info.rewind_nbytes = 0;
|
s->thread_info.rewind_nbytes = 0;
|
||||||
s->thread_info.rewind_requested = FALSE;
|
s->thread_info.rewind_requested = FALSE;
|
||||||
|
|
||||||
|
if (s->thread_info.state == PA_SINK_SUSPENDED)
|
||||||
|
return;
|
||||||
|
|
||||||
if (nbytes > 0)
|
if (nbytes > 0)
|
||||||
pa_log_debug("Processing rewind...");
|
pa_log_debug("Processing rewind...");
|
||||||
|
|
||||||
|
|
@ -556,7 +559,7 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbytes > 0)
|
if (nbytes > 0)
|
||||||
if (s->monitor_source && PA_SOURCE_IS_OPENED(s->monitor_source->thread_info.state))
|
if (s->monitor_source && PA_SOURCE_IS_LINKED(s->monitor_source->thread_info.state))
|
||||||
pa_source_process_rewind(s->monitor_source, nbytes);
|
pa_source_process_rewind(s->monitor_source, nbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -636,7 +639,7 @@ static void inputs_drop(pa_sink *s, pa_mix_info *info, unsigned n, pa_memchunk *
|
||||||
/* Drop read data */
|
/* Drop read data */
|
||||||
pa_sink_input_drop(i, result->length);
|
pa_sink_input_drop(i, result->length);
|
||||||
|
|
||||||
if (s->monitor_source && PA_SOURCE_IS_OPENED(pa_source_get_state(s->monitor_source))) {
|
if (s->monitor_source && PA_SOURCE_IS_LINKED(s->monitor_source->thread_info.state)) {
|
||||||
|
|
||||||
if (pa_hashmap_size(i->thread_info.direct_outputs) > 0) {
|
if (pa_hashmap_size(i->thread_info.direct_outputs) > 0) {
|
||||||
void *ostate = NULL;
|
void *ostate = NULL;
|
||||||
|
|
@ -692,7 +695,7 @@ static void inputs_drop(pa_sink *s, pa_mix_info *info, unsigned n, pa_memchunk *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->monitor_source && PA_SOURCE_IS_OPENED(pa_source_get_state(s->monitor_source)))
|
if (s->monitor_source && PA_SOURCE_IS_LINKED(s->monitor_source->thread_info.state))
|
||||||
pa_source_post(s->monitor_source, result);
|
pa_source_post(s->monitor_source, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -703,7 +706,7 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
|
||||||
size_t block_size_max;
|
size_t block_size_max;
|
||||||
|
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
|
||||||
pa_assert(pa_frame_aligned(length, &s->sample_spec));
|
pa_assert(pa_frame_aligned(length, &s->sample_spec));
|
||||||
pa_assert(result);
|
pa_assert(result);
|
||||||
|
|
||||||
|
|
@ -712,6 +715,13 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
|
||||||
pa_assert(!s->thread_info.rewind_requested);
|
pa_assert(!s->thread_info.rewind_requested);
|
||||||
pa_assert(s->thread_info.rewind_nbytes == 0);
|
pa_assert(s->thread_info.rewind_nbytes == 0);
|
||||||
|
|
||||||
|
if (s->thread_info.state == PA_SINK_SUSPENDED) {
|
||||||
|
result->memblock = pa_memblock_ref(s->silence.memblock);
|
||||||
|
result->index = s->silence.index;
|
||||||
|
result->length = PA_MIN(s->silence.length, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (length <= 0)
|
if (length <= 0)
|
||||||
length = pa_frame_align(MIX_BUFFER_LENGTH, &s->sample_spec);
|
length = pa_frame_align(MIX_BUFFER_LENGTH, &s->sample_spec);
|
||||||
|
|
||||||
|
|
@ -776,7 +786,7 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
|
||||||
size_t length, block_size_max;
|
size_t length, block_size_max;
|
||||||
|
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
|
||||||
pa_assert(target);
|
pa_assert(target);
|
||||||
pa_assert(target->memblock);
|
pa_assert(target->memblock);
|
||||||
pa_assert(target->length > 0);
|
pa_assert(target->length > 0);
|
||||||
|
|
@ -787,6 +797,11 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
|
||||||
pa_assert(!s->thread_info.rewind_requested);
|
pa_assert(!s->thread_info.rewind_requested);
|
||||||
pa_assert(s->thread_info.rewind_nbytes == 0);
|
pa_assert(s->thread_info.rewind_nbytes == 0);
|
||||||
|
|
||||||
|
if (s->thread_info.state == PA_SINK_SUSPENDED) {
|
||||||
|
pa_silence_memchunk(target, &s->sample_spec);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
length = target->length;
|
length = target->length;
|
||||||
block_size_max = pa_mempool_block_size_max(s->core->mempool);
|
block_size_max = pa_mempool_block_size_max(s->core->mempool);
|
||||||
if (length > block_size_max)
|
if (length > block_size_max)
|
||||||
|
|
@ -854,7 +869,7 @@ void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target) {
|
||||||
size_t l, d;
|
size_t l, d;
|
||||||
|
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
|
||||||
pa_assert(target);
|
pa_assert(target);
|
||||||
pa_assert(target->memblock);
|
pa_assert(target->memblock);
|
||||||
pa_assert(target->length > 0);
|
pa_assert(target->length > 0);
|
||||||
|
|
@ -884,7 +899,7 @@ void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target) {
|
||||||
/* Called from IO thread context */
|
/* Called from IO thread context */
|
||||||
void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
|
void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
|
||||||
pa_assert(length > 0);
|
pa_assert(length > 0);
|
||||||
pa_assert(pa_frame_aligned(length, &s->sample_spec));
|
pa_assert(pa_frame_aligned(length, &s->sample_spec));
|
||||||
pa_assert(result);
|
pa_assert(result);
|
||||||
|
|
@ -910,7 +925,7 @@ pa_usec_t pa_sink_get_latency(pa_sink *s) {
|
||||||
|
|
||||||
/* The returned value is supposed to be in the time domain of the sound card! */
|
/* The returned value is supposed to be in the time domain of the sound card! */
|
||||||
|
|
||||||
if (!PA_SINK_IS_OPENED(s->state))
|
if (s->state == PA_SINK_SUSPENDED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(s->flags & PA_SINK_LATENCY))
|
if (!(s->flags & PA_SINK_LATENCY))
|
||||||
|
|
@ -985,8 +1000,8 @@ void pa_sink_propagate_flat_volume(pa_sink *s, const pa_cvolume *old_volume) {
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
|
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert(PA_SINK_IS_LINKED(s->state));
|
|
||||||
pa_assert(old_volume);
|
pa_assert(old_volume);
|
||||||
|
pa_assert(PA_SINK_IS_LINKED(s->state));
|
||||||
pa_assert(s->flags & PA_SINK_FLAT_VOLUME);
|
pa_assert(s->flags & PA_SINK_FLAT_VOLUME);
|
||||||
|
|
||||||
/* This is called whenever the sink volume changes that is not
|
/* This is called whenever the sink volume changes that is not
|
||||||
|
|
@ -1626,6 +1641,9 @@ void pa_sink_request_rewind(pa_sink*s, size_t nbytes) {
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
|
pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
|
||||||
|
|
||||||
|
if (s->thread_info.state == PA_SINK_SUSPENDED)
|
||||||
|
return;
|
||||||
|
|
||||||
if (nbytes == (size_t) -1)
|
if (nbytes == (size_t) -1)
|
||||||
nbytes = s->thread_info.max_rewind;
|
nbytes = s->thread_info.max_rewind;
|
||||||
|
|
||||||
|
|
@ -1687,7 +1705,7 @@ pa_usec_t pa_sink_get_requested_latency(pa_sink *s) {
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert(PA_SINK_IS_LINKED(s->state));
|
pa_assert(PA_SINK_IS_LINKED(s->state));
|
||||||
|
|
||||||
if (!PA_SINK_IS_OPENED(s->state))
|
if (s->state == PA_SINK_SUSPENDED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
|
pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
|
||||||
|
|
|
||||||
|
|
@ -479,7 +479,10 @@ void pa_source_process_rewind(pa_source *s, size_t nbytes) {
|
||||||
void *state = NULL;
|
void *state = NULL;
|
||||||
|
|
||||||
pa_source_assert_ref(s);
|
pa_source_assert_ref(s);
|
||||||
pa_assert(PA_SOURCE_IS_OPENED(s->thread_info.state));
|
pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
|
||||||
|
|
||||||
|
if (s->thread_info.state == PA_SOURCE_SUSPENDED)
|
||||||
|
return;
|
||||||
|
|
||||||
if (nbytes <= 0)
|
if (nbytes <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -498,9 +501,12 @@ void pa_source_post(pa_source*s, const pa_memchunk *chunk) {
|
||||||
void *state = NULL;
|
void *state = NULL;
|
||||||
|
|
||||||
pa_source_assert_ref(s);
|
pa_source_assert_ref(s);
|
||||||
pa_assert(PA_SOURCE_IS_OPENED(s->thread_info.state));
|
pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
|
||||||
pa_assert(chunk);
|
pa_assert(chunk);
|
||||||
|
|
||||||
|
if (s->thread_info.state == PA_SOURCE_SUSPENDED)
|
||||||
|
return;
|
||||||
|
|
||||||
if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&s->thread_info.soft_volume)) {
|
if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&s->thread_info.soft_volume)) {
|
||||||
pa_memchunk vchunk = *chunk;
|
pa_memchunk vchunk = *chunk;
|
||||||
|
|
||||||
|
|
@ -534,11 +540,14 @@ void pa_source_post(pa_source*s, const pa_memchunk *chunk) {
|
||||||
/* Called from IO thread context */
|
/* Called from IO thread context */
|
||||||
void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk *chunk) {
|
void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk *chunk) {
|
||||||
pa_source_assert_ref(s);
|
pa_source_assert_ref(s);
|
||||||
pa_assert(PA_SOURCE_IS_OPENED(s->thread_info.state));
|
pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
|
||||||
pa_source_output_assert_ref(o);
|
pa_source_output_assert_ref(o);
|
||||||
pa_assert(o->thread_info.direct_on_input);
|
pa_assert(o->thread_info.direct_on_input);
|
||||||
pa_assert(chunk);
|
pa_assert(chunk);
|
||||||
|
|
||||||
|
if (s->thread_info.state == PA_SOURCE_SUSPENDED)
|
||||||
|
return;
|
||||||
|
|
||||||
if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&s->thread_info.soft_volume)) {
|
if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&s->thread_info.soft_volume)) {
|
||||||
pa_memchunk vchunk = *chunk;
|
pa_memchunk vchunk = *chunk;
|
||||||
|
|
||||||
|
|
@ -564,7 +573,7 @@ pa_usec_t pa_source_get_latency(pa_source *s) {
|
||||||
pa_source_assert_ref(s);
|
pa_source_assert_ref(s);
|
||||||
pa_assert(PA_SOURCE_IS_LINKED(s->state));
|
pa_assert(PA_SOURCE_IS_LINKED(s->state));
|
||||||
|
|
||||||
if (!PA_SOURCE_IS_OPENED(s->state))
|
if (s->state == PA_SOURCE_SUSPENDED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(s->flags & PA_SOURCE_LATENCY))
|
if (!(s->flags & PA_SOURCE_LATENCY))
|
||||||
|
|
@ -675,8 +684,8 @@ pa_bool_t pa_source_get_mute(pa_source *s, pa_bool_t force_refresh) {
|
||||||
|
|
||||||
/* Called from main thread */
|
/* Called from main thread */
|
||||||
pa_bool_t pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist *p) {
|
pa_bool_t pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist *p) {
|
||||||
|
|
||||||
pa_source_assert_ref(s);
|
pa_source_assert_ref(s);
|
||||||
|
pa_assert(p);
|
||||||
|
|
||||||
pa_proplist_update(s->proplist, mode, p);
|
pa_proplist_update(s->proplist, mode, p);
|
||||||
|
|
||||||
|
|
@ -1000,7 +1009,7 @@ pa_usec_t pa_source_get_requested_latency(pa_source *s) {
|
||||||
pa_source_assert_ref(s);
|
pa_source_assert_ref(s);
|
||||||
pa_assert(PA_SOURCE_IS_LINKED(s->state));
|
pa_assert(PA_SOURCE_IS_LINKED(s->state));
|
||||||
|
|
||||||
if (!PA_SOURCE_IS_OPENED(s->state))
|
if (s->state == PA_SOURCE_SUSPENDED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_GET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
|
pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_GET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue