[MPlayer-cvslog] r18812 - trunk/libao2/ao_jack.c

reimar subversion at mplayerhq.hu
Sun Jun 25 11:02:47 CEST 2006


Author: reimar
Date: Sun Jun 25 11:02:47 2006
New Revision: 18812

Modified:
   trunk/libao2/ao_jack.c

Log:
respect AOPLAY_FINAL_CHUNK and do not discard samples read from buffer
on underrun.


Modified: trunk/libao2/ao_jack.c
==============================================================================
--- trunk/libao2/ao_jack.c	(original)
+++ trunk/libao2/ao_jack.c	Sun Jun 25 11:02:47 2006
@@ -130,10 +130,13 @@
  *
  * Assumes the data in the buffer is of type float, the number of bytes
  * read is res * num_bufs * sizeof(float), where res is the return value.
+ * If there is not enough data in the buffer remaining parts will be filled
+ * with silence.
  */
 static int read_buffer(float **bufs, int cnt, int num_bufs) {
   int buffered = buf_used();
   int i, j;
+  int orig_cnt = cnt;
   if (cnt * sizeof(float) * num_bufs > buffered)
     cnt = buffered / sizeof(float) / num_bufs;
   for (i = 0; i < cnt; i++) {
@@ -142,6 +145,9 @@
       read_pos = (read_pos + sizeof(float)) % BUFFSIZE;
     }
   }
+  for (i = cnt; i < orig_cnt; i++)
+    for (j = 0; j < num_bufs; j++)
+      bufs[j][i] = 0;
   return cnt;
 }
 
@@ -177,11 +183,11 @@
   int i;
   for (i = 0; i < num_ports; i++)
     bufs[i] = jack_port_get_buffer(ports[i], nframes);
-  if (!paused && !underrun)
-    if (read_buffer(bufs, nframes, num_ports) < nframes)
-      underrun = 1;
   if (paused || underrun)
     silence(bufs, nframes, num_ports);
+  else
+    if (read_buffer(bufs, nframes, num_ports) < nframes)
+      underrun = 1;
   if (estimate) {
     float now = (float)GetTimer() / 1000000.0;
     float diff = callback_time + callback_interval - now;
@@ -349,6 +355,7 @@
  * \brief write data into buffer and reset underrun flag
  */
 static int play(void *data, int len, int flags) {
+  if (!(flags & AOPLAY_FINAL_CHUNK))
   len -= len % ao_data.outburst;
   underrun = 0;
   return write_buffer(data, len);



More information about the MPlayer-cvslog mailing list