diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-02-14 16:55:10 +0300 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-02-16 14:14:13 +0300 |
commit | a9a17f5fe51498b182d4a11ac48207b8c7ffe8ec (patch) | |
tree | f6374c96e05f2d43c94e5004d07302b58d258a41 /winsup/cygwin/fhandler | |
parent | c750a728bd21ad6234797e923fea47e3a6000260 (diff) |
Cygwin: dsp: Fix SNDCTL_DSP_GET[IO]SPACE before read()/write().
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>
Diffstat (limited to 'winsup/cygwin/fhandler')
-rw-r--r-- | winsup/cygwin/fhandler/dsp.cc | 32 |
1 files 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; |