[MPlayer-cvslog] CVS: main/libao2 ao_jack.c,1.9,1.10

Reimar Döffinger CVS syncmail at mplayerhq.hu
Fri Jun 3 22:35:10 CEST 2005


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libao2
In directory mail:/var2/tmp/cvs-serv1577

Modified Files:
	ao_jack.c 
Log Message:
Fix latency calculation and buffersize setting.


Index: ao_jack.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_jack.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ao_jack.c	1 Jun 2005 09:20:46 -0000	1.9
+++ ao_jack.c	3 Jun 2005 20:35:07 -0000	1.10
@@ -41,6 +41,7 @@
 static jack_port_t *ports[MAX_CHANS];
 static int num_ports; ///< Number of used ports == number of channels
 static jack_client_t *client;
+static float jack_latency;
 static volatile int paused = 0; ///< set if paused
 static volatile int underrun = 0; ///< signals if an underrun occured
 
@@ -261,13 +262,16 @@
       goto err_out;
     }
   }
+  rate = jack_get_sample_rate(client);
+  jack_latency = (float)(jack_port_get_total_latency(client, ports[0]) +
+                         jack_get_buffer_size(client)) / (float)rate;
   buffer = (unsigned char *) malloc(BUFFSIZE);
 
   ao_data.channels = channels;
-  ao_data.samplerate = rate = jack_get_sample_rate(client);
+  ao_data.samplerate = rate;
   ao_data.format = AF_FORMAT_FLOAT_NE;
   ao_data.bps = channels * rate * sizeof(float);
-  ao_data.buffersize = jack_port_get_total_latency(client, ports[0]) * channels;
+  ao_data.buffersize = CHUNK_SIZE * NUM_CHUNKS;
   ao_data.outburst = CHUNK_SIZE;
   free(matching_ports);
   free(port_name);
@@ -334,7 +338,7 @@
 
 static float get_delay() {
   int buffered = BUFFSIZE - CHUNK_SIZE - buf_free(); // could be less
-  float in_jack = (float)ao_data.buffersize / (float)ao_data.bps;
+  float in_jack = jack_latency;
 #ifdef JACK_ESTIMATE_DELAY
   unsigned int elapsed = GetTimer() - callback_time;
   in_jack += (float)callback_samples / (float)ao_data.samplerate - (float)elapsed / 1000.0 / 1000.0;




More information about the MPlayer-cvslog mailing list