pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/www/firefox60 firefox60: Disable the nonblocking audio...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/6cf5e8a317af
branches:  trunk
changeset: 335137:6cf5e8a317af
user:      nia <nia%pkgsrc.org@localhost>
date:      Thu Jun 13 22:01:56 2019 +0000

description:
firefox60: Disable the nonblocking audio code for now.

It seems to cause frame drops at higher latencies.

diffstat:

 www/firefox60/Makefile          |   4 +-
 www/firefox60/files/cubeb_sun.c |  49 +++++++++++++++-------------------------
 2 files changed, 21 insertions(+), 32 deletions(-)

diffs (154 lines):

diff -r a71bc74cff2a -r 6cf5e8a317af www/firefox60/Makefile
--- a/www/firefox60/Makefile    Thu Jun 13 19:44:35 2019 +0000
+++ b/www/firefox60/Makefile    Thu Jun 13 22:01:56 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.27 2019/06/13 14:16:37 nia Exp $
+# $NetBSD: Makefile,v 1.28 2019/06/13 22:01:56 nia Exp $
 
 FIREFOX_VER=           ${MOZ_BRANCH}${MOZ_BRANCH_MINOR}
 MOZ_BRANCH=            60.7
@@ -6,7 +6,7 @@
 
 DISTNAME=      firefox-${FIREFOX_VER}.source
 PKGNAME=       firefox${MOZ_BRANCH:C/\..*$//}-${MOZ_BRANCH}${MOZ_BRANCH_MINOR:S/b/beta/:S/esr//}
-PKGREVISION=   4
+PKGREVISION=   5
 CATEGORIES=    www
 MASTER_SITES+= ${MASTER_SITE_MOZILLA:=firefox/releases/${FIREFOX_VER}/source/}
 EXTRACT_SUFX=  .tar.xz
diff -r a71bc74cff2a -r 6cf5e8a317af www/firefox60/files/cubeb_sun.c
--- a/www/firefox60/files/cubeb_sun.c   Thu Jun 13 19:44:35 2019 +0000
+++ b/www/firefox60/files/cubeb_sun.c   Thu Jun 13 22:01:56 2019 +0000
@@ -8,7 +8,6 @@
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -47,7 +46,7 @@
 #endif
 
 #ifndef SUN_BUFFER_FRAMES
-#define SUN_BUFFER_FRAMES (32)
+#define SUN_BUFFER_FRAMES (256)
 #endif
 
 /*
@@ -97,6 +96,7 @@
   char input_name[32];
   char output_name[32];
   uint64_t frames_written;
+  uint64_t blocks_written;
 };
 
 int
@@ -434,7 +434,6 @@
   long to_write = 0;
   size_t write_ofs = 0;
   size_t read_ofs = 0;
-  struct pollfd pfds[1];
   int drain = 0;
 
   s->state_cb(s, s->user_ptr, CUBEB_STATE_STARTED);
@@ -479,15 +478,7 @@
     if (to_write < SUN_BUFFER_FRAMES) {
       drain = 1;
     }
-    pfds[0].fd = s->play_fd;
-    if (s->play_fd != -1) {
-      if (to_write > 0) {
-        pfds[0].events = POLLOUT;
-      }
-    } else {
-      pfds[0].events = 0;
-      to_write = 0;
-    }
+    to_write = s->play_fd != -1 ? to_write : 0;
     to_read = s->record_fd != -1 ? SUN_BUFFER_FRAMES : 0;
     write_ofs = 0;
     read_ofs = 0;
@@ -495,17 +486,7 @@
       size_t bytes;
       ssize_t n, frames;
 
-      if (pfds[0].events != 0 && poll(pfds, 1, SUN_POLL_TIMEOUT) == -1) {
-        LOG("poll failed");
-        state = CUBEB_STATE_ERROR;
-        break;
-      }
-      if ((pfds[0].revents & POLLHUP) || (pfds[0].revents & POLLERR)) {
-        LOG("audio device disconnected");
-        state = CUBEB_STATE_ERROR;
-        break;
-      }
-      if (to_write > 0 && (pfds[0].revents & POLLOUT)) {
+      if (to_write > 0) {
         bytes = FRAMES_TO_BYTES(to_write, s->p_info.play.channels);
         if ((n = write(s->play_fd, s->play_buf + write_ofs, bytes)) < 0) {
           state = CUBEB_STATE_ERROR;
@@ -517,9 +498,6 @@
         pthread_mutex_unlock(&s->mutex);
         to_write -= frames;
         write_ofs += frames;
-        if (to_write == 0) {
-          pfds[0].events = 0;
-        }
       }
       if (to_read > 0) {
         bytes = FRAMES_TO_BYTES(to_read, s->r_info.record.channels);
@@ -558,7 +536,6 @@
   cubeb_stream *s = NULL;
 
   (void)stream_name;
-  (void)latency_frames;
   if ((s = calloc(1, sizeof(cubeb_stream))) == NULL) {
     ret = CUBEB_ERROR;
     goto error;
@@ -607,7 +584,7 @@
       goto error;
     }
     if (s->play_fd == -1) {
-      if ((s->play_fd = open(s->output_name, O_WRONLY | O_NONBLOCK)) == -1) {
+      if ((s->play_fd = open(s->output_name, O_WRONLY)) == -1) {
         LOG("Audio device cannot be opened as write-only");
         ret = CUBEB_ERROR_DEVICE_UNAVAILABLE;
         goto error;
@@ -677,10 +654,22 @@
 static int
 sun_stream_get_position(cubeb_stream * s, uint64_t * position)
 {
+#ifdef AUDIO_GETOOFFS
+  struct audio_offset offset;
+
+  if (ioctl(s->play_fd, AUDIO_GETOOFFS, &offset) == -1) {
+    return CUBEB_ERROR;
+  }
+  s->blocks_written += offset.deltablks;
+  *position = BYTES_TO_FRAMES(s->blocks_written * s->p_info.blocksize,
+                              s->p_info.play.channels);
+  return CUBEB_OK;
+#else
   pthread_mutex_lock(&s->mutex);
   *position = s->frames_written;
   pthread_mutex_unlock(&s->mutex);
   return CUBEB_OK;
+#endif
 }
 
 static int
@@ -693,11 +682,11 @@
     return CUBEB_ERROR;
   }
 
-  *latency = BYTES_TO_FRAMES(info.play.seek + info.blocksize,
+  *latency = BYTES_TO_FRAMES(info.play.seek + info.blocksize / 2,
                              info.play.channels);
   return CUBEB_OK;
 #else
-  cubeb_params params;
+  cubeb_stream_params params;
 
   params.rate = stream->p_info.play.sample_rate;
 



Home | Main Index | Thread Index | Old Index