]> git.proxmox.com Git - mirror_qemu.git/commitdiff
audio: internal API change
authormalc <av1474@comtv.ru>
Fri, 18 Sep 2009 07:37:39 +0000 (11:37 +0400)
committermalc <av1474@comtv.ru>
Fri, 18 Sep 2009 10:04:36 +0000 (14:04 +0400)
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>
12 files changed:
audio/alsaaudio.c
audio/audio.c
audio/audio_int.h
audio/coreaudio.c
audio/dsoundaudio.c
audio/esdaudio.c
audio/fmodaudio.c
audio/noaudio.c
audio/ossaudio.c
audio/paaudio.c
audio/sdlaudio.c
audio/wavaudio.c

index 017484141590111fc25117e0f1ac1fe4c5716c88..a4baebcb4023e23a6ecf5164f284533666a01480 100644 (file)
@@ -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");
index d8e1e1519ab7973885c401461b5806c15d8a0b3a..f061f45f9189a2303b7673345f58c60381567bbf 100644 (file)
@@ -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;
index 7ea872926e587b33d18cc7d55e1a2c1a3d2b3d80..4acc8d58c4045676b4075d7edb63343db7588363 100644 (file)
@@ -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);
index dab4e5f30f486c3aefcbca496be5af7b9be24016..0a26413d75d012bb095cf23e1cb4c90009b5236c 100644 (file)
@@ -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,
index f89f39aa08c85b5761b2128d6fd2dab3bb48c750..5b255acd023622218f0dc52db77b0f66ede1e15e 100644 (file)
@@ -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,
index 90a8a7a689dff5d7019906bc884d1658af7391d1..79142d1706b1770627f6594d1e43130952c4ae0b 100644 (file)
@@ -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;
index e852e9e43099250fea9191460332bb2fe02ede19..7f08e14718ec71b3689f237087d718df9ab1b9c3 100644 (file)
@@ -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;
     }
 
index 82272b7199595c4d9a8191f81cd085dfcd6c9174..4925234c07192e88efb9baca3d411fe86de23406 100644 (file)
@@ -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 ());
index 2e8b7bf0855e18701e424ab774fd534cea1d3afe..9f017b467b8f75c4065223e62757ae6ae06d0d28 100644 (file)
@@ -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) {
index cf415f4402162b11f50eb4a191c02296fdada899..18292eb1e6a19c980cc692766c9664e0da10403a 100644 (file)
@@ -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;
index 250c7aefa69667da5c65c02225c175bbd42d09bb..8e7e5cb70b014b9464dfdd62263ee807c523217b 100644 (file)
@@ -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,
index e659aa541ca8a15f7309578e0266d98ca6394b95..c522be4531f2831b44b00cf88596a59afcaad04a 100644 (file)
@@ -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;