mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-10-01 16:53:46 +00:00
audio: use size_t where makes sense
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: c5193e687fc6cc0f60cb3e90fe69ddf2027d0df1.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
1d793fec6c
commit
7520462bc1
|
@ -681,10 +681,10 @@ static void alsa_write_pending (ALSAVoiceOut *alsa)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alsa_run_out (HWVoiceOut *hw, int live)
|
static size_t alsa_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
|
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
|
||||||
int decr;
|
size_t decr;
|
||||||
snd_pcm_sframes_t avail;
|
snd_pcm_sframes_t avail;
|
||||||
|
|
||||||
avail = alsa_get_avail (alsa->handle);
|
avail = alsa_get_avail (alsa->handle);
|
||||||
|
@ -739,8 +739,8 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as,
|
||||||
|
|
||||||
alsa->pcm_buf = audio_calloc(__func__, obt.samples, 1 << hw->info.shift);
|
alsa->pcm_buf = audio_calloc(__func__, obt.samples, 1 << hw->info.shift);
|
||||||
if (!alsa->pcm_buf) {
|
if (!alsa->pcm_buf) {
|
||||||
dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n",
|
dolog("Could not allocate DAC buffer (%zu samples, each %d bytes)\n",
|
||||||
hw->samples, 1 << hw->info.shift);
|
hw->samples, 1 << hw->info.shift);
|
||||||
alsa_anal_close1 (&handle);
|
alsa_anal_close1 (&handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -841,8 +841,8 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
||||||
|
|
||||||
alsa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
alsa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
||||||
if (!alsa->pcm_buf) {
|
if (!alsa->pcm_buf) {
|
||||||
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
|
dolog("Could not allocate ADC buffer (%zu samples, each %d bytes)\n",
|
||||||
hw->samples, 1 << hw->info.shift);
|
hw->samples, 1 << hw->info.shift);
|
||||||
alsa_anal_close1 (&handle);
|
alsa_anal_close1 (&handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -863,17 +863,17 @@ static void alsa_fini_in (HWVoiceIn *hw)
|
||||||
alsa->pcm_buf = NULL;
|
alsa->pcm_buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alsa_run_in (HWVoiceIn *hw)
|
static size_t alsa_run_in(HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
|
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
|
||||||
int hwshift = hw->info.shift;
|
int hwshift = hw->info.shift;
|
||||||
int i;
|
int i;
|
||||||
int live = audio_pcm_hw_get_live_in (hw);
|
size_t live = audio_pcm_hw_get_live_in (hw);
|
||||||
int dead = hw->samples - live;
|
size_t dead = hw->samples - live;
|
||||||
int decr;
|
size_t decr;
|
||||||
struct {
|
struct {
|
||||||
int add;
|
size_t add;
|
||||||
int len;
|
size_t len;
|
||||||
} bufs[2] = {
|
} bufs[2] = {
|
||||||
{ .add = hw->wpos, .len = 0 },
|
{ .add = hw->wpos, .len = 0 },
|
||||||
{ .add = 0, .len = 0 }
|
{ .add = 0, .len = 0 }
|
||||||
|
@ -913,7 +913,7 @@ static int alsa_run_in (HWVoiceIn *hw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decr = MIN (dead, avail);
|
decr = MIN(dead, avail);
|
||||||
if (!decr) {
|
if (!decr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
156
audio/audio.c
156
audio/audio.c
|
@ -528,10 +528,10 @@ static int audio_attach_capture (HWVoiceOut *hw)
|
||||||
/*
|
/*
|
||||||
* Hard voice (capture)
|
* Hard voice (capture)
|
||||||
*/
|
*/
|
||||||
static int audio_pcm_hw_find_min_in (HWVoiceIn *hw)
|
static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
SWVoiceIn *sw;
|
SWVoiceIn *sw;
|
||||||
int m = hw->total_samples_captured;
|
size_t m = hw->total_samples_captured;
|
||||||
|
|
||||||
for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
|
for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
|
||||||
if (sw->active) {
|
if (sw->active) {
|
||||||
|
@ -541,28 +541,28 @@ static int audio_pcm_hw_find_min_in (HWVoiceIn *hw)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_pcm_hw_get_live_in (HWVoiceIn *hw)
|
size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
int live = hw->total_samples_captured - audio_pcm_hw_find_min_in (hw);
|
size_t live = hw->total_samples_captured - audio_pcm_hw_find_min_in (hw);
|
||||||
if (audio_bug(__func__, live < 0 || live > hw->samples)) {
|
if (audio_bug(__func__, live > hw->samples)) {
|
||||||
dolog ("live=%d hw->samples=%d\n", live, hw->samples);
|
dolog("live=%zu hw->samples=%zu\n", live, hw->samples);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return live;
|
return live;
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf,
|
size_t audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf,
|
||||||
int live, int pending)
|
size_t live, size_t pending)
|
||||||
{
|
{
|
||||||
int left = hw->samples - pending;
|
size_t left = hw->samples - pending;
|
||||||
int len = MIN (left, live);
|
size_t len = MIN (left, live);
|
||||||
int clipped = 0;
|
size_t clipped = 0;
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
struct st_sample *src = hw->mix_buf + hw->rpos;
|
struct st_sample *src = hw->mix_buf + hw->rpos;
|
||||||
uint8_t *dst = advance (pcm_buf, hw->rpos << hw->info.shift);
|
uint8_t *dst = advance (pcm_buf, hw->rpos << hw->info.shift);
|
||||||
int samples_till_end_of_buf = hw->samples - hw->rpos;
|
size_t samples_till_end_of_buf = hw->samples - hw->rpos;
|
||||||
int samples_to_clip = MIN (len, samples_till_end_of_buf);
|
size_t samples_to_clip = MIN (len, samples_till_end_of_buf);
|
||||||
|
|
||||||
hw->clip (dst, src, samples_to_clip);
|
hw->clip (dst, src, samples_to_clip);
|
||||||
|
|
||||||
|
@ -576,14 +576,14 @@ int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf,
|
||||||
/*
|
/*
|
||||||
* Soft voice (capture)
|
* Soft voice (capture)
|
||||||
*/
|
*/
|
||||||
static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw)
|
static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw)
|
||||||
{
|
{
|
||||||
HWVoiceIn *hw = sw->hw;
|
HWVoiceIn *hw = sw->hw;
|
||||||
int live = hw->total_samples_captured - sw->total_hw_samples_acquired;
|
ssize_t live = hw->total_samples_captured - sw->total_hw_samples_acquired;
|
||||||
int rpos;
|
ssize_t rpos;
|
||||||
|
|
||||||
if (audio_bug(__func__, live < 0 || live > hw->samples)) {
|
if (audio_bug(__func__, live < 0 || live > hw->samples)) {
|
||||||
dolog ("live=%d hw->samples=%d\n", live, hw->samples);
|
dolog("live=%zu hw->samples=%zu\n", live, hw->samples);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,17 +596,17 @@ static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size)
|
static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size)
|
||||||
{
|
{
|
||||||
HWVoiceIn *hw = sw->hw;
|
HWVoiceIn *hw = sw->hw;
|
||||||
int samples, live, ret = 0, swlim, isamp, osamp, rpos, total = 0;
|
size_t samples, live, ret = 0, swlim, isamp, osamp, rpos, total = 0;
|
||||||
struct st_sample *src, *dst = sw->buf;
|
struct st_sample *src, *dst = sw->buf;
|
||||||
|
|
||||||
rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
|
rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
|
||||||
|
|
||||||
live = hw->total_samples_captured - sw->total_hw_samples_acquired;
|
live = hw->total_samples_captured - sw->total_hw_samples_acquired;
|
||||||
if (audio_bug(__func__, live < 0 || live > hw->samples)) {
|
if (audio_bug(__func__, live > hw->samples)) {
|
||||||
dolog ("live_in=%d hw->samples=%d\n", live, hw->samples);
|
dolog("live_in=%zu hw->samples=%zu\n", live, hw->samples);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,9 +620,9 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size)
|
||||||
|
|
||||||
while (swlim) {
|
while (swlim) {
|
||||||
src = hw->conv_buf + rpos;
|
src = hw->conv_buf + rpos;
|
||||||
isamp = hw->wpos - rpos;
|
if (hw->wpos > rpos) {
|
||||||
/* XXX: <= ? */
|
isamp = hw->wpos - rpos;
|
||||||
if (isamp <= 0) {
|
} else {
|
||||||
isamp = hw->samples - rpos;
|
isamp = hw->samples - rpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,11 +631,6 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size)
|
||||||
}
|
}
|
||||||
osamp = swlim;
|
osamp = swlim;
|
||||||
|
|
||||||
if (audio_bug(__func__, osamp < 0)) {
|
|
||||||
dolog ("osamp=%d\n", osamp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
|
st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
|
||||||
swlim -= osamp;
|
swlim -= osamp;
|
||||||
rpos = (rpos + isamp) % hw->samples;
|
rpos = (rpos + isamp) % hw->samples;
|
||||||
|
@ -656,10 +651,10 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size)
|
||||||
/*
|
/*
|
||||||
* Hard voice (playback)
|
* Hard voice (playback)
|
||||||
*/
|
*/
|
||||||
static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep)
|
static size_t audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep)
|
||||||
{
|
{
|
||||||
SWVoiceOut *sw;
|
SWVoiceOut *sw;
|
||||||
int m = INT_MAX;
|
size_t m = SIZE_MAX;
|
||||||
int nb_live = 0;
|
int nb_live = 0;
|
||||||
|
|
||||||
for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
|
for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
|
||||||
|
@ -673,9 +668,9 @@ static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live)
|
static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live)
|
||||||
{
|
{
|
||||||
int smin;
|
size_t smin;
|
||||||
int nb_live1;
|
int nb_live1;
|
||||||
|
|
||||||
smin = audio_pcm_hw_find_min_out (hw, &nb_live1);
|
smin = audio_pcm_hw_find_min_out (hw, &nb_live1);
|
||||||
|
@ -684,10 +679,10 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nb_live1) {
|
if (nb_live1) {
|
||||||
int live = smin;
|
size_t live = smin;
|
||||||
|
|
||||||
if (audio_bug(__func__, live < 0 || live > hw->samples)) {
|
if (audio_bug(__func__, live > hw->samples)) {
|
||||||
dolog ("live=%d hw->samples=%d\n", live, hw->samples);
|
dolog("live=%zu hw->samples=%zu\n", live, hw->samples);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return live;
|
return live;
|
||||||
|
@ -698,10 +693,10 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live)
|
||||||
/*
|
/*
|
||||||
* Soft voice (playback)
|
* Soft voice (playback)
|
||||||
*/
|
*/
|
||||||
static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf, int size)
|
static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size)
|
||||||
{
|
{
|
||||||
int hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, blck;
|
size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, blck;
|
||||||
int ret = 0, pos = 0, total = 0;
|
size_t ret = 0, pos = 0, total = 0;
|
||||||
|
|
||||||
if (!sw) {
|
if (!sw) {
|
||||||
return size;
|
return size;
|
||||||
|
@ -710,8 +705,8 @@ static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf, int size)
|
||||||
hwsamples = sw->hw->samples;
|
hwsamples = sw->hw->samples;
|
||||||
|
|
||||||
live = sw->total_hw_samples_mixed;
|
live = sw->total_hw_samples_mixed;
|
||||||
if (audio_bug(__func__, live < 0 || live > hwsamples)) {
|
if (audio_bug(__func__, live > hwsamples)) {
|
||||||
dolog ("live=%d hw->samples=%d\n", live, hwsamples);
|
dolog("live=%zu hw->samples=%zu\n", live, hwsamples);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,7 +760,7 @@ static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf, int size)
|
||||||
|
|
||||||
#ifdef DEBUG_OUT
|
#ifdef DEBUG_OUT
|
||||||
dolog (
|
dolog (
|
||||||
"%s: write size %d ret %d total sw %d\n",
|
"%s: write size %zu ret %zu total sw %zu\n",
|
||||||
SW_NAME (sw),
|
SW_NAME (sw),
|
||||||
size >> sw->info.shift,
|
size >> sw->info.shift,
|
||||||
ret,
|
ret,
|
||||||
|
@ -844,7 +839,7 @@ static void audio_timer (void *opaque)
|
||||||
/*
|
/*
|
||||||
* Public API
|
* Public API
|
||||||
*/
|
*/
|
||||||
int AUD_write (SWVoiceOut *sw, void *buf, int size)
|
size_t AUD_write(SWVoiceOut *sw, void *buf, size_t size)
|
||||||
{
|
{
|
||||||
if (!sw) {
|
if (!sw) {
|
||||||
/* XXX: Consider options */
|
/* XXX: Consider options */
|
||||||
|
@ -859,7 +854,7 @@ int AUD_write (SWVoiceOut *sw, void *buf, int size)
|
||||||
return audio_pcm_sw_write(sw, buf, size);
|
return audio_pcm_sw_write(sw, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AUD_read (SWVoiceIn *sw, void *buf, int size)
|
size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size)
|
||||||
{
|
{
|
||||||
if (!sw) {
|
if (!sw) {
|
||||||
/* XXX: Consider options */
|
/* XXX: Consider options */
|
||||||
|
@ -968,17 +963,17 @@ void AUD_set_active_in (SWVoiceIn *sw, int on)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int audio_get_avail (SWVoiceIn *sw)
|
static size_t audio_get_avail (SWVoiceIn *sw)
|
||||||
{
|
{
|
||||||
int live;
|
size_t live;
|
||||||
|
|
||||||
if (!sw) {
|
if (!sw) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
live = sw->hw->total_samples_captured - sw->total_hw_samples_acquired;
|
live = sw->hw->total_samples_captured - sw->total_hw_samples_acquired;
|
||||||
if (audio_bug(__func__, live < 0 || live > sw->hw->samples)) {
|
if (audio_bug(__func__, live > sw->hw->samples)) {
|
||||||
dolog ("live=%d sw->hw->samples=%d\n", live, sw->hw->samples);
|
dolog("live=%zu sw->hw->samples=%zu\n", live, sw->hw->samples);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,9 +986,9 @@ static int audio_get_avail (SWVoiceIn *sw)
|
||||||
return (((int64_t) live << 32) / sw->ratio) << sw->info.shift;
|
return (((int64_t) live << 32) / sw->ratio) << sw->info.shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int audio_get_free (SWVoiceOut *sw)
|
static size_t audio_get_free(SWVoiceOut *sw)
|
||||||
{
|
{
|
||||||
int live, dead;
|
size_t live, dead;
|
||||||
|
|
||||||
if (!sw) {
|
if (!sw) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1001,8 +996,8 @@ static int audio_get_free (SWVoiceOut *sw)
|
||||||
|
|
||||||
live = sw->total_hw_samples_mixed;
|
live = sw->total_hw_samples_mixed;
|
||||||
|
|
||||||
if (audio_bug(__func__, live < 0 || live > sw->hw->samples)) {
|
if (audio_bug(__func__, live > sw->hw->samples)) {
|
||||||
dolog ("live=%d sw->hw->samples=%d\n", live, sw->hw->samples);
|
dolog("live=%zu sw->hw->samples=%zu\n", live, sw->hw->samples);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,9 +1012,10 @@ static int audio_get_free (SWVoiceOut *sw)
|
||||||
return (((int64_t) dead << 32) / sw->ratio) << sw->info.shift;
|
return (((int64_t) dead << 32) / sw->ratio) << sw->info.shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audio_capture_mix_and_clear (HWVoiceOut *hw, int rpos, int samples)
|
static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos,
|
||||||
|
size_t samples)
|
||||||
{
|
{
|
||||||
int n;
|
size_t n;
|
||||||
|
|
||||||
if (hw->enabled) {
|
if (hw->enabled) {
|
||||||
SWVoiceCap *sc;
|
SWVoiceCap *sc;
|
||||||
|
@ -1030,17 +1026,17 @@ static void audio_capture_mix_and_clear (HWVoiceOut *hw, int rpos, int samples)
|
||||||
|
|
||||||
n = samples;
|
n = samples;
|
||||||
while (n) {
|
while (n) {
|
||||||
int till_end_of_hw = hw->samples - rpos2;
|
size_t till_end_of_hw = hw->samples - rpos2;
|
||||||
int to_write = MIN (till_end_of_hw, n);
|
size_t to_write = MIN(till_end_of_hw, n);
|
||||||
int bytes = to_write << hw->info.shift;
|
size_t bytes = to_write << hw->info.shift;
|
||||||
int written;
|
size_t written;
|
||||||
|
|
||||||
sw->buf = hw->mix_buf + rpos2;
|
sw->buf = hw->mix_buf + rpos2;
|
||||||
written = audio_pcm_sw_write (sw, NULL, bytes);
|
written = audio_pcm_sw_write (sw, NULL, bytes);
|
||||||
if (written - bytes) {
|
if (written - bytes) {
|
||||||
dolog ("Could not mix %d bytes into a capture "
|
dolog("Could not mix %zu bytes into a capture "
|
||||||
"buffer, mixed %d\n",
|
"buffer, mixed %zu\n",
|
||||||
bytes, written);
|
bytes, written);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
n -= to_write;
|
n -= to_write;
|
||||||
|
@ -1049,9 +1045,9 @@ static void audio_capture_mix_and_clear (HWVoiceOut *hw, int rpos, int samples)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = MIN (samples, hw->samples - rpos);
|
n = MIN(samples, hw->samples - rpos);
|
||||||
mixeng_clear (hw->mix_buf + rpos, n);
|
mixeng_clear(hw->mix_buf + rpos, n);
|
||||||
mixeng_clear (hw->mix_buf, samples - n);
|
mixeng_clear(hw->mix_buf, samples - n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audio_run_out (AudioState *s)
|
static void audio_run_out (AudioState *s)
|
||||||
|
@ -1060,16 +1056,16 @@ static void audio_run_out (AudioState *s)
|
||||||
SWVoiceOut *sw;
|
SWVoiceOut *sw;
|
||||||
|
|
||||||
while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
|
while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
|
||||||
int played;
|
size_t played, live, prev_rpos, free;
|
||||||
int live, free, nb_live, cleanup_required, prev_rpos;
|
int nb_live, cleanup_required;
|
||||||
|
|
||||||
live = audio_pcm_hw_get_live_out (hw, &nb_live);
|
live = audio_pcm_hw_get_live_out (hw, &nb_live);
|
||||||
if (!nb_live) {
|
if (!nb_live) {
|
||||||
live = 0;
|
live = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio_bug(__func__, live < 0 || live > hw->samples)) {
|
if (audio_bug(__func__, live > hw->samples)) {
|
||||||
dolog ("live=%d hw->samples=%d\n", live, hw->samples);
|
dolog ("live=%zu hw->samples=%zu\n", live, hw->samples);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1104,13 +1100,13 @@ static void audio_run_out (AudioState *s)
|
||||||
played = hw->pcm_ops->run_out (hw, live);
|
played = hw->pcm_ops->run_out (hw, live);
|
||||||
replay_audio_out(&played);
|
replay_audio_out(&played);
|
||||||
if (audio_bug(__func__, hw->rpos >= hw->samples)) {
|
if (audio_bug(__func__, hw->rpos >= hw->samples)) {
|
||||||
dolog ("hw->rpos=%d hw->samples=%d played=%d\n",
|
dolog("hw->rpos=%zu hw->samples=%zu played=%zu\n",
|
||||||
hw->rpos, hw->samples, played);
|
hw->rpos, hw->samples, played);
|
||||||
hw->rpos = 0;
|
hw->rpos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_OUT
|
#ifdef DEBUG_OUT
|
||||||
dolog ("played=%d\n", played);
|
dolog("played=%zu\n", played);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (played) {
|
if (played) {
|
||||||
|
@ -1125,8 +1121,8 @@ static void audio_run_out (AudioState *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) {
|
if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) {
|
||||||
dolog ("played=%d sw->total_hw_samples_mixed=%d\n",
|
dolog("played=%zu sw->total_hw_samples_mixed=%zu\n",
|
||||||
played, sw->total_hw_samples_mixed);
|
played, sw->total_hw_samples_mixed);
|
||||||
played = sw->total_hw_samples_mixed;
|
played = sw->total_hw_samples_mixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,7 +1162,7 @@ static void audio_run_in (AudioState *s)
|
||||||
|
|
||||||
while ((hw = audio_pcm_hw_find_any_enabled_in(s, hw))) {
|
while ((hw = audio_pcm_hw_find_any_enabled_in(s, hw))) {
|
||||||
SWVoiceIn *sw;
|
SWVoiceIn *sw;
|
||||||
int captured = 0, min;
|
size_t captured = 0, min;
|
||||||
|
|
||||||
if (replay_mode != REPLAY_MODE_PLAY) {
|
if (replay_mode != REPLAY_MODE_PLAY) {
|
||||||
captured = hw->pcm_ops->run_in(hw);
|
captured = hw->pcm_ops->run_in(hw);
|
||||||
|
@ -1181,7 +1177,7 @@ static void audio_run_in (AudioState *s)
|
||||||
sw->total_hw_samples_acquired -= min;
|
sw->total_hw_samples_acquired -= min;
|
||||||
|
|
||||||
if (sw->active) {
|
if (sw->active) {
|
||||||
int avail;
|
size_t avail;
|
||||||
|
|
||||||
avail = audio_get_avail (sw);
|
avail = audio_get_avail (sw);
|
||||||
if (avail > 0) {
|
if (avail > 0) {
|
||||||
|
@ -1197,15 +1193,15 @@ static void audio_run_capture (AudioState *s)
|
||||||
CaptureVoiceOut *cap;
|
CaptureVoiceOut *cap;
|
||||||
|
|
||||||
for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) {
|
for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) {
|
||||||
int live, rpos, captured;
|
size_t live, rpos, captured;
|
||||||
HWVoiceOut *hw = &cap->hw;
|
HWVoiceOut *hw = &cap->hw;
|
||||||
SWVoiceOut *sw;
|
SWVoiceOut *sw;
|
||||||
|
|
||||||
captured = live = audio_pcm_hw_get_live_out (hw, NULL);
|
captured = live = audio_pcm_hw_get_live_out (hw, NULL);
|
||||||
rpos = hw->rpos;
|
rpos = hw->rpos;
|
||||||
while (live) {
|
while (live) {
|
||||||
int left = hw->samples - rpos;
|
size_t left = hw->samples - rpos;
|
||||||
int to_capture = MIN (live, left);
|
size_t to_capture = MIN(live, left);
|
||||||
struct st_sample *src;
|
struct st_sample *src;
|
||||||
struct capture_callback *cb;
|
struct capture_callback *cb;
|
||||||
|
|
||||||
|
@ -1228,8 +1224,8 @@ static void audio_run_capture (AudioState *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)) {
|
if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)) {
|
||||||
dolog ("captured=%d sw->total_hw_samples_mixed=%d\n",
|
dolog("captured=%zu sw->total_hw_samples_mixed=%zu\n",
|
||||||
captured, sw->total_hw_samples_mixed);
|
captured, sw->total_hw_samples_mixed);
|
||||||
captured = sw->total_hw_samples_mixed;
|
captured = sw->total_hw_samples_mixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ SWVoiceOut *AUD_open_out (
|
||||||
);
|
);
|
||||||
|
|
||||||
void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
|
void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
|
||||||
int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size);
|
size_t AUD_write (SWVoiceOut *sw, void *pcm_buf, size_t size);
|
||||||
int AUD_get_buffer_size_out (SWVoiceOut *sw);
|
int AUD_get_buffer_size_out (SWVoiceOut *sw);
|
||||||
void AUD_set_active_out (SWVoiceOut *sw, int on);
|
void AUD_set_active_out (SWVoiceOut *sw, int on);
|
||||||
int AUD_is_active_out (SWVoiceOut *sw);
|
int AUD_is_active_out (SWVoiceOut *sw);
|
||||||
|
@ -134,7 +134,7 @@ SWVoiceIn *AUD_open_in (
|
||||||
);
|
);
|
||||||
|
|
||||||
void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
|
void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
|
||||||
int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size);
|
size_t AUD_read (SWVoiceIn *sw, void *pcm_buf, size_t size);
|
||||||
void AUD_set_active_in (SWVoiceIn *sw, int on);
|
void AUD_set_active_in (SWVoiceIn *sw, int on);
|
||||||
int AUD_is_active_in (SWVoiceIn *sw);
|
int AUD_is_active_in (SWVoiceIn *sw);
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,12 @@ typedef struct HWVoiceOut {
|
||||||
|
|
||||||
f_sample *clip;
|
f_sample *clip;
|
||||||
|
|
||||||
int rpos;
|
size_t rpos;
|
||||||
uint64_t ts_helper;
|
uint64_t ts_helper;
|
||||||
|
|
||||||
struct st_sample *mix_buf;
|
struct st_sample *mix_buf;
|
||||||
|
|
||||||
int samples;
|
size_t samples;
|
||||||
QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
|
QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
|
||||||
QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
|
QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
|
||||||
int ctl_caps;
|
int ctl_caps;
|
||||||
|
@ -82,13 +82,13 @@ typedef struct HWVoiceIn {
|
||||||
|
|
||||||
t_sample *conv;
|
t_sample *conv;
|
||||||
|
|
||||||
int wpos;
|
size_t wpos;
|
||||||
int total_samples_captured;
|
size_t total_samples_captured;
|
||||||
uint64_t ts_helper;
|
uint64_t ts_helper;
|
||||||
|
|
||||||
struct st_sample *conv_buf;
|
struct st_sample *conv_buf;
|
||||||
|
|
||||||
int samples;
|
size_t samples;
|
||||||
QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
|
QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
|
||||||
int ctl_caps;
|
int ctl_caps;
|
||||||
struct audio_pcm_ops *pcm_ops;
|
struct audio_pcm_ops *pcm_ops;
|
||||||
|
@ -103,7 +103,7 @@ struct SWVoiceOut {
|
||||||
int64_t ratio;
|
int64_t ratio;
|
||||||
struct st_sample *buf;
|
struct st_sample *buf;
|
||||||
void *rate;
|
void *rate;
|
||||||
int total_hw_samples_mixed;
|
size_t total_hw_samples_mixed;
|
||||||
int active;
|
int active;
|
||||||
int empty;
|
int empty;
|
||||||
HWVoiceOut *hw;
|
HWVoiceOut *hw;
|
||||||
|
@ -120,7 +120,7 @@ struct SWVoiceIn {
|
||||||
struct audio_pcm_info info;
|
struct audio_pcm_info info;
|
||||||
int64_t ratio;
|
int64_t ratio;
|
||||||
void *rate;
|
void *rate;
|
||||||
int total_hw_samples_acquired;
|
size_t total_hw_samples_acquired;
|
||||||
struct st_sample *buf;
|
struct st_sample *buf;
|
||||||
f_sample *clip;
|
f_sample *clip;
|
||||||
HWVoiceIn *hw;
|
HWVoiceIn *hw;
|
||||||
|
@ -149,12 +149,12 @@ struct audio_driver {
|
||||||
struct audio_pcm_ops {
|
struct audio_pcm_ops {
|
||||||
int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque);
|
int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque);
|
||||||
void (*fini_out)(HWVoiceOut *hw);
|
void (*fini_out)(HWVoiceOut *hw);
|
||||||
int (*run_out) (HWVoiceOut *hw, int live);
|
size_t (*run_out)(HWVoiceOut *hw, size_t live);
|
||||||
int (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
|
int (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
|
||||||
|
|
||||||
int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaque);
|
int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaque);
|
||||||
void (*fini_in) (HWVoiceIn *hw);
|
void (*fini_in) (HWVoiceIn *hw);
|
||||||
int (*run_in) (HWVoiceIn *hw);
|
size_t (*run_in)(HWVoiceIn *hw);
|
||||||
int (*ctl_in) (HWVoiceIn *hw, int cmd, ...);
|
int (*ctl_in) (HWVoiceIn *hw, int cmd, ...);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -208,10 +208,10 @@ audio_driver *audio_driver_lookup(const char *name);
|
||||||
void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
|
void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
|
||||||
void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
|
void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
|
||||||
|
|
||||||
int audio_pcm_hw_get_live_in (HWVoiceIn *hw);
|
size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw);
|
||||||
|
|
||||||
int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf,
|
size_t audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf,
|
||||||
int live, int pending);
|
size_t live, size_t pending);
|
||||||
|
|
||||||
int audio_bug (const char *funcname, int cond);
|
int audio_bug (const char *funcname, int cond);
|
||||||
void *audio_calloc (const char *funcname, int nmemb, size_t size);
|
void *audio_calloc (const char *funcname, int nmemb, size_t size);
|
||||||
|
@ -224,7 +224,7 @@ void audio_run(AudioState *s, const char *msg);
|
||||||
|
|
||||||
#define VOICE_VOLUME_CAP (1 << VOICE_VOLUME)
|
#define VOICE_VOLUME_CAP (1 << VOICE_VOLUME)
|
||||||
|
|
||||||
static inline int audio_ring_dist (int dst, int src, int len)
|
static inline size_t audio_ring_dist(size_t dst, size_t src, size_t len)
|
||||||
{
|
{
|
||||||
return (dst >= src) ? (dst - src) : (len - src + dst);
|
return (dst >= src) ? (dst - src) : (len - src + dst);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,16 +75,16 @@ static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw)
|
||||||
HWBUF = NULL;
|
HWBUF = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int glue (audio_pcm_hw_alloc_resources_, TYPE) (HW *hw)
|
static bool glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
|
||||||
{
|
{
|
||||||
HWBUF = audio_calloc(__func__, hw->samples, sizeof(struct st_sample));
|
HWBUF = audio_calloc(__func__, hw->samples, sizeof(struct st_sample));
|
||||||
if (!HWBUF) {
|
if (!HWBUF) {
|
||||||
dolog ("Could not allocate " NAME " buffer (%d samples)\n",
|
dolog("Could not allocate " NAME " buffer (%zu samples)\n",
|
||||||
hw->samples);
|
hw->samples);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
|
static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
|
||||||
|
@ -265,7 +265,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio_bug(__func__, hw->samples <= 0)) {
|
if (audio_bug(__func__, hw->samples <= 0)) {
|
||||||
dolog ("hw->samples=%d\n", hw->samples);
|
dolog("hw->samples=%zd\n", hw->samples);
|
||||||
goto err1;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
|
||||||
[hw->info.swap_endianness]
|
[hw->info.swap_endianness]
|
||||||
[audio_bits_to_index (hw->info.bits)];
|
[audio_bits_to_index (hw->info.bits)];
|
||||||
|
|
||||||
if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) {
|
if (!glue(audio_pcm_hw_alloc_resources_, TYPE)(hw)) {
|
||||||
goto err1;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,9 @@ typedef struct coreaudioVoiceOut {
|
||||||
UInt32 audioDevicePropertyBufferFrameSize;
|
UInt32 audioDevicePropertyBufferFrameSize;
|
||||||
AudioStreamBasicDescription outputStreamBasicDescription;
|
AudioStreamBasicDescription outputStreamBasicDescription;
|
||||||
AudioDeviceIOProcID ioprocid;
|
AudioDeviceIOProcID ioprocid;
|
||||||
int live;
|
size_t live;
|
||||||
int decr;
|
size_t decr;
|
||||||
int rpos;
|
size_t rpos;
|
||||||
} coreaudioVoiceOut;
|
} coreaudioVoiceOut;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||||
|
@ -397,9 +397,9 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, const char *fn_name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coreaudio_run_out (HWVoiceOut *hw, int live)
|
static size_t coreaudio_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
int decr;
|
size_t decr;
|
||||||
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
|
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
|
||||||
|
|
||||||
if (coreaudio_lock (core, "coreaudio_run_out")) {
|
if (coreaudio_lock (core, "coreaudio_run_out")) {
|
||||||
|
|
|
@ -454,19 +454,20 @@ static int dsound_ctl_out (HWVoiceOut *hw, int cmd, ...)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dsound_run_out (HWVoiceOut *hw, int live)
|
static size_t dsound_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;
|
DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;
|
||||||
LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
|
LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
|
||||||
int len, hwshift;
|
size_t len;
|
||||||
|
int hwshift;
|
||||||
DWORD blen1, blen2;
|
DWORD blen1, blen2;
|
||||||
DWORD len1, len2;
|
DWORD len1, len2;
|
||||||
DWORD decr;
|
DWORD decr;
|
||||||
DWORD wpos, ppos, old_pos;
|
DWORD wpos, ppos, old_pos;
|
||||||
LPVOID p1, p2;
|
LPVOID p1, p2;
|
||||||
int bufsize;
|
size_t bufsize;
|
||||||
dsound *s = ds->s;
|
dsound *s = ds->s;
|
||||||
AudiodevDsoundOptions *dso = &s->dev->u.dsound;
|
AudiodevDsoundOptions *dso = &s->dev->u.dsound;
|
||||||
|
|
||||||
|
@ -533,9 +534,9 @@ static int dsound_run_out (HWVoiceOut *hw, int live)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio_bug(__func__, len < 0 || len > bufsize)) {
|
if (audio_bug(__func__, len > bufsize)) {
|
||||||
dolog ("len=%d bufsize=%d old_pos=%ld ppos=%ld\n",
|
dolog("len=%zu bufsize=%zu old_pos=%ld ppos=%ld\n",
|
||||||
len, bufsize, old_pos, ppos);
|
len, bufsize, old_pos, ppos);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,13 +641,13 @@ static int dsound_ctl_in (HWVoiceIn *hw, int cmd, ...)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dsound_run_in (HWVoiceIn *hw)
|
static size_t dsound_run_in(HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DSoundVoiceIn *ds = (DSoundVoiceIn *) hw;
|
DSoundVoiceIn *ds = (DSoundVoiceIn *) hw;
|
||||||
LPDIRECTSOUNDCAPTUREBUFFER dscb = ds->dsound_capture_buffer;
|
LPDIRECTSOUNDCAPTUREBUFFER dscb = ds->dsound_capture_buffer;
|
||||||
int live, len, dead;
|
size_t live, len, dead;
|
||||||
DWORD blen1, blen2;
|
DWORD blen1, blen2;
|
||||||
DWORD len1, len2;
|
DWORD len1, len2;
|
||||||
DWORD decr;
|
DWORD decr;
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct st_sample { mixeng_real l; mixeng_real r; };
|
||||||
struct mixeng_volume { int mute; int64_t r; int64_t l; };
|
struct mixeng_volume { int mute; int64_t r; int64_t l; };
|
||||||
struct st_sample { int64_t l; int64_t r; };
|
struct st_sample { int64_t l; int64_t r; };
|
||||||
#endif
|
#endif
|
||||||
|
typedef struct st_sample st_sample;
|
||||||
|
|
||||||
typedef void (t_sample) (struct st_sample *dst, const void *src, int samples);
|
typedef void (t_sample) (struct st_sample *dst, const void *src, int samples);
|
||||||
typedef void (f_sample) (void *dst, const struct st_sample *src, int samples);
|
typedef void (f_sample) (void *dst, const struct st_sample *src, int samples);
|
||||||
|
@ -41,10 +42,10 @@ extern t_sample *mixeng_conv[2][2][2][3];
|
||||||
extern f_sample *mixeng_clip[2][2][2][3];
|
extern f_sample *mixeng_clip[2][2][2][3];
|
||||||
|
|
||||||
void *st_rate_start (int inrate, int outrate);
|
void *st_rate_start (int inrate, int outrate);
|
||||||
void st_rate_flow (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
|
void st_rate_flow(void *opaque, st_sample *ibuf, st_sample *obuf,
|
||||||
int *isamp, int *osamp);
|
size_t *isamp, size_t *osamp);
|
||||||
void st_rate_flow_mix (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
|
void st_rate_flow_mix(void *opaque, st_sample *ibuf, st_sample *obuf,
|
||||||
int *isamp, int *osamp);
|
size_t *isamp, size_t *osamp);
|
||||||
void st_rate_stop (void *opaque);
|
void st_rate_stop (void *opaque);
|
||||||
void mixeng_clear (struct st_sample *buf, int len);
|
void mixeng_clear (struct st_sample *buf, int len);
|
||||||
void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol);
|
void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol);
|
||||||
|
|
|
@ -41,10 +41,10 @@ typedef struct NoVoiceIn {
|
||||||
int64_t old_ticks;
|
int64_t old_ticks;
|
||||||
} NoVoiceIn;
|
} NoVoiceIn;
|
||||||
|
|
||||||
static int no_run_out (HWVoiceOut *hw, int live)
|
static size_t no_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
NoVoiceOut *no = (NoVoiceOut *) hw;
|
NoVoiceOut *no = (NoVoiceOut *) hw;
|
||||||
int decr, samples;
|
size_t decr, samples;
|
||||||
int64_t now;
|
int64_t now;
|
||||||
int64_t ticks;
|
int64_t ticks;
|
||||||
int64_t bytes;
|
int64_t bytes;
|
||||||
|
@ -52,7 +52,7 @@ static int no_run_out (HWVoiceOut *hw, int live)
|
||||||
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||||
ticks = now - no->old_ticks;
|
ticks = now - no->old_ticks;
|
||||||
bytes = muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECOND);
|
bytes = muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECOND);
|
||||||
bytes = MIN(bytes, INT_MAX);
|
bytes = MIN(bytes, SIZE_MAX);
|
||||||
samples = bytes >> hw->info.shift;
|
samples = bytes >> hw->info.shift;
|
||||||
|
|
||||||
no->old_ticks = now;
|
no->old_ticks = now;
|
||||||
|
@ -92,12 +92,12 @@ static void no_fini_in (HWVoiceIn *hw)
|
||||||
(void) hw;
|
(void) hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int no_run_in (HWVoiceIn *hw)
|
static size_t no_run_in(HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
NoVoiceIn *no = (NoVoiceIn *) hw;
|
NoVoiceIn *no = (NoVoiceIn *) hw;
|
||||||
int live = audio_pcm_hw_get_live_in (hw);
|
size_t live = audio_pcm_hw_get_live_in(hw);
|
||||||
int dead = hw->samples - live;
|
size_t dead = hw->samples - live;
|
||||||
int samples = 0;
|
size_t samples = 0;
|
||||||
|
|
||||||
if (dead) {
|
if (dead) {
|
||||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||||
|
@ -106,7 +106,7 @@ static int no_run_in (HWVoiceIn *hw)
|
||||||
muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECOND);
|
muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECOND);
|
||||||
|
|
||||||
no->old_ticks = now;
|
no->old_ticks = now;
|
||||||
bytes = MIN (bytes, INT_MAX);
|
bytes = MIN (bytes, SIZE_MAX);
|
||||||
samples = bytes >> hw->info.shift;
|
samples = bytes >> hw->info.shift;
|
||||||
samples = MIN (samples, dead);
|
samples = MIN (samples, dead);
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,13 +411,14 @@ static void oss_write_pending (OSSVoiceOut *oss)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int oss_run_out (HWVoiceOut *hw, int live)
|
static size_t oss_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
|
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
|
||||||
int err, decr;
|
int err;
|
||||||
|
size_t decr;
|
||||||
struct audio_buf_info abinfo;
|
struct audio_buf_info abinfo;
|
||||||
struct count_info cntinfo;
|
struct count_info cntinfo;
|
||||||
int bufsize;
|
size_t bufsize;
|
||||||
|
|
||||||
bufsize = hw->samples << hw->info.shift;
|
bufsize = hw->samples << hw->info.shift;
|
||||||
|
|
||||||
|
@ -476,8 +477,8 @@ static void oss_fini_out (HWVoiceOut *hw)
|
||||||
if (oss->mmapped) {
|
if (oss->mmapped) {
|
||||||
err = munmap (oss->pcm_buf, hw->samples << hw->info.shift);
|
err = munmap (oss->pcm_buf, hw->samples << hw->info.shift);
|
||||||
if (err) {
|
if (err) {
|
||||||
oss_logerr (errno, "Failed to unmap buffer %p, size %d\n",
|
oss_logerr(errno, "Failed to unmap buffer %p, size %zu\n",
|
||||||
oss->pcm_buf, hw->samples << hw->info.shift);
|
oss->pcm_buf, hw->samples << hw->info.shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -543,8 +544,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
if (oss->pcm_buf == MAP_FAILED) {
|
if (oss->pcm_buf == MAP_FAILED) {
|
||||||
oss_logerr (errno, "Failed to map %d bytes of DAC\n",
|
oss_logerr(errno, "Failed to map %zu bytes of DAC\n",
|
||||||
hw->samples << hw->info.shift);
|
hw->samples << hw->info.shift);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int err;
|
int err;
|
||||||
|
@ -568,8 +569,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
|
||||||
if (!oss->mmapped) {
|
if (!oss->mmapped) {
|
||||||
err = munmap (oss->pcm_buf, hw->samples << hw->info.shift);
|
err = munmap (oss->pcm_buf, hw->samples << hw->info.shift);
|
||||||
if (err) {
|
if (err) {
|
||||||
oss_logerr (errno, "Failed to unmap buffer %p size %d\n",
|
oss_logerr(errno, "Failed to unmap buffer %p size %zu\n",
|
||||||
oss->pcm_buf, hw->samples << hw->info.shift);
|
oss->pcm_buf, hw->samples << hw->info.shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +582,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
|
||||||
1 << hw->info.shift);
|
1 << hw->info.shift);
|
||||||
if (!oss->pcm_buf) {
|
if (!oss->pcm_buf) {
|
||||||
dolog (
|
dolog (
|
||||||
"Could not allocate DAC buffer (%d samples, each %d bytes)\n",
|
"Could not allocate DAC buffer (%zu samples, each %d bytes)\n",
|
||||||
hw->samples,
|
hw->samples,
|
||||||
1 << hw->info.shift
|
1 << hw->info.shift
|
||||||
);
|
);
|
||||||
|
@ -693,8 +694,8 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
||||||
hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;
|
hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;
|
||||||
oss->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
oss->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
||||||
if (!oss->pcm_buf) {
|
if (!oss->pcm_buf) {
|
||||||
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
|
dolog("Could not allocate ADC buffer (%zu samples, each %d bytes)\n",
|
||||||
hw->samples, 1 << hw->info.shift);
|
hw->samples, 1 << hw->info.shift);
|
||||||
oss_anal_close (&fd);
|
oss_anal_close (&fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -714,17 +715,17 @@ static void oss_fini_in (HWVoiceIn *hw)
|
||||||
oss->pcm_buf = NULL;
|
oss->pcm_buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int oss_run_in (HWVoiceIn *hw)
|
static size_t oss_run_in(HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
|
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
|
||||||
int hwshift = hw->info.shift;
|
int hwshift = hw->info.shift;
|
||||||
int i;
|
int i;
|
||||||
int live = audio_pcm_hw_get_live_in (hw);
|
size_t live = audio_pcm_hw_get_live_in (hw);
|
||||||
int dead = hw->samples - live;
|
size_t dead = hw->samples - live;
|
||||||
size_t read_samples = 0;
|
size_t read_samples = 0;
|
||||||
struct {
|
struct {
|
||||||
int add;
|
size_t add;
|
||||||
int len;
|
size_t len;
|
||||||
} bufs[2] = {
|
} bufs[2] = {
|
||||||
{ .add = hw->wpos, .len = 0 },
|
{ .add = hw->wpos, .len = 0 },
|
||||||
{ .add = 0, .len = 0 }
|
{ .add = 0, .len = 0 }
|
||||||
|
@ -751,9 +752,9 @@ static int oss_run_in (HWVoiceIn *hw)
|
||||||
|
|
||||||
if (nread > 0) {
|
if (nread > 0) {
|
||||||
if (nread & hw->info.align) {
|
if (nread & hw->info.align) {
|
||||||
dolog ("warning: Misaligned read %zd (requested %d), "
|
dolog("warning: Misaligned read %zd (requested %zu), "
|
||||||
"alignment %d\n", nread, bufs[i].add << hwshift,
|
"alignment %d\n", nread, bufs[i].add << hwshift,
|
||||||
hw->info.align + 1);
|
hw->info.align + 1);
|
||||||
}
|
}
|
||||||
read_samples += nread >> hwshift;
|
read_samples += nread >> hwshift;
|
||||||
hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift);
|
hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift);
|
||||||
|
@ -766,9 +767,9 @@ static int oss_run_in (HWVoiceIn *hw)
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
oss_logerr (
|
oss_logerr(
|
||||||
errno,
|
errno,
|
||||||
"Failed to read %d bytes of audio (to %p)\n",
|
"Failed to read %zu bytes of audio (to %p)\n",
|
||||||
bufs[i].len, p
|
bufs[i].len, p
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -30,30 +30,30 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
HWVoiceOut hw;
|
HWVoiceOut hw;
|
||||||
int done;
|
size_t done;
|
||||||
int live;
|
size_t live;
|
||||||
int decr;
|
size_t decr;
|
||||||
int rpos;
|
size_t rpos;
|
||||||
pa_stream *stream;
|
pa_stream *stream;
|
||||||
void *pcm_buf;
|
void *pcm_buf;
|
||||||
struct audio_pt pt;
|
struct audio_pt pt;
|
||||||
paaudio *g;
|
paaudio *g;
|
||||||
int samples;
|
size_t samples;
|
||||||
} PAVoiceOut;
|
} PAVoiceOut;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
HWVoiceIn hw;
|
HWVoiceIn hw;
|
||||||
int done;
|
size_t done;
|
||||||
int dead;
|
size_t dead;
|
||||||
int incr;
|
size_t incr;
|
||||||
int wpos;
|
size_t wpos;
|
||||||
pa_stream *stream;
|
pa_stream *stream;
|
||||||
void *pcm_buf;
|
void *pcm_buf;
|
||||||
struct audio_pt pt;
|
struct audio_pt pt;
|
||||||
const void *read_data;
|
const void *read_data;
|
||||||
size_t read_index, read_length;
|
size_t read_index, read_length;
|
||||||
paaudio *g;
|
paaudio *g;
|
||||||
int samples;
|
size_t samples;
|
||||||
} PAVoiceIn;
|
} PAVoiceIn;
|
||||||
|
|
||||||
static void qpa_conn_fini(PAConnection *c);
|
static void qpa_conn_fini(PAConnection *c);
|
||||||
|
@ -219,7 +219,7 @@ static void *qpa_thread_out (void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int decr, to_mix, rpos;
|
size_t decr, to_mix, rpos;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (pa->done) {
|
if (pa->done) {
|
||||||
|
@ -244,7 +244,7 @@ static void *qpa_thread_out (void *arg)
|
||||||
|
|
||||||
while (to_mix) {
|
while (to_mix) {
|
||||||
int error;
|
int error;
|
||||||
int chunk = MIN (to_mix, hw->samples - rpos);
|
size_t chunk = MIN (to_mix, hw->samples - rpos);
|
||||||
struct st_sample *src = hw->mix_buf + rpos;
|
struct st_sample *src = hw->mix_buf + rpos;
|
||||||
|
|
||||||
hw->clip (pa->pcm_buf, src, chunk);
|
hw->clip (pa->pcm_buf, src, chunk);
|
||||||
|
@ -273,9 +273,9 @@ static void *qpa_thread_out (void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qpa_run_out (HWVoiceOut *hw, int live)
|
static size_t qpa_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
int decr;
|
size_t decr;
|
||||||
PAVoiceOut *pa = (PAVoiceOut *) hw;
|
PAVoiceOut *pa = (PAVoiceOut *) hw;
|
||||||
|
|
||||||
if (audio_pt_lock(&pa->pt, __func__)) {
|
if (audio_pt_lock(&pa->pt, __func__)) {
|
||||||
|
@ -306,7 +306,7 @@ static void *qpa_thread_in (void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int incr, to_grab, wpos;
|
size_t incr, to_grab, wpos;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (pa->done) {
|
if (pa->done) {
|
||||||
|
@ -331,7 +331,7 @@ static void *qpa_thread_in (void *arg)
|
||||||
|
|
||||||
while (to_grab) {
|
while (to_grab) {
|
||||||
int error;
|
int error;
|
||||||
int chunk = MIN (to_grab, hw->samples - wpos);
|
size_t chunk = MIN (to_grab, hw->samples - wpos);
|
||||||
void *buf = advance (pa->pcm_buf, wpos);
|
void *buf = advance (pa->pcm_buf, wpos);
|
||||||
|
|
||||||
if (qpa_simple_read (pa, buf,
|
if (qpa_simple_read (pa, buf,
|
||||||
|
@ -359,9 +359,9 @@ static void *qpa_thread_in (void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qpa_run_in (HWVoiceIn *hw)
|
static size_t qpa_run_in(HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
int live, incr, dead;
|
size_t live, incr, dead;
|
||||||
PAVoiceIn *pa = (PAVoiceIn *) hw;
|
PAVoiceIn *pa = (PAVoiceIn *) hw;
|
||||||
|
|
||||||
if (audio_pt_lock(&pa->pt, __func__)) {
|
if (audio_pt_lock(&pa->pt, __func__)) {
|
||||||
|
@ -582,8 +582,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
|
||||||
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
||||||
pa->rpos = hw->rpos;
|
pa->rpos = hw->rpos;
|
||||||
if (!pa->pcm_buf) {
|
if (!pa->pcm_buf) {
|
||||||
dolog ("Could not allocate buffer (%d bytes)\n",
|
dolog("Could not allocate buffer (%zu bytes)\n",
|
||||||
hw->samples << hw->info.shift);
|
hw->samples << hw->info.shift);
|
||||||
goto fail2;
|
goto fail2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,8 +650,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
||||||
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
||||||
pa->wpos = hw->wpos;
|
pa->wpos = hw->wpos;
|
||||||
if (!pa->pcm_buf) {
|
if (!pa->pcm_buf) {
|
||||||
dolog ("Could not allocate buffer (%d bytes)\n",
|
dolog("Could not allocate buffer (%zu bytes)\n",
|
||||||
hw->samples << hw->info.shift);
|
hw->samples << hw->info.shift);
|
||||||
goto fail2;
|
goto fail2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
* Return number of samples processed.
|
* Return number of samples processed.
|
||||||
*/
|
*/
|
||||||
void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
|
void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
|
||||||
int *isamp, int *osamp)
|
size_t *isamp, size_t *osamp)
|
||||||
{
|
{
|
||||||
struct rate *rate = opaque;
|
struct rate *rate = opaque;
|
||||||
struct st_sample *istart, *iend;
|
struct st_sample *istart, *iend;
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
|
|
||||||
typedef struct SDLVoiceOut {
|
typedef struct SDLVoiceOut {
|
||||||
HWVoiceOut hw;
|
HWVoiceOut hw;
|
||||||
int live;
|
size_t live;
|
||||||
int decr;
|
size_t decr;
|
||||||
} SDLVoiceOut;
|
} SDLVoiceOut;
|
||||||
|
|
||||||
static struct SDLAudioState {
|
static struct SDLAudioState {
|
||||||
|
@ -184,22 +184,22 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
|
||||||
SDLVoiceOut *sdl = opaque;
|
SDLVoiceOut *sdl = opaque;
|
||||||
SDLAudioState *s = &glob_sdl;
|
SDLAudioState *s = &glob_sdl;
|
||||||
HWVoiceOut *hw = &sdl->hw;
|
HWVoiceOut *hw = &sdl->hw;
|
||||||
int samples = len >> hw->info.shift;
|
size_t samples = len >> hw->info.shift;
|
||||||
int to_mix, decr;
|
size_t to_mix, decr;
|
||||||
|
|
||||||
if (s->exit || !sdl->live) {
|
if (s->exit || !sdl->live) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dolog ("in callback samples=%d live=%d\n", samples, sdl->live); */
|
/* dolog ("in callback samples=%zu live=%zu\n", samples, sdl->live); */
|
||||||
|
|
||||||
to_mix = MIN(samples, sdl->live);
|
to_mix = MIN(samples, sdl->live);
|
||||||
decr = to_mix;
|
decr = to_mix;
|
||||||
while (to_mix) {
|
while (to_mix) {
|
||||||
int chunk = MIN(to_mix, hw->samples - hw->rpos);
|
size_t chunk = MIN(to_mix, hw->samples - hw->rpos);
|
||||||
struct st_sample *src = hw->mix_buf + hw->rpos;
|
struct st_sample *src = hw->mix_buf + hw->rpos;
|
||||||
|
|
||||||
/* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */
|
/* dolog ("in callback to_mix %zu, chunk %zu\n", to_mix, chunk); */
|
||||||
hw->clip(buf, src, chunk);
|
hw->clip(buf, src, chunk);
|
||||||
hw->rpos = (hw->rpos + chunk) % hw->samples;
|
hw->rpos = (hw->rpos + chunk) % hw->samples;
|
||||||
to_mix -= chunk;
|
to_mix -= chunk;
|
||||||
|
@ -209,7 +209,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
|
||||||
sdl->live -= decr;
|
sdl->live -= decr;
|
||||||
sdl->decr += decr;
|
sdl->decr += decr;
|
||||||
|
|
||||||
/* dolog ("done len=%d\n", len); */
|
/* dolog ("done len=%zu\n", len); */
|
||||||
|
|
||||||
/* SDL2 does not clear the remaining buffer for us, so do it on our own */
|
/* SDL2 does not clear the remaining buffer for us, so do it on our own */
|
||||||
if (samples) {
|
if (samples) {
|
||||||
|
@ -217,9 +217,9 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sdl_run_out (HWVoiceOut *hw, int live)
|
static size_t sdl_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
int decr;
|
size_t decr;
|
||||||
SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
|
SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
|
||||||
|
|
||||||
SDL_LockAudio();
|
SDL_LockAudio();
|
||||||
|
|
|
@ -152,11 +152,11 @@ static void line_out_fini (HWVoiceOut *hw)
|
||||||
spice_server_remove_interface (&out->sin.base);
|
spice_server_remove_interface (&out->sin.base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int line_out_run (HWVoiceOut *hw, int live)
|
static size_t line_out_run (HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
SpiceVoiceOut *out = container_of (hw, SpiceVoiceOut, hw);
|
SpiceVoiceOut *out = container_of (hw, SpiceVoiceOut, hw);
|
||||||
int rpos, decr;
|
size_t rpos, decr;
|
||||||
int samples;
|
size_t samples;
|
||||||
|
|
||||||
if (!live) {
|
if (!live) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -275,12 +275,12 @@ static void line_in_fini (HWVoiceIn *hw)
|
||||||
spice_server_remove_interface (&in->sin.base);
|
spice_server_remove_interface (&in->sin.base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int line_in_run (HWVoiceIn *hw)
|
static size_t line_in_run(HWVoiceIn *hw)
|
||||||
{
|
{
|
||||||
SpiceVoiceIn *in = container_of (hw, SpiceVoiceIn, hw);
|
SpiceVoiceIn *in = container_of (hw, SpiceVoiceIn, hw);
|
||||||
int num_samples;
|
size_t num_samples;
|
||||||
int ready;
|
int ready;
|
||||||
int len[2];
|
size_t len[2];
|
||||||
uint64_t delta_samp;
|
uint64_t delta_samp;
|
||||||
const uint32_t *samples;
|
const uint32_t *samples;
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,10 @@ typedef struct WAVVoiceOut {
|
||||||
int total_samples;
|
int total_samples;
|
||||||
} WAVVoiceOut;
|
} WAVVoiceOut;
|
||||||
|
|
||||||
static int wav_run_out (HWVoiceOut *hw, int live)
|
static size_t wav_run_out(HWVoiceOut *hw, size_t live)
|
||||||
{
|
{
|
||||||
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
|
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
|
||||||
int rpos, decr, samples;
|
size_t rpos, decr, samples;
|
||||||
uint8_t *dst;
|
uint8_t *dst;
|
||||||
struct st_sample *src;
|
struct st_sample *src;
|
||||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||||
|
@ -139,8 +139,8 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as,
|
||||||
hw->samples = 1024;
|
hw->samples = 1024;
|
||||||
wav->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
wav->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
||||||
if (!wav->pcm_buf) {
|
if (!wav->pcm_buf) {
|
||||||
dolog ("Could not allocate buffer (%d bytes)\n",
|
dolog("Could not allocate buffer (%zu bytes)\n",
|
||||||
hw->samples << hw->info.shift);
|
hw->samples << hw->info.shift);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,9 +179,9 @@ void replay_net_packet_event(ReplayNetState *rns, unsigned flags,
|
||||||
/* Audio */
|
/* Audio */
|
||||||
|
|
||||||
/*! Saves/restores number of played samples of audio out operation. */
|
/*! Saves/restores number of played samples of audio out operation. */
|
||||||
void replay_audio_out(int *played);
|
void replay_audio_out(size_t *played);
|
||||||
/*! Saves/restores recorded samples of audio in operation. */
|
/*! Saves/restores recorded samples of audio in operation. */
|
||||||
void replay_audio_in(int *recorded, void *samples, int *wpos, int size);
|
void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size);
|
||||||
|
|
||||||
/* VM state operations */
|
/* VM state operations */
|
||||||
|
|
||||||
|
|
|
@ -15,18 +15,18 @@
|
||||||
#include "replay-internal.h"
|
#include "replay-internal.h"
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
|
|
||||||
void replay_audio_out(int *played)
|
void replay_audio_out(size_t *played)
|
||||||
{
|
{
|
||||||
if (replay_mode == REPLAY_MODE_RECORD) {
|
if (replay_mode == REPLAY_MODE_RECORD) {
|
||||||
g_assert(replay_mutex_locked());
|
g_assert(replay_mutex_locked());
|
||||||
replay_save_instructions();
|
replay_save_instructions();
|
||||||
replay_put_event(EVENT_AUDIO_OUT);
|
replay_put_event(EVENT_AUDIO_OUT);
|
||||||
replay_put_dword(*played);
|
replay_put_qword(*played);
|
||||||
} else if (replay_mode == REPLAY_MODE_PLAY) {
|
} else if (replay_mode == REPLAY_MODE_PLAY) {
|
||||||
g_assert(replay_mutex_locked());
|
g_assert(replay_mutex_locked());
|
||||||
replay_account_executed_instructions();
|
replay_account_executed_instructions();
|
||||||
if (replay_next_event_is(EVENT_AUDIO_OUT)) {
|
if (replay_next_event_is(EVENT_AUDIO_OUT)) {
|
||||||
*played = replay_get_dword();
|
*played = replay_get_qword();
|
||||||
replay_finish_event();
|
replay_finish_event();
|
||||||
} else {
|
} else {
|
||||||
error_report("Missing audio out event in the replay log");
|
error_report("Missing audio out event in the replay log");
|
||||||
|
@ -35,7 +35,7 @@ void replay_audio_out(int *played)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void replay_audio_in(int *recorded, void *samples, int *wpos, int size)
|
void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
uint64_t left, right;
|
uint64_t left, right;
|
||||||
|
@ -43,8 +43,8 @@ void replay_audio_in(int *recorded, void *samples, int *wpos, int size)
|
||||||
g_assert(replay_mutex_locked());
|
g_assert(replay_mutex_locked());
|
||||||
replay_save_instructions();
|
replay_save_instructions();
|
||||||
replay_put_event(EVENT_AUDIO_IN);
|
replay_put_event(EVENT_AUDIO_IN);
|
||||||
replay_put_dword(*recorded);
|
replay_put_qword(*recorded);
|
||||||
replay_put_dword(*wpos);
|
replay_put_qword(*wpos);
|
||||||
for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
|
for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
|
||||||
; pos = (pos + 1) % size) {
|
; pos = (pos + 1) % size) {
|
||||||
audio_sample_to_uint64(samples, pos, &left, &right);
|
audio_sample_to_uint64(samples, pos, &left, &right);
|
||||||
|
@ -55,8 +55,8 @@ void replay_audio_in(int *recorded, void *samples, int *wpos, int size)
|
||||||
g_assert(replay_mutex_locked());
|
g_assert(replay_mutex_locked());
|
||||||
replay_account_executed_instructions();
|
replay_account_executed_instructions();
|
||||||
if (replay_next_event_is(EVENT_AUDIO_IN)) {
|
if (replay_next_event_is(EVENT_AUDIO_IN)) {
|
||||||
*recorded = replay_get_dword();
|
*recorded = replay_get_qword();
|
||||||
*wpos = replay_get_dword();
|
*wpos = replay_get_qword();
|
||||||
for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
|
for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
|
||||||
; pos = (pos + 1) % size) {
|
; pos = (pos + 1) % size) {
|
||||||
left = replay_get_qword();
|
left = replay_get_qword();
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
/* Current version of the replay mechanism.
|
/* Current version of the replay mechanism.
|
||||||
Increase it when file format changes. */
|
Increase it when file format changes. */
|
||||||
#define REPLAY_VERSION 0xe02007
|
#define REPLAY_VERSION 0xe02008
|
||||||
/* Size of replay log header */
|
/* Size of replay log header */
|
||||||
#define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t))
|
#define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue