Re: [pulseaudio-discuss] [PATCH v2] Add configurable RTP stream name

2018-07-04 Thread Peter Meerwald-Stadler

> Path add configuration option 'stream_name' for stream/session name
> So user will see it on receiver side as RTP Strean ($stream_name)

nitpick below
 
> ex: load-module module-rtp-send source=rtp.monitor stream_name=MyServerMedia
> ---
>  src/modules/rtp/module-rtp-send.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/modules/rtp/module-rtp-send.c 
> b/src/modules/rtp/module-rtp-send.c
> index 61900c01..107907b7 100644
> --- a/src/modules/rtp/module-rtp-send.c
> +++ b/src/modules/rtp/module-rtp-send.c
> @@ -66,6 +66,7 @@ PA_MODULE_USAGE(
>  "loop= "
>  "ttl= "
>  "inhibit_auto_suspend="
> +"stream_name="
>  );
> 
>  #define DEFAULT_PORT 46000
> @@ -90,6 +91,7 @@ static const char* const valid_modargs[] = {
>  "loop",
>  "ttl",
>  "inhibit_auto_suspend",
> +"stream_name",
>  NULL
>  };
> 
> @@ -469,7 +471,10 @@ int pa__init(pa_module*m) {
>  k = sizeof(sa_dst);
>  pa_assert_se((r = getsockname(fd, (struct sockaddr*) _dst, )) >= 0);
> 
> -n = pa_sprintf_malloc("PulseAudio RTP Stream on %s", pa_get_fqdn(hn, 
> sizeof(hn)));
> +n = pa_xstrdup(pa_modargs_get_value(ma, "stream_name", NULL));
> +if(n == NULL) {

please add a space after if, i.e
if (n == NULL)

> +n = pa_sprintf_malloc("PulseAudio RTP Stream on %s", pa_get_fqdn(hn, 
> sizeof(hn)));
> +}
> 
>  if (af == AF_INET) {
>  p = pa_sdp_build(af,
> @@ -485,7 +490,7 @@ int pa__init(pa_module*m) {
>  #endif
>  }
> 
> -pa_xfree(n);
> +pa_xfree(n); /* safe for NULL */
> 
>  pa_rtp_context_init_send(>rtp_context, fd, m->core->cookie, payload, 
> pa_frame_size());
>  pa_sap_context_init_send(>sap_context, sap_fd, p);
> --
> 2.18.0
> 
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 5/8] raop: Fix typo

2017-09-06 Thread Peter Meerwald-Stadler
Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 24bec3e..9dc4942 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -526,7 +526,7 @@ static ssize_t resend_udp_audio_packets(pa_raop_client *c, 
uint16_t seq, uint16_
 if (buffer && packet->length > 0)
 written = pa_write(c->udp_cfd, buffer, packet->length, NULL);
 if (written < 0 && errno == EAGAIN) {
-pa_log_debug("Discarding UDP (audio-restransmitted, seq=%d) packet 
due to EAGAIN", seq + i);
+pa_log_debug("Discarding UDP (audio-retransmitted, seq=%d) packet 
due to EAGAIN", seq + i);
 pa_memblock_release(packet->memblock);
 continue;
 }
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 8/8] core: Fix gcc-7 -Wimplicit-fallthrough= warnings by rearranging comment

2017-09-06 Thread Peter Meerwald-Stadler
'Fall through.' must appear separately

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/pulsecore/protocol-esound.c | 5 ++---
 src/pulsecore/protocol-simple.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 4f83ac4..a0aca97 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -1354,11 +1354,10 @@ static int sink_input_process_msg(pa_msgobject *o, int 
code, void *userdata, int
 case PA_SINK_INPUT_MESSAGE_GET_LATENCY: {
 pa_usec_t *r = userdata;
 
+/* The default handler will add in the extra latency added by the 
resampler. */
 *r = pa_bytes_to_usec(pa_memblockq_get_length(c->input_memblockq), 
>sink_input->sample_spec);
-
-/* Fall through, the default handler will add in the extra
- * latency added by the resampler */
 }
+/* Fall through. */
 
 default:
 return pa_sink_input_process_msg(o, code, userdata, offset, chunk);
diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c
index 923ec87..5e2d6c8 100644
--- a/src/pulsecore/protocol-simple.c
+++ b/src/pulsecore/protocol-simple.c
@@ -336,11 +336,10 @@ static int sink_input_process_msg(pa_msgobject *o, int 
code, void *userdata, int
 case PA_SINK_INPUT_MESSAGE_GET_LATENCY: {
 pa_usec_t *r = userdata;
 
+/* The default handler will add in the extra latency added by the 
resampler.*/
 *r = pa_bytes_to_usec(pa_memblockq_get_length(c->input_memblockq), 
>sink_input->sample_spec);
-
-/* Fall through, the default handler will add in the extra
- * latency added by the resampler */
 }
+/* Fall through. */
 
 default:
 return pa_sink_input_process_msg(o, code, userdata, offset, chunk);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/8] bluetooth: ofono: Fix Coverity warning

2017-09-06 Thread Peter Meerwald-Stadler
Dereference before null check

Coverity ID: #1454315

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/bluetooth/backend-ofono.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/bluetooth/backend-ofono.c 
b/src/modules/bluetooth/backend-ofono.c
index 2c51497..782b353 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -545,11 +545,11 @@ static DBusMessage 
*hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
 return r;
 }
 
-card = pa_hashmap_get(backend->cards, path);
+pa_assert_se(card = pa_hashmap_get(backend->cards, path));
 
 card->connecting = false;
 
-if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->fd >= 0) {
+if (codec != HFP_AUDIO_CODEC_CVSD || card->fd >= 0) {
 pa_log_warn("New audio connection invalid arguments (path=%s fd=%d, 
codec=%d)", path, fd, codec);
 pa_assert_se(r = dbus_message_new_error(m, 
"org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
 shutdown(fd, SHUT_RDWR);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/8] bluetooth: bluez5: Fix Coverity warning

2017-09-06 Thread Peter Meerwald-Stadler
Use pa_assert_se() to check return value (pro forma) like everywhere else

Coverity ID: #154313

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/bluetooth/bluez5-util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/bluetooth/bluez5-util.c 
b/src/modules/bluetooth/bluez5-util.c
index 304a26e..cc8d87f 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -1024,7 +1024,7 @@ void 
pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is
 
 pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, 
d->path, "org.bluez.Device1", "Disconnect"));
 dbus_message_set_no_reply(m, true);
-dbus_connection_send(pa_dbus_connection_get(y->connection), m, 
NULL);
+
pa_assert_se(dbus_connection_send(pa_dbus_connection_get(y->connection), m, 
NULL));
 dbus_message_unref(m);
 }
 }
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/8] raop: Fix gcc-7 warnings, EWOULDBLOCK

2017-09-06 Thread Peter Meerwald-Stadler
EAGAIN is used allover the code rather than EWOULDBLOCK
POSIX allows EAGAIN and EWOULDBLOCK to have the same value (and in fact it is)
don't check for EWOULDBLOCK

modules/raop/raop-client.c: In function ‘send_udp_audio_packet’:
modules/raop/raop-client.c:473:41: warning: logical ‘or’ of equal expressions 
[-Wlogical-op]
 if (written < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
 ^~
modules/raop/raop-client.c: In function ‘resend_udp_audio_packets’:
modules/raop/raop-client.c:528:45: warning: logical ‘or’ of equal expressions 
[-Wlogical-op]
 if (written < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
     ^~

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 4 ++--
 src/pulsecore/iochannel.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index ae950f7..24bec3e 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -470,7 +470,7 @@ static ssize_t send_udp_audio_packet(pa_raop_client *c, 
pa_memchunk *block, size
 buffer += packet->index;
 if (buffer && packet->length > 0)
 written = pa_write(c->udp_sfd, buffer, packet->length, NULL);
-if (written < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
+if (written < 0 && errno == EAGAIN) {
 pa_log_debug("Discarding UDP (audio, seq=%d) packet due to EAGAIN 
(%s)", c->seq, pa_cstrerror(errno));
 written = packet->length;
 }
@@ -525,7 +525,7 @@ static ssize_t resend_udp_audio_packets(pa_raop_client *c, 
uint16_t seq, uint16_
 
 if (buffer && packet->length > 0)
 written = pa_write(c->udp_cfd, buffer, packet->length, NULL);
-if (written < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
+if (written < 0 && errno == EAGAIN) {
 pa_log_debug("Discarding UDP (audio-restransmitted, seq=%d) packet 
due to EAGAIN", seq + i);
 pa_memblock_release(packet->memblock);
 continue;
diff --git a/src/pulsecore/iochannel.c b/src/pulsecore/iochannel.c
index 8973375..e25824b 100644
--- a/src/pulsecore/iochannel.c
+++ b/src/pulsecore/iochannel.c
@@ -227,7 +227,7 @@ ssize_t pa_iochannel_write(pa_iochannel*io, const 
void*data, size_t l) {
 return r; /* Fast path - we almost always successfully write 
everything */
 
 if (r < 0) {
-if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
+if (errno == EINTR || errno == EAGAIN)
 r = 0;
 else
 return r;
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 6/8] core: Fix gcc-7 -Wimplicit-fallthrough= warnings

2017-09-06 Thread Peter Meerwald-Stadler
the comment /* Fall through. */ fixes the warning, but gcc-7 seems to be more
picky about the position in the code

pulsecore/sink-input.c: In function ‘pa_sink_input_update_proplist’:
pulsecore/sink-input.c:1531:13: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
 for (state = NULL; (key = pa_proplist_iterate(i->proplist, 
));) {
 ^~~
pulsecore/sink-input.c:1539:9: note: here
 case PA_UPDATE_REPLACE: {
 ^~~~

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/pulsecore/sink-input.c| 11 +++
 src/pulsecore/source-output.c | 11 +++
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 4155b69..d1e16ee 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1526,7 +1526,7 @@ void pa_sink_input_update_proplist(pa_sink_input *i, 
pa_update_mode_t mode, pa_p
 pa_assert_ctl_context();
 
 switch (mode) {
-case PA_UPDATE_SET: {
+case PA_UPDATE_SET:
 /* Delete everything that is not in p. */
 for (state = NULL; (key = pa_proplist_iterate(i->proplist, 
));) {
 if (!pa_proplist_contains(p, key))
@@ -1534,18 +1534,14 @@ void pa_sink_input_update_proplist(pa_sink_input *i, 
pa_update_mode_t mode, pa_p
 }
 
 /* Fall through. */
-}
-
-case PA_UPDATE_REPLACE: {
+case PA_UPDATE_REPLACE:
 for (state = NULL; (key = pa_proplist_iterate(p, ));) {
 pa_proplist_get(p, key, (const void **) , );
 pa_sink_input_set_property_arbitrary(i, key, value, nbytes);
 }
 
 break;
-}
-
-case PA_UPDATE_MERGE: {
+case PA_UPDATE_MERGE:
 for (state = NULL; (key = pa_proplist_iterate(p, ));) {
 if (pa_proplist_contains(i->proplist, key))
 continue;
@@ -1555,7 +1551,6 @@ void pa_sink_input_update_proplist(pa_sink_input *i, 
pa_update_mode_t mode, pa_p
 }
 
 break;
-}
 }
 }
 
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index a4c99af..d2b645c 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -1171,7 +1171,7 @@ void pa_source_output_update_proplist(pa_source_output 
*o, pa_update_mode_t mode
 pa_assert_ctl_context();
 
 switch (mode) {
-case PA_UPDATE_SET: {
+case PA_UPDATE_SET:
 /* Delete everything that is not in p. */
 for (state = NULL; (key = pa_proplist_iterate(o->proplist, 
));) {
 if (!pa_proplist_contains(p, key))
@@ -1179,18 +1179,14 @@ void pa_source_output_update_proplist(pa_source_output 
*o, pa_update_mode_t mode
 }
 
 /* Fall through. */
-}
-
-case PA_UPDATE_REPLACE: {
+case PA_UPDATE_REPLACE:
 for (state = NULL; (key = pa_proplist_iterate(p, ));) {
 pa_proplist_get(p, key, (const void **) , );
 pa_source_output_set_property_arbitrary(o, key, value, nbytes);
 }
 
 break;
-}
-
-case PA_UPDATE_MERGE: {
+case PA_UPDATE_MERGE:
 for (state = NULL; (key = pa_proplist_iterate(p, ));) {
 if (pa_proplist_contains(o->proplist, key))
 continue;
@@ -1200,7 +1196,6 @@ void pa_source_output_update_proplist(pa_source_output 
*o, pa_update_mode_t mode
 }
 
 break;
-}
 }
 }
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/8] json-test: Fix Coverity warning

2017-09-06 Thread Peter Meerwald-Stadler
Cosmetic resource leak in test code

Coverity ID: #1454314

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/tests/json-test.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/tests/json-test.c b/src/tests/json-test.c
index 3e956db..0894a30 100644
--- a/src/tests/json-test.c
+++ b/src/tests/json-test.c
@@ -248,7 +248,11 @@ START_TEST(bad_test) {
 };
 
 for (i = 0; i < PA_ELEMENTSOF(bad_parse); i++) {
-fail_unless(pa_json_parse(bad_parse[i]) == NULL);
+pa_json_object *obj;
+
+fail_unless((obj = pa_json_parse(bad_parse[i])) == NULL);
+if (obj)
+pa_json_object_free(obj);
 }
 }
 END_TEST
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 7/8] core: Fix typo and gcc-7 -Wimplicit-fallthrough= warnings

2017-09-06 Thread Peter Meerwald-Stadler
Correct spelling of 'through' in a comment helps to fix a warning :)
also drop some unrelated comments

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/pulsecore/resampler.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 063c4c5..d42cbc2 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -161,7 +161,7 @@ static pa_resample_method_t fix_method(
 method = PA_RESAMPLER_AUTO;
 break;
 }
- /* Else fall through */
+/* Else fall through */
 case PA_RESAMPLER_FFMPEG:
 case PA_RESAMPLER_SOXR_MQ:
 case PA_RESAMPLER_SOXR_HQ:
@@ -273,20 +273,20 @@ static pa_sample_format_t choose_work_format(
 switch (method) {
 /* This block is for resampling functions that only
  * support the S16 sample format. */
-case PA_RESAMPLER_SPEEX_FIXED_BASE: /* fall through */
+case PA_RESAMPLER_SPEEX_FIXED_BASE:
 case PA_RESAMPLER_FFMPEG:
 work_format = PA_SAMPLE_S16NE;
 break;
 
 /* This block is for resampling functions that support
  * any sample format. */
-case PA_RESAMPLER_COPY: /* fall through */
+case PA_RESAMPLER_COPY:
 case PA_RESAMPLER_TRIVIAL:
 if (!map_required && a == b) {
 work_format = a;
 break;
 }
-/* Else fall trough */
+/* Else fall through */
 case PA_RESAMPLER_PEAKS:
 /* PEAKS, COPY and TRIVIAL do not benefit from increased
  * working precision, so for better performance use s16ne
@@ -295,7 +295,7 @@ static pa_sample_format_t choose_work_format(
 work_format = PA_SAMPLE_S16NE;
 break;
 }
-/* Else fall trough */
+/* Else fall through */
 case PA_RESAMPLER_SOXR_MQ:
 case PA_RESAMPLER_SOXR_HQ:
 case PA_RESAMPLER_SOXR_VHQ:
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 3/4] pactl, pacmd, cli-command: Add send-message command

2017-07-22 Thread Peter Meerwald-Stadler
gt; +static void string_callback(pa_context *c, const char *response, void 
> *userdata) {
> +if (!response) {
> +pa_log(_("Failure: %s"), pa_strerror(pa_context_errno(c)));
> +quit(1);
> +return;
> +}
> +
> +printf("%s\n", response);
> +
> +complete_action();
> +}
> +
>  static void volume_relative_adjust(pa_cvolume *cv) {
>  pa_assert(volume_flags & VOL_RELATIVE);
>  
> @@ -1404,6 +1420,10 @@ static void context_state_callback(pa_context *c, void 
> *userdata) {
>  o = pa_context_set_port_latency_offset(c, card_name, 
> port_name, latency_offset, simple_callback, NULL);
>  break;
>  
> +case SEND_OBJECT_MESSAGE:
> +o = pa_context_send_message_to_object(c, recipient, 
> message, message_args, string_callback, NULL);
> +break;
> +
>  case SUBSCRIBE:
>  pa_context_set_subscribe_callback(c, 
> context_subscribe_callback, NULL);
>  
> @@ -1580,6 +1600,7 @@ static void help(const char *argv0) {
>  printf("%s %s %s %s\n", argv0, _("[options]"), 
> "set-(sink-input|source-output)-mute", _("#N 1|0|toggle"));
>  printf("%s %s %s %s\n", argv0, _("[options]"), "set-sink-formats", _("#N 
> FORMATS"));
>  printf("%s %s %s %s\n", argv0, _("[options]"), 
> "set-port-latency-offset", _("CARD-NAME|CARD-#N PORT OFFSET"));
> +printf("%s %s %s %s\n", argv0, _("[options]"), "send-message", 
> _("RECIPIENT MESSAGE MESSAGE_PARAMETERS"));
>  printf("%s %s %s\n",argv0, _("[options]"), "subscribe");
>  printf(_("\nThe special names @DEFAULT_SINK@, @DEFAULT_SOURCE@ and 
> @DEFAULT_MONITOR@\n"
>   "can be used to specify the default sink, source and 
> monitor.\n"));
> @@ -2015,6 +2036,19 @@ int main(int argc, char *argv[]) {
>  goto quit;
>  }
>  
> +} else if (pa_streq(argv[optind], "send-message")) {
> +action = SEND_OBJECT_MESSAGE;
> +
> +if (argc < optind+3) {

spaces around + operator

> +pa_log(_("You have to specify at least a recipient and a 
> message"));
> +goto quit;
> +}
> +
> +recipient = pa_xstrdup(argv[optind + 1]);
> +message = pa_xstrdup(argv[optind + 2]);
> +if (argc == optind+4)

spaces around + operator

> +message_args = pa_xstrdup(argv[optind + 3]);
> +
>  } else if (pa_streq(argv[optind], "subscribe"))
>  
>  action = SUBSCRIBE;
> @@ -2108,6 +2142,9 @@ quit:
>  pa_xfree(profile_name);
>  pa_xfree(port_name);
>  pa_xfree(formats);
> +pa_xfree(recipient);
> +pa_xfree(message);
> +pa_xfree(message_args);
>  
>  if (sndfile)
>  sf_close(sndfile);
> -- 
> 2.11.0
> 
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Should "sink_master" arguments be renamed to "master_sink"?

2017-04-14 Thread Peter Meerwald-Stadler

> With the recent patches, we seem to be standardising on "sink_master"
> and "source_master" as the modarg names for specifying the master
> device. To me "master_sink" and "master_source" would look better,
> however. I won't explain why, because if my preferred modarg naming
> scheme isn't obviously better, there's little point in changing the
> naming. So, should I write a patch or not?

my vote is leave as-is, little benefit and at least I have plenty of 
scripts loading modules in a specific way

thanks, p.

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] loopback: Calculate and track minimum possible latency

2017-04-03 Thread Peter Meerwald-Stadler
oundaries(u, NULL, dest, true);
>  set_sink_input_latency(u, dest);
>  update_effective_source_latency(u, u->source_output->source, dest);
>  
> @@ -925,6 +1050,67 @@ static void sink_input_suspend_cb(pa_sink_input *i, 
> bool suspended) {
>  update_adjust_timer(u);
>  }
>  
> +/* Called from output thread context */
> +static void update_sink_latency_range_cb(pa_sink_input *i) {
> +struct userdata *u;
> +
> +pa_sink_input_assert_ref(i);
> +pa_sink_input_assert_io_context(i);
> +pa_assert_se(u = i->userdata);
> +
> +/* Sink latency may have changed */
> +pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(u->msg), 
> LOOPBACK_MESSAGE_SINK_LATENCY_RANGE_CHANGED, NULL, 0, NULL, NULL);
> +}
> +
> +/* Called from main context */
> +static int loopback_process_msg_cb(pa_msgobject *o, int code, void 
> *userdata, int64_t offset, pa_memchunk *chunk) {
> +struct loopback_msg *msg;
> +struct userdata *u;
> +pa_usec_t current_latency;
> +
> +pa_assert(o);
> +pa_assert_ctl_context();
> +
> +msg = LOOPBACK_MSG(o);
> +pa_assert_se(u = msg->userdata);
> +
> +switch (code) {
> +
> +case LOOPBACK_MESSAGE_SOURCE_LATENCY_RANGE_CHANGED:
> +
> +update_effective_source_latency(u, u->source_output->source, 
> u->sink_input->sink);
> +current_latency = 
> pa_source_get_requested_latency(u->source_output->source);
> +if (current_latency > u->configured_source_latency) {
> +/* The minimum latency has changed to a value larger than 
> the configured latency. so

, so

> + * the source latency has been increased. The case that the 
> minimum latency changes
> + * back to a smaller value is not handled because this never 
> happens with the current
> + * source implementations */

.

> +pa_log_warn("Source minimum latency increased to %0.2f ms", 
> (double)current_latency / PA_USEC_PER_MSEC);
> +u->configured_source_latency = current_latency;
> +update_latency_boundaries(u, u->source_output->source, 
> u->sink_input->sink, false);
> +}
> +
> +return 0;
> +
> +case LOOPBACK_MESSAGE_SINK_LATENCY_RANGE_CHANGED:
> +
> +current_latency = 
> pa_sink_get_requested_latency(u->sink_input->sink);
> +if (current_latency > u->configured_sink_latency) {
> +/* The minimum latency has changed to a value larger than 
> the configured latency, so
> + * the sink latency has been increased. The case that the 
> minimum latency changes back
> + * to a smaller value is not handled because this never 
> happens with the current sink
> + * implementations */
> +pa_log_warn("Sink minimum latency increased to %0.2f ms", 
> (double)current_latency / PA_USEC_PER_MSEC);
> +u->configured_sink_latency = current_latency;
> +update_latency_boundaries(u, u->source_output->source, 
> u->sink_input->sink, false);
> +}
> +
> +return 0;
> +}
> +
> +return 0;
> +}
> +
>  int pa__init(pa_module *m) {
>  pa_modargs *ma = NULL;
>  struct userdata *u;
> @@ -1102,6 +1288,8 @@ int pa__init(pa_module *m) {
>  u->sink_input->may_move_to = sink_input_may_move_to_cb;
>  u->sink_input->moving = sink_input_moving_cb;
>  u->sink_input->suspend = sink_input_suspend_cb;
> +u->sink_input->update_sink_latency_range = update_sink_latency_range_cb;
> +u->sink_input->update_sink_fixed_latency = update_sink_latency_range_cb;
>  u->sink_input->userdata = u;
>  
>  pa_source_output_new_data_init(_output_data);
> @@ -1150,9 +1338,11 @@ int pa__init(pa_module *m) {
>  u->source_output->may_move_to = source_output_may_move_to_cb;
>  u->source_output->moving = source_output_moving_cb;
>  u->source_output->suspend = source_output_suspend_cb;
> +u->source_output->update_source_latency_range = 
> update_source_latency_range_cb;
> +u->source_output->update_source_fixed_latency = 
> update_source_latency_range_cb;
>  u->source_output->userdata = u;
>  
> -update_latency_boundaries(u, u->source_output->source, 
> u->sink_input->sink);
> +update_latency_boundaries(u, u->source_output->source, 
> u->sink_input->sink, true);
>  set_sink_input_latency(u, u->sink_input->sink);
>  set_source_output_latency(u, u->source_output->source);
>  
> @@ -1193,6 +1383,11 @@ int pa__init(pa_module *m) {
>  && (n = pa_proplist_gets(u->source_output->source->proplist, 
> PA_PROP_DEVICE_ICON_NAME)))
>  pa_proplist_sets(u->sink_input->proplist, PA_PROP_MEDIA_ICON_NAME, 
> n);
>  
> +/* Setup message handler for main thread */
> +u->msg = pa_msgobject_new(loopback_msg);
> +u->msg->parent.process_msg = loopback_process_msg_cb;
> +u->msg->userdata = u;
> +
>  /* The output thread is not yet running, set effective_source_latency 
> directly */
>  update_effective_source_latency(u, u->source_output->source, NULL);
>  
> -- 
> 2.10.1
> 
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] ifdef foo

2017-03-15 Thread Peter Meerwald-Stadler
> In src/modules/module-protocol-stub.c
> I see the following comment
> 
>449 #else /* USE_TCP_SOCKETS */

the comment relates to the #ifdef USE_TCP_SOCKETS likely above
the idea is to show what the #else is for (this can become complicated in 
case of nested #ifdefs)

>450 if (u->socket_server_unix)
>451 if 
> (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t)))
>452 pa_http_protocol_remove_server_string(u->http_protocol, t);
> 
> But I always thought that TCP sockets and Unix sockets where different. 
> That unix sockets where the ones that exist as an inode in the 
> filesystem, where-as TCP sockets are bound to a network port. Is the 
> comment wrong or am I misunderstanding?

p.

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v3] filter-apply, ladspa-sink, virtual-surround-sink: filter-apply supports ladspa-sink and virtual-surround-sink properly

2017-03-10 Thread Peter Meerwald-Stadler
rtual-surround-sink.c
> +++ b/src/modules/module-virtual-surround-sink.c
> @@ -50,7 +50,7 @@ PA_MODULE_LOAD_ONCE(false);
>  PA_MODULE_USAGE(
>  _("sink_name= "
>"sink_properties= "
> -  "master= "
> +  "sink_master= "
>"format= "
>"rate= "
>"channels= "
> @@ -58,9 +58,11 @@ PA_MODULE_USAGE(
>"use_volume_sharing= "
>"force_flat_volume= "
>"hrir=/path/to/left_hrir.wav "
> +  "autoloaded= "
>  ));
>  
>  #define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
> +#define DEFAULT_AUTOLOADED false
>  
>  struct userdata {
>  pa_module *module;
> @@ -87,12 +89,14 @@ struct userdata {
>  
>  float *input_buffer;
>  int input_buffer_offset;
> +
> +bool autoloaded;
>  };
>  
>  static const char* const valid_modargs[] = {
>  "sink_name",
>  "sink_properties",
> -"master",
> +"sink_master",
>  "format",
>  "rate",
>  "channels",
> @@ -100,6 +104,7 @@ static const char* const valid_modargs[] = {
>  "use_volume_sharing",
>  "force_flat_volume",
>  "hrir",
> +"autoloaded",
>  NULL
>  };
>  
> @@ -428,6 +433,19 @@ static void sink_input_state_change_cb(pa_sink_input *i, 
> pa_sink_input_state_t s
>  }
>  
>  /* Called from main context */
> +static bool sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
> +struct userdata *u;
> +
> +pa_sink_input_assert_ref(i);
> +pa_assert_se(u = i->userdata);
> +
> +if (u->autoloaded)
> +return false;
> +
> +return u->sink != dest;
> +}
> +
> +/* Called from main context */
>  static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
>  struct userdata *u;
>  
> @@ -591,7 +609,7 @@ int pa__init(pa_module*m) {
>  goto fail;
>  }
>  
> -if (!(master = pa_namereg_get(m->core, pa_modargs_get_value(ma, 
> "master", NULL), PA_NAMEREG_SINK))) {
> +if (!(master = pa_namereg_get(m->core, pa_modargs_get_value(ma, 
> "sink_master", NULL), PA_NAMEREG_SINK))) {
>  pa_log("Master sink not found");
>  goto fail;
>  }
> @@ -672,6 +690,12 @@ int pa__init(pa_module*m) {
>  goto fail;
>  }
>  
> +u->autoloaded = DEFAULT_AUTOLOADED;
> +if (pa_modargs_get_value_boolean(ma, "autoloaded", >autoloaded) < 0) {
> +pa_log("Failed to parse autoloaded value");
> +goto fail;
> +}
> +
>  if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, 
> PA_PROP_DEVICE_DESCRIPTION))) {
>  const char *z;
>  
> @@ -731,6 +755,7 @@ int pa__init(pa_module*m) {
>  u->sink_input->attach = sink_input_attach_cb;
>  u->sink_input->detach = sink_input_detach_cb;
>  u->sink_input->state_change = sink_input_state_change_cb;
> +u->sink_input->may_move_to = sink_input_may_move_to_cb;
>  u->sink_input->moving = sink_input_moving_cb;
>  u->sink_input->volume_changed = use_volume_sharing ? NULL : 
> sink_input_volume_changed_cb;
>  u->sink_input->mute_changed = sink_input_mute_changed_cb;
> diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
> index bc9e8f8..7451624 100644
> --- a/src/pulse/proplist.h
> +++ b/src/pulse/proplist.h
> @@ -69,6 +69,12 @@ PA_C_DECL_BEGIN
>  /** For streams: the name of a filter that is desired, e.g.\ "echo-cancel" 
> or "equalizer-sink". Differs from PA_PROP_FILTER_WANT in that it forces 
> PulseAudio to apply the filter, regardless of whether PulseAudio thinks it 
> makes sense to do so or not. If this is set, PA_PROP_FILTER_WANT is ignored. 
> In other words, you almost certainly do not want to use this. \since 1.0 */
>  #define PA_PROP_FILTER_APPLY   "filter.apply"
>  
> +/** For streams: some module required extra parameters, e.g.\ "plugin=ladspa 
> label=ladspa_stereo control=0" in case of "ladspa-sink" filter */

some modules require

> +#define PA_PROP_FILTER_APPLY_EXTRA_PARAMETERS  
> "filter.apply.extra.parameters"
> +
> +/** For streams: some applications may want to classify sub filter groups 
> and they can be used as multiple instances. (e.g load multiple plugin 
> instances of "ladspa-sink" filter) */

e.g.

> +#define PA_PROP_FILTER_APPLY_EXTRA_GROUP   "filter.apply.extra.group"
> +
>  /** For streams: the name of a filter that should specifically suppressed 
> (i.e.\ overrides PA_PROP_FILTER_WANT). Useful for the times that 
> PA_PROP_FILTER_WANT is automatically added (e.g. echo-cancellation for phone 
> streams when $VOIP_APP does its own, internal AEC) \since 1.0 */

that should specifically be suppressed

>  #define PA_PROP_FILTER_SUPPRESS"filter.suppress"

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 0/8] more Coverity fixes and cleanups

2017-03-10 Thread Peter Meerwald-Stadler

> > Peter Meerwald-Stadler (8):
> >raop: Fix potential dereference after NULL check
> >raop: Fix potential NULL dereference
> >raop: Log if pa_atoi() fails, latency is not used anyway
> >raop: Error out on parsing server port component
> >core: Assert return value of pa_shared_set/_remove() in dbus-shared
> >core: Document behaviour of pa_shared_remove() in case name does not
> >  exist
> >oss: Fix dead code
> >pulse: Explicitly ignore pa_mainloop_run() return value in thread
> >  function

> Look good to me, except where noted.

entire series is now applied after addressing Georg's comments

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 05/10] raop: Fix resource leaks

2017-03-08 Thread Peter Meerwald-Stadler

> > diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
> > index 4c3083e..03558f6 100644
> > --- a/src/modules/raop/raop-client.c
> > +++ b/src/modules/raop/raop-client.c
> > @@ -1223,7 +1223,7 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
> > pa_rtsp_state_t state, pa_rtsp_st
> > static bool waiting = false;
> > const char *current = NULL;
> > char space[] = " ";
> > -char *token,*ath = NULL;
> > +char *token, *ath = NULL;
> > char *publ, *wath, *mth, *val;
> 
> Should we initialize mth to NULL here to prevent freeing a random address 
> later?
> This could happen when `wath = pa_xstrdup(pa_headerlist_gets(headers, 
> "WWW-Authenticate"));` becomes NULL.
> 
> > char *realm = NULL, *nonce = NULL, *response = NULL;
> > char comma[] = ",";
> > @@ -1260,9 +1260,6 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
> > pa_rtsp_state_t state, pa_rtsp_st
> > pa_raop_basic_response(DEFAULT_USER_NAME, c->password, 
> > );
> > ath = pa_sprintf_malloc("Basic %s",
> > response);
> > -
> > -pa_xfree(response);
> > -pa_xfree(realm);
> > } else if (pa_safe_streq(mth, "Digest")) {
> > rtrim_char(realm, '\"');
> > rtrim_char(nonce, '\"');

yes, this is addressed in a followup patch

thanks, regards, p.

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/8] raop: Error out on parsing server port component

2017-03-08 Thread Peter Meerwald-Stadler
don't ignore server port parsing errors as suggested by Hajime Fujita

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
Cc: Hajime Fujita <crisp.fuj...@nifty.com>
---
 src/modules/raop/raop-client.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 78f86a4..ae950f7 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -988,7 +988,7 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_socket_client *sc = NULL;
 uint32_t sport = DEFAULT_UDP_AUDIO_PORT;
 uint32_t cport =0, tport = 0;
-char *ajs, *token, *pc;
+char *ajs, *token, *pc, *trs;
 const char *token_state = NULL;
 char delimiters[] = ";";
 
@@ -1031,17 +1031,21 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_socket_client_unref(sc);
 sc = NULL;
 } else if (c->protocol == PA_RAOP_PROTOCOL_UDP) {
-char *trs = pa_xstrdup(pa_headerlist_gets(headers, 
"Transport"));
+trs = pa_xstrdup(pa_headerlist_gets(headers, "Transport"));
 
 if (trs) {
 /* Now parse out the server port component of the 
response. */
 while ((token = pa_split(trs, delimiters, _state))) {
 if ((pc = strstr(token, "="))) {
 *pc = 0;
-if (pa_streq(token, "control_port"))
-(void) pa_atou(pc + 1, );
-if (pa_streq(token, "timing_port"))
-(void) pa_atou(pc + 1, );
+if (pa_streq(token, "control_port")) {
+if (pa_atou(pc + 1, ) < 0)
+goto setup_error_parse;
+}
+if (pa_streq(token, "timing_port")) {
+if (pa_atou(pc + 1, ) < 0)
+goto setup_error_parse;
+}
 *pc = '=';
 }
 pa_xfree(token);
@@ -1072,6 +1076,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_xfree(ajs);
 break;
 
+setup_error_parse:
+pa_log("Failed parsing server port components");
+pa_xfree(token);
+pa_xfree(trs);
+/* fall-thru */
 setup_error:
 if (c->tcp_sfd >= 0)
 pa_close(c->tcp_sfd);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 6/8] core: Document behaviour of pa_shared_remove() in case name does not exist

2017-03-08 Thread Peter Meerwald-Stadler
ignore pa_shared_remove() return value
Coverity ID: #1380672

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/pulsecore/shared.c | 2 +-
 src/pulsecore/shared.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/shared.c b/src/pulsecore/shared.c
index 1b5eea9..9bc7eb5 100644
--- a/src/pulsecore/shared.c
+++ b/src/pulsecore/shared.c
@@ -111,6 +111,6 @@ int pa_shared_replace(pa_core *c, const char *name, void 
*data) {
 pa_assert(c);
 pa_assert(name);
 
-pa_shared_remove(c, name);
+(void) pa_shared_remove(c, name);
 return pa_shared_set(c, name, data);
 }
diff --git a/src/pulsecore/shared.h b/src/pulsecore/shared.h
index 49e8738..19ac462 100644
--- a/src/pulsecore/shared.h
+++ b/src/pulsecore/shared.h
@@ -44,7 +44,9 @@ int pa_shared_set(pa_core *c, const char *name, void *data);
 /* Remove the specified shared property. Return non-zero on failure */
 int pa_shared_remove(pa_core *c, const char *name);
 
-/* A combination of pa_shared_remove() and pa_shared_set() */
+/* A combination of pa_shared_remove() and pa_shared_set(); this function
+ * first tries to remove the property by this name and then sets the
+ * property. Return non-zero on failure. */
 int pa_shared_replace(pa_core *c, const char *name, void *data);
 
 /* Dump the current set of shared properties */
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 08/10] raop: Silence unchecked return value warnings

2017-03-08 Thread Peter Meerwald-Stadler

> > --- a/src/modules/raop/raop-client.c
> > +++ b/src/modules/raop/raop-client.c
> > @@ -1034,9 +1034,9 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
> > pa_rtsp_state_t state, pa_rtsp_
> > if ((pc = strstr(token, "="))) {
> > *pc = 0;
> > if (pa_streq(token, "control_port"))
> > -pa_atou(pc + 1, );
> > +(void) pa_atou(pc + 1, );
> > if (pa_streq(token, "timing_port"))
> > -pa_atou(pc + 1, );
> > +(void) pa_atou(pc + 1, );
> 
> I think these should jump to `setup_error` in case of error instead of 
> ignoring.

I've posted a followup patch implementing your suggestion; strictly, this 
is adding functionality to the code, so maybe better to do it in two 
patches anyway :)

regards, p.

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 7/8] oss: Fix dead code

2017-03-08 Thread Peter Meerwald-Stadler
mode cannot be 0
Coverity ID: #1137964

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/oss/module-oss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 8a5a692..5ad765d 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -1195,7 +1195,7 @@ int pa__init(pa_module*m) {
 goto fail;
 }
 
-mode = (playback && record) ? O_RDWR : (playback ? O_WRONLY : (record ? 
O_RDONLY : 0));
+mode = (playback && record) ? O_RDWR : (playback ? O_WRONLY : O_RDONLY);
 
 ss = m->core->default_sample_spec;
 map = m->core->default_channel_map;
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 5/8] core: Assert return value of pa_shared_set/_remove() in dbus-shared

2017-03-08 Thread Peter Meerwald-Stadler
it must succeed, or we are leaking memory

Coverity ID: #1380674, #1380673

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/pulsecore/dbus-shared.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/dbus-shared.c b/src/pulsecore/dbus-shared.c
index 935b068..3422c29 100644
--- a/src/pulsecore/dbus-shared.c
+++ b/src/pulsecore/dbus-shared.c
@@ -45,7 +45,7 @@ static pa_dbus_connection* dbus_connection_new(pa_core *c, 
pa_dbus_wrap_connecti
 pconn->property_name = name;
 pconn->connection = conn;
 
-pa_shared_set(c, name, pconn);
+pa_assert_se(pa_shared_set(c, name, pconn) >= 0);
 
 return pconn;
 }
@@ -88,7 +88,7 @@ void pa_dbus_connection_unref(pa_dbus_connection *c) {
 
 pa_dbus_wrap_connection_free(c->connection);
 
-pa_shared_remove(c->core, c->property_name);
+pa_assert_se(pa_shared_remove(c->core, c->property_name) >= 0);
 pa_xfree(c);
 }
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/8] raop: Fix potential NULL dereference

2017-03-08 Thread Peter Meerwald-Stadler
wath may be NULL, as suggested by Hajime Fujita
Coverity ID: #1398156

setting val = NULL is not needed

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
Cc: Hajime Fujita <crisp.fuj...@nifty.com>
---
 src/modules/raop/raop-client.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index f23cf93..e2cf04e 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1229,7 +1229,7 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 const char *current = NULL;
 char space[] = " ";
 char *token, *ath = NULL;
-char *publ, *wath, *mth, *val;
+char *publ, *wath, *mth = NULL, *val;
 char *realm = NULL, *nonce = NULL, *response = NULL;
 char comma[] = ",";
 
@@ -1244,19 +1244,18 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 goto fail;
 }
 
-if (wath)
+if (wath) {
 mth = pa_split(wath, space, );
-while ((token = pa_split(wath, comma, ))) {
-val = NULL;
-if ((val = strstr(token, "="))) {
-if (NULL == realm && val > strstr(token, "realm"))
-realm = pa_xstrdup(val + 2);
-else if (NULL == nonce && val > strstr(token, "nonce"))
-nonce = pa_xstrdup(val + 2);
-val = NULL;
-}
+while ((token = pa_split(wath, comma, ))) {
+if ((val = strstr(token, "="))) {
+if (NULL == realm && val > strstr(token, "realm"))
+realm = pa_xstrdup(val + 2);
+else if (NULL == nonce && val > strstr(token, 
"nonce"))
+nonce = pa_xstrdup(val + 2);
+}
 
-pa_xfree(token);
+pa_xfree(token);
+}
 }
 
 if (pa_safe_streq(mth, "Basic") && realm) {
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 8/8] pulse: Explicitly ignore pa_mainloop_run() return value in thread function

2017-03-08 Thread Peter Meerwald-Stadler
Coverity ID: #1137975

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/pulse/thread-mainloop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pulse/thread-mainloop.c b/src/pulse/thread-mainloop.c
index cbfc474..993b7ba 100644
--- a/src/pulse/thread-mainloop.c
+++ b/src/pulse/thread-mainloop.c
@@ -97,7 +97,7 @@ static void thread(void *userdata) {
 
 pa_mutex_lock(m->mutex);
 
-pa_mainloop_run(m->real_mainloop, NULL);
+(void) pa_mainloop_run(m->real_mainloop, NULL);
 
 pa_mutex_unlock(m->mutex);
 }
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/8] raop: Log if pa_atoi() fails, latency is not used anyway

2017-03-08 Thread Peter Meerwald-Stadler
Coverity ID: #1398152

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index e2cf04e..78f86a4 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1102,8 +1102,10 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_log_debug("RAOP: RECORD");
 
 alt = pa_xstrdup(pa_headerlist_gets(headers, "Audio-Latency"));
-if (alt)
-pa_atoi(alt, );
+if (alt) {
+if (pa_atoi(alt, ) < 0)
+pa_log("Failed to parse audio latency");
+}
 
 pa_raop_packet_buffer_reset(c->pbuf, c->seq);
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 0/8] more Coverity fixes and cleanups

2017-03-08 Thread Peter Meerwald-Stadler
some more Coverity fixes and cleanups
also addresses Hajime Fujita's earlier review comments

Peter Meerwald-Stadler (8):
  raop: Fix potential dereference after NULL check
  raop: Fix potential NULL dereference
  raop: Log if pa_atoi() fails, latency is not used anyway
  raop: Error out on parsing server port component
  core: Assert return value of pa_shared_set/_remove() in dbus-shared
  core: Document behaviour of pa_shared_remove() in case name does not
exist
  oss: Fix dead code
  pulse: Explicitly ignore pa_mainloop_run() return value in thread
function

 src/modules/oss/module-oss.c   |  2 +-
 src/modules/raop/raop-client.c | 50 +-
 src/modules/raop/raop-sink.c   | 10 +
 src/pulse/thread-mainloop.c|  2 +-
 src/pulsecore/dbus-shared.c|  4 ++--
 src/pulsecore/shared.c |  2 +-
 src/pulsecore/shared.h |  4 +++-
 7 files changed, 44 insertions(+), 30 deletions(-)

-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/8] raop: Fix potential dereference after NULL check

2017-03-08 Thread Peter Meerwald-Stadler
Coverity ID: #1398157

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-sink.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/modules/raop/raop-sink.c b/src/modules/raop/raop-sink.c
index c5ff8b9..4ca625f 100644
--- a/src/modules/raop/raop-sink.c
+++ b/src/modules/raop/raop-sink.c
@@ -246,10 +246,12 @@ static int sink_process_msg(pa_msgobject *o, int code, 
void *data, int64_t offse
 
 if (u->rtpoll_item) {
 pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, 
);
-for (i = 0; i < nbfds; i++) {
-if (pollfd && pollfd->fd >= 0)
-   pa_close(pollfd->fd);
-pollfd++;
+if (pollfd) {
+for (i = 0; i < nbfds; i++) {
+if (pollfd->fd >= 0)
+   pa_close(pollfd->fd);
+pollfd++;
+}
 }
 pa_rtpoll_item_free(u->rtpoll_item);
 u->rtpoll_item = NULL;
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 0/3] misc cleanups

2017-03-08 Thread Peter Meerwald-Stadler

> On 07.03.2017 16:56, Peter Meerwald-Stadler wrote:
> > Peter Meerwald-Stadler (3):
> >build: Use #ifdef to check for #defines
> >core-util: Fix description of pa_split()
> >raop: Fix check for invalid file descriptor
> >
> >   src/modules/dbus/module-dbus-protocol.c |  4 ++--
> >   src/modules/raop/raop-client.c  | 30
> +++---
> >   src/modules/raop/raop-sink.c|  2 +-
> >   src/pulsecore/core-util.c   |  4 ++--
> >   src/pulsecore/dbus-util.c   |  4 ++--
> >   src/pulsecore/shm.c |  2 +-
> >   src/utils/padsp.c   |  6 +++---
> >   7 files changed, 26 insertions(+), 26 deletions(-)
> >
> All three look good to me.

applied, thanks!

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 0/3] misc cleanups

2017-03-07 Thread Peter Meerwald-Stadler
Peter Meerwald-Stadler (3):
  build: Use #ifdef to check for #defines
  core-util: Fix description of pa_split()
  raop: Fix check for invalid file descriptor

 src/modules/dbus/module-dbus-protocol.c |  4 ++--
 src/modules/raop/raop-client.c  | 30 +++---
 src/modules/raop/raop-sink.c|  2 +-
 src/pulsecore/core-util.c   |  4 ++--
 src/pulsecore/dbus-util.c   |  4 ++--
 src/pulsecore/shm.c |  2 +-
 src/utils/padsp.c   |  6 +++---
 7 files changed, 26 insertions(+), 26 deletions(-)

-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/3] raop: Fix check for invalid file descriptor

2017-03-07 Thread Peter Meerwald-Stadler
file descriptor 0 is valid

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 30 +++---
 src/modules/raop/raop-sink.c   |  2 +-
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 1bd4c4a..f23cf93 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -968,10 +968,10 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 break;
 
 annonce_error:
-if (c->udp_cfd > 0)
+if (c->udp_cfd >= 0)
 pa_close(c->udp_cfd);
 c->udp_cfd = -1;
-if (c->udp_tfd > 0)
+if (c->udp_tfd >= 0)
 pa_close(c->udp_tfd);
 c->udp_tfd = -1;
 
@@ -1073,11 +1073,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 break;
 
 setup_error:
-if (c->tcp_sfd > 0)
+if (c->tcp_sfd >= 0)
 pa_close(c->tcp_sfd);
 c->tcp_sfd = -1;
 
-if (c->udp_sfd > 0)
+if (c->udp_sfd >= 0)
 pa_close(c->udp_sfd);
 c->udp_sfd = -1;
 
@@ -1135,11 +1135,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 case STATE_TEARDOWN: {
 pa_log_debug("RAOP: TEARDOWN");
 
-if (c->tcp_sfd > 0)
+if (c->tcp_sfd >= 0)
 pa_close(c->tcp_sfd);
 c->tcp_sfd = -1;
 
-if (c->udp_sfd > 0)
+if (c->udp_sfd >= 0)
 pa_close(c->udp_sfd);
 c->udp_sfd = -1;
 
@@ -1163,11 +1163,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 
 c->is_recording = false;
 
-if (c->tcp_sfd > 0)
+if (c->tcp_sfd >= 0)
 pa_close(c->tcp_sfd);
 c->tcp_sfd = -1;
 
-if (c->udp_sfd > 0)
+if (c->udp_sfd >= 0)
 pa_close(c->udp_sfd);
 c->udp_sfd = -1;
 
@@ -1507,11 +1507,11 @@ bool pa_raop_client_is_alive(pa_raop_client *c) {
 
 switch (c->protocol) {
 case PA_RAOP_PROTOCOL_TCP:
-if (c->tcp_sfd > 0)
+if (c->tcp_sfd >= 0)
 return true;
 break;
 case PA_RAOP_PROTOCOL_UDP:
-if (c->udp_sfd > 0)
+if (c->udp_sfd >= 0)
 return true;
 break;
 default:
@@ -1531,11 +1531,11 @@ bool pa_raop_client_can_stream(pa_raop_client *c) {
 
 switch (c->protocol) {
 case PA_RAOP_PROTOCOL_TCP:
-if (c->tcp_sfd > 0 && c->is_recording)
+if (c->tcp_sfd >= 0 && c->is_recording)
 return true;
 break;
 case PA_RAOP_PROTOCOL_UDP:
-if (c->udp_sfd > 0 && c->is_recording)
+if (c->udp_sfd >= 0 && c->is_recording)
 return true;
 break;
 default:
@@ -1557,14 +1557,14 @@ int pa_raop_client_stream(pa_raop_client *c) {
 
 switch (c->protocol) {
 case PA_RAOP_PROTOCOL_TCP:
-if (c->tcp_sfd > 0 && !c->is_recording) {
+if (c->tcp_sfd >= 0 && !c->is_recording) {
 c->is_recording = true;
 c->is_first_packet = true;
 c->sync_count = 0;
 }
 break;
 case PA_RAOP_PROTOCOL_UDP:
-if (c->udp_sfd > 0 && !c->is_recording) {
+if (c->udp_sfd >= 0 && !c->is_recording) {
 c->is_recording = true;
 c->is_first_packet = true;
 c->sync_count = 0;
@@ -1722,7 +1722,7 @@ pa_volume_t pa_raop_client_adjust_volume(pa_raop_client 
*c, pa_volume_t volume)
 
 void pa_raop_client_handle_oob_packet(pa_raop_client *c, const int fd, const 
uint8_t packet[], ssize_t size) {
 pa_assert(c);
-pa_assert(fd > 0);
+pa_assert(fd >= 0);
 pa_assert(packet);
 
 if (c->protocol == PA_RAOP_PROTOCOL_UDP) {
diff --git a/src/modules/raop/raop-sink.c b/src/modules/raop/raop-sink.c
index d321a2d..c5ff8b9 100644
--- a/src/modules/raop/raop-sink.c
+++ b/src/modules/raop/raop-sink.c
@@ -247,7 +247,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void 
*data, int64_t offse
 if (u->rtpoll_item) {
 pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, 
);
 for (i = 0; i < nbfds; i++) {
-if (pollfd 

[pulseaudio-discuss] [PATCH 1/3] build: Use #ifdef to check for #defines

2017-03-07 Thread Peter Meerwald-Stadler
for example, in case HAVE_MEMFD is #undef, checking with #if HAVE_MEMFD
gives a warning (gcc 5.4.1, Ubuntu)

pulsecore/shm.c: In function 'sharedmem_create':
pulsecore/shm.c:208:5: warning: "HAVE_MEMFD" is not defined [-Wundef]
 #if HAVE_MEMFD

use #ifdef or #if defined() to check for presence of a #define

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/dbus/module-dbus-protocol.c | 4 ++--
 src/pulsecore/dbus-util.c   | 4 ++--
 src/pulsecore/shm.c | 2 +-
 src/utils/padsp.c   | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/modules/dbus/module-dbus-protocol.c 
b/src/modules/dbus/module-dbus-protocol.c
index 8079d6b..2cd206e 100644
--- a/src/modules/dbus/module-dbus-protocol.c
+++ b/src/modules/dbus/module-dbus-protocol.c
@@ -220,7 +220,7 @@ static void io_event_cb(pa_mainloop_api *mainloop, 
pa_io_event *e, int fd, pa_io
 unsigned int flags = 0;
 DBusWatch *watch = userdata;
 
-#if HAVE_DBUS_WATCH_GET_UNIX_FD
+#ifdef HAVE_DBUS_WATCH_GET_UNIX_FD
 pa_assert(fd == dbus_watch_get_unix_fd(watch));
 #else
 pa_assert(fd == dbus_watch_get_fd(watch));
@@ -291,7 +291,7 @@ static dbus_bool_t watch_add_cb(DBusWatch *watch, void 
*data) {
 
 ev = mainloop->io_new(
 mainloop,
-#if HAVE_DBUS_WATCH_GET_UNIX_FD
+#ifdef HAVE_DBUS_WATCH_GET_UNIX_FD
 dbus_watch_get_unix_fd(watch),
 #else
 dbus_watch_get_fd(watch),
diff --git a/src/pulsecore/dbus-util.c b/src/pulsecore/dbus-util.c
index d786af4..80e2866 100644
--- a/src/pulsecore/dbus-util.c
+++ b/src/pulsecore/dbus-util.c
@@ -100,7 +100,7 @@ static void handle_io_event(pa_mainloop_api *ea, 
pa_io_event *e, int fd, pa_io_e
 unsigned int flags = 0;
 DBusWatch *watch = userdata;
 
-#if HAVE_DBUS_WATCH_GET_UNIX_FD
+#ifdef HAVE_DBUS_WATCH_GET_UNIX_FD
 pa_assert(fd == dbus_watch_get_unix_fd(watch));
 #else
 pa_assert(fd == dbus_watch_get_fd(watch));
@@ -153,7 +153,7 @@ static dbus_bool_t add_watch(DBusWatch *watch, void *data) {
 
 ev = c->mainloop->io_new(
 c->mainloop,
-#if HAVE_DBUS_WATCH_GET_UNIX_FD
+#ifdef HAVE_DBUS_WATCH_GET_UNIX_FD
 dbus_watch_get_unix_fd(watch),
 #else
 dbus_watch_get_fd(watch),
diff --git a/src/pulsecore/shm.c b/src/pulsecore/shm.c
index 919d71a..0742cb8 100644
--- a/src/pulsecore/shm.c
+++ b/src/pulsecore/shm.c
@@ -205,7 +205,7 @@ static int sharedmem_create(pa_shm *m, pa_mem_type_t type, 
size_t size, mode_t m
 pa_assert_se(pa_close(fd) == 0);
 m->fd = -1;
 }
-#if HAVE_MEMFD
+#ifdef HAVE_MEMFD
 else
 m->fd = fd;
 #endif
diff --git a/src/utils/padsp.c b/src/utils/padsp.c
index 7a94114..f74122a 100644
--- a/src/utils/padsp.c
+++ b/src/utils/padsp.c
@@ -2285,7 +2285,7 @@ static int dsp_ioctl(fd_info *i, unsigned long request, 
void*argp, int *_errno)
 break;
 }
 
-#if HAVE_DECL_SOUND_PCM_READ_RATE
+#ifdef HAVE_DECL_SOUND_PCM_READ_RATE
 case SOUND_PCM_READ_RATE:
 debug(DEBUG_LEVEL_NORMAL, __FILE__": SOUND_PCM_READ_RATE\n");
 
@@ -2295,7 +2295,7 @@ static int dsp_ioctl(fd_info *i, unsigned long request, 
void*argp, int *_errno)
 break;
 #endif
 
-#if HAVE_DECL_SOUND_PCM_READ_CHANNELS
+#ifdef HAVE_DECL_SOUND_PCM_READ_CHANNELS
 case SOUND_PCM_READ_CHANNELS:
 debug(DEBUG_LEVEL_NORMAL, __FILE__": SOUND_PCM_READ_CHANNELS\n");
 
@@ -2305,7 +2305,7 @@ static int dsp_ioctl(fd_info *i, unsigned long request, 
void*argp, int *_errno)
 break;
 #endif
 
-#if HAVE_DECL_SOUND_PCM_READ_BITS
+#ifdef HAVE_DECL_SOUND_PCM_READ_BITS
 case SOUND_PCM_READ_BITS:
 debug(DEBUG_LEVEL_NORMAL, __FILE__": SOUND_PCM_READ_BITS\n");
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/3] core-util: Fix description of pa_split()

2017-03-07 Thread Peter Meerwald-Stadler
Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/pulsecore/core-util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index cd1c96d..d4cfa20 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1062,7 +1062,7 @@ int pa_parse_volume(const char *v, pa_volume_t *volume) {
 return 0;
 }
 
-/* Split the specified string wherever one of the strings in delimiter
+/* Split the specified string wherever one of the characters in delimiter
  * occurs. Each time it is called returns a newly allocated string
  * with pa_xmalloc(). The variable state points to, should be
  * initialized to NULL before the first call. */
@@ -1082,7 +1082,7 @@ char *pa_split(const char *c, const char *delimiter, 
const char**state) {
 return pa_xstrndup(current, l);
 }
 
-/* Split the specified string wherever one of the strings in delimiter
+/* Split the specified string wherever one of the characters in delimiter
  * occurs. Each time it is called returns a pointer to the substring within the
  * string and the length in 'n'. Note that the resultant string cannot be used
  * as-is without the length parameter, since it is merely pointing to a point
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] New reviewer: Georg Chini

2017-03-07 Thread Peter Meerwald-Stadler

> Georg Chini kindly offered to help with reviewing patches, and we
> granted him commit rights too. This should reduce our problems with
> keeping up with the incoming patches.

great, welcome!

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 01/10] build: Add Coverity scan model

2017-03-07 Thread Peter Meerwald-Stadler

> Ack, go ahead and push this. Do we need to modify our Coverity project
> settings?

pushed, no need to modify server side Coverity settings

Philip can re-enable the periodic scans

thanks, p.

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 09/10] raop: Fix potential resource leaks

2017-03-05 Thread Peter Meerwald-Stadler
Coverity ID: #1410204, #1410203, #1410202, #1410201, #1410200, #1410199

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/module-raop-discover.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/modules/raop/module-raop-discover.c 
b/src/modules/raop/module-raop-discover.c
index dc55b9c..9c7ac3c 100644
--- a/src/modules/raop/module-raop-discover.c
+++ b/src/modules/raop/module-raop-discover.c
@@ -177,6 +177,7 @@ static void resolver_cb(
  *  - TCP = only TCP,
  *  - UDP = only UDP,
  *  - TCP,UDP = both supported (UDP should be prefered) */
+pa_xfree(tp);
 if (pa_str_in_list(value, ",", "UDP"))
 tp = pa_xstrdup("UDP");
 else if (pa_str_in_list(value, ",", "TCP"))
@@ -190,16 +191,18 @@ static void resolver_cb(
  *  - 2 = FairPlay,
  *  - 3 = MFiSAP,
  *  - 4 = FairPlay SAPv2.5. */
- if (pa_str_in_list(value, ",", "1"))
- et = pa_xstrdup("RSA");
- else
- et = pa_xstrdup("none");
+pa_xfree(et);
+if (pa_str_in_list(value, ",", "1"))
+et = pa_xstrdup("RSA");
+else
+et = pa_xstrdup("none");
 } else if (pa_streq(key, "cn")) {
 /* Suported audio codecs:
  *  - 0 = PCM,
  *  - 1 = ALAC,
  *  - 2 = AAC,
  *  - 3 = AAC ELD. */
+pa_xfree(cn);
 if (pa_str_in_list(value, ",", "1"))
 cn = pa_xstrdup("ALAC");
 else
@@ -213,12 +216,15 @@ static void resolver_cb(
 /* Requires password ? (true/false) */
 } else if (pa_streq(key, "ch")) {
 /* Number of channels */
+pa_xfree(ch);
 ch = pa_xstrdup(value);
 } else if (pa_streq(key, "ss")) {
 /* Sample size */
+pa_xfree(ss);
 ss = pa_xstrdup(value);
 } else if (pa_streq(key, "sr")) {
 /* Sample rate */
+pa_xfree(sr);
 sr = pa_xstrdup(value);
 }
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 08/10] raop: Silence unchecked return value warnings

2017-03-05 Thread Peter Meerwald-Stadler
Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index c6e1877..d329a09 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1034,9 +1034,9 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 if ((pc = strstr(token, "="))) {
 *pc = 0;
 if (pa_streq(token, "control_port"))
-pa_atou(pc + 1, );
+(void) pa_atou(pc + 1, );
 if (pa_streq(token, "timing_port"))
-pa_atou(pc + 1, );
+(void) pa_atou(pc + 1, );
 *pc = '=';
 }
 pa_xfree(token);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 05/10] raop: Fix resource leaks

2017-03-05 Thread Peter Meerwald-Stadler
Coverity ID: #1398158, #1398159

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 4c3083e..03558f6 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1223,7 +1223,7 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 static bool waiting = false;
 const char *current = NULL;
 char space[] = " ";
-char *token,*ath = NULL;
+char *token, *ath = NULL;
 char *publ, *wath, *mth, *val;
 char *realm = NULL, *nonce = NULL, *response = NULL;
 char comma[] = ",";
@@ -1260,9 +1260,6 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 pa_raop_basic_response(DEFAULT_USER_NAME, c->password, 
);
 ath = pa_sprintf_malloc("Basic %s",
 response);
-
-pa_xfree(response);
-pa_xfree(realm);
 } else if (pa_safe_streq(mth, "Digest")) {
 rtrim_char(realm, '\"');
 rtrim_char(nonce, '\"');
@@ -1271,17 +1268,18 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 ath = pa_sprintf_malloc("Digest username=\"%s\", 
realm=\"%s\", nonce=\"%s\", uri=\"*\", response=\"%s\"",
 DEFAULT_USER_NAME, realm, nonce,
 response);
-
-pa_xfree(response);
-pa_xfree(realm);
-pa_xfree(nonce);
 } else {
 pa_log_error("unsupported authentication method: %s", mth);
+pa_xfree(realm);
+pa_xfree(nonce);
 pa_xfree(wath);
 pa_xfree(mth);
 goto error;
 }
 
+pa_xfree(response);
+pa_xfree(realm);
+pa_xfree(nonce);
 pa_xfree(wath);
 pa_xfree(mth);
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 04/10] raop: Fix memleak

2017-03-05 Thread Peter Meerwald-Stadler
use local scope for trs variable simplifying cleanup
Coverity ID: #1398160

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index e39663d..4c3083e 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -983,14 +983,13 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_socket_client *sc = NULL;
 uint32_t sport = DEFAULT_UDP_AUDIO_PORT;
 uint32_t cport =0, tport = 0;
-char *ajs, *trs, *token, *pc;
+char *ajs, *token, *pc;
 const char *token_state = NULL;
 char delimiters[] = ";";
 
 pa_log_debug("RAOP: SETUP");
 
 ajs = pa_xstrdup(pa_headerlist_gets(headers, "Audio-Jack-Status"));
-trs = pa_xstrdup(pa_headerlist_gets(headers, "Transport"));
 
 if (ajs) {
 c->jack_type = JACK_TYPE_ANALOG;
@@ -1027,6 +1026,8 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_socket_client_unref(sc);
 sc = NULL;
 } else if (c->protocol == PA_RAOP_PROTOCOL_UDP) {
+char *trs = pa_xstrdup(pa_headerlist_gets(headers, 
"Transport"));
+
 if (trs) {
 /* Now parse out the server port component of the 
response. */
 while ((token = pa_split(trs, delimiters, _state))) {
@@ -1040,6 +1041,7 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 }
 pa_xfree(token);
 }
+pa_xfree(trs);
 } else {
 pa_log_warn("\"Transport\" missing in RTSP setup 
response");
 }
@@ -1062,7 +1064,6 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 
 pa_rtsp_record(c->rtsp, >seq, >rtptime);
 
-pa_xfree(trs);
 pa_xfree(ajs);
 break;
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 10/10] raop: Fix potential NULL dereference

2017-03-05 Thread Peter Meerwald-Stadler
'realm' is mandatory

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index d329a09..5248691 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1254,13 +1254,13 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 pa_xfree(token);
 }
 
-if (pa_safe_streq(mth, "Basic")) {
+if (pa_safe_streq(mth, "Basic") && realm) {
 rtrim_char(realm, '\"');
 
 pa_raop_basic_response(DEFAULT_USER_NAME, c->password, 
);
 ath = pa_sprintf_malloc("Basic %s",
 response);
-} else if (pa_safe_streq(mth, "Digest")) {
+} else if (pa_safe_streq(mth, "Digest") && realm && nonce) {
 rtrim_char(realm, '\"');
 rtrim_char(nonce, '\"');
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 07/10] raop: Fix indentation

2017-03-05 Thread Peter Meerwald-Stadler
Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 03558f6..c6e1877 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1032,8 +1032,8 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 /* Now parse out the server port component of the 
response. */
 while ((token = pa_split(trs, delimiters, _state))) {
 if ((pc = strstr(token, "="))) {
-*pc = 0;
- if (pa_streq(token, "control_port"))
+*pc = 0;
+if (pa_streq(token, "control_port"))
 pa_atou(pc + 1, );
 if (pa_streq(token, "timing_port"))
 pa_atou(pc + 1, );
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 00/10] Coverity fixes, raop

2017-03-05 Thread Peter Meerwald-Stadler
the first patch commits the model file as used on scan.coverity.com
and rewrites pa_assert_se() so that Coverity doesn't complain about
side-effects

some more Coverity fixes for the raop code

Peter Meerwald-Stadler (10):
  build: Add Coverity scan model
  raop: Fix double free
  raop: Fix loop searching for port number
  raop: Fix memleak
  raop: Fix resource leaks
  raop: Fix potential memory leak
  raop: Fix indentation
  raop: Silence unchecked return value warnings
  raop: Fix potential resource leaks
  raop: Fix potential NULL dereference

 coverity/model.c| 18 ++
 src/modules/raop/module-raop-discover.c | 22 +
 src/modules/raop/raop-client.c  | 44 +
 src/modules/raop/raop-sink.c|  6 ++---
 src/pulsecore/macro.h   |  9 +++
 5 files changed, 70 insertions(+), 29 deletions(-)
 create mode 100644 coverity/model.c

-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 03/10] raop: Fix loop searching for port number

2017-03-05 Thread Peter Meerwald-Stadler
do...while not reachable, loop should try different ports in case EADDRINUSE is 
returned
Coverity ID: #1398161

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 94342d2..e39663d 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -799,13 +799,16 @@ static int open_bind_udp_socket(pa_raop_client *c, 
uint16_t *actual_port) {
 }
 
 do {
-*sa_port = htons(port);
+int ret;
 
-if (bind(fd, sa, salen) < 0 && errno != EADDRINUSE) {
-pa_log("bind_socket() failed: %s", pa_cstrerror(errno));
+*sa_port = htons(port);
+ret = bind(fd, sa, salen);
+if (!ret)
+break;
+if (ret < 0 && errno != EADDRINUSE) {
+pa_log("bind() failed: %s", pa_cstrerror(errno));
 goto fail;
 }
-break;
 } while (++port > 0);
 
 pa_log_debug("Socket bound to port %d (SOCK_DGRAM)", port);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 02/10] raop: Fix double free

2017-03-05 Thread Peter Meerwald-Stadler
make nick variable local, fix double free
Coverity CID: #1398162

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-sink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modules/raop/raop-sink.c b/src/modules/raop/raop-sink.c
index 7d8fe36..d321a2d 100644
--- a/src/modules/raop/raop-sink.c
+++ b/src/modules/raop/raop-sink.c
@@ -460,7 +460,6 @@ pa_sink* pa_raop_sink_new(pa_module *m, pa_modargs *ma, 
const char *driver) {
 const char /* *username, */ *password;
 pa_sink_new_data data;
 const char *name = NULL;
-char * nick = NULL;
 
 pa_assert(m);
 pa_assert(ma);
@@ -550,9 +549,11 @@ pa_sink* pa_raop_sink_new(pa_module *m, pa_modargs *ma, 
const char *driver) {
 if ((name = pa_modargs_get_value(ma, "sink_name", NULL))) {
 pa_sink_new_data_set_name(, name);
 } else {
+char *nick;
+
 if ((name = pa_modargs_get_value(ma, "name", NULL)))
 nick = pa_sprintf_malloc("raop_client.%s", name);
-if (!nick)
+else
 nick = pa_sprintf_malloc("raop_client.%s", server);
 pa_sink_new_data_set_name(, nick);
 pa_xfree(nick);
@@ -618,7 +619,6 @@ pa_sink* pa_raop_sink_new(pa_module *m, pa_modargs *ma, 
const char *driver) {
 
 fail:
 pa_xfree(thread_name);
-pa_xfree(nick);
 
 if (u)
 userdata_free(u);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 01/10] build: Add Coverity scan model

2017-03-05 Thread Peter Meerwald-Stadler
the modeling file help to avoid false positives and increase scanning
accuracy by explaining code Coverity can't see (out of tree libraries);
the model file must be uploaded by an admin to:
https://scan.coverity.com/projects/pulseaudio?tab=analysis_settings

the pa_assert_se() macro needs to be rewritten for Coverity so that
the assignment is not declared a side-effect

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
Cc: Philip Withnall <phi...@tecnocode.co.uk>
---
 coverity/model.c  | 18 ++
 src/pulsecore/macro.h |  9 +
 2 files changed, 27 insertions(+)
 create mode 100644 coverity/model.c

diff --git a/coverity/model.c b/coverity/model.c
new file mode 100644
index 000..afe7ca5
--- /dev/null
+++ b/coverity/model.c
@@ -0,0 +1,18 @@
+/* Coverity Scan model
+ * Copyright (C) 2017 Peter Meerwald-Stadler <pme...@pmeerw.net>
+ *
+ * This is a modeling file for Coverity Scan which helps to avoid false
+ * positives and increase scanning accuracy by explaining code Coverity
+ * can't see (out of tree libraries); the model file must be uploaded by
+ * an admin to:
+ * https://scan.coverity.com/projects/pulseaudio?tab=analysis_settings
+ */
+
+void fail(void) {
+__coverity_panic__();
+}
+
+void fail_unless(int x) {
+if (!x)
+__coverity_panic__();
+}
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 2c5d5f2..dbce5cd 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -186,6 +186,7 @@ static inline size_t PA_ALIGN(size_t l) {
 
 /* pa_assert_se() is an assert which guarantees side effects of x,
  * i.e. is never optimized away, regardless of NDEBUG or FASTPATH. */
+#ifndef __COVERITY__
 #define pa_assert_se(expr)  \
 do {\
 if (PA_UNLIKELY(!(expr))) { \
@@ -193,6 +194,14 @@ static inline size_t PA_ALIGN(size_t l) {
 abort();\
 }   \
 } while (false)
+#else
+#define pa_assert_se(expr)  \
+do {\
+int _unique_var = (expr);   \
+if (!_unique_var)   \
+abort();\
+} while (false)
+#endif
 
 /* Does exactly nothing */
 #define pa_nop() do {} while (false)
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Coverity scan

2017-03-01 Thread Peter Meerwald-Stadler
Hello,

> I’ve just disabled the weekly Jenkins/Coverity Scan builds of
> PulseAudio on jenkins.freedesktop.org to stop them continually
> recreating the pa_assert_se() issues in the report.

ok
what coverity version is installed on jenkins?
 
> I don’t have time to modify the definition of pa_assert_se() to fix
> this in upstream git at the moment. I’d love to re-enable the builds in
> Jenkins when someone does fix this though. Arun seemed to approve of
> them, at least.

can't we just stick
#nodef pa_assert_se(_unique_x) do { int _unique_y = _unique_x ; if (!_unique_y) 
__coverity_panic__(); } while (0)
into config/user_nodefs.h for now?

thanks, p.

> 
> On Wed, 2017-02-22 at 12:06 +, Philip Withnall wrote:
> > Hi,
> > 
> > On Wed, 2017-02-22 at 11:52 +, Philip Withnall wrote:
> > > Apologies if this has been discussed before (I don’t follow
> > > PulseAudio
> > > development), but why not stick this in the server-side Coverity
> > > modelling file? Does that not work?
> > 
> > Having just tried it, apparently it doesn’t work. I guess the
> > preprocessing is all done at cov-build time, and no information about
> > macros is sent up to the server for the modelling file to use.
> > 
> > > Failing that, there’s the __COVERITY__ macro which could be used to
> > > change the definition of pa_assert_se() in upstream git:
> > > https://lost-contact.mit.edu/afs/cs.stanford.edu/pkg/prevent-4.3.1/
> > > i3
> > > 86
> > > _linux26/opt/prevent-linux-4.3.1/doc/prevent_admin.html#N40430
> > 
> > So there’s still this to try.
> 
> ^-- This is the approach I think is worth trying.
> 
> Philip
> 
> > (Note: I’m not on the PulseAudio mailing list, so please include me
> > in
> > CC in replies.)

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/4] roap: Fix double free

2017-02-22 Thread Peter Meerwald-Stadler
make nick variable local, fix double free
Coverity CID: #1398162

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-sink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modules/raop/raop-sink.c b/src/modules/raop/raop-sink.c
index 7d8fe36..d321a2d 100644
--- a/src/modules/raop/raop-sink.c
+++ b/src/modules/raop/raop-sink.c
@@ -460,7 +460,6 @@ pa_sink* pa_raop_sink_new(pa_module *m, pa_modargs *ma, 
const char *driver) {
 const char /* *username, */ *password;
 pa_sink_new_data data;
 const char *name = NULL;
-char * nick = NULL;
 
 pa_assert(m);
 pa_assert(ma);
@@ -550,9 +549,11 @@ pa_sink* pa_raop_sink_new(pa_module *m, pa_modargs *ma, 
const char *driver) {
 if ((name = pa_modargs_get_value(ma, "sink_name", NULL))) {
 pa_sink_new_data_set_name(, name);
 } else {
+char *nick;
+
 if ((name = pa_modargs_get_value(ma, "name", NULL)))
 nick = pa_sprintf_malloc("raop_client.%s", name);
-if (!nick)
+else
 nick = pa_sprintf_malloc("raop_client.%s", server);
 pa_sink_new_data_set_name(, nick);
 pa_xfree(nick);
@@ -618,7 +619,6 @@ pa_sink* pa_raop_sink_new(pa_module *m, pa_modargs *ma, 
const char *driver) {
 
 fail:
 pa_xfree(thread_name);
-pa_xfree(nick);
 
 if (u)
 userdata_free(u);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/4] roap-client: Fix loop searching for port number

2017-02-22 Thread Peter Meerwald-Stadler
do...while not reachable, loop should try different ports in case EADDRINUSE is 
returned
Coverity ID: #1398161

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 94342d2..e39663d 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -799,13 +799,16 @@ static int open_bind_udp_socket(pa_raop_client *c, 
uint16_t *actual_port) {
 }
 
 do {
-*sa_port = htons(port);
+int ret;
 
-if (bind(fd, sa, salen) < 0 && errno != EADDRINUSE) {
-pa_log("bind_socket() failed: %s", pa_cstrerror(errno));
+*sa_port = htons(port);
+ret = bind(fd, sa, salen);
+if (!ret)
+break;
+if (ret < 0 && errno != EADDRINUSE) {
+pa_log("bind() failed: %s", pa_cstrerror(errno));
 goto fail;
 }
-break;
 } while (++port > 0);
 
 pa_log_debug("Socket bound to port %d (SOCK_DGRAM)", port);
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/4] roap: Fix memleak

2017-02-22 Thread Peter Meerwald-Stadler
use local scope for trs variable simplifying cleanup
Coverity ID: #1398160

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index e39663d..4c3083e 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -983,14 +983,13 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_socket_client *sc = NULL;
 uint32_t sport = DEFAULT_UDP_AUDIO_PORT;
 uint32_t cport =0, tport = 0;
-char *ajs, *trs, *token, *pc;
+char *ajs, *token, *pc;
 const char *token_state = NULL;
 char delimiters[] = ";";
 
 pa_log_debug("RAOP: SETUP");
 
 ajs = pa_xstrdup(pa_headerlist_gets(headers, "Audio-Jack-Status"));
-trs = pa_xstrdup(pa_headerlist_gets(headers, "Transport"));
 
 if (ajs) {
 c->jack_type = JACK_TYPE_ANALOG;
@@ -1027,6 +1026,8 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 pa_socket_client_unref(sc);
 sc = NULL;
 } else if (c->protocol == PA_RAOP_PROTOCOL_UDP) {
+char *trs = pa_xstrdup(pa_headerlist_gets(headers, 
"Transport"));
+
 if (trs) {
 /* Now parse out the server port component of the 
response. */
 while ((token = pa_split(trs, delimiters, _state))) {
@@ -1040,6 +1041,7 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 }
 pa_xfree(token);
 }
+pa_xfree(trs);
 } else {
 pa_log_warn("\"Transport\" missing in RTSP setup 
response");
 }
@@ -1062,7 +1064,6 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_
 
 pa_rtsp_record(c->rtsp, >seq, >rtptime);
 
-pa_xfree(trs);
 pa_xfree(ajs);
 break;
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/4] raop: Fix resource leaks

2017-02-22 Thread Peter Meerwald-Stadler
Coverity ID: #1398158, #1398159

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/raop/raop-client.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index 4c3083e..03558f6 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1223,7 +1223,7 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 static bool waiting = false;
 const char *current = NULL;
 char space[] = " ";
-char *token,*ath = NULL;
+char *token, *ath = NULL;
 char *publ, *wath, *mth, *val;
 char *realm = NULL, *nonce = NULL, *response = NULL;
 char comma[] = ",";
@@ -1260,9 +1260,6 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 pa_raop_basic_response(DEFAULT_USER_NAME, c->password, 
);
 ath = pa_sprintf_malloc("Basic %s",
 response);
-
-pa_xfree(response);
-pa_xfree(realm);
 } else if (pa_safe_streq(mth, "Digest")) {
 rtrim_char(realm, '\"');
 rtrim_char(nonce, '\"');
@@ -1271,17 +1268,18 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, 
pa_rtsp_state_t state, pa_rtsp_st
 ath = pa_sprintf_malloc("Digest username=\"%s\", 
realm=\"%s\", nonce=\"%s\", uri=\"*\", response=\"%s\"",
 DEFAULT_USER_NAME, realm, nonce,
 response);
-
-pa_xfree(response);
-pa_xfree(realm);
-pa_xfree(nonce);
 } else {
 pa_log_error("unsupported authentication method: %s", mth);
+pa_xfree(realm);
+pa_xfree(nonce);
 pa_xfree(wath);
 pa_xfree(mth);
 goto error;
 }
 
+pa_xfree(response);
+pa_xfree(realm);
+pa_xfree(nonce);
 pa_xfree(wath);
 pa_xfree(mth);
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Coverity scan

2017-02-22 Thread Peter Meerwald-Stadler
Hi,

as written and discussed before (
https://lists.freedesktop.org/archives/pulseaudio-discuss/2015-September/024378.html
http://comments.gmane.org/gmane.comp.audio.pulseaudio.general/19270
http://pulseaudio-discuss.freedesktop.narkive.com/RH83JeQl/coverity-and-pa-asser-se
) I think we need to teach Coverity scan about the semantics of 
pa_assert_se()

this can be done in Coverity's config/user_nodefs.h, this is a local 
change to the Coverity installation (it sucks)

please have below line in your Coverity setup when submitting a build:
#nodef pa_assert_se(uniquex) do { int uniquey = uniquex ; if (!(uniquey)) 
__coverity_panic__(); } while (0)

ideally, this should be on a build server which also has a fixed set of 
libraries and configure options...

thanks, p.

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] sink, source: Add a mode to avoid resampling if possible

2017-01-28 Thread Peter Meerwald-Stadler
emixing,
>  remixing_use_all_sink_channels,
>  disable_lfe_remixing,
> diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in
> index 2d74afa..a955523 100644
> --- a/src/daemon/daemon.conf.in
> +++ b/src/daemon/daemon.conf.in
> @@ -54,6 +54,7 @@ ifelse(@HAVE_DBUS@, 1, [dnl
>  ; log-backtrace = 0
>  
>  ; resample-method = speex-float-1
> +; avoid-resampling = false
>  ; enable-remixing = yes
>  ; remixing-use-all-sink-channels = yes
>  ; enable-lfe-remixing = no
> diff --git a/src/daemon/main.c b/src/daemon/main.c
> index 280252a..f35252d 100644
> --- a/src/daemon/main.c
> +++ b/src/daemon/main.c
> @@ -1036,6 +1036,7 @@ int main(int argc, char *argv[]) {
>  c->resample_method = conf->resample_method;
>  c->realtime_priority = conf->realtime_priority;
>  c->realtime_scheduling = conf->realtime_scheduling;
> +c->avoid_resampling = conf->avoid_resampling;
>  c->disable_remixing = conf->disable_remixing;
>  c->remixing_use_all_sink_channels = conf->remixing_use_all_sink_channels;
>  c->disable_lfe_remixing = conf->disable_lfe_remixing;
> diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
> index d2fe887..212f6f7 100644
> --- a/src/pulsecore/core.h
> +++ b/src/pulsecore/core.h
> @@ -199,6 +199,7 @@ struct pa_core {
>  bool disallow_exit:1;
>  bool running_as_daemon:1;
>  bool realtime_scheduling:1;
> +bool avoid_resampling:1;
>  bool disable_remixing:1;
>  bool remixing_use_all_sink_channels:1;
>  bool disable_lfe_remixing:1;
> diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
> index aa21822..370ea9b 100644
> --- a/src/pulsecore/sink.c
> +++ b/src/pulsecore/sink.c
> @@ -1414,6 +1414,7 @@ int pa_sink_update_rate(pa_sink *s, uint32_t rate, bool 
> passthrough) {
>  pa_sink_input *i;
>  bool default_rate_is_usable = false;
>  bool alternate_rate_is_usable = false;
> +bool avoid_resampling = s->core->avoid_resampling;
>  
>  if (rate == s->sample_spec.rate)
>  return 0;
> @@ -1421,7 +1422,7 @@ int pa_sink_update_rate(pa_sink *s, uint32_t rate, bool 
> passthrough) {
>  if (!s->update_rate)
>  return -1;
>  
> -if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough)) {
> +if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough && 
> !avoid_resampling)) {
>  pa_log_debug("Default and alternate sample rates are the same, so 
> there is no point in switching.");
>  return -1;
>  }
> @@ -1442,7 +1443,12 @@ int pa_sink_update_rate(pa_sink *s, uint32_t rate, 
> bool passthrough) {
>  if (PA_UNLIKELY(!pa_sample_rate_valid(desired_rate)))
>  return -1;
>  
> -if (!passthrough && default_rate != desired_rate && alternate_rate != 
> desired_rate) {
> +if (avoid_resampling) {
> +/* We just try to set the sink input's sample rate if it's not too 
> low */
> +if (rate > default_rate || rate > alternate_rate)
> +desired_rate = rate;
> +
> +} else if (!passthrough && default_rate != desired_rate && 
> alternate_rate != desired_rate) {
>  if (default_rate % 11025 == 0 && desired_rate % 11025 == 0)
>  default_rate_is_usable = true;
>  if (default_rate % 4000 == 0 && desired_rate % 4000 == 0)
> diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
> index 8ce7818..ba59929 100644
> --- a/src/pulsecore/source.c
> +++ b/src/pulsecore/source.c
> @@ -982,6 +982,7 @@ int pa_source_update_rate(pa_source *s, uint32_t rate, 
> bool passthrough) {
>  uint32_t alternate_rate = s->alternate_sample_rate;
>  bool default_rate_is_usable = false;
>  bool alternate_rate_is_usable = false;
> +bool avoid_resampling = s->core->avoid_resampling;
>  
>  if (rate == s->sample_spec.rate)
>  return 0;
> @@ -989,7 +990,7 @@ int pa_source_update_rate(pa_source *s, uint32_t rate, 
> bool passthrough) {
>  if (!s->update_rate && !s->monitor_of)
>  return -1;
>  
> -if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough)) {
> +if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough && 
> !avoid_resampling)) {
>  pa_log_debug("Default and alternate sample rates are the same, so 
> there is no point in switching.");
>  return -1;
>  }
> @@ -1010,7 +1011,12 @@ int pa_source_update_rate(pa_source *s, uint32_t rate, 
> bool passthrough) {
>  if (PA_UNLIKELY(!pa_sample_rate_valid(desired_

Re: [pulseaudio-discuss] Purpose of 8-byte buffer alignment in cpu-mix-test.c

2016-11-20 Thread Peter Meerwald-Stadler
Hi Tanu,

> > Do you happen to remember why the audio buffers in run_mix_test() in
> > src/tests/cpu-mix-test.c are forced to have 8-byte alignment? I plan to
> > replace the stack-allocated buffers with regular memblocks, and the
> > memblock backing memory is only aligned to 4 bytes on 32-bit machines.
> > It's possible to still have the old alignment behaviour, but that
> > requires extra code, and if 4-byte alignment is equally fine, then I'd
> > prefer to avoid the extra code.
> 
> Also, why is the alignment so carefully controlled? All tests are run
> on a buffer that begins one sample after the 8-byte alignment boundary.
> Is this done to catch bugs related to weird (but valid) sample
> alignments?

probably this also constitutes a worst-case runtime-wise; I can't remember 
really

it would be nice to have explicit alignment requirements/guarantees on 
buffers that are potentially processed by SIMDy code; alignment might make 
the code run faster

regards, p.

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] json libraries

2016-11-03 Thread Peter Meerwald-Stadler
Hi,

here is a comparison of JSON parsing libraries, 
http://seriot.ch/parsing_json.php

maybe of interest since PA is now using its own code instead of json-c...

regards, p.

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 0/6] Coverity cleanups

2016-09-04 Thread Peter Meerwald-Stadler
> > v2 of Coverity cleanups, thanks for feedback from Tanu
> > 
> > Peter Meerwald-Stadler (6):
> >   padsp: Fix flush and improve error handling
> >   core: Replace PA_PAGE_SIZE with pa_page_size()
> >   tests: Assert granularity range in stripnul.c
> >   source-output: Avoid potential NULL dereference
> >   sink-input: Avoid potential NULL dereference
> >   sample: RFC: Assert validity of sample_spec
> 
> Apart from the source-output/sink-input patches, these look good to me.

Applied.
Regarding the source-output/sink-input patches, do you think the patch 
description is inappropriate or do you object the patch itself?
You suggested just asserting data->source...

thanks, p.

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 5/6] sink-input: Avoid potential NULL dereference

2016-08-30 Thread Peter Meerwald-Stadler
if data->sink is NULL, pa_sink_input_new_data_set_sink() may fail to set 
data->sink;
the false retval is ignored, leading to a NULL dereference in 
pa_sink_get_state(data->sink) below

CID 1323591
---
 src/pulsecore/sink-input.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 0dda204..39e2e61 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -337,7 +337,7 @@ int pa_sink_input_new(
 if (!data->format && data->nego_formats && 
!pa_idxset_isempty(data->nego_formats))
 data->format = pa_format_info_copy(pa_idxset_first(data->nego_formats, 
NULL));
 
-if (PA_LIKELY(data->format)) {
+if (PA_LIKELY(data->format) && PA_LIKELY(data->sink)) {
 pa_log_debug("Negotiated format: %s", pa_format_info_snprint(fmt, 
sizeof(fmt), data->format));
 } else {
 pa_format_info *format;
-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 6/6] sample: RFC: Assert validity of sample_spec

2016-08-30 Thread Peter Meerwald-Stadler
passing an invalid sample_spec to
pa_sample_size_of_format(),
pa_frame_size(),
pa_bytes_per_second(),
pa_bytes_to_usec(),
pa_usec_to_bytes()
currently gives a result of 0

this is problematic as
(a) it leads to many potential divide-by-zero issues flagged by Coverity,
(b) pa_sample_spec_valid() is called often and the mostly unnecessary validation
of the sample_spec cannot be optimized away due to pa_return_val_if_fail()
(c) nobody checks the result for 0 and the behaviour is not documented

this patch replaces pa_return_val_if_fail() with pa_assert()

note that this commit changes the API!
note that pa_return_val_if_fail() strangely logs an assertion, but then happily
continues...

fixes numerious CIDs
---
 src/pulse/sample.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/pulse/sample.c b/src/pulse/sample.c
index 1331c72..cb04254 100644
--- a/src/pulse/sample.c
+++ b/src/pulse/sample.c
@@ -56,37 +56,36 @@ size_t pa_sample_size_of_format(pa_sample_format_t f) {
 }
 
 size_t pa_sample_size(const pa_sample_spec *spec) {
-
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return size_table[spec->format];
 }
 
 size_t pa_frame_size(const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return size_table[spec->format] * spec->channels;
 }
 
 size_t pa_bytes_per_second(const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return spec->rate * size_table[spec->format] * spec->channels;
 }
 
 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return (((pa_usec_t) (length / (size_table[spec->format] * 
spec->channels)) * PA_USEC_PER_SEC) / spec->rate);
 }
 
 size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return (size_t) (((t * spec->rate) / PA_USEC_PER_SEC)) * 
(size_table[spec->format] * spec->channels);
 }
-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 3/6] tests: Assert granularity range in stripnul.c

2016-08-30 Thread Peter Meerwald-Stadler
granularity must not be larger than buffer size

CID 1138482
---
 src/tests/stripnul.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/tests/stripnul.c b/src/tests/stripnul.c
index 75390bd..e4b07aa 100644
--- a/src/tests/stripnul.c
+++ b/src/tests/stripnul.c
@@ -26,6 +26,8 @@
 #include 
 #include 
 
+#define MAX_BUFFER (16*1024)
+
 int main(int argc, char *argv[]) {
 FILE *i, *o;
 size_t granularity;
@@ -34,13 +36,14 @@ int main(int argc, char *argv[]) {
 
 pa_assert_se(argc >= 2);
 pa_assert_se((granularity = (size_t) atoi(argv[1])) >= 1);
+pa_assert(granularity <= MAX_BUFFER);
 pa_assert_se((i = (argc >= 3) ? fopen(argv[2], "r") : stdin));
 pa_assert_se((o = (argc >= 4) ? fopen(argv[3], "w") : stdout));
 
 zero = pa_xmalloc0(granularity);
 
 for (;;) {
-uint8_t buffer[16*1024], *p;
+uint8_t buffer[MAX_BUFFER], *p;
 size_t k;
 
 k = fread(buffer, granularity, sizeof(buffer)/granularity, i);
-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 0/6] Coverity cleanups

2016-08-30 Thread Peter Meerwald-Stadler
v2 of Coverity cleanups, thanks for feedback from Tanu

Peter Meerwald-Stadler (6):
  padsp: Fix flush and improve error handling
  core: Replace PA_PAGE_SIZE with pa_page_size()
  tests: Assert granularity range in stripnul.c
  source-output: Avoid potential NULL dereference
  sink-input: Avoid potential NULL dereference
  sample: RFC: Assert validity of sample_spec

 src/daemon/main.c |2 +-
 src/pulse/sample.c|   11 +--
 src/pulsecore/core-util.c |   26 --
 src/pulsecore/core-util.h |   13 +
 src/pulsecore/macro.h |   21 -
 src/pulsecore/memblock.c  |5 +++--
 src/pulsecore/sample-util.c   |2 +-
 src/pulsecore/shm.c   |7 ---
 src/pulsecore/sink-input.c|4 ++--
 src/pulsecore/sink.c  |2 +-
 src/pulsecore/source-output.c |2 +-
 src/tests/sigbus-test.c   |   13 +++--
 src/tests/stripnul.c  |5 -
 src/utils/padsp.c |   11 +--
 14 files changed, 75 insertions(+), 49 deletions(-)

-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 2/6] core: Replace PA_PAGE_SIZE with pa_page_size()

2016-08-30 Thread Peter Meerwald-Stadler
PA_PAGE_SIZE using sysconf() may return a negative number

CID 1137925, CID 1137926, CID 1138485

instead of calling sysconf() directly, add function pa_page_size()
which uses the guestimate 4096 in case sysconf(_SC_PAGE_SIZE) fails

using PA_ONCE to only evaluate sysconf() once
---
 src/daemon/main.c   |2 +-
 src/pulsecore/core-util.c   |   26 --
 src/pulsecore/core-util.h   |   13 +
 src/pulsecore/macro.h   |   21 -
 src/pulsecore/memblock.c|5 +++--
 src/pulsecore/sample-util.c |2 +-
 src/pulsecore/shm.c |7 ---
 src/pulsecore/sink-input.c  |2 +-
 src/pulsecore/sink.c|2 +-
 src/tests/sigbus-test.c |   13 +++--
 10 files changed, 55 insertions(+), 38 deletions(-)

diff --git a/src/daemon/main.c b/src/daemon/main.c
index a313dc5..dc5e5bc 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -918,7 +918,7 @@ int main(int argc, char *argv[]) {
 
 pa_log_debug("Found %u CPUs.", pa_ncpus());
 
-pa_log_info("Page size is %lu bytes", (unsigned long) PA_PAGE_SIZE);
+pa_log_info("Page size is %zu bytes", pa_page_size());
 
 #ifdef HAVE_VALGRIND_MEMCHECK_H
 pa_log_debug("Compiled with Valgrind support: yes");
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index da1b0c8..350f35b 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -138,6 +138,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "core-util.h"
 
@@ -2553,6 +2554,7 @@ void *pa_will_need(const void *p, size_t l) {
 size_t size;
 int r = ENOTSUP;
 size_t bs;
+const size_t page_size = pa_page_size();
 
 pa_assert(p);
 pa_assert(l > 0);
@@ -2577,7 +2579,7 @@ void *pa_will_need(const void *p, size_t l) {
 #ifdef RLIMIT_MEMLOCK
 pa_assert_se(getrlimit(RLIMIT_MEMLOCK, ) == 0);
 
-if (rlim.rlim_cur < PA_PAGE_SIZE) {
+if (rlim.rlim_cur < page_size) {
 pa_log_debug("posix_madvise() failed (or doesn't exist), resource 
limits don't allow mlock(), can't page in data: %s", pa_cstrerror(r));
 errno = EPERM;
 return (void*) p;
@@ -2585,7 +2587,7 @@ void *pa_will_need(const void *p, size_t l) {
 
 bs = PA_PAGE_ALIGN((size_t) rlim.rlim_cur);
 #else
-bs = PA_PAGE_SIZE*4;
+bs = page_size*4;
 #endif
 
 pa_log_debug("posix_madvise() failed (or doesn't exist), trying mlock(): 
%s", pa_cstrerror(r));
@@ -3669,3 +3671,23 @@ bool pa_running_in_vm(void) {
 
 return false;
 }
+
+size_t pa_page_size(void) {
+#if defined(PAGE_SIZE)
+return PAGE_SIZE;
+#elif defined(PAGESIZE)
+return PAGESIZE;
+#elif defined(HAVE_SYSCONF)
+static size_t page_size = 4096; /* Let's hope it's like x86. */
+
+PA_ONCE_BEGIN {
+long ret = sysconf(_SC_PAGE_SIZE);
+if (ret > 0)
+page_size = ret;
+} PA_ONCE_END;
+
+return page_size;
+#else
+return 4096;
+#endif
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 5725ca7..ede1ae2 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -302,4 +302,17 @@ bool pa_running_in_vm(void);
 char *pa_win32_get_toplevel(HANDLE handle);
 #endif
 
+size_t pa_page_size(void);
+
+/* Rounds down */
+static inline void* PA_PAGE_ALIGN_PTR(const void *p) {
+return (void*) (((size_t) p) & ~(pa_page_size() - 1));
+}
+
+/* Rounds up */
+static inline size_t PA_PAGE_ALIGN(size_t l) {
+size_t page_size = pa_page_size();
+return (l + page_size - 1) & ~(page_size - 1);
+}
+
 #endif
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index f80b43c..2c5d5f2 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -44,17 +44,6 @@
 #endif
 #endif
 
-#if defined(PAGE_SIZE)
-#define PA_PAGE_SIZE ((size_t) PAGE_SIZE)
-#elif defined(PAGESIZE)
-#define PA_PAGE_SIZE ((size_t) PAGESIZE)
-#elif defined(HAVE_SYSCONF)
-#define PA_PAGE_SIZE ((size_t) (sysconf(_SC_PAGE_SIZE)))
-#else
-/* Let's hope it's like x86. */
-#define PA_PAGE_SIZE ((size_t) 4096)
-#endif
-
 /* Rounds down */
 static inline void* PA_ALIGN_PTR(const void *p) {
 return (void*) (((size_t) p) & ~(sizeof(void*) - 1));
@@ -65,16 +54,6 @@ static inline size_t PA_ALIGN(size_t l) {
 return ((l + sizeof(void*) - 1) & ~(sizeof(void*) - 1));
 }
 
-/* Rounds down */
-static inline void* PA_PAGE_ALIGN_PTR(const void *p) {
-return (void*) (((size_t) p) & ~(PA_PAGE_SIZE - 1));
-}
-
-/* Rounds up */
-static inline size_t PA_PAGE_ALIGN(size_t l) {
-return (l + PA_PAGE_SIZE - 1) & ~(PA_PAGE_SIZE - 1);
-}
-
 #if defined(__GNUC__)
 #define PA_UNUSED __attribute__ ((unused))
 #else
diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index 17520ed..dbad32a 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -828,13 +828,14 @@ static void memblock_replace_import(pa_memblock *b) {
 pa_mempool *pa_mempool_new(pa_mem_type_t type, size_t size, bool per_client) {
 pa_mempool *p;
 char 

[pulseaudio-discuss] [PATCH 6/6] sample: RFC: Assert validity of sample_spec

2016-08-18 Thread Peter Meerwald-Stadler
passing an invalid sample_spec to
pa_sample_size_of_format(),
pa_frame_size(),
pa_bytes_per_second(),
pa_bytes_to_usec(),
pa_usec_to_bytes()
currently gives a result of 0

this is problematic as
(a) it leads to many potential divide-by-zero issues flagged by Coverity,
(b) pa_sample_spec_valid() is called often and the mostly unnecessary validation
of the sample_spec cannot be optimized away due to pa_return_val_if_fail()
(c) nobody checks the result for 0 and the behaviour is not documented

this patch replaces pa_return_val_if_fail() with pa_assert()

note that this commit changes the API!
note that pa_return_val_if_fail() strangely logs an assertion, but then happily
continues...

fixes numerious CIDs
---
 src/pulse/sample.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/pulse/sample.c b/src/pulse/sample.c
index 1331c72..cb04254 100644
--- a/src/pulse/sample.c
+++ b/src/pulse/sample.c
@@ -56,37 +56,36 @@ size_t pa_sample_size_of_format(pa_sample_format_t f) {
 }
 
 size_t pa_sample_size(const pa_sample_spec *spec) {
-
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return size_table[spec->format];
 }
 
 size_t pa_frame_size(const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return size_table[spec->format] * spec->channels;
 }
 
 size_t pa_bytes_per_second(const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return spec->rate * size_table[spec->format] * spec->channels;
 }
 
 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return (((pa_usec_t) (length / (size_table[spec->format] * 
spec->channels)) * PA_USEC_PER_SEC) / spec->rate);
 }
 
 size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) {
 pa_assert(spec);
-pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
+pa_assert(pa_sample_spec_valid(spec));
 
 return (size_t) (((t * spec->rate) / PA_USEC_PER_SEC)) * 
(size_table[spec->format] * spec->channels);
 }
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/6] source-output: Avoid potential NULL dereference

2016-08-18 Thread Peter Meerwald-Stadler
if data->source is NULL, pa_source_output_new_data_set_source() may fail to set 
data->source;
the false retval is ignored, leading to a NULL dereference in 
pa_source_get_state(data->source) below

CID 1323590
---
 src/pulsecore/source-output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 35ef1c5..d6a1d57 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -271,7 +271,8 @@ int pa_source_output_new(
 pa_return_val_if_fail(source, -PA_ERR_NOENTITY);
 }
 
-pa_source_output_new_data_set_source(data, source, false);
+if (!pa_source_output_new_data_set_source(data, source, false))
+return -PA_ERR_NOTSUPPORTED;
 }
 
 /* If something didn't pick a format for us, pick the top-most format since
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 5/6] sink-input: Avoid potential NULL dereference

2016-08-18 Thread Peter Meerwald-Stadler
if data->sink is NULL, pa_sink_input_new_data_set_sink() may fail to set 
data->sink;
the false retval is ignored, leading to a NULL dereference in 
pa_sink_get_state(data->sink) below

CID 1323591
---
 src/pulsecore/sink-input.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 435e63e..36f4aa8 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -329,7 +329,8 @@ int pa_sink_input_new(
 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);
+if (!pa_sink_input_new_data_set_sink(data, sink, false))
+return -PA_ERR_NOTSUPPORTED;
 }
 
 /* If something didn't pick a format for us, pick the top-most format since
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/6] core: PA_PAGE_SIZE using sysconf() may return a negative number

2016-08-18 Thread Peter Meerwald-Stadler
instead of calling sysconf() directly, add function pa_page_size()
which uses the guestimate 4096 in case sysconf(_SC_PAGE_SIZE) fails

using PA_ONCE to only evaluate sysconf() once

the name macro.h/.c is a bit unfortunate when adding functions

CID 1137925, CID 1137926, CID 1138485
---
 src/Makefile.am   |  2 +-
 src/pulsecore/macro.c | 39 +++
 src/pulsecore/macro.h |  3 ++-
 3 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 src/pulsecore/macro.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 7b19497..13c5375 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -692,7 +692,7 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
pulsecore/lock-autospawn.c pulsecore/lock-autospawn.h \
pulsecore/log.c pulsecore/log.h \
pulsecore/ratelimit.c pulsecore/ratelimit.h \
-   pulsecore/macro.h \
+   pulsecore/macro.c pulsecore/macro.h \
pulsecore/mcalign.c pulsecore/mcalign.h \
pulsecore/memblock.c pulsecore/memblock.h \
pulsecore/memblockq.c pulsecore/memblockq.h \
diff --git a/src/pulsecore/macro.c b/src/pulsecore/macro.c
new file mode 100644
index 000..70cadf1
--- /dev/null
+++ b/src/pulsecore/macro.c
@@ -0,0 +1,39 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2016 Peter Meerwald-Stadler
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation; either version 2.1 of the
+  License, or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
+#include "macro.h"
+
+#if defined(HAVE_SYSCONF)
+size_t pa_page_size(void) {
+static size_t page_size = 4096; /* Let's hope it's like x86. */
+
+PA_ONCE_BEGIN {
+long ret = sysconf(_SC_PAGE_SIZE);
+if (ret > 0)
+page_size = ret;
+} PA_ONCE_END;
+
+return page_size;
+}
+#endif
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index f80b43c..3871180 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -49,7 +49,8 @@
 #elif defined(PAGESIZE)
 #define PA_PAGE_SIZE ((size_t) PAGESIZE)
 #elif defined(HAVE_SYSCONF)
-#define PA_PAGE_SIZE ((size_t) (sysconf(_SC_PAGE_SIZE)))
+size_t pa_page_size(void);
+#define PA_PAGE_SIZE (pa_page_size())
 #else
 /* Let's hope it's like x86. */
 #define PA_PAGE_SIZE ((size_t) 4096)
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/6] tests: Assert granularity range in stripnul.c

2016-08-18 Thread Peter Meerwald-Stadler
CID 1138482
---
 src/tests/stripnul.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/tests/stripnul.c b/src/tests/stripnul.c
index 75390bd..78bb040 100644
--- a/src/tests/stripnul.c
+++ b/src/tests/stripnul.c
@@ -34,6 +34,7 @@ int main(int argc, char *argv[]) {
 
 pa_assert_se(argc >= 2);
 pa_assert_se((granularity = (size_t) atoi(argv[1])) >= 1);
+pa_assert(granularity <= 1024);
 pa_assert_se((i = (argc >= 3) ? fopen(argv[2], "r") : stdin));
 pa_assert_se((o = (argc >= 4) ? fopen(argv[3], "w") : stdout));
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/6] padsp: Fix flush

2016-08-18 Thread Peter Meerwald-Stadler
read() can return a number of bytes read less than k

CID 1137981
---
 src/utils/padsp.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/utils/padsp.c b/src/utils/padsp.c
index 943479b..bb01f7f 100644
--- a/src/utils/padsp.c
+++ b/src/utils/padsp.c
@@ -1768,11 +1768,18 @@ static int dsp_flush_fd(int fd) {
 while (l > 0) {
 char buf[1024];
 size_t k;
+ssize_t r;
 
 k = (size_t) l > sizeof(buf) ? sizeof(buf) : (size_t) l;
-if (read(fd, buf, k) < 0)
+r = read(fd, buf, k);
+if (r < 0) {
+if (errno == EAGAIN)
+break;
 debug(DEBUG_LEVEL_NORMAL, __FILE__": read(): %s\n", 
strerror(errno));
-l -= k;
+return -1;
+} else if (r == 0)
+return 0;
+l -= r;
 }
 
 return 0;
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 1/2] bluetooth: Fix potential NULL pointer dereference

2016-08-17 Thread Peter Meerwald-Stadler

> On Wed, 2016-08-17 at 14:43 +0200, Peter Meerwald-Stadler wrote:
> > I can't find an easy argument why the NULL dereference can't happen (as I 
> > am not intimate with the semantics of the dbus functions involved)
> 
> Sorry, I should have provided an explanation already in my previous
> mail.

will add that to the commit message, thanks!
 
> > why is d always != NULL when 
> > dbus_message_is_method_call(p->message, "org.bluez.Device",
> > "GetProperties") != 0?
> 
> Because of this part:
> 
>     if (dbus_message_has_interface(p->message, "org.bluez.Manager") ||
> dbus_message_has_interface(p->message, "org.bluez.Adapter"))
> d = NULL;
> else if (!(d = pa_hashmap_get(y->devices, 
> dbus_message_get_path(p->message {
> pa_log_warn("Received GetProperties() reply from unknown device: %s 
> (device removed?)", dbus_message_get_path(p->message));
> goto finish2;
> }
> 
> d can be NULL only if p->message interface is org.bluez.Manager or
> org.bluez.Adapter. If
> 
>     dbus_message_is_method_call(p->message, "org.bluez.Device", 
> "GetProperties")
> 
> returns true, we know that the interface is org.bluez.Device.
> 
> -- 
> Tanu
> _______
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 2/2] bluetooth: Fix negative array index write

2016-08-17 Thread Peter Meerwald-Stadler
From: Peter Meerwald <p.meerw...@bct-electronic.com>

CID 1533121

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>

---
v2: use pa_read() as Tanu suggested
---
 src/modules/bluetooth/backend-native.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/backend-native.c 
b/src/modules/bluetooth/backend-native.c
index 86376c0..cf88126 100644
--- a/src/modules/bluetooth/backend-native.c
+++ b/src/modules/bluetooth/backend-native.c
@@ -231,14 +231,17 @@ static void rfcomm_io_callback(pa_mainloop_api *io, 
pa_io_event *e, int fd, pa_i
 ssize_t len;
 int gain;
 
-len = read(fd, buf, 511);
+len = pa_read(fd, buf, 511, NULL);
+if (len < 0) {
+pa_log_error("RFCOMM read error: %s", pa_cstrerror(errno));
+goto fail;
+}
 buf[len] = 0;
 pa_log_debug("RFCOMM << %s", buf);
 
 if (sscanf(buf, "AT+VGS=%d", ) == 1) {
   t->speaker_gain = gain;
   pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, 
PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED), t);
-
 } else if (sscanf(buf, "AT+VGM=%d", ) == 1) {
   t->microphone_gain = gain;
   pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, 
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), t);
@@ -259,7 +262,6 @@ static void rfcomm_io_callback(pa_mainloop_api *io, 
pa_io_event *e, int fd, pa_i
 fail:
 pa_bluetooth_transport_unlink(t);
 pa_bluetooth_transport_free(t);
-return;
 }
 
 static void transport_destroy(pa_bluetooth_transport *t) {
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH v2 1/2] bluetooth: Reorganize code to avoid Coverity NULL dereference warning

2016-08-17 Thread Peter Meerwald-Stadler
From: Peter Meerwald <p.meerw...@bct-electronic.com>

CID 1353122

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>

---
v2: wording as suggested by Tanu, thanks!
---
 src/modules/bluetooth/bluez4-util.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/modules/bluetooth/bluez4-util.c 
b/src/modules/bluetooth/bluez4-util.c
index 3793898..542ce35 100644
--- a/src/modules/bluetooth/bluez4-util.c
+++ b/src/modules/bluetooth/bluez4-util.c
@@ -657,13 +657,13 @@ static void get_properties_reply(DBusPendingCall 
*pending, void *userdata) {
 
 pa_assert(p->call_data == d);
 
-if (d != NULL)
+if (d != NULL) {
 old_any_connected = pa_bluez4_device_any_audio_connected(d);
+valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR ? -1 : 1;
 
-valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR ? -1 : 1;
-
-if (dbus_message_is_method_call(p->message, "org.bluez.Device", 
"GetProperties"))
-d->device_info_valid = valid;
+if (dbus_message_is_method_call(p->message, "org.bluez.Device", 
"GetProperties"))
+d->device_info_valid = valid;
+}
 
 if (dbus_message_is_error(r, DBUS_ERROR_SERVICE_UNKNOWN)) {
 pa_log_debug("Bluetooth daemon is apparently not available.");
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 1/2] bluetooth: Fix potential NULL pointer dereference

2016-08-17 Thread Peter Meerwald-Stadler

> > CID 1353122
> > 
> > Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
> > ---
> >  src/modules/bluetooth/bluez4-util.c | 10 +-
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/modules/bluetooth/bluez4-util.c
> > b/src/modules/bluetooth/bluez4-util.c
> > index 3793898..542ce35 100644
> > --- a/src/modules/bluetooth/bluez4-util.c
> > +++ b/src/modules/bluetooth/bluez4-util.c
> > @@ -657,13 +657,13 @@ static void
> > get_properties_reply(DBusPendingCall *pending, void *userdata) {
> >  
> >  pa_assert(p->call_data == d);
> >  
> > -if (d != NULL)
> > +if (d != NULL) {
> >  old_any_connected = pa_bluez4_device_any_audio_connected(d);
> > +valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR
> > ? -1 : 1;
> >  
> > -valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR ? -1
> > : 1;
> > -
> > -if (dbus_message_is_method_call(p->message, "org.bluez.Device",
> > "GetProperties"))
> > -d->device_info_valid = valid;
> > +if (dbus_message_is_method_call(p->message,
> > "org.bluez.Device", "GetProperties"))
> > +d->device_info_valid = valid;
> > +}
> >  
> >  if (dbus_message_is_error(r, DBUS_ERROR_SERVICE_UNKNOWN)) {
> >  pa_log_debug("Bluetooth daemon is apparently not
> > available.");
> 
> I don't think there's any risk of NULL pointer dereference, so the
> commit message needs to be changed. The change itself is fine, though,
> if it gets rid of a false positive from Coverity.

I can't find an easy argument why the NULL dereference can't happen (as I 
am not intimate with the semantics of the dbus functions involved)

why is d always != NULL when 
dbus_message_is_method_call(p->message, "org.bluez.Device", "GetProperties") != 
0?

will to change to: reorganize code to avoid Coverity warning

thanks, p.

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/2] bluetooth: Fix negative array index write

2016-08-16 Thread Peter Meerwald-Stadler
From: Peter Meerwald <p.meerw...@bct-electronic.com>

CID 1533121

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/bluetooth/backend-native.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/modules/bluetooth/backend-native.c 
b/src/modules/bluetooth/backend-native.c
index 86376c0..b5f78f5 100644
--- a/src/modules/bluetooth/backend-native.c
+++ b/src/modules/bluetooth/backend-native.c
@@ -232,13 +232,16 @@ static void rfcomm_io_callback(pa_mainloop_api *io, 
pa_io_event *e, int fd, pa_i
 int gain;
 
 len = read(fd, buf, 511);
+if (len < 0) {
+pa_log_error("RFCOMM read error: %s", pa_cstrerror(errno));
+goto fail;
+}
 buf[len] = 0;
 pa_log_debug("RFCOMM << %s", buf);
 
 if (sscanf(buf, "AT+VGS=%d", ) == 1) {
   t->speaker_gain = gain;
   pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, 
PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED), t);
-
 } else if (sscanf(buf, "AT+VGM=%d", ) == 1) {
   t->microphone_gain = gain;
   pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, 
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), t);
@@ -259,7 +262,6 @@ static void rfcomm_io_callback(pa_mainloop_api *io, 
pa_io_event *e, int fd, pa_i
 fail:
 pa_bluetooth_transport_unlink(t);
 pa_bluetooth_transport_free(t);
-return;
 }
 
 static void transport_destroy(pa_bluetooth_transport *t) {
-- 
2.9.3

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/2] bluetooth: Fix potential NULL pointer dereference

2016-08-16 Thread Peter Meerwald-Stadler
From: Peter Meerwald <p.meerw...@bct-electronic.com>

CID 1353122

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/bluetooth/bluez4-util.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/modules/bluetooth/bluez4-util.c 
b/src/modules/bluetooth/bluez4-util.c
index 3793898..542ce35 100644
--- a/src/modules/bluetooth/bluez4-util.c
+++ b/src/modules/bluetooth/bluez4-util.c
@@ -657,13 +657,13 @@ static void get_properties_reply(DBusPendingCall 
*pending, void *userdata) {
 
 pa_assert(p->call_data == d);
 
-if (d != NULL)
+if (d != NULL) {
 old_any_connected = pa_bluez4_device_any_audio_connected(d);
+valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR ? -1 : 1;
 
-valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR ? -1 : 1;
-
-if (dbus_message_is_method_call(p->message, "org.bluez.Device", 
"GetProperties"))
-d->device_info_valid = valid;
+if (dbus_message_is_method_call(p->message, "org.bluez.Device", 
"GetProperties"))
+d->device_info_valid = valid;
+}
 
 if (dbus_message_is_error(r, DBUS_ERROR_SERVICE_UNKNOWN)) {
 pa_log_debug("Bluetooth daemon is apparently not available.");
-- 
2.9.3

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/3] bluetooth: Fix dead code

2016-08-15 Thread Peter Meerwald-Stadler
CID 1353115

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/bluetooth/module-bluez4-discover.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/modules/bluetooth/module-bluez4-discover.c 
b/src/modules/bluetooth/module-bluez4-discover.c
index e39036a..cac7510 100644
--- a/src/modules/bluetooth/module-bluez4-discover.c
+++ b/src/modules/bluetooth/module-bluez4-discover.c
@@ -124,7 +124,7 @@ static pa_hook_result_t 
load_module_for_device(pa_bluez4_discovery *y, const pa_
 
 int pa__init(pa_module* m) {
 struct userdata *u;
-pa_modargs *ma = NULL;
+pa_modargs *ma;
 
 pa_assert(m);
 
@@ -140,7 +140,6 @@ int pa__init(pa_module* m) {
 u->module = m;
 u->core = m->core;
 u->modargs = ma;
-ma = NULL;
 u->hashmap = pa_hashmap_new(pa_idxset_string_hash_func, 
pa_idxset_string_compare_func);
 
 if (!(u->discovery = pa_bluez4_discovery_get(u->core)))
@@ -154,9 +153,6 @@ int pa__init(pa_module* m) {
 fail:
 pa__done(m);
 
-if (ma)
-pa_modargs_free(ma);
-
 return -1;
 }
 
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/3] Remove newline at end of log messages

2016-08-15 Thread Peter Meerwald-Stadler
Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/daemon/main.c| 14 +++---
 src/modules/alsa/alsa-util.c | 16 
 src/modules/bluetooth/backend-native.c   |  2 +-
 src/modules/bluetooth/bluez4-util.c  |  2 +-
 src/modules/bluetooth/module-bluez4-device.c |  2 +-
 src/modules/xen/module-xenpv-sink.c  | 28 ++--
 src/pulsecore/core-util.c|  6 +++---
 src/pulsecore/macro.h|  4 ++--
 src/pulsecore/shm.c  |  2 +-
 src/tests/cpu-mix-test.c |  2 +-
 src/tests/cpu-remap-test.c   |  4 ++--
 src/tests/cpu-volume-test.c  |  2 +-
 src/tests/interpol-test.c|  2 +-
 src/tests/lfe-filter-test.c  |  4 ++--
 src/tests/lo-test-util.c | 20 ++--
 src/tests/mix-test.c |  2 +-
 src/tests/remix-test.c   |  2 +-
 src/tests/utf8-test.c|  6 +++---
 18 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/src/daemon/main.c b/src/daemon/main.c
index 28bbf52..a313dc5 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -550,7 +550,7 @@ int main(int argc, char *argv[]) {
 case PA_CMD_DUMP_CONF: {
 
 if (d < argc) {
-pa_log("Too many arguments.\n");
+pa_log("Too many arguments.");
 goto finish;
 }
 
@@ -565,7 +565,7 @@ int main(int argc, char *argv[]) {
 int i;
 
 if (d < argc) {
-pa_log("Too many arguments.\n");
+pa_log("Too many arguments.");
 goto finish;
 }
 
@@ -585,7 +585,7 @@ int main(int argc, char *argv[]) {
 case PA_CMD_VERSION :
 
 if (d < argc) {
-pa_log("Too many arguments.\n");
+pa_log("Too many arguments.");
 goto finish;
 }
 
@@ -597,7 +597,7 @@ int main(int argc, char *argv[]) {
 pid_t pid;
 
 if (d < argc) {
-pa_log("Too many arguments.\n");
+pa_log("Too many arguments.");
 goto finish;
 }
 
@@ -614,7 +614,7 @@ int main(int argc, char *argv[]) {
 case PA_CMD_KILL:
 
 if (d < argc) {
-pa_log("Too many arguments.\n");
+pa_log("Too many arguments.");
 goto finish;
 }
 
@@ -628,7 +628,7 @@ int main(int argc, char *argv[]) {
 case PA_CMD_CLEANUP_SHM:
 
 if (d < argc) {
-pa_log("Too many arguments.\n");
+pa_log("Too many arguments.");
 goto finish;
 }
 
@@ -642,7 +642,7 @@ int main(int argc, char *argv[]) {
 }
 
 if (d < argc) {
-pa_log("Too many arguments.\n");
+pa_log("Too many arguments.");
 goto finish;
 }
 
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index a4bb449..dfb2aa7 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -474,32 +474,32 @@ int pa_alsa_set_sw_params(snd_pcm_t *pcm, 
snd_pcm_uframes_t avail_min, bool peri
 snd_pcm_sw_params_alloca();
 
 if ((err = snd_pcm_sw_params_current(pcm, swparams)) < 0) {
-pa_log_warn("Unable to determine current swparams: %s\n", 
pa_alsa_strerror(err));
+pa_log_warn("Unable to determine current swparams: %s", 
pa_alsa_strerror(err));
 return err;
 }
 
 if ((err = snd_pcm_sw_params_set_period_event(pcm, swparams, 
period_event)) < 0) {
-pa_log_warn("Unable to disable period event: %s\n", 
pa_alsa_strerror(err));
+pa_log_warn("Unable to disable period event: %s", 
pa_alsa_strerror(err));
 return err;
 }
 
 if ((err = snd_pcm_sw_params_set_tstamp_mode(pcm, swparams, 
SND_PCM_TSTAMP_ENABLE)) < 0) {
-pa_log_warn("Unable to enable time stamping: %s\n", 
pa_alsa_strerror(err));
+pa_log_warn("Unable to enable time stamping: %s", 
pa_alsa_strerror(err));
 return err;
 }
 
 if ((err = snd_pcm_sw_params_get_boundary(swparams, )) < 0) {
-pa_log_warn("Unable to get boundary: %s\n", pa_alsa_strerror(err));
+pa_log_warn("Unable to get boundary: %s", pa_alsa_strerror(err));
 return err;
 }
 
 if ((err = snd_pcm_sw_params_set_stop_threshold(pcm, swparams, boundary)) 
< 0) {
-pa_log_warn("Unable to set stop threshold: %s\n", 
pa_alsa_strerror(err));
+pa_log_warn("Unable to set stop threshold: %s", 

[pulseaudio-discuss] [PATCH 2/3] bluetooth: Don't free modargs twice

2016-08-15 Thread Peter Meerwald-Stadler
CID1353139

Signed-off-by: Peter Meerwald-Stadler <pme...@pmeerw.net>
---
 src/modules/bluetooth/module-bluez5-device.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/module-bluez5-device.c 
b/src/modules/bluetooth/module-bluez5-device.c
index e610095..edfd8c7 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -2198,12 +2198,11 @@ int pa__init(pa_module* m) {
 u->transport_microphone_gain_changed_slot =
 pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, 
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), PA_HOOK_NORMAL, 
(pa_hook_cb_t) transport_microphone_gain_changed_cb, u);
 
-
 if (add_card(u) < 0)
-goto fail;
+goto fail2;
 
 if (!(u->msg = pa_msgobject_new(bluetooth_msg)))
-goto fail;
+goto fail2;
 
 u->msg->parent.process_msg = device_process_msg;
 u->msg->card = u->card;
@@ -2230,6 +2229,8 @@ fail:
 if (ma)
 pa_modargs_free(ma);
 
+fail2:
+
 pa__done(m);
 
 return -1;
-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 00/12] patches addressing some Coverity issues

2016-08-15 Thread Peter Meerwald-Stadler

> > the remaining patches will go to next after review
> Also ack'ed.

patches were forgotten since September 2015... applied them now

 
> > Peter Meerwald (12):
> >   modules: Fix unchecked return in module-card-restore
> >   core: Assert that memblockq's base is != 0

> >   tests: Assert fillrate > 0 in alsa-time-test
applied

> >   daemon: No need to check optarg, -p requires argument
> >   modules: Fix entry leak in module-card-restore
> >   modules: Cleanup get_sinks() in module-equalizer-sink
> >   core: Add missing return on protocol error

> >   modules: Use pa_assert_se() to check return value of
> > dbus_message_iter_close_container()
applied

> >   modules: Check pa_threaded_mainloop_start() return value
applied

> >   tests: Check pa_rtpoll_run() return value
applied

> >   stream: Check pa_tagstruct_get_format_info() retval in
> > pa_create_stream_callback()
applied

> >   alsa: Check pa_modargs_get_value_boolean() retval for use_ucm
applied

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] sink-input, source-output: Fix logging, don't overwrite old_value when value == 0

2016-08-15 Thread Peter Meerwald-Stadler
---
 src/pulsecore/sink-input.c|   10 --
 src/pulsecore/source-output.c |   10 --
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 1ed5dda..435e63e 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1433,13 +1433,11 @@ void pa_sink_input_set_property(pa_sink_input *i, const 
char *key, const char *v
 
 if (pa_proplist_contains(i->proplist, key)) {
 old_value = pa_xstrdup(pa_proplist_gets(i->proplist, key));
-if (value && old_value) {
-if (pa_streq(value, old_value))
-goto finish;
-} else {
-pa_xfree(old_value);
+if (value && old_value && pa_streq(value, old_value))
+goto finish;
+
+if (!old_value)
 old_value = pa_xstrdup("(data)");
-}
 } else {
 if (!value)
 goto finish;
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index c70af7a..35ef1c5 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -1086,13 +1086,11 @@ void pa_source_output_set_property(pa_source_output *o, 
const char *key, const c
 
 if (pa_proplist_contains(o->proplist, key)) {
 old_value = pa_xstrdup(pa_proplist_gets(o->proplist, key));
-if (value && old_value) {
-if (pa_streq(value, old_value))
-goto finish;
-} else {
-pa_xfree(old_value);
+if (value && old_value && pa_streq(value, old_value))
+goto finish;
+
+if (!old_value)
 old_value = pa_xstrdup("(data)");
-}
 } else {
 if (!value)
 goto finish;
-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] sink-input, source-output: Fix a leak during property change logging

2016-08-10 Thread Peter Meerwald-Stadler
Hello,

> > starring at the same issue ATM :)
> > the proposed fix below gets rid of the potential leak, but 
 
> > (2) in case value == 0, we'd still overwrite old_value, makes no
> > sense
> 
> Why not? value is the new value, old_value is the old value. The new
> value doesn't affect what we should print in the log message for the
> old value.

in case old_value != 0 and value == 0, we'd log
key: (data) -> (unset)
but the correct logging IMHO would be
key: old_value -> (unset)

new suggestion:

if (pa_proplist_contains(o->proplist, key)) {
old_value = pa_xstrdup(pa_proplist_gets(o->proplist, key));
if (value && old_value && pa_streq(value, old_value))
goto finish;
if (!old_value)
old_value = pa_xstrdup("(data)");
} else {


> > (3) could use pa_safe_streq()
> > 
> > my suggestion would be
> > 
> > if (pa_proplist_contains(o->proplist, key)) {
> > old_value = pa_xstrdup(pa_proplist_gets(o->proplist, key));
> > if (str_safe_streq(value, old_value))
> > goto finish;
> 
> This doesn't handle correctly the transition from non-utf8 data to
> unset (i.e. when both variables are NULL).

right

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] sink-input, source-output: Fix a leak during property change logging

2016-08-10 Thread Peter Meerwald-Stadler
Hi,

> Using pa_xfree() irrespective of whether old_value is NULL or not to
> avoid potentially confusing nest of if statements.

starring at the same issue ATM :)
the proposed fix below gets rid of the potential leak, but 

(1) why do we set old_value to "(data)" in the first place?
wouldn't "(null)" make more sense?

(2) in case value == 0, we'd still overwrite old_value, makes no sense
 
(3) could use pa_safe_streq()

my suggestion would be

if (pa_proplist_contains(o->proplist, key)) {
old_value = pa_xstrdup(pa_proplist_gets(o->proplist, key));
if (str_safe_streq(value, old_value))
goto finish;
if (!old_value)
old_value = pa_xstrdup("(null)"); // or data?
} else {
 
regards, p.

> CID: 1352052
> ---
>  src/pulsecore/sink-input.c| 4 +++-
>  src/pulsecore/source-output.c | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
> index a7f6d55..1ed5dda 100644
> --- a/src/pulsecore/sink-input.c
> +++ b/src/pulsecore/sink-input.c
> @@ -1436,8 +1436,10 @@ void pa_sink_input_set_property(pa_sink_input *i, 
> const char *key, const char *v
>  if (value && old_value) {
>  if (pa_streq(value, old_value))
>  goto finish;
> -} else
> +} else {
> +pa_xfree(old_value);
>  old_value = pa_xstrdup("(data)");
> +}
>  } else {
>  if (!value)
>  goto finish;
> diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
> index 9e951ff..6c48bbc 100644
> --- a/src/pulsecore/source-output.c
> +++ b/src/pulsecore/source-output.c
> @@ -1089,8 +1089,10 @@ void pa_source_output_set_property(pa_source_output 
> *o, const char *key, const c
>  if (value && old_value) {
>  if (pa_streq(value, old_value))
>  goto finish;
> -} else
> +} else {
> +pa_xfree(old_value);
>  old_value = pa_xstrdup("(data)");
> +}
>  } else {
>  if (!value)
>  goto finish;
> -- 
> 2.7.4
> 
> _______
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] need help building/cross compiling tests

2016-05-02 Thread Peter Meerwald-Stadler
Hi,

> I am trying to build tests. I was able to build them, but after running 
> them on target I am getting error:
> cann't find libcheck.so.0.

maybe not deployed to device?

> Does anybody know is libcheck is included in the pulseaudio sources?

no, it is not; maybe a build issue? maybe you libcheck locally install (so 
headers are available), but not as a dependency for cross-dev pulseaudio?

> Or has anybody cross compiled libcheck for arm-linux-gnueabi target?

http://libcheck.github.io/check/

regards, p.

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Added set-(sink|source)-latency-offset commands to pactl and pacmd.

2016-01-05 Thread Peter Meerwald-Stadler
t_set_port_latency_offset(c, card_name, 
> port_name, latency_offset, simple_callback, NULL);
>  break;
>  
> +case SET_SINK_LATENCY_OFFSET:
> +o = pa_context_set_sink_latency_offset(c, sink_name, 
> latency_offset, simple_callback, NULL);
> +break;
> +
> +case SET_SOURCE_LATENCY_OFFSET:
> +o = pa_context_set_source_latency_offset(c, source_name, 
> latency_offset, simple_callback, NULL);
> +break;
> +
>  case SUBSCRIBE:
>  pa_context_set_subscribe_callback(c, 
> context_subscribe_callback, NULL);
>  
> @@ -1580,6 +1590,7 @@ static void help(const char *argv0) {
>  printf("%s %s %s %s\n", argv0, _("[options]"), 
> "set-(sink-input|source-output)-mute", _("#N 1|0|toggle"));
>  printf("%s %s %s %s\n", argv0, _("[options]"), "set-sink-formats", _("#N 
> FORMATS"));
>  printf("%s %s %s %s\n", argv0, _("[options]"), 
> "set-port-latency-offset", _("CARD-NAME|CARD-#N PORT OFFSET"));
> +printf("%s %s %s %s\n", argv0, _("[options]"), 
> "set-(sink|source)-latency-offset", _("NAME|#N OFFSET"));
>  printf("%s %s %s\n",argv0, _("[options]"), "subscribe");
>  printf(_("\nThe special names @DEFAULT_SINK@, @DEFAULT_SOURCE@ and 
> @DEFAULT_MONITOR@\n"
>   "can be used to specify the default sink, source and 
> monitor.\n"));
> @@ -2046,6 +2057,34 @@ int main(int argc, char *argv[]) {
>  goto quit;
>  }
>  
> +} else if (pa_streq(argv[optind], "set-sink-latency-offset")) {
> +action = SET_SINK_LATENCY_OFFSET;
> +
> +if (argc != optind+3) {
> +pa_log(_("You have to specify a sink name/index and a 
> latency offset"));
> +goto quit;
> +}
> +
> +sink_name = pa_xstrdup(argv[optind+1]);
> +if (pa_atoi(argv[optind + 2], _offset) < 0) {
> +pa_log(_("Could not parse latency offset"));
> +goto quit;
> +}
> +
> +} else if (pa_streq(argv[optind], "set-source-latency-offset")) {
> +action = SET_SOURCE_LATENCY_OFFSET;
> +
> +if (argc != optind+3) {
> +pa_log(_("You have to specify a source name/index and a 
> latency offset"));
> +goto quit;
> +}
> +
> +source_name = pa_xstrdup(argv[optind+1]);
> +if (pa_atoi(argv[optind + 2], _offset) < 0) {
> +pa_log(_("Could not parse latency offset"));
> +goto quit;
> +}
> +
>  } else if (pa_streq(argv[optind], "help")) {
>  help(bn);
>  ret = 0;
> -- 
> 2.5.0
> 
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Added set-(sink|source)-latency-offset commands to pactl and pacmd.

2016-01-05 Thread Peter Meerwald-Stadler
tagstruct_getu32(t, ) < 0 ||
> > +pa_tagstruct_gets(t, _name) < 0 ||
> > +pa_tagstruct_gets64(t, ) < 0 ||
> > +!pa_tagstruct_eof(t)) {
> > +protocol_error(c);
> > +return;
> > +}
> > +
> > +CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
> > +CHECK_VALIDITY(c->pstream, !source_name ||
> > pa_namereg_is_valid_name_or_wildcard(source_name, PA_NAMEREG_SOURCE), tag,
> > PA_ERR_INVALID);
> > +CHECK_VALIDITY(c->pstream, (idx != PA_INVALID_INDEX) ^ (source_name
> > != NULL), tag, PA_ERR_INVALID);
> > +CHECK_VALIDITY(c->pstream, source_name, tag, PA_ERR_INVALID);
> > +
> > +if (idx != PA_INVALID_INDEX)
> > +source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
> > +else
> > +source = pa_namereg_get(c->protocol->core, source_name,
> > PA_NAMEREG_SOURCE);
> > +
> > +CHECK_VALIDITY(c->pstream, source, tag, PA_ERR_NOENTITY);
> > +
> > +pa_source_set_latency_offset(source, offset);
> > +
> > +pa_pstream_send_simple_ack(c->pstream, tag);
> > +}
> > +
> >  /*** pstream callbacks ***/
> >
> >  static void pstream_packet_callback(pa_pstream *p, pa_packet *packet,
> > const pa_cmsg_ancil_data *ancil_data, void *userdata) {
> > diff --git a/src/utils/pacmd.c b/src/utils/pacmd.c
> > index 616573c..e0ea919 100644
> > --- a/src/utils/pacmd.c
> > +++ b/src/utils/pacmd.c
> > @@ -72,6 +72,7 @@ static void help(const char *argv0) {
> >  printf("%s %s %s\n", argv0, "set-card-profile", _("CARD PROFILE"));
> >  printf("%s %s %s\n", argv0, "set-(sink|source)-port", _("NAME|#N
> > PORT"));
> >  printf("%s %s %s\n", argv0, "set-port-latency-offset",
> > _("CARD-NAME|CARD-#N PORT OFFSET"));
> > +printf("%s %s %s\n", argv0, "set-sink-(sink|source)-latency-offset",
> > _("NAME|#N OFFSET"));
> >  printf("%s %s %s\n", argv0, "set-log-target", _("TARGET"));
> >  printf("%s %s %s\n", argv0, "set-log-level", _("NUMERIC-LEVEL"));
> >      printf("%s %s %s\n", argv0, "set-log-meta", _("1|0"));
> > diff --git a/src/utils/pactl.c b/src/utils/pactl.c
> > index e9bf005..f04bef4 100644
> > --- a/src/utils/pactl.c
> > +++ b/src/utils/pactl.c
> > @@ -130,6 +130,8 @@ static enum {
> >  SET_SOURCE_OUTPUT_MUTE,
> >  SET_SINK_FORMATS,
> >  SET_PORT_LATENCY_OFFSET,
> > +SET_SINK_LATENCY_OFFSET,
> > +SET_SOURCE_LATENCY_OFFSET,
> >  SUBSCRIBE
> >  } action = NONE;
> >
> > @@ -1404,6 +1406,14 @@ static void context_state_callback(pa_context *c,
> > void *userdata) {
> >  o = pa_context_set_port_latency_offset(c, card_name,
> > port_name, latency_offset, simple_callback, NULL);
> >  break;
> >
> > +case SET_SINK_LATENCY_OFFSET:
> > +o = pa_context_set_sink_latency_offset(c, sink_name,
> > latency_offset, simple_callback, NULL);
> > +break;
> > +
> > +case SET_SOURCE_LATENCY_OFFSET:
> > +o = pa_context_set_source_latency_offset(c,
> > source_name, latency_offset, simple_callback, NULL);
> > +break;
> > +
> >  case SUBSCRIBE:
> >  pa_context_set_subscribe_callback(c,
> > context_subscribe_callback, NULL);
> >
> > @@ -1580,6 +1590,7 @@ static void help(const char *argv0) {
> >  printf("%s %s %s %s\n", argv0, _("[options]"),
> > "set-(sink-input|source-output)-mute", _("#N 1|0|toggle"));
> >  printf("%s %s %s %s\n", argv0, _("[options]"), "set-sink-formats",
> > _("#N FORMATS"));
> >  printf("%s %s %s %s\n", argv0, _("[options]"),
> > "set-port-latency-offset", _("CARD-NAME|CARD-#N PORT OFFSET"));
> > +printf("%s %s %s %s\n", argv0, _("[options]"),
> > "set-(sink|source)-latency-offset", _("NAME|#N OFFSET"));
> >  printf("%s %s %s\n",argv0, _("[options]"), "subscribe");
> >  printf(_("\nThe special names @DEFAULT_SINK@, @DEFAULT_SOURCE@ and
> > @DEFAULT_MONITOR@\n"
> >   "can be used to specify the default sink, source and
> > monitor.\n"));
> > @@ -2046,6 +2057,34 @@ int main(int argc, char *argv[]) {
> >  goto quit;
> >  }
> >
> > +} else if (pa_streq(argv[optind], "set-sink-latency-offset")) {
> > +action = SET_SINK_LATENCY_OFFSET;
> > +
> > +if (argc != optind+3) {
> > +pa_log(_("You have to specify a sink name/index and a
> > latency offset"));
> > +goto quit;
> > +}
> > +
> > +sink_name = pa_xstrdup(argv[optind+1]);
> > +if (pa_atoi(argv[optind + 2], _offset) < 0) {
> > +pa_log(_("Could not parse latency offset"));
> > +goto quit;
> > +}
> > +
> > +} else if (pa_streq(argv[optind], "set-source-latency-offset")) {
> > +action = SET_SOURCE_LATENCY_OFFSET;
> > +
> > +if (argc != optind+3) {
> > +pa_log(_("You have to specify a source name/index and a
> > latency offset"));
> > +goto quit;
> > +}
> > +
> > +source_name = pa_xstrdup(argv[optind+1]);
> > +if (pa_atoi(argv[optind + 2], _offset) < 0) {
> > +pa_log(_("Could not parse latency offset"));
> > +goto quit;
> > +}
> > +
> >  } else if (pa_streq(argv[optind], "help")) {
> >  help(bn);
> >  ret = 0;
> > --
> > 2.5.0
> >
> >
> 

-- 

Peter Meerwald-Stadler
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss