From b6ed58307d1a1a5f3d29c677d545c116648e2160 Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Thu, 18 Aug 2022 20:38:00 +0900 Subject: [PATCH] protocol-native: ignore invalid sink/source device name As Tizen module select the proper sink/source based on the framework policy, explicit sink/source device request will not be accepted even it is a valid device. This patch will ignore the requsted device which is even invalid one for keeping the consistency. + print error for validity macro [Version] 15.0-10 [Issue Type] Exception Change-Id: If795b6699af5f058cd0070b4d09cdf2d58726e9a --- packaging/pulseaudio.spec | 2 +- src/pulsecore/protocol-native.c | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/packaging/pulseaudio.spec b/packaging/pulseaudio.spec index 206d66d..de5399d 100644 --- a/packaging/pulseaudio.spec +++ b/packaging/pulseaudio.spec @@ -4,7 +4,7 @@ Name: pulseaudio Summary: Improved Linux sound server Version: 15.0 -Release: 9 +Release: 10 Group: Multimedia/Audio License: LGPL-2.1 URL: http://pulseaudio.org diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 4ce4093..d859791 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -1990,6 +1990,23 @@ static void protocol_error(pa_native_connection *c) { native_connection_unlink(c); } +#ifdef __TIZEN__ +#define CHECK_VALIDITY(pstream, expression, tag, error) do { \ +if (!(expression)) { \ + pa_log_error("%s", #expression);\ + pa_pstream_send_error((pstream), (tag), (error)); \ + return; \ +} \ +} while(0); + +#define CHECK_VALIDITY_GOTO(pstream, expression, tag, error, label) do { \ +if (!(expression)) { \ + pa_log_error("%s", #expression);\ + pa_pstream_send_error((pstream), (tag), (error)); \ + goto label; \ +} \ +} while(0); +#else /* __TIZEN__ */ #define CHECK_VALIDITY(pstream, expression, tag, error) do { \ if (!(expression)) { \ pa_pstream_send_error((pstream), (tag), (error)); \ @@ -2003,6 +2020,7 @@ if (!(expression)) { \ goto label; \ } \ } while(0); +#endif /* __TIZEN__ */ static pa_tagstruct *reply_new(uint32_t tag) { pa_tagstruct *reply; @@ -2075,6 +2093,11 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u goto finish; } +#ifdef __TIZEN__ + pa_log_info("name:%s, sink_index:%u, sink_name:%s, corked:%u, syncid:%u", + name, sink_index, sink_name, corked, syncid); +#endif + CHECK_VALIDITY_GOTO(c->pstream, c->authorized, tag, PA_ERR_ACCESS, finish); CHECK_VALIDITY_GOTO(c->pstream, !sink_name || pa_namereg_is_valid_name_or_wildcard(sink_name, PA_NAMEREG_SINK), tag, PA_ERR_INVALID, finish); CHECK_VALIDITY_GOTO(c->pstream, sink_index == PA_INVALID_INDEX || !sink_name, tag, PA_ERR_INVALID, finish); @@ -2192,15 +2215,23 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u if (sink_index != PA_INVALID_INDEX) { if (!(sink = pa_idxset_get_by_index(c->protocol->core->sinks, sink_index))) { +#ifdef __TIZEN__ + pa_log_warn("[NOENTITY] ingoring given sink index %u ...", sink_index); +#else pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY); goto finish; +#endif } } else if (sink_name) { if (!(sink = pa_namereg_get(c->protocol->core, sink_name, PA_NAMEREG_SINK))) { +#ifdef __TIZEN__ + pa_log_warn("[NOENTITY] ingoring given sink name %s ...", sink_name); +#else pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY); goto finish; +#endif } } @@ -2426,6 +2457,11 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin goto finish; } +#ifdef __TIZEN__ + pa_log_info("name:%s, source_index:%u, source_name:%s, corked:%u", + name, source_index, source_name, corked); +#endif + CHECK_VALIDITY_GOTO(c->pstream, c->authorized, tag, PA_ERR_ACCESS, finish); CHECK_VALIDITY_GOTO(c->pstream, !source_name || pa_namereg_is_valid_name_or_wildcard(source_name, PA_NAMEREG_SOURCE), tag, PA_ERR_INVALID, finish); CHECK_VALIDITY_GOTO(c->pstream, source_index == PA_INVALID_INDEX || !source_name, tag, PA_ERR_INVALID, finish); @@ -2554,15 +2590,23 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin if (source_index != PA_INVALID_INDEX) { if (!(source = pa_idxset_get_by_index(c->protocol->core->sources, source_index))) { +#ifdef __TIZEN__ + pa_log_warn("[NOENTITY] ingoring given source index %u ...", source_index); +#else pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY); goto finish; +#endif } } else if (source_name) { if (!(source = pa_namereg_get(c->protocol->core, source_name, PA_NAMEREG_SOURCE))) { +#ifdef __TIZEN__ + pa_log_warn("[NOENTITY] ingoring given source name %s ...", source_name); +#else pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY); goto finish; +#endif } } -- 2.7.4