Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-05-24 09:20:17 +0400
committerChristopher Faylor <me@cgf.cx>2001-05-24 09:20:17 +0400
commit52cd2f88cd6f67147534ca854da7f51aafead01e (patch)
tree6f42cfbe3b55ec5f0529c5dbb2534be541146bfb /winsup/cygwin/fhandler_dsp.cc
parentffa9dc2c1cb07fdcd0dc55aa21a68db8b2b8230f (diff)
* exceptions.cc (handle_exceptions): Bump repeat count for debugging kick out.
* fhandler.h (fhandler_dev_dsp): Add a fixup_after_exec. * fhandler_dsp.cc (class Audio): Add TOT_BLOCK_SIZE to enum. (operator new): New. (bigwavebuffer): Declare using TOT_BLOCK_SIZE to avoid buffer overruns. (Audio::Audio): Optimize slightly. (fhandler_dev_dsp::open): Allocate s_audio using static buffer. (fhandler_dev_dsp::fixup_after_exec): New function. Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_dsp.cc')
-rw-r--r--winsup/cygwin/fhandler_dsp.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc
index c6d96c4e6..91049ae04 100644
--- a/winsup/cygwin/fhandler_dsp.cc
+++ b/winsup/cygwin/fhandler_dsp.cc
@@ -28,7 +28,12 @@ static void CALLBACK wave_callback (HWAVE hWave, UINT msg, DWORD instance,
class Audio
{
public:
- enum { MAX_BLOCKS = 12, BLOCK_SIZE = 16384 };
+ enum
+ {
+ MAX_BLOCKS = 12,
+ BLOCK_SIZE = 16384,
+ TOT_BLOCK_SIZE = BLOCK_SIZE + sizeof (WAVEHDR)
+ };
Audio ();
~Audio ();
@@ -43,6 +48,8 @@ public:
void setformat (int format) {formattype_ = format;}
int numbytesoutput ();
+ void *operator new (size_t, void *p) {return p;}
+
private:
char *initialisebuffer ();
void waitforcallback ();
@@ -57,21 +64,17 @@ private:
char *freeblocks_[MAX_BLOCKS];
int formattype_;
- char bigwavebuffer_[MAX_BLOCKS * BLOCK_SIZE];
+ char bigwavebuffer_[MAX_BLOCKS * TOT_BLOCK_SIZE];
};
+static char audio_buf[sizeof (class Audio)];
+
Audio::Audio ()
{
- int size = BLOCK_SIZE + sizeof (WAVEHDR);
-
InitializeCriticalSection (&lock_);
- memset (freeblocks_, 0, sizeof (freeblocks_));
+ memset (bigwavebuffer_, 0, sizeof (bigwavebuffer_));
for (int i = 0; i < MAX_BLOCKS; i++)
- {
- char *pBuffer = &bigwavebuffer_[i * size];
- memset (pBuffer, 0, size);
- freeblocks_[i] = pBuffer;
- }
+ freeblocks_[i] = &bigwavebuffer_[i * TOT_BLOCK_SIZE];
}
Audio::~Audio ()
@@ -436,7 +439,7 @@ fhandler_dev_dsp::open (const char *path, int flags, mode_t mode = 0)
set_flags (flags);
if (!s_audio)
- s_audio = new Audio;
+ s_audio = new (audio_buf) Audio;
// Work out initial sample format & frequency
if (strcmp (path, "/dev/dsp") == 0L)
@@ -632,3 +635,10 @@ fhandler_dev_dsp::dump ()
{
paranoid_printf ("here, fhandler_dev_dsp");
}
+
+void
+fhandler_dev_dsp::fixup_after_exec (HANDLE)
+{
+ /* FIXME: Is there a better way to do this? */
+ s_audio = new (audio_buf) Audio;
+}