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: Fix SNDCTL_DSP_{POST,SYNC} ioctl() behaviour.
Date: Sat, 25 Feb 2023 08:59:51 +0000 (GMT)	[thread overview]
Message-ID: <20230225085951.E3747385B507@sourceware.org> (raw)

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

commit 0ab22f0af975e114003ec6bfa5d72f66f5999c44
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Sat Feb 25 10:28:34 2023 +0900

    Cygwin: dsp: Fix SNDCTL_DSP_{POST,SYNC} ioctl() behaviour.
    
    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.
    
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

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;
 };
 
 static void CALLBACK waveIn_callback (HWAVEIN hWave, UINT msg,
@@ -1429,11 +1431,16 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
 	return 0;
 
       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;
 
     default:

                 reply	other threads:[~2023-02-25  8:59 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=20230225085951.E3747385B507@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).