Cygwin: dsp: Fix SNDCTL_DSP_GET[IO]SPACE before read()/write().

Even with the commit 3a4c740f59, 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: 3a4c740f59 ("Cygwin: dsp: Implement SNDCTL_DSP_SETFRAGMENT ioctl().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
This commit is contained in:
Takashi Yano 2023-02-14 22:55:10 +09:00
parent c750a728bd
commit a9a17f5fe5
1 changed files with 22 additions and 10 deletions

View File

@ -1369,11 +1369,17 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
return -1; return -1;
} }
audio_buf_info *p = (audio_buf_info *) buf; audio_buf_info *p = (audio_buf_info *) buf;
if (audio_out_) { if (audio_out_)
audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_); audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
} else { else if (fragment_has_been_set)
Audio_out::default_buf_info(p, audiofreq_, audiobits_, audiochannels_); {
} 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", debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
buf, p->fragments, p->fragsize, p->bytes); buf, p->fragments, p->fragsize, p->bytes);
return 0; return 0;
@ -1387,11 +1393,17 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
return -1; return -1;
} }
audio_buf_info *p = (audio_buf_info *) buf; audio_buf_info *p = (audio_buf_info *) buf;
if (audio_in_) { if (audio_in_)
audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_); audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
} else { else if (fragment_has_been_set)
Audio_in::default_buf_info(p, audiofreq_, audiobits_, audiochannels_); {
} 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", debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
buf, p->fragments, p->fragsize, p->bytes); buf, p->fragments, p->fragsize, p->bytes);
return 0; return 0;