rtp: Make init return a value for success/failure
authorArun Raghavan <arun@arunraghavan.net>
Thu, 12 May 2016 12:26:43 +0000 (17:56 +0530)
committerArun Raghavan <arun@arunraghavan.net>
Fri, 8 Nov 2019 12:09:03 +0000 (17:39 +0530)
This will be used in the future when writing other RTP implementations
that can fail on init.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
src/modules/rtp/module-rtp-send.c
src/modules/rtp/rtp.c
src/modules/rtp/rtp.h

index 0c3dd91..a7a3f77 100644 (file)
@@ -491,7 +491,8 @@ int pa__init(pa_module*m) {
 
     pa_xfree(n);
 
-    pa_rtp_context_init_send(&u->rtp_context, fd, m->core->cookie, payload, pa_frame_size(&ss));
+    if (pa_rtp_context_init_send(&u->rtp_context, fd, m->core->cookie, payload, pa_frame_size(&ss)) < 0)
+        goto fail;
     pa_sap_context_init_send(&u->sap_context, sap_fd, p);
 
     pa_log_info("RTP stream initialized with mtu %u on %s:%u from %s ttl=%u, SSRC=0x%08x, payload=%u, initial sequence #%u", mtu, dst_addr, port, src_addr, ttl, u->rtp_context.ssrc, payload, u->rtp_context.sequence);
index 5ab80e7..279c455 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "rtp.h"
 
-pa_rtp_context* pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint32_t ssrc, uint8_t payload, size_t frame_size) {
+int pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint32_t ssrc, uint8_t payload, size_t frame_size) {
     pa_assert(c);
     pa_assert(fd >= 0);
 
@@ -58,7 +58,7 @@ pa_rtp_context* pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint32_t ssr
     c->recv_buf_size = 0;
     pa_memchunk_reset(&c->memchunk);
 
-    return c;
+    return 0;
 }
 
 #define MAX_IOVECS 16
index 0b877d5..7c7ae44 100644 (file)
@@ -39,7 +39,7 @@ typedef struct pa_rtp_context {
     pa_memchunk memchunk;
 } pa_rtp_context;
 
-pa_rtp_context* pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint32_t ssrc, uint8_t payload, size_t frame_size);
+int pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint32_t ssrc, uint8_t payload, size_t frame_size);
 
 /* If the memblockq doesn't have a silence memchunk set, then the caller must
  * guarantee that the current read index doesn't point to a hole. */