* [PATCH] Cygwin: dsp: Fix SNDCTL_DSP_GET[IO]SPACE before read()/write().
@ 2023-02-14 14:35 Takashi Yano
0 siblings, 0 replies; only message in thread
From: Takashi Yano @ 2023-02-14 14:35 UTC (permalink / raw)
To: cygwin-patches; +Cc: Takashi Yano
Even with the commit 3a4c740f59c0, SNDCTL_DSP_GET[IO]SPACE ioctl()
does not return the fragment set by SNDCTL_DSP_SETFRAGMENT if it
is issued before read()/write(). This patch fixes the issue.
Fixes: 3a4c740f59c0 ("Cygwin: dsp: Implement SNDCTL_DSP_SETFRAGMENT ioctl().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
winsup/cygwin/fhandler/dsp.cc | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/winsup/cygwin/fhandler/dsp.cc b/winsup/cygwin/fhandler/dsp.cc
index dd1aac8e2..16db6bb29 100644
--- a/winsup/cygwin/fhandler/dsp.cc
+++ b/winsup/cygwin/fhandler/dsp.cc
@@ -1369,11 +1369,17 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
return -1;
}
audio_buf_info *p = (audio_buf_info *) buf;
- if (audio_out_) {
- audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
- } else {
- Audio_out::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);
- }
+ if (audio_out_)
+ audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
+ else if (fragment_has_been_set)
+ {
+ p->bytes = fragsize_ * fragstotal_;
+ p->fragsize = fragsize_;
+ p->fragstotal = fragstotal_;
+ p->fragments = fragstotal_;
+ }
+ else
+ Audio_out::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);
debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
buf, p->fragments, p->fragsize, p->bytes);
return 0;
@@ -1387,11 +1393,17 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
return -1;
}
audio_buf_info *p = (audio_buf_info *) buf;
- if (audio_in_) {
- audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
- } else {
- Audio_in::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);
- }
+ if (audio_in_)
+ audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
+ else if (fragment_has_been_set)
+ {
+ p->bytes = 0;
+ p->fragsize = fragsize_;
+ p->fragstotal = fragstotal_;
+ p->fragments = 0;
+ }
+ else
+ Audio_in::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);
debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
buf, p->fragments, p->fragsize, p->bytes);
return 0;
--
2.39.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-14 14:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 14:35 [PATCH] Cygwin: dsp: Fix SNDCTL_DSP_GET[IO]SPACE before read()/write() Takashi Yano
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).