static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate)

{

    int64_t now;

    int64_t ticks;

    int64_t bytes;

    int64_t samples;



    now = qemu_get_clock (vm_clock);

    ticks = now - rate->start_ticks;

    bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec ());

    samples = (bytes - rate->bytes_sent) >> info->shift;

    if (samples < 0 || samples > 65536) {

        fprintf (stderr, "Resetting rate control (%" PRId64 " samples)\n", samples);

        rate_start (rate);

        samples = 0;

    }

    rate->bytes_sent += samples << info->shift;

    return samples;

}

static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate)

{

    int64_t now;

    int64_t ticks;

    int64_t bytes;

    int64_t samples;



    now = qemu_get_clock (vm_clock);

    ticks = now - rate->start_ticks;

    bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec ());

    samples = (bytes - rate->bytes_sent) >> info->shift;

    if (samples < 0 || samples > 65536) {

        fprintf (stderr, "Resetting rate control (%" PRId64 " samples)\n", samples);

        rate_start (rate);

        samples = 0;

    }

    rate->bytes_sent += samples << info->shift;

    return samples;

}

static int FUNC_0 (struct audio_pcm_info *VAR_0, SpiceRateCtl *VAR_1)

{

    int64_t now;

    int64_t ticks;

    int64_t bytes;

    int64_t samples;



    now = qemu_get_clock (vm_clock);

    ticks = now - VAR_1->start_ticks;

    bytes = muldiv64 (ticks, VAR_0->bytes_per_second, get_ticks_per_sec ());

    samples = (bytes - VAR_1->bytes_sent) >> VAR_0->shift;

    if (samples < 0 || samples > 65536) {

        fprintf (stderr, "Resetting VAR_1 control (%" PRId64 " samples)\n", samples);

        rate_start (VAR_1);

        samples = 0;

    }

    VAR_1->bytes_sent += samples << VAR_0->shift;

    return samples;

}

static int FUNC_0 (struct audio_pcm_info *VAR_0, SpiceRateCtl *VAR_1)
{ int64_t now; int64_t ticks; int64_t bytes; int64_t samples; now = qemu_get_clock (vm_clock); ticks = now - VAR_1->start_ticks; bytes = muldiv64 (ticks, VAR_0->bytes_per_second, get_ticks_per_sec ()); samples = (bytes - VAR_1->bytes_sent) >> VAR_0->shift; if (samples < 0 || samples > 65536) { fprintf (stderr, "Resetting VAR_1 control (%" PRId64 " samples)\n", samples); rate_start (VAR_1); samples = 0; } VAR_1->bytes_sent += samples << VAR_0->shift; return samples; }