From c158e4641ad8be435fd403bc6dc00f2f99e0940e Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 17 Sep 2014 00:14:21 +0200 Subject: ao_oss: move code around More logical, and preparation for the next commit. No functional changes. --- audio/out/ao_oss.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index 496259b579..9ed10cf6c1 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -508,23 +508,6 @@ static void reset(struct ao *ao) #endif } -// return: how many samples can be played without blocking -static int get_space(struct ao *ao) -{ - struct priv *p = ao->priv; - - audio_buf_info zz = {0}; - if (ioctl(p->audio_fd, SNDCTL_DSP_GETOSPACE, &zz) != -1) { - // calculate exact buffer space: - return zz.fragments * zz.fragsize / ao->sstride; - } - - if (p->audio_fd < 0 || device_writable(ao) > 0) - return p->outburst / ao->sstride; - - return 0; -} - // plays 'len' samples of 'data' // it should round it down to outburst*n // return: number of samples played @@ -555,15 +538,6 @@ static int play(struct ao *ao, void **data, int samples, int flags) return len / ao->sstride; } -// resume playing, after audio_pause() -static void audio_resume(struct ao *ao) -{ - struct priv *p = ao->priv; - p->audio_end = 0; - if (p->prepause_samples > 0) - ao_play_silence(ao, p->prepause_samples); -} - // return: delay in seconds between first and last sample in buffer static float get_delay(struct ao *ao) { @@ -593,6 +567,24 @@ static float get_delay(struct ao *ao) return ((float)p->buffersize) / (float)ao->bps; } + +// return: how many samples can be played without blocking +static int get_space(struct ao *ao) +{ + struct priv *p = ao->priv; + + audio_buf_info zz = {0}; + if (ioctl(p->audio_fd, SNDCTL_DSP_GETOSPACE, &zz) != -1) { + // calculate exact buffer space: + return zz.fragments * zz.fragsize / ao->sstride; + } + + if (p->audio_fd < 0 || device_writable(ao) > 0) + return p->outburst / ao->sstride; + + return 0; +} + // stop playing, keep buffers (for pause) static void audio_pause(struct ao *ao) { @@ -605,6 +597,15 @@ static void audio_pause(struct ao *ao) #endif } +// resume playing, after audio_pause() +static void audio_resume(struct ao *ao) +{ + struct priv *p = ao->priv; + p->audio_end = 0; + if (p->prepause_samples > 0) + ao_play_silence(ao, p->prepause_samples); +} + #define OPT_BASE_STRUCT struct priv const struct ao_driver audio_out_oss = { -- cgit v1.2.3