audio: internal API change
pcm_ops.run_out now takes number of live samples (which will be always greater than zero) as a second argument, every driver was calling audio_pcm_hw_get_live_out anyway with exception of fmod which used audio_pcm_hw_get_live_out2 for no good reason. Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
parent
3fd7f635cd
commit
bdff253c8f
@ -763,17 +763,12 @@ static void alsa_write_pending (ALSAVoiceOut *alsa)
|
||||
}
|
||||
}
|
||||
|
||||
static int alsa_run_out (HWVoiceOut *hw)
|
||||
static int alsa_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
|
||||
int live, decr;
|
||||
int decr;
|
||||
snd_pcm_sframes_t avail;
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
if (!live) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
avail = alsa_get_avail (alsa->handle);
|
||||
if (avail < 0) {
|
||||
dolog ("Could not get number of available playback frames\n");
|
||||
|
@ -969,16 +969,17 @@ static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep)
|
||||
return m;
|
||||
}
|
||||
|
||||
int audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live)
|
||||
static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live)
|
||||
{
|
||||
int smin;
|
||||
int nb_live1;
|
||||
|
||||
smin = audio_pcm_hw_find_min_out (hw, nb_live);
|
||||
|
||||
if (!*nb_live) {
|
||||
return 0;
|
||||
smin = audio_pcm_hw_find_min_out (hw, &nb_live1);
|
||||
if (nb_live) {
|
||||
*nb_live = nb_live1;
|
||||
}
|
||||
else {
|
||||
|
||||
if (nb_live1) {
|
||||
int live = smin;
|
||||
|
||||
if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
|
||||
@ -987,19 +988,7 @@ int audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live)
|
||||
}
|
||||
return live;
|
||||
}
|
||||
}
|
||||
|
||||
int audio_pcm_hw_get_live_out (HWVoiceOut *hw)
|
||||
{
|
||||
int nb_live;
|
||||
int live;
|
||||
|
||||
live = audio_pcm_hw_get_live_out2 (hw, &nb_live);
|
||||
if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
|
||||
dolog ("live=%d hw->samples=%d\n", live, hw->samples);
|
||||
return 0;
|
||||
}
|
||||
return live;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1357,7 +1346,7 @@ static void audio_run_out (AudioState *s)
|
||||
int played;
|
||||
int live, free, nb_live, cleanup_required, prev_rpos;
|
||||
|
||||
live = audio_pcm_hw_get_live_out2 (hw, &nb_live);
|
||||
live = audio_pcm_hw_get_live_out (hw, &nb_live);
|
||||
if (!nb_live) {
|
||||
live = 0;
|
||||
}
|
||||
@ -1395,7 +1384,7 @@ static void audio_run_out (AudioState *s)
|
||||
}
|
||||
|
||||
prev_rpos = hw->rpos;
|
||||
played = hw->pcm_ops->run_out (hw);
|
||||
played = hw->pcm_ops->run_out (hw, live);
|
||||
if (audio_bug (AUDIO_FUNC, hw->rpos >= hw->samples)) {
|
||||
dolog ("hw->rpos=%d hw->samples=%d played=%d\n",
|
||||
hw->rpos, hw->samples, played);
|
||||
@ -1494,7 +1483,7 @@ static void audio_run_capture (AudioState *s)
|
||||
HWVoiceOut *hw = &cap->hw;
|
||||
SWVoiceOut *sw;
|
||||
|
||||
captured = live = audio_pcm_hw_get_live_out (hw);
|
||||
captured = live = audio_pcm_hw_get_live_out (hw, NULL);
|
||||
rpos = hw->rpos;
|
||||
while (live) {
|
||||
int left = hw->samples - rpos;
|
||||
|
@ -155,7 +155,7 @@ struct audio_driver {
|
||||
struct audio_pcm_ops {
|
||||
int (*init_out)(HWVoiceOut *hw, struct audsettings *as);
|
||||
void (*fini_out)(HWVoiceOut *hw);
|
||||
int (*run_out) (HWVoiceOut *hw);
|
||||
int (*run_out) (HWVoiceOut *hw, int live);
|
||||
int (*write) (SWVoiceOut *sw, void *buf, int size);
|
||||
int (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
|
||||
|
||||
@ -218,8 +218,6 @@ int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len);
|
||||
int audio_pcm_hw_get_live_in (HWVoiceIn *hw);
|
||||
|
||||
int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len);
|
||||
int audio_pcm_hw_get_live_out (HWVoiceOut *hw);
|
||||
int audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live);
|
||||
|
||||
int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf,
|
||||
int live, int pending);
|
||||
|
@ -190,17 +190,15 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, const char *fn_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coreaudio_run_out (HWVoiceOut *hw)
|
||||
static int coreaudio_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
int live, decr;
|
||||
int decr;
|
||||
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
|
||||
|
||||
if (coreaudio_lock (core, "coreaudio_run_out")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
|
||||
if (core->decr > live) {
|
||||
ldebug ("core->decr %d live %d core->live %d\n",
|
||||
core->decr,
|
||||
|
@ -658,13 +658,13 @@ static int dsound_write (SWVoiceOut *sw, void *buf, int len)
|
||||
return audio_pcm_sw_write (sw, buf, len);
|
||||
}
|
||||
|
||||
static int dsound_run_out (HWVoiceOut *hw)
|
||||
static int dsound_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
int err;
|
||||
HRESULT hr;
|
||||
DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;
|
||||
LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
|
||||
int live, len, hwshift;
|
||||
int len, hwshift;
|
||||
DWORD blen1, blen2;
|
||||
DWORD len1, len2;
|
||||
DWORD decr;
|
||||
@ -680,8 +680,6 @@ static int dsound_run_out (HWVoiceOut *hw)
|
||||
hwshift = hw->info.shift;
|
||||
bufsize = hw->samples << hwshift;
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
|
||||
hr = IDirectSoundBuffer_GetCurrentPosition (
|
||||
dsb,
|
||||
&ppos,
|
||||
|
@ -158,16 +158,15 @@ static void *qesd_thread_out (void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int qesd_run_out (HWVoiceOut *hw)
|
||||
static int qesd_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
int live, decr;
|
||||
int decr;
|
||||
ESDVoiceOut *esd = (ESDVoiceOut *) hw;
|
||||
|
||||
if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
decr = audio_MIN (live, esd->decr);
|
||||
esd->decr -= decr;
|
||||
esd->live = live - decr;
|
||||
|
@ -224,22 +224,15 @@ static int fmod_lock_sample (
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fmod_run_out (HWVoiceOut *hw)
|
||||
static int fmod_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
FMODVoiceOut *fmd = (FMODVoiceOut *) hw;
|
||||
int live, decr;
|
||||
int decr;
|
||||
void *p1 = 0, *p2 = 0;
|
||||
unsigned int blen1 = 0, blen2 = 0;
|
||||
unsigned int len1 = 0, len2 = 0;
|
||||
int nb_live;
|
||||
|
||||
live = audio_pcm_hw_get_live_out2 (hw, &nb_live);
|
||||
if (!live) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!hw->pending_disable && nb_live) {
|
||||
ldebug ("live=%d nb_live=%d\n", live, nb_live);
|
||||
if (!hw->pending_disable) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -38,19 +38,14 @@ typedef struct NoVoiceIn {
|
||||
int64_t old_ticks;
|
||||
} NoVoiceIn;
|
||||
|
||||
static int no_run_out (HWVoiceOut *hw)
|
||||
static int no_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
NoVoiceOut *no = (NoVoiceOut *) hw;
|
||||
int live, decr, samples;
|
||||
int decr, samples;
|
||||
int64_t now;
|
||||
int64_t ticks;
|
||||
int64_t bytes;
|
||||
|
||||
live = audio_pcm_hw_get_live_out (&no->hw);
|
||||
if (!live) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
now = qemu_get_clock (vm_clock);
|
||||
ticks = now - no->old_ticks;
|
||||
bytes = muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ());
|
||||
|
@ -389,19 +389,14 @@ static void oss_write_pending (OSSVoiceOut *oss)
|
||||
}
|
||||
}
|
||||
|
||||
static int oss_run_out (HWVoiceOut *hw)
|
||||
static int oss_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
|
||||
int err, live, decr;
|
||||
int err, decr;
|
||||
struct audio_buf_info abinfo;
|
||||
struct count_info cntinfo;
|
||||
int bufsize;
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
if (!live) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bufsize = hw->samples << hw->info.shift;
|
||||
|
||||
if (oss->mmapped) {
|
||||
|
@ -120,16 +120,15 @@ static void *qpa_thread_out (void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int qpa_run_out (HWVoiceOut *hw)
|
||||
static int qpa_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
int live, decr;
|
||||
int decr;
|
||||
PAVoiceOut *pa = (PAVoiceOut *) hw;
|
||||
|
||||
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
decr = audio_MIN (live, pa->decr);
|
||||
pa->decr -= decr;
|
||||
pa->live = live - decr;
|
||||
|
@ -282,9 +282,9 @@ static int sdl_write_out (SWVoiceOut *sw, void *buf, int len)
|
||||
return audio_pcm_sw_write (sw, buf, len);
|
||||
}
|
||||
|
||||
static int sdl_run_out (HWVoiceOut *hw)
|
||||
static int sdl_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
int decr, live;
|
||||
int decr;
|
||||
SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
|
||||
SDLAudioState *s = &glob_sdl;
|
||||
|
||||
@ -292,8 +292,6 @@ static int sdl_run_out (HWVoiceOut *hw)
|
||||
return 0;
|
||||
}
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
|
||||
if (sdl->decr > live) {
|
||||
ldebug ("sdl->decr %d live %d sdl->live %d\n",
|
||||
sdl->decr,
|
||||
|
@ -46,10 +46,10 @@ static struct {
|
||||
.wav_path = "qemu.wav"
|
||||
};
|
||||
|
||||
static int wav_run_out (HWVoiceOut *hw)
|
||||
static int wav_run_out (HWVoiceOut *hw, int live)
|
||||
{
|
||||
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
|
||||
int rpos, live, decr, samples;
|
||||
int rpos, decr, samples;
|
||||
uint8_t *dst;
|
||||
struct st_sample *src;
|
||||
int64_t now = qemu_get_clock (vm_clock);
|
||||
@ -64,11 +64,6 @@ static int wav_run_out (HWVoiceOut *hw)
|
||||
samples = bytes >> hw->info.shift;
|
||||
}
|
||||
|
||||
live = audio_pcm_hw_get_live_out (hw);
|
||||
if (!live) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
wav->old_ticks = now;
|
||||
decr = audio_MIN (live, samples);
|
||||
samples = decr;
|
||||
|
Loading…
Reference in New Issue
Block a user