Mercurial > mplayer.hg
changeset 15630:7c67124786a0
Fix latency calculation and buffersize setting.
author | reimar |
---|---|
date | Fri, 03 Jun 2005 20:35:07 +0000 |
parents | 2256ab57c9ac |
children | d5a95e6f5f07 |
files | libao2/ao_jack.c |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libao2/ao_jack.c Fri Jun 03 17:24:30 2005 +0000 +++ b/libao2/ao_jack.c Fri Jun 03 20:35:07 2005 +0000 @@ -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;