summaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authormalc <av1474@comtv.ru>2009-09-18 11:37:39 +0400
committermalc <av1474@comtv.ru>2009-09-18 14:04:36 +0400
commitbdff253c8fb4c8a64bb4792cc161dd79ab4aaf65 (patch)
tree8e12d54b246e2787a7b1bd3b0e50d236910a05a0 /audio
parent3fd7f635cdd5ee13f08c6ba1b0974a17eb9c9347 (diff)
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>
Diffstat (limited to 'audio')
-rw-r--r--audio/alsaaudio.c9
-rw-r--r--audio/audio.c33
-rw-r--r--audio/audio_int.h4
-rw-r--r--audio/coreaudio.c6
-rw-r--r--audio/dsoundaudio.c6
-rw-r--r--audio/esdaudio.c5
-rw-r--r--audio/fmodaudio.c13
-rw-r--r--audio/noaudio.c9
-rw-r--r--audio/ossaudio.c9
-rw-r--r--audio/paaudio.c5
-rw-r--r--audio/sdlaudio.c6
-rw-r--r--audio/wavaudio.c9
12 files changed, 33 insertions, 81 deletions
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 0174841415..a4baebcb40 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -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");
diff --git a/audio/audio.c b/audio/audio.c
index d8e1e1519a..f061f45f91 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -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;
diff --git a/audio/audio_int.h b/audio/audio_int.h
index 7ea872926e..4acc8d58c4 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -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);
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index dab4e5f30f..0a26413d75 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -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,
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index f89f39aa08..5b255acd02 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -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,
diff --git a/audio/esdaudio.c b/audio/esdaudio.c
index 90a8a7a689..79142d1706 100644
--- a/audio/esdaudio.c
+++ b/audio/esdaudio.c
@@ -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;
diff --git a/audio/fmodaudio.c b/audio/fmodaudio.c
index e852e9e430..7f08e14718 100644
--- a/audio/fmodaudio.c
+++ b/audio/fmodaudio.c
@@ -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;
}
diff --git a/audio/noaudio.c b/audio/noaudio.c
index 82272b7199..4925234c07 100644
--- a/audio/noaudio.c
+++ b/audio/noaudio.c
@@ -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 ());
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 2e8b7bf085..9f017b467b 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -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) {
diff --git a/audio/paaudio.c b/audio/paaudio.c
index cf415f4402..18292eb1e6 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -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;
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index 250c7aefa6..8e7e5cb70b 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -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,
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index e659aa541c..c522be4531 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -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;