From 41abcc5825d33d78bd370997ba664e3c64eb6683 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 5 Apr 2016 10:26:06 +0200 Subject: Revert "Refactor to avoid nonnull checks on "this" pointer." This reverts commit 0008bdea02b690ab19ffe997499cb9a96ee5a66d. This patch introduced a regression. Calling FOO=$(...) in zsh hangs indefinitely and has to be killed forcefully. Signed-off-by: Corinna Vinschen --- winsup/cygwin/fhandler_dsp.cc | 55 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 40 deletions(-) (limited to 'winsup/cygwin/fhandler_dsp.cc') diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index 55944b47e..9fa2c6e03 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -65,7 +65,7 @@ class fhandler_dev_dsp::Audio void convert_S16LE_S16BE (unsigned char *buffer, int size_bytes); void fillFormat (WAVEFORMATEX * format, int rate, int bits, int channels); - static unsigned blockSize (int rate, int bits, int channels); + unsigned blockSize (int rate, int bits, int channels); void (fhandler_dev_dsp::Audio::*convert_) (unsigned char *buffer, int size_bytes); @@ -117,7 +117,6 @@ class fhandler_dev_dsp::Audio_out: public Audio void stop (bool immediately = false); int write (const char *pSampleData, int nBytes); void buf_info (audio_buf_info *p, int rate, int bits, int channels); - static void default_buf_info (audio_buf_info *p, int rate, int bits, int channels); void callback_sampledone (WAVEHDR *pHdr); bool parsewav (const char *&pData, int &nBytes, int rate, int bits, int channels); @@ -152,7 +151,6 @@ public: void stop (); bool read (char *pSampleData, int &nBytes); void buf_info (audio_buf_info *p, int rate, int bits, int channels); - static void default_buf_info (audio_buf_info *p, int rate, int bits, int channels); void callback_blockfull (WAVEHDR *pHdr); private: @@ -503,11 +501,11 @@ void fhandler_dev_dsp::Audio_out::buf_info (audio_buf_info *p, int rate, int bits, int channels) { - if (dev_) + p->fragstotal = MAX_BLOCKS; + if (this && dev_) { /* If the device is running we use the internal values, possibly set from the wave file. */ - p->fragstotal = MAX_BLOCKS; p->fragsize = blockSize (freq_, bits_, channels_); p->fragments = Qisr2app_->query (); if (pHdr_ != NULL) @@ -518,17 +516,10 @@ fhandler_dev_dsp::Audio_out::buf_info (audio_buf_info *p, } else { - default_buf_info(p, rate, bits, channels); - } -} - -void fhandler_dev_dsp::Audio_out::default_buf_info (audio_buf_info *p, - int rate, int bits, int channels) -{ - p->fragstotal = MAX_BLOCKS; p->fragsize = blockSize (rate, bits, channels); p->fragments = MAX_BLOCKS; p->bytes = p->fragsize * p->fragments; + } } /* This is called on an interupt so use locking.. Note Qisr2app_ @@ -962,23 +953,14 @@ fhandler_dev_dsp::Audio_in::waitfordata () return true; } -void fhandler_dev_dsp::Audio_in::default_buf_info (audio_buf_info *p, - int rate, int bits, int channels) -{ - p->fragstotal = MAX_BLOCKS; - p->fragsize = blockSize (rate, bits, channels); - p->fragments = 0; - p->bytes = 0; -} - void fhandler_dev_dsp::Audio_in::buf_info (audio_buf_info *p, int rate, int bits, int channels) { - if (dev_) + p->fragstotal = MAX_BLOCKS; + p->fragsize = blockSize (rate, bits, channels); + if (this && dev_) { - p->fragstotal = MAX_BLOCKS; - p->fragsize = blockSize (rate, bits, channels); p->fragments = Qisr2app_->query (); if (pHdr_ != NULL) p->bytes = pHdr_->dwBytesRecorded - bufferIndex_ @@ -988,7 +970,8 @@ fhandler_dev_dsp::Audio_in::buf_info (audio_buf_info *p, } else { - default_buf_info(p, rate, bits, channels); + p->fragments = 0; + p->bytes = 0; } } @@ -1362,13 +1345,9 @@ 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_); - } - debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d", - buf, p->fragments, p->fragsize, p->bytes); + audio_out_->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; } @@ -1380,13 +1359,9 @@ 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_); - } - debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d", - buf, p->fragments, p->fragsize, p->bytes); + audio_in_->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; } -- cgit v1.2.3