fixes for 5.0:

- audio: windows (dsound) fixes.
 - vga: ati blitter sanity check fixes.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABCgAGBQJejEYoAAoJEEy22O7T6HE4B8wQAMHEcbyXVnh2hc/0x1wHi6T5
 IlsLkWvTEC0ZsyG5FcCm9XVC3b+WYCOyt4p+Zci9/lCZuYVCQjsKAafy8zb/8gZo
 c+bQny3APdzE+LSO8sByRDCrnwAxEzyzdcqEj8NKXUhTK0fZRCopyi4nWDIfK1b8
 fNWhWvObeTQEqULbPk+NRFPzI49vMijNK/y7CA64X12jddstG6psaeNYxrjzSTVf
 Fk2L9f4rccVAIA2Cl1hmp18QqqFiQeL/Bw8zi/mGaMBE9ip+SyrTP70MY1GavRDF
 tRfwAHu+eVD3i6iiyoGOapQjgelprn83Qrce8gXJ4/ldxHLbeGnfVx90usp77d/9
 cMQygbIGzbOCpZFPZ0C6aCQrEBJ8aqrZdiCK9i6Z3loqh3plVWBpoUpKT6L1FF+U
 igO21JX3Sz/T4i2RVToylx/2LFii0A8uoT7OMqT45+yjFcra4T6LWdgQtntomKlV
 J51VIXjAzWrxQ3SNOZHrgKYq6MYuLRU6zDQW/arglgA3t0t+gco6LG63Jbx3IH+C
 CL2j4TVG5XHXf74hkWbWQlMxz7Os49k1DQojB9QfOk4L6M0IpJxZXFE8v+v/tIjE
 TF/KeM20Wv6rc8TWYx96SO8gCTW6lgysRymSn1tU09uWAx/bAfSxTru2E7VErmMx
 aiPUv6uzVdFJG8yRHX8j
 =AoE+
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20200407-pull-request' into staging

fixes for 5.0:
- audio: windows (dsound) fixes.
- vga: ati blitter sanity check fixes.

# gpg: Signature made Tue 07 Apr 2020 10:21:44 BST
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/fixes-20200407-pull-request:
  ati-vga: Fix checks in ati_2d_blt() to avoid crash
  dsoundaudio: dsound_get_buffer_in should honor *size
  dsoundaudio: fix "Could not lock capture buffer" warning
  dsoundaudio: fix never-ending playback loop

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-04-07 14:01:49 +01:00
commit ca74fc1988
3 changed files with 38 additions and 20 deletions

View File

@ -1491,16 +1491,14 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size)
size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)
{
size_t src_size, copy_size;
void *src = hw->pcm_ops->get_buffer_in(hw, &src_size);
copy_size = MIN(size, src_size);
void *src = hw->pcm_ops->get_buffer_in(hw, &size);
memcpy(buf, src, copy_size);
hw->pcm_ops->put_buffer_in(hw, src, copy_size);
return copy_size;
memcpy(buf, src, size);
hw->pcm_ops->put_buffer_in(hw, src, size);
return size;
}
static int audio_driver_init(AudioState *s, struct audio_driver *drv,
bool msg, Audiodev *dev)
{

View File

@ -279,7 +279,7 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFFER dsb, DWORD *statusp,
return -1;
}
if (*statusp & DSERR_BUFFERLOST) {
if (*statusp & DSBSTATUS_BUFFERLOST) {
dsound_restore_out(dsb, s);
return -1;
}
@ -540,7 +540,12 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size)
}
req_size = audio_ring_dist(cpos, hw->pos_emul, hw->size_emul);
req_size = MIN(req_size, hw->size_emul - hw->pos_emul);
req_size = MIN(*size, MIN(req_size, hw->size_emul - hw->pos_emul));
if (req_size == 0) {
*size = 0;
return NULL;
}
err = dsound_lock_in(dscb, &hw->info, hw->pos_emul, req_size, &ret, NULL,
&act_size, NULL, false, ds->s);

View File

@ -53,12 +53,20 @@ void ati_2d_blt(ATIVGAState *s)
s->vga.vbe_start_addr, surface_data(ds), surface_stride(ds),
surface_bits_per_pixel(ds),
(s->regs.dp_mix & GMC_ROP3_MASK) >> 16);
int dst_x = (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ?
s->regs.dst_x : s->regs.dst_x + 1 - s->regs.dst_width);
int dst_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
s->regs.dst_y : s->regs.dst_y + 1 - s->regs.dst_height);
unsigned dst_x = (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ?
s->regs.dst_x : s->regs.dst_x + 1 - s->regs.dst_width);
unsigned dst_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
s->regs.dst_y : s->regs.dst_y + 1 - s->regs.dst_height);
int bpp = ati_bpp_from_datatype(s);
if (!bpp) {
qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n");
return;
}
int dst_stride = DEFAULT_CNTL ? s->regs.dst_pitch : s->regs.default_pitch;
if (!dst_stride) {
qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n");
return;
}
uint8_t *dst_bits = s->vga.vram_ptr + (DEFAULT_CNTL ?
s->regs.dst_offset : s->regs.default_offset);
@ -82,12 +90,16 @@ void ati_2d_blt(ATIVGAState *s)
switch (s->regs.dp_mix & GMC_ROP3_MASK) {
case ROP3_SRCCOPY:
{
int src_x = (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ?
s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_width);
int src_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
s->regs.src_y : s->regs.src_y + 1 - s->regs.dst_height);
unsigned src_x = (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ?
s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_width);
unsigned src_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
s->regs.src_y : s->regs.src_y + 1 - s->regs.dst_height);
int src_stride = DEFAULT_CNTL ?
s->regs.src_pitch : s->regs.default_pitch;
if (!src_stride) {
qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n");
return;
}
uint8_t *src_bits = s->vga.vram_ptr + (DEFAULT_CNTL ?
s->regs.src_offset : s->regs.default_offset);
@ -137,8 +149,10 @@ void ati_2d_blt(ATIVGAState *s)
dst_y * surface_stride(ds),
s->regs.dst_height * surface_stride(ds));
}
s->regs.dst_x += s->regs.dst_width;
s->regs.dst_y += s->regs.dst_height;
s->regs.dst_x = (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ?
dst_x + s->regs.dst_width : dst_x);
s->regs.dst_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
dst_y + s->regs.dst_height : dst_y);
break;
}
case ROP3_PATCOPY:
@ -179,7 +193,8 @@ void ati_2d_blt(ATIVGAState *s)
dst_y * surface_stride(ds),
s->regs.dst_height * surface_stride(ds));
}
s->regs.dst_y += s->regs.dst_height;
s->regs.dst_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
dst_y + s->regs.dst_height : dst_y);
break;
}
default: