audio/out: consistently use double return type for get_delay

ao_get_delay() returns double, but the get_delay callback still
returned float.
This commit is contained in:
wm4 2014-11-09 11:45:04 +01:00
parent 3d7d1f3f26
commit 5db0fbd95e
12 changed files with 25 additions and 27 deletions

View File

@ -54,7 +54,7 @@ struct priv {
snd_pcm_format_t alsa_fmt;
int can_pause;
snd_pcm_sframes_t prepause_frames;
float delay_before_pause;
double delay_before_pause;
int buffersize; // in frames
int outburst; // in frames
@ -84,7 +84,7 @@ struct priv {
MP_WARN(ao, "%s: %s\n", (message), snd_strerror(err)); \
} while (0)
static float get_delay(struct ao *ao);
static double get_delay(struct ao *ao);
static void uninit(struct ao *ao);
/* to set/get/query special features/parameters */
@ -586,7 +586,7 @@ static void audio_pause(struct ao *ao)
if (snd_pcm_delay(p->alsa, &p->prepause_frames) < 0
|| p->prepause_frames < 0)
p->prepause_frames = 0;
p->delay_before_pause = p->prepause_frames / (float)ao->samplerate;
p->delay_before_pause = p->prepause_frames / (double)ao->samplerate;
err = snd_pcm_drop(p->alsa);
CHECK_ALSA_ERROR("pcm drop error");
@ -697,7 +697,7 @@ alsa_error:
}
/* delay in seconds between first and last sample in buffer */
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct priv *p = ao->priv;
snd_pcm_sframes_t delay;
@ -713,7 +713,7 @@ static float get_delay(struct ao *ao)
snd_pcm_forward(p->alsa, -delay);
delay = 0;
}
return (float)delay / (float)ao->samplerate;
return delay / (double)ao->samplerate;
}
#define MAX_POLL_FDS 20

View File

@ -581,12 +581,12 @@ static int get_space(struct ao *ao)
return mp_ring_available(p->buffer) / ao->sstride;
}
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
// FIXME: should also report the delay of coreaudio itself (hardware +
// internal buffers)
struct priv *p = ao->priv;
return mp_ring_buffered(p->buffer) / (float)ao->bps;
return mp_ring_buffered(p->buffer) / (double)ao->bps;
}
static void uninit(struct ao *ao)

View File

@ -104,8 +104,6 @@ struct priv {
struct ao_device_list *listing; ///temporary during list_devs()
};
static float get_delay(struct ao *ao);
/***************************************************************************************/
/**
@ -678,12 +676,12 @@ static int play(struct ao *ao, void **data, int samples, int flags)
\brief get the delay between the first and last sample in the buffer
\return delay in seconds
*/
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct priv *p = ao->priv;
int space = check_free_buffer_size(ao);
return (float)(p->buffer_size - space) / (float)ao->bps;
return (p->buffer_size - space) / (double)ao->bps;
}
#define OPT_BASE_STRUCT struct priv

View File

@ -176,7 +176,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
return accepted;
}
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct priv *priv = ao->priv;

View File

@ -293,12 +293,12 @@ static int play(struct ao *ao, void **data, int samples, int flags)
return num * CHUNK_SAMPLES;
}
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
ALint queued;
unqueue_buffers();
alGetSourcei(sources[0], AL_BUFFERS_QUEUED, &queued);
return queued * CHUNK_SAMPLES / (float)ao->samplerate;
return queued * CHUNK_SAMPLES / (double)ao->samplerate;
}
#define OPT_BASE_STRUCT struct priv

View File

@ -546,7 +546,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
}
// return: delay in seconds between first and last sample in buffer
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct priv *p = ao->priv;
if (p->audio_fd < 0) {
@ -560,18 +560,18 @@ static float get_delay(struct ao *ao)
#ifdef SNDCTL_DSP_GETODELAY
int r = 0;
if (ioctl(p->audio_fd, SNDCTL_DSP_GETODELAY, &r) != -1)
return ((float)r) / (float)ao->bps;
return r / (double)ao->bps;
#endif
p->audio_delay_method = 1; // fallback if not supported
}
if (p->audio_delay_method == 1) {
audio_buf_info zz = {0};
if (ioctl(p->audio_fd, SNDCTL_DSP_GETOSPACE, &zz) != -1) {
return ((float)(p->buffersize - zz.bytes)) / (float)ao->bps;
return (p->buffersize - zz.bytes) / (double)ao->bps;
}
p->audio_delay_method = 0; // fallback if not supported
}
return ((float)p->buffersize) / (float)ao->bps;
return p->buffersize / (double)ao->bps;
}

View File

@ -530,7 +530,7 @@ static int get_space(struct ao *ao)
return space / ao->sstride;
}
static float get_delay_hackfixed(struct ao *ao)
static double get_delay_hackfixed(struct ao *ao)
{
/* This code basically does what pa_stream_get_latency() _should_
* do, but doesn't due to multiple known bugs in PulseAudio (at
@ -585,7 +585,7 @@ static float get_delay_hackfixed(struct ao *ao)
return latency / 1e6;
}
static float get_delay_pulse(struct ao *ao)
static double get_delay_pulse(struct ao *ao)
{
struct priv *priv = ao->priv;
pa_usec_t latency = (pa_usec_t) -1;
@ -603,7 +603,7 @@ static float get_delay_pulse(struct ao *ao)
}
// Return the current latency in seconds
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct priv *priv = ao->priv;
if (priv->cfg_latency_hacks) {

View File

@ -153,7 +153,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
return rsd_write(priv->rd, data[0], samples * ao->sstride) / ao->sstride;
}
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct priv *priv = ao->priv;
return rsd_delay_ms(priv->rd) / 1000.0;

View File

@ -282,7 +282,7 @@ static int get_space(struct ao *ao)
/*
* return: delay in seconds between first and last sample in buffer
*/
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct priv *p = ao->priv;

View File

@ -135,7 +135,7 @@ struct ao_driver {
// push based: see ao_play()
int (*play)(struct ao *ao, void **data, int samples, int flags);
// push based: see ao_get_delay()
float (*get_delay)(struct ao *ao);
double (*get_delay)(struct ao *ao);
// push based: block until all queued audio is played (optional)
void (*drain)(struct ao *ao);
// Optional. Return true if audio has stopped in any way.

View File

@ -147,7 +147,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
// it takes until the last sample in the buffer reaches the speakers. This is
// used for audio/video synchronization, so it's very important to implement
// this correctly.
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct ao_pull_state *p = ao->api_priv;

View File

@ -93,11 +93,11 @@ static double unlocked_get_delay(struct ao *ao)
return driver_delay + mp_audio_buffer_seconds(p->buffer);
}
static float get_delay(struct ao *ao)
static double get_delay(struct ao *ao)
{
struct ao_push_state *p = ao->api_priv;
pthread_mutex_lock(&p->lock);
float delay = unlocked_get_delay(ao);
double delay = unlocked_get_delay(ao);
pthread_mutex_unlock(&p->lock);
return delay;
}