]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
add conn to many procedure calls
authorMike Brady <mikebrady@eircom.net>
Thu, 16 Mar 2017 12:33:56 +0000 (12:33 +0000)
committerMike Brady <mikebrady@eircom.net>
Thu, 16 Mar 2017 12:33:56 +0000 (12:33 +0000)
player.c
rtp.c
rtp.h
rtsp.c

index e052a816e56dee228e893d6944d026e8ec0f1c73..d1d9a90d958f721b7514689c772547930e5f098d 100644 (file)
--- a/player.c
+++ b/player.c
@@ -782,7 +782,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
           int64_t reference_timestamp;
           uint64_t reference_timestamp_time, remote_reference_timestamp_time;
           get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
-                                        &remote_reference_timestamp_time);
+                                        &remote_reference_timestamp_time, conn);
           reference_timestamp *= conn->output_sample_ratio;
           if (conn->first_packet_timestamp == 0) { // if this is the very first packet
             // debug(1,"First frame seen, time %u, with %d
@@ -943,7 +943,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
             // not the time of the playing of the first frame
             uint64_t reference_timestamp_time; // don't need this...
             get_reference_timestamp_stuff(&play_segment_reference_frame, &reference_timestamp_time,
-                                          &play_segment_reference_frame_remote_time);
+                                          &play_segment_reference_frame_remote_time, conn);
             play_segment_reference_frame *= conn->output_sample_ratio;
 #ifdef CONFIG_METADATA
             send_ssnc_metadata('prsm', NULL, 0,
@@ -973,7 +973,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
       int64_t reference_timestamp;
       uint64_t reference_timestamp_time, remote_reference_timestamp_time;
       get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
-                                    &remote_reference_timestamp_time); // all types okay
+                                    &remote_reference_timestamp_time, conn); // all types okay
       reference_timestamp *= conn->output_sample_ratio;
       if (reference_timestamp) {                        // if we have a reference time
         int64_t packet_timestamp = curframe->timestamp; // types okay
@@ -1059,7 +1059,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
       seq_t next = seq_sum(conn->ab_read, i);
       abuf = conn->audio_buffer + BUFIDX(next);
       if (!abuf->ready) {
-        rtp_request_resend(next, 1);
+        rtp_request_resend(next, 1, conn);
         // debug(1,"Resend %u.",next);
         conn->resend_requests++;
       }
@@ -1338,9 +1338,9 @@ static void *player_thread_func(void *arg) {
   
   // create and start the timing, control and audio receiver threads
   pthread_t rtp_audio_thread, rtp_control_thread, rtp_timing_thread;
-  pthread_create(&rtp_audio_thread, NULL, &rtp_audio_receiver, (void *)conn);
-  pthread_create(&rtp_control_thread, NULL, &rtp_control_receiver, (void *)conn);
-  pthread_create(&rtp_timing_thread, NULL, &rtp_timing_receiver, (void *)conn);
+  pthread_create(&rtp_audio_thread, NULL, &rtp_audio_receiver, (void*) conn);
+  pthread_create(&rtp_control_thread, NULL, &rtp_control_receiver, (void*) conn);
+  pthread_create(&rtp_timing_thread, NULL, &rtp_timing_receiver, (void*) conn);
 
   session_corrections = 0;
   play_segment_reference_frame = 0; // zero signals that we are not in a play segment
@@ -1604,7 +1604,7 @@ static void *player_thread_func(void *arg) {
           int64_t reference_timestamp;
           uint64_t reference_timestamp_time, remote_reference_timestamp_time;
           get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
-                                        &remote_reference_timestamp_time); // types okay
+                                        &remote_reference_timestamp_time, conn); // types okay
           reference_timestamp *= conn->output_sample_ratio;
           int64_t rt, nt;
           rt = reference_timestamp; // uint32_t to int64_t
diff --git a/rtp.c b/rtp.c
index 26ea8193fcc989a4eb83e367fb337faf03ded9bf..c15d2281062b26238c969a40c956ac296d340507 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -94,11 +94,11 @@ static pthread_mutex_t reference_time_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 uint64_t static local_to_remote_time_difference; // used to switch between local and remote clocks
 
-void *rtp_audio_receiver(void *arg) {
+void *rtp_audio_receiver(voidarg) {
   debug(2, "Audio receiver -- Server RTP thread starting.");
 
   // we inherit the signal mask (SIGUSR1)
-  rtsp_conn_info *conn = arg;
+  rtsp_conn_info *conn = (rtsp_conn_info*)arg;
 
   int32_t last_seqno = -1;
   uint8_t packet[2048], *pktp;
@@ -193,11 +193,12 @@ void *rtp_audio_receiver(void *arg) {
   return NULL;
 }
 
-void *rtp_control_receiver(void *arg) {
+void *rtp_control_receiver(voidarg) {
   // we inherit the signal mask (SIGUSR1)
 
   debug(2, "Control receiver -- Server RTP thread starting.");
-  rtsp_conn_info *conn = arg;
+  
+  rtsp_conn_info *conn = (rtsp_conn_info*)arg;
 
   reference_timestamp = 0; // nothing valid received yet
   uint8_t packet[2048], *pktp;
@@ -355,8 +356,7 @@ void *rtp_timing_sender(void *arg) {
 void *rtp_timing_receiver(void *arg) {
   debug(2, "Timing receiver -- Server RTP thread starting.");
   // we inherit the signal mask (SIGUSR1)
-
-  rtsp_conn_info *conn = arg;
+  rtsp_conn_info *conn = (rtsp_conn_info*)arg;
 
   uint8_t packet[2048], *pktp;
   ssize_t nread;
@@ -500,7 +500,7 @@ void *rtp_timing_receiver(void *arg) {
         int64_t reference_timestamp;
         uint64_t reference_timestamp_time, remote_reference_timestamp_time;
         get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
-                                      &remote_reference_timestamp_time);
+                                      &remote_reference_timestamp_time, conn);
         uint64_t frame_difference = 0;
         if (reference_timestamp >= play_segment_reference_frame)
           frame_difference = (uint64_t)reference_timestamp - (uint64_t)play_segment_reference_frame;
@@ -622,7 +622,7 @@ static int bind_port(int ip_family, const char *self_ip_address, uint32_t scope_
 }
 
 void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t active_remote,
-               int *lsport, int *lcport, int *ltport) {
+               int *lsport, int *lcport, int *ltport, rtsp_conn_info *conn) {
 
   // this gets the local and remote ip numbers (and ports used for the TCD stuff)
   // we use the local stuff to specify the address we are coming from and
@@ -731,7 +731,7 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t
 }
 
 void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
-                                   uint64_t *remote_timestamp_time) {
+                                   uint64_t *remote_timestamp_time, rtsp_conn_info *conn) {
   // types okay
   pthread_mutex_lock(&reference_time_mutex);
   *timestamp = reference_timestamp;
@@ -740,19 +740,19 @@ void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
   pthread_mutex_unlock(&reference_time_mutex);
 }
 
-void clear_reference_timestamp(void) {
+void clear_reference_timestamp(rtsp_conn_info *conn) {
   pthread_mutex_lock(&reference_time_mutex);
   reference_timestamp = 0;
   reference_timestamp_time = 0;
   pthread_mutex_unlock(&reference_time_mutex);
 }
 
-void rtp_shutdown(void) {
+void rtp_shutdown(rtsp_conn_info *conn) {
   if (!running)
     debug(1, "rtp_shutdown called without active stream!");
 
   debug(2, "shutting down RTP thread");
-  clear_reference_timestamp();
+  clear_reference_timestamp(conn);
   //  debug(1,"Shut down audio, control and timing threads");
   //  usleep(3000000); // hack
   //  pthread_kill(rtp_audio_thread, SIGUSR1);
@@ -764,7 +764,7 @@ void rtp_shutdown(void) {
   running = 0;
 }
 
-void rtp_request_resend(seq_t first, uint32_t count) {
+void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
   if (running) {
     // if (!request_sent) {
     debug(3, "requesting resend of %d packets starting at %u.", count, first);
@@ -795,7 +795,7 @@ void rtp_request_resend(seq_t first, uint32_t count) {
   }
 }
 
-void rtp_request_client_pause() {
+void rtp_request_client_pause(rtsp_conn_info *conn) {
   if (running) {
     if (client_active_remote == 0) {
       debug(1, "Can't request a client pause: no valid active remote.");
diff --git a/rtp.h b/rtp.h
index 4f6da117336f46966fcd26055e030f26203862f3..b02a9409100d212b2b25899a1c902a0618f5df52 100644 (file)
--- a/rtp.h
+++ b/rtp.h
@@ -11,14 +11,14 @@ void *rtp_timing_receiver(void *arg);
 
 void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int controlport, int timingport,
                uint32_t active_remote, int *local_server_port, int *local_control_port,
-               int *local_timing_port);
-void rtp_shutdown(void);
-void rtp_request_resend(seq_t first, uint32_t count);
-void rtp_request_client_pause(void); // ask the client to pause
+               int *local_timing_port, rtsp_conn_info* conn);
+void rtp_shutdown(rtsp_conn_info* conn);
+void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info* conn);
+void rtp_request_client_pause(rtsp_conn_info* conn); // ask the client to pause
 
 void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
-                                   uint64_t *remote_timestamp_time);
-void clear_reference_timestamp(void);
+                                   uint64_t *remote_timestamp_time, rtsp_conn_info* conn);
+void clear_reference_timestamp(rtsp_conn_info* conn);
 
 uint64_t static local_to_remote_time_jitters;
 uint64_t static local_to_remote_time_jitters_count;
diff --git a/rtsp.c b/rtsp.c
index db617a396cf1552825ade72a972d52b8c7c7743c..22369669852ac0b284146163b05b4f6fb8afc451 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -797,7 +797,7 @@ static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *
   tport = atoi(p);
 
   //  rtsp_take_player();
-  rtp_setup(&conn->local, &conn->remote, cport, tport, active_remote, &lsport, &lcport, &ltport);
+  rtp_setup(&conn->local, &conn->remote, cport, tport, active_remote, &lsport, &lcport, &ltport, conn);
   if (!lsport)
     goto error;
   char *q;
@@ -1772,7 +1772,7 @@ static void *rtsp_conversation_thread_func(void *pconn) {
   debug(1, "Closing down RTSP conversation thread...");
   if (rtsp_playing()) {
     player_stop(&conn->player_thread,conn); // might be less noisy doing this first
-    rtp_shutdown();
+    rtp_shutdown(conn);
     // usleep(400000); // let an angel pass...
     pthread_mutex_unlock(&play_lock);
   }