Commit bdff253c authored by malc's avatar malc
Browse files

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: default avatarmalc <av1474@comtv.ru>
parent 3fd7f635
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -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");
+11 −22
Original line number Diff line number Diff line
@@ -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,20 +988,8 @@ 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;
}

/*
 * Soft voice (playback)
@@ -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;
+1 −3
Original line number Diff line number Diff line
@@ -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);
+2 −4
Original line number Diff line number Diff line
@@ -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,
+2 −4
Original line number Diff line number Diff line
@@ -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,
Loading