public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: dsp: Avoid setting buffer that is too small.
Date: Sun, 17 Sep 2023 13:40:49 +0000 (GMT)	[thread overview]
Message-ID: <20230917134049.87A52385559F@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=322c7150b25ebd2c4c2bd4e3abbe0978f66f3737

commit 322c7150b25ebd2c4c2bd4e3abbe0978f66f3737
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Sun Sep 17 08:49:34 2023 +0900

    Cygwin: dsp: Avoid setting buffer that is too small.
    
    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.
    
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

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 = (int *) buf;
 	fragstotal_ = min (*p >> 16, MAX_BLOCKS);
 	fragsize_ = 1 << (*p & 0xffff);
+	while (fragsize_ * fragstotal_ < 16384)
+	  fragsize_ *= 2;
 	fragment_has_been_set = true;
 	return 0;
       }

                 reply	other threads:[~2023-09-17 13:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230917134049.87A52385559F@sourceware.org \
    --to=tyan0@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).