From 02e713b5b9c8f5b86cde670928bd8a0f9230cd50 Mon Sep 17 00:00:00 2001 From: Maninblack Date: Tue, 4 Mar 2025 17:09:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0pulseaudio=E7=BB=B4?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maninblack --- src/pulse/introspect.c | 4 +++- src/pulsecore/protocol-native.c | 16 ++++++++++++++++ src/pulsecore/sink-input.c | 10 ++++++++++ src/pulsecore/source-output.c | 22 ++++++++++++++++++---- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c index daae4cac4..fa558a290 100644 --- a/src/pulse/introspect.c +++ b/src/pulse/introspect.c @@ -33,6 +33,7 @@ #include "internal.h" #include "introspect.h" +#include "log/audio_log.h" /*** Statistics ***/ @@ -2057,6 +2058,7 @@ pa_operation* pa_context_move_sink_input_by_index(pa_context *c, uint32_t idx, u } pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx, const char *source_name, pa_context_success_cb_t cb, void* userdata) { + AUDIO_FATAL_LOG("pa_context_move_source_output_by_name start"); pa_operation *o; pa_tagstruct *t; uint32_t tag; @@ -2078,7 +2080,7 @@ pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx, pa_tagstruct_puts(t, source_name); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref); - + AUDIO_FATAL_LOG("pa_context_move_source_output_by_name end"); return o; } diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 21e58603c..34a8c5e0a 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -624,6 +624,12 @@ static record_stream* record_stream_new( (double) s->configured_source_latency / PA_USEC_PER_MSEC); pa_source_output_put(s->source_output); + if (s->source_output->source) { + AUDIO_INFO_LOG("[NEW]: SourceOutput[%{public}u] -----> source[%{public}u, %{public}s].", + s->source_output->index, s->source_output->source->index, s->source_output->source->name); + } else { + AUDIO_ERR_LOG("SourceOutput[%{public}u] -----> source is nullptr", s->source_output->index); + } return s; } @@ -1133,6 +1139,12 @@ static playback_stream* playback_stream_new( (double) s->configured_sink_latency / PA_USEC_PER_MSEC); pa_sink_input_put(s->sink_input); + if (s->sink_input->sink) { + AUDIO_INFO_LOG("[NEW]: SinkInput[%{public}u] -----> sink[%{public}u, %{public}s].", + s->sink_input->index, s->sink_input->sink->index, s->sink_input->sink->name); + } else { + AUDIO_ERR_LOG("SourceInput[%{public}u] -----> sink is nullptr", s->sink_input->index); + } out: if (formats) @@ -4666,24 +4678,28 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag return; } } else { + AUDIO_FATAL_LOG("PA_COMMAND_MOVE_SOURCE_OUTPUT start"); pa_source_output *so = NULL; pa_source *source; pa_assert(command == PA_COMMAND_MOVE_SOURCE_OUTPUT); so = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx); + AUDIO_FATAL_LOG("want to move source-output:%{public}u", idx); if (idx_device != PA_INVALID_INDEX) source = pa_idxset_get_by_index(c->protocol->core->sources, idx_device); else source = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SOURCE); + AUDIO_FATAL_LOG("move to source:%{public}s", name_device); CHECK_VALIDITY(c->pstream, so && source, tag, PA_ERR_NOENTITY); if (pa_source_output_move_to(so, source, true) < 0) { pa_pstream_send_error(c->pstream, tag, PA_ERR_INVALID); return; } + AUDIO_FATAL_LOG("PA_COMMAND_MOVE_SOURCE_OUTPUT end"); } pa_pstream_send_simple_ack(c->pstream, tag); diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index c1cd281bd..ed729c2a1 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -1882,6 +1882,10 @@ int pa_sink_input_start_move(pa_sink_input *i) { return r; pa_log_debug("Starting to move sink input %u from '%s'", (unsigned) i->index, i->sink->name); + if (i->sink) { + AUDIO_INFO_LOG("[StartMove]: SinkInput[%{public}u] --xxxx--> sink[%{public}u, %{public}s]", + i->index, i->sink->index, i->sink->name); + } /* Kill directly connected outputs */ while ((o = pa_idxset_first(i->direct_outputs, NULL))) { @@ -2190,6 +2194,11 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, bool save) { i->moving(i, dest); i->sink = dest; + if (dest) { + AUDIO_INFO_LOG("[FinishMove]: SinkInput[%{public}u] ----------> sink[%{public}u, %{public}s]", + i->index, dest->index, dest->name); + } + /* save == true, means user is calling the move_to() and want to save the preferred_sink */ if (save) { @@ -2252,6 +2261,7 @@ void pa_sink_input_fail_move(pa_sink_input *i) { return; } + AUDIO_WARNING_LOG("[FailMove]: SinkInput[%{public}u] moving FAILED.", i->index); if (i->moving) i->moving(i, NULL); diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 7c6cb78a3..7b511e00d 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -1349,7 +1349,7 @@ bool pa_source_output_may_move_to(pa_source_output *o, pa_source *dest) { /* Make sure we're not creating a filter source cycle */ if (find_filter_source_output(o, dest)) { - pa_log_debug("Can't connect output to %s, as that would create a cycle.", dest->name); + AUDIO_FATAL_LOG("Can't connect output to %{public}s, as that would create a cycle.", dest->name); return false; } @@ -1359,13 +1359,13 @@ bool pa_source_output_may_move_to(pa_source_output *o, pa_source *dest) { * source that is moving, there's no IO thread associated to the old * source. */ if (is_filter_source_moving(o)) { - pa_log_debug("Can't move output from filter source %s, because the filter source itself is currently moving.", + AUDIO_FATAL_LOG("Can't move output from filter source %{public}s, because the filter source itself is currently moving.", o->source->name); return false; } if (pa_idxset_size(dest->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) { - pa_log_warn("Failed to move source output: too many outputs per source."); + AUDIO_FATAL_LOG("Failed to move source output: too many outputs per source."); return false; } @@ -1393,6 +1393,10 @@ int pa_source_output_start_move(pa_source_output *o) { return r; pa_log_debug("Starting to move source output %u from '%s'", (unsigned) o->index, o->source->name); + if (o->source) { + AUDIO_INFO_LOG("[StartMove]: SourceOutput[%{public}u] --xxxx--> source[%{public}u, %{public}s]", + o->index, o->source->index, o->source->name); + } origin = o->source; @@ -1613,6 +1617,11 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, bool save o->moving(o, dest); o->source = dest; + if (dest) { + AUDIO_INFO_LOG("[FinishMove]: SourceOutput[%{public}u] ----------> source[%{public}u, %{public}s]", + o->index, dest->index, dest->name); + } + /* save == true, means user is calling the move_to() and want to save the preferred_source */ if (save) { @@ -1667,6 +1676,7 @@ void pa_source_output_fail_move(pa_source_output *o) { return; } + AUDIO_WARNING_LOG("[FailMove]: SourceOutput[%{public}u] moving FAILED.", o->index); if (o->moving) o->moving(o, NULL); @@ -1686,17 +1696,21 @@ int pa_source_output_move_to(pa_source_output *o, pa_source *dest, bool save) { if (dest == o->source) return 0; - if (!pa_source_output_may_move_to(o, dest)) + if (!pa_source_output_may_move_to(o, dest)) { + AUDIO_FATAL_LOG("pa_source_output_may_move_to failed"); return -PA_ERR_NOTSUPPORTED; + } pa_source_output_ref(o); if ((r = pa_source_output_start_move(o)) < 0) { + AUDIO_FATAL_LOG("pa_source_output_start_move failed"); pa_source_output_unref(o); return r; } if ((r = pa_source_output_finish_move(o, dest, save)) < 0) { + AUDIO_FATAL_LOG("pa_source_output_finish_move failed"); pa_source_output_fail_move(o); pa_source_output_unref(o); return r; -- Gitee From e91aea98bd5dec0c6dfeeecd48268f6c081a4c62 Mon Sep 17 00:00:00 2001 From: Maninblack Date: Tue, 4 Mar 2025 20:53:46 +0800 Subject: [PATCH 2/3] bugfix Signed-off-by: Maninblack --- src/pulsecore/sink-input.c | 1 + src/pulsecore/source-output.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index ed729c2a1..70566f8c8 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -41,6 +41,7 @@ #include #include "sink-input.h" +#include "log/audio_log.h" /* #define SINK_INPUT_DEBUG */ diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 7b511e00d..1ebe13a7b 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -40,6 +40,7 @@ #include #include "source-output.h" +#include "log/audio_log.h" #define MEMBLOCKQ_MAXLENGTH (32*1024*1024) -- Gitee From f4a0bc0c8b60a9625ef282ff3adc429f4d2763cc Mon Sep 17 00:00:00 2001 From: shanliang Date: Wed, 5 Mar 2025 21:06:41 +0800 Subject: [PATCH 3/3] add log Signed-off-by: shanliang --- src/pulsecore/source-output.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 1ebe13a7b..a6437a62a 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -1292,17 +1292,23 @@ pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o) { /* Called from main context */ bool pa_source_output_may_move(pa_source_output *o) { + AUDIO_FATAL_LOG("pa_source_output_may_move start"); pa_source_output_assert_ref(o); pa_assert_ctl_context(); pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state)); - if (o->flags & PA_SOURCE_OUTPUT_DONT_MOVE) - pa_log_info("Refused move to new default source!"); + if (o->flags & PA_SOURCE_OUTPUT_DONT_MOVE) { + AUDIO_FATAL_LOG("o->flags:%{public}d flag:%{public}d", (int32_t)o->flags, + (int32_t)(o->flags & PA_SOURCE_OUTPUT_DONT_MOVE)); return false; + } - if (o->direct_on_input) + if (o->direct_on_input) { + AUDIO_FATAL_LOG("direct_on_input"); return false; + } + AUDIO_FATAL_LOG("pa_source_output_may_move end"); return true; } @@ -1335,6 +1341,7 @@ static bool is_filter_source_moving(pa_source_output *o) { /* Called from main context */ bool pa_source_output_may_move_to(pa_source_output *o, pa_source *dest) { + AUDIO_FATAL_LOG("pa_source_output_may_move_to start"); pa_source_output_assert_ref(o); pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state)); pa_source_assert_ref(dest); @@ -1342,11 +1349,16 @@ bool pa_source_output_may_move_to(pa_source_output *o, pa_source *dest) { if (dest == o->source) return true; - if (dest->unlink_requested) + if (dest->unlink_requested) { + AUDIO_FATAL_LOG("unlink_requested"); return false; + } + - if (!pa_source_output_may_move(o)) + if (!pa_source_output_may_move(o)) { + AUDIO_FATAL_LOG("pa_source_output_may_move failed"); return false; + } /* Make sure we're not creating a filter source cycle */ if (find_filter_source_output(o, dest)) { @@ -1370,10 +1382,15 @@ bool pa_source_output_may_move_to(pa_source_output *o, pa_source *dest) { return false; } - if (o->may_move_to) - if (!o->may_move_to(o, dest)) + if (o->may_move_to) { + if (!o->may_move_to(o, dest)) { + AUDIO_FATAL_LOG("o->may_move_to failed"); return false; + } + } + + AUDIO_FATAL_LOG("pa_source_output_may_move_to end"); return true; } -- Gitee