This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: /dev/dsp
- To: cygwin-patches at cygwin dot com
- Subject: Re: /dev/dsp
- From: "Andy Younger" <andylyounger at hotmail dot com>
- Date: Wed, 18 Apr 2001 16:35:55 -0000
>
>Your patch isn't ok. I can't apply it since it's malformed.
>Could you please generate a new patch and send it to the list again?
>And please send it only once and not inline _and_ as an attachment.
>
Ok. hopefully right this time, fingers crosse.
Patch created by
diff -up fhandler_dsp.cc.original fhandler_dsp.cc >fhandler_dsp.cc-patch
2>&1
Changelog:
Mon Apr 16 23:20:00 2001 Andy Younger <andylyounger@hotmail.com>
* fhandler_dsp.cc: Improved handling of 8 bit playback modes.
Put in mock support for SNDCTL_DSP_SETFRAGMENT. This permits
Esd & mikmod to compile out of the box.
Cheers,
Andy.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
--- fhandler_dsp.cc.original Wed Apr 18 17:25:48 2001
+++ fhandler_dsp.cc Wed Apr 18 15:24:25 2001
@@ -28,7 +28,7 @@ static void CALLBACK wave_callback(HWAVE
class Audio
{
public:
- enum { MAX_BLOCKS = 8, BLOCK_SIZE = 16384 };
+ enum { MAX_BLOCKS = 12, BLOCK_SIZE = 16384 };
Audio ();
~Audio ();
@@ -40,7 +40,7 @@ public:
bool write (const void *pSampleData, int nBytes);
int blocks ();
void callback_sampledone (void *pData);
-
+ void setformat(int format) { formattype_ = format; }
int numbytesoutput ();
private:
@@ -55,6 +55,7 @@ private:
int bufferIndex_;
CRITICAL_SECTION lock_;
char *freeblocks_[MAX_BLOCKS];
+ int formattype_;
char bigwavebuffer_[MAX_BLOCKS * BLOCK_SIZE];
};
@@ -293,6 +294,17 @@ Audio::flush()
// Send internal buffer out to the soundcard
WAVEHDR *pHeader = ((WAVEHDR *)buffer_) - 1;
pHeader->dwBufferLength = bufferIndex_;
+
+ // Quick bit of sample buffer conversion
+ if (formattype_ == AFMT_S8)
+ {
+ unsigned char *p = ((unsigned char *)buffer_);
+ for (int i = 0; i < bufferIndex_; i++)
+ {
+ p[i] -= 0x7f;
+ }
+ }
+
if (waveOutPrepareHeader(dev_, pHeader, sizeof(WAVEHDR)) == S_OK &&
waveOutWrite(dev_, pHeader, sizeof (WAVEHDR)) == S_OK)
{
@@ -513,10 +525,13 @@ fhandler_dev_dsp::ioctl(unsigned int cmd
int nBits = 0;
if (*intptr == AFMT_S16_LE)
nBits = 16;
+ else if (*intptr == AFMT_U8)
+ nBits = 8;
else if (*intptr == AFMT_S8)
nBits = 8;
if (nBits)
{
+ s_audio.setformat(*intptr);
s_audio.close();
if (s_audio.open(audiofreq_, nBits, audiochannels_) == true)
{
@@ -586,7 +601,14 @@ fhandler_dev_dsp::ioctl(unsigned int cmd
return 1;
} break;
-
+
+ CASE(SNDCTL_DSP_SETFRAGMENT)
+ {
+ // Fake!! esound & mikmod require this on non PowerPC platforms.
+ //
+ return 1;
+ } break;
+
default:
debug_printf("/dev/dsp: ioctl not handled yet! FIXME:\n");
break;