From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 87A52385559F; Sun, 17 Sep 2023 13:40:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87A52385559F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694958049; bh=HSBUGeDeKfTcUPohjiehRcDyllM36sxqPeDRwYkj0+A=; h=From:To:Subject:Date:From; b=UJX+/WV45NOdf9DgMBePUf3+HV6BXDIitzcgJDI7X02F0Wk/jwvznFNgxwr8YC2KW tyWN0a29DdNUi0WqUqRBfhDtdTYsxWQ7HhFLFbVLiNfhxEi98jnkC2CommgUdMpOQK xqtl0YjUs4ev0KrT6sJNW77AEw738awhCB4L9dDg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: dsp: Avoid setting buffer that is too small. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 8484773f47ccb14a24e3b40a5b5a329ae5768f82 X-Git-Newrev: 322c7150b25ebd2c4c2bd4e3abbe0978f66f3737 Message-Id: <20230917134049.87A52385559F@sourceware.org> Date: Sun, 17 Sep 2023 13:40:49 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D322c7150b25= ebd2c4c2bd4e3abbe0978f66f3737 commit 322c7150b25ebd2c4c2bd4e3abbe0978f66f3737 Author: Takashi Yano Date: Sun Sep 17 08:49:34 2023 +0900 Cygwin: dsp: Avoid setting buffer that is too small. =20 The buffer size that is too small causes choppy sound. That is not practical at all. With this patch, the minimum value of the buffer size (i.e. fragstotal * fragsize) is restricted to 16384 bytes. =20 Signed-off-by: Takashi Yano Diff: --- winsup/cygwin/fhandler/dsp.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/winsup/cygwin/fhandler/dsp.cc b/winsup/cygwin/fhandler/dsp.cc index 03c812a9c..97f3eaa27 100644 --- a/winsup/cygwin/fhandler/dsp.cc +++ b/winsup/cygwin/fhandler/dsp.cc @@ -1430,6 +1430,8 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf) int *p =3D (int *) buf; fragstotal_ =3D min (*p >> 16, MAX_BLOCKS); fragsize_ =3D 1 << (*p & 0xffff); + while (fragsize_ * fragstotal_ < 16384) + fragsize_ *=3D 2; fragment_has_been_set =3D true; return 0; }