chiark / gitweb /
disorder-playrtp now releases its lock around activate/deactivate
[disorder] / clients / playrtp.c
index 03e4ad2e297de1a3c10601f3c8c3c6418953a234..92cbb75e87525bd4867e5363d015693bebc75309 100644 (file)
@@ -104,7 +104,7 @@ unsigned minbuffer = 2 * 44100 / 10;  /* 0.2 seconds */
 /** @brief Buffer high watermark
  *
  * We'll only start playing when this many samples are available. */
-static unsigned readahead = 2 * 2 * 44100;
+static unsigned readahead = 44100;      /* 0.5 seconds */
 
 /** @brief Maximum buffer size
  *
@@ -763,7 +763,9 @@ int main(int argc, char **argv) {
     info("Playing...");
     next_timestamp = pheap_first(&packets)->timestamp;
     active = 1;
+    pthread_mutex_unlock(&lock);
     backend->activate();
+    pthread_mutex_lock(&lock);
     /* Wait until the buffer empties out */
     while(nsamples >= minbuffer
          || (nsamples > 0
@@ -771,7 +773,9 @@ int main(int argc, char **argv) {
       pthread_cond_wait(&cond, &lock);
     }
     /* Stop playing for a bit until the buffer re-fills */
+    pthread_mutex_unlock(&lock);
     backend->deactivate();
+    pthread_mutex_lock(&lock);
     active = 0;
     /* Go back round */
   }