From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id E3747385B507; Sat, 25 Feb 2023 08:59:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3747385B507 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677315591; bh=IgipfRuzfNfmoIi8w09zfP6CCcmdXSGWA+CUTAvwvDY=; h=From:To:Subject:Date:From; b=N3T2dFoZXa//NG5cJ7Yi4akCuC0Tj7bGtxxQMSKOFjzkLt5z2P9U6l6HvQDVLXP2k t9gSkWcViJIpDtsucLZN5sAlC5zXUkVaWRR+Z1FeMuCOfAmEpafjLqAe3LXmr0RCOZ NdEULD/I3PBDShFbkn6t5uPu7aG8/49+dvlJEzhw= 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: Fix SNDCTL_DSP_{POST,SYNC} ioctl() behaviour. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: e95a7a795522165a2d022dbb4df281d6be661c83 X-Git-Newrev: 0ab22f0af975e114003ec6bfa5d72f66f5999c44 Message-Id: <20230225085951.E3747385B507@sourceware.org> Date: Sat, 25 Feb 2023 08:59:51 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D0ab22f0af97= 5e114003ec6bfa5d72f66f5999c44 commit 0ab22f0af975e114003ec6bfa5d72f66f5999c44 Author: Takashi Yano Date: Sat Feb 25 10:28:34 2023 +0900 Cygwin: dsp: Fix SNDCTL_DSP_{POST,SYNC} ioctl() behaviour. =20 Previously, SNDCTL_DSP_POST and SNDCTL_DSP_SYNC were implemented wrongly. Due to this issue, module-oss of pulseaudio generates choppy sound when SNDCTL_DSP_POST is called. This patch fixes that. =20 Signed-off-by: Takashi Yano Diff: --- winsup/cygwin/fhandler/dsp.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/fhandler/dsp.cc b/winsup/cygwin/fhandler/dsp.cc index 16db6bb29..27f0a50ce 100644 --- a/winsup/cygwin/fhandler/dsp.cc +++ b/winsup/cygwin/fhandler/dsp.cc @@ -133,6 +133,8 @@ class fhandler_dev_dsp::Audio_out: public Audio int freq_; int bits_; int channels_; + + friend fhandler_dev_dsp; }; =20 static void CALLBACK waveIn_callback (HWAVEIN hWave, UINT msg, @@ -1429,11 +1431,16 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *b= uf) return 0; =20 CASE (SNDCTL_DSP_POST) + if (audio_out_) + audio_out_->sendcurrent (); // force out last block whatever size.. + return 0; + CASE (SNDCTL_DSP_SYNC) - // Stop audio out device - close_audio_out (); - // Stop audio in device - close_audio_in (); + if (audio_out_) + { + audio_out_->sendcurrent (); // force out last block whatever size.. + audio_out_->waitforallsent (); // block till finished.. + } return 0; =20 default: