pywin32-checkins Mailing List for Python for Windows Extensions (Page 121)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Mark H. <mha...@us...> - 2004-12-15 01:08:01
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2704/win32comext/shell/src Modified Files: PyIShellFolder.cpp Log Message: Autoduck correction. Index: PyIShellFolder.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellFolder.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyIShellFolder.cpp 6 Oct 2004 05:17:15 -0000 1.9 --- PyIShellFolder.cpp 15 Dec 2004 01:07:51 -0000 1.10 *************** *** 276,280 **** } ! // @pymethod |PyIShellFolder|GetUIObjectOf|Description of GetUIObjectOf. PyObject *PyIShellFolder::GetUIObjectOf(PyObject *self, PyObject *args) { --- 276,280 ---- } ! // @pymethod int, <o PyIUnknown>|PyIShellFolder|GetUIObjectOf|Description of GetUIObjectOf. PyObject *PyIShellFolder::GetUIObjectOf(PyObject *self, PyObject *args) { |
From: Mark H. <mha...@us...> - 2004-12-14 10:19:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26644 Modified Files: univgw_dataconv.cpp Log Message: When univgw can't convert a variant, indicate the VT in the exception. Index: univgw_dataconv.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/univgw_dataconv.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** univgw_dataconv.cpp 8 Nov 2003 00:34:32 -0000 1.6 --- univgw_dataconv.cpp 14 Dec 2004 10:19:35 -0000 1.7 *************** *** 584,588 **** // could try default, but this error indicates we need to // beef up the VARIANT support, rather than default. ! PyErr_SetString(PyExc_TypeError, "The VARIANT type is unknown."); goto Error; } --- 584,589 ---- // could try default, but this error indicates we need to // beef up the VARIANT support, rather than default. ! PyErr_Format(PyExc_TypeError, "The VARIANT type is unknown (0x%x).", ! vtArgType); goto Error; } |
From: Roger U. <ru...@us...> - 2004-12-11 19:50:05
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9976/com/win32com/src/extensions Modified Files: PyIServiceProvider.cpp Log Message: Fix pointer-checking type Index: PyIServiceProvider.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIServiceProvider.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIServiceProvider.cpp 31 Oct 2003 07:20:58 -0000 1.3 --- PyIServiceProvider.cpp 11 Dec 2004 19:49:56 -0000 1.4 *************** *** 39,45 **** IServiceProvider *pMy = GetI(self); ! if (pMy) return NULL; ! IUnknown *pv; PY_INTERFACE_PRECALL; HRESULT hr = pMy->QueryService(clsid, iid, (void **)&pv); --- 39,45 ---- IServiceProvider *pMy = GetI(self); ! if (!pMy) return NULL; ! IUnknown *pv; PY_INTERFACE_PRECALL; HRESULT hr = pMy->QueryService(clsid, iid, (void **)&pv); |
From: Lars I. <lar...@us...> - 2004-12-06 20:09:52
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10590/com/win32comext/directsound/src Modified Files: PyIDirectSound.cpp directsound.cpp Log Message: Documentation improvements - work in progress. Index: PyIDirectSound.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyIDirectSound.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIDirectSound.cpp 30 Nov 2004 21:30:28 -0000 1.1 --- PyIDirectSound.cpp 6 Dec 2004 20:09:41 -0000 1.2 *************** *** 62,66 **** } ! // @pymethod |PyIDirectSound|SetCooperativeLevel|Description of SetCooperativeLevel. PyObject *PyIDirectSound::SetCooperativeLevel(PyObject *self, PyObject *args) { --- 62,66 ---- } ! // @pymethod |PyIDirectSound|SetCooperativeLevel|The IDirectSound::SetCooperativeLevel method sets the cooperative level of the application for this sound device. PyObject *PyIDirectSound::SetCooperativeLevel(PyObject *self, PyObject *args) { *************** *** 108,112 **** } ! // @pymethod |PyIDirectSound|CreateSoundBuffer|Description of CreateSoundBuffer. PyObject *PyIDirectSound::CreateSoundBuffer(PyObject *self, PyObject *args) { --- 108,112 ---- } ! // @pymethod |PyIDirectSound|CreateSoundBuffer|The IDirectSound::CreateSoundBuffer method creates a DirectSoundBuffer object to hold a sequence of audio samples. PyObject *PyIDirectSound::CreateSoundBuffer(PyObject *self, PyObject *args) { *************** *** 152,156 **** } ! // @pymethod |PyIDirectSound|GetCaps|Description of GetCaps. PyObject *PyIDirectSound::GetCaps(PyObject *self, PyObject *args) { --- 152,156 ---- } ! // @pymethod |PyIDirectSound|GetCaps|The GetCaps method retrieves the capabilities of the hardware device that is represented by the DirectSound object. See <l DSCAPS contants>. PyObject *PyIDirectSound::GetCaps(PyObject *self, PyObject *args) { *************** *** 177,181 **** } ! // @pymethod |PyIDirectSound|Compact|Description of Compact. PyObject *PyIDirectSound::Compact(PyObject *self, PyObject *args) { --- 177,181 ---- } ! // @pymethod |PyIDirectSound|Compact|The Compact method moves the unused portions of on-board sound memory, if any, to a contiguous block so that the largest portion of free memory will be available. PyObject *PyIDirectSound::Compact(PyObject *self, PyObject *args) { *************** *** 201,205 **** } ! // @pymethod |PyIDirectSound|GetSpeakerConfig|Description of GetSpeakerConfig. PyObject *PyIDirectSound::GetSpeakerConfig(PyObject *self, PyObject *args) { --- 201,205 ---- } ! // @pymethod |PyIDirectSound|GetSpeakerConfig|The GetSpeakerConfig method retrieves the speaker configuration. PyObject *PyIDirectSound::GetSpeakerConfig(PyObject *self, PyObject *args) { *************** *** 225,229 **** } ! // @pymethod |PyIDirectSound|SetSpeakerConfig|Description of SetSpeakerConfig. PyObject *PyIDirectSound::SetSpeakerConfig(PyObject *self, PyObject *args) { --- 225,229 ---- } ! // @pymethod |PyIDirectSound|SetSpeakerConfig|The SetSpeakerConfig method specifies the speaker configuration of the DirectSound object. PyObject *PyIDirectSound::SetSpeakerConfig(PyObject *self, PyObject *args) { Index: directsound.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/directsound.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** directsound.cpp 2 Dec 2004 09:48:36 -0000 1.3 --- directsound.cpp 6 Dec 2004 20:09:41 -0000 1.4 *************** *** 138,142 **** /* List of module functions */ ! // @module directsound|A module encapsulating the DirectSound interfaces static struct PyMethodDef directsound_methods[]= { --- 138,142 ---- /* List of module functions */ ! /* @module directsound|A module encapsulating the DirectSound interfaces. See <l DirectSound examples> for a quick overview. */ static struct PyMethodDef directsound_methods[]= { *************** *** 188,202 **** PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(g_interfaceSupportData[0])); ! ADD_CONSTANT(DSCAPS_PRIMARYMONO); ADD_CONSTANT(DSCAPS_PRIMARYSTEREO); ADD_CONSTANT(DSCAPS_PRIMARY8BIT); ADD_CONSTANT(DSCAPS_PRIMARY16BIT); ADD_CONSTANT(DSCAPS_CONTINUOUSRATE); ADD_CONSTANT(DSCAPS_EMULDRIVER); ADD_CONSTANT(DSCAPS_CERTIFIED); ADD_CONSTANT(DSCAPS_SECONDARYMONO); ADD_CONSTANT(DSCAPS_SECONDARYSTEREO); ADD_CONSTANT(DSCAPS_SECONDARY8BIT); ! ADD_CONSTANT(DSCAPS_SECONDARY16BIT); ADD_CONSTANT(DSBPLAY_LOOPING); // @const directsound|DSBPLAY_LOOPING|text. ADD_CONSTANT(DSBSTATUS_PLAYING); --- 188,215 ---- PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(g_interfaceSupportData[0])); ! // @topic DSCAPS constants| ! ! // @const directsound|DSCAPS_PRIMARYMONO|The device supports monophonic primary buffers. ! ADD_CONSTANT(DSCAPS_PRIMARYMONO); ! // @const directsound|DSCAPS_PRIMARYSTEREO|The device supports stereo primary buffers. ADD_CONSTANT(DSCAPS_PRIMARYSTEREO); + // @const directsound|DSCAPS_PRIMARY8BIT|The device supports hardware-mixed secondary buffers with 8-bit samples. ADD_CONSTANT(DSCAPS_PRIMARY8BIT); + // @const directsound|DSCAPS_PRIMARY16BIT|The device supports primary sound buffers with 16-bit samples. ADD_CONSTANT(DSCAPS_PRIMARY16BIT); + // @const directsound|DSCAPS_CONTINUOUSRATE|The device supports all sample rates between the dwMinSecondarySampleRate and dwMaxSecondarySampleRate member values. Typically, this means that the actual output rate will be within +/- 10 hertz (Hz) of the requested frequency. ADD_CONSTANT(DSCAPS_CONTINUOUSRATE); + // @const directsound|DSCAPS_EMULDRIVER|The device does not have a DirectSound driver installed, so it is being emulated through the waveform-audio functions. Performance degradation should be expected. ADD_CONSTANT(DSCAPS_EMULDRIVER); + // @const directsound|DSCAPS_CERTIFIED|This driver has been tested and certified by Microsoft. ADD_CONSTANT(DSCAPS_CERTIFIED); + // @const directsound|DSCAPS_SECONDARYMONO|The device supports hardware-mixed monophonic secondary buffers. ADD_CONSTANT(DSCAPS_SECONDARYMONO); + // @const directsound|DSCAPS_SECONDARYSTEREO|The device supports hardware-mixed stereo secondary buffers. ADD_CONSTANT(DSCAPS_SECONDARYSTEREO); + // @const directsound|DSCAPS_SECONDARY8BIT|The device supports hardware-mixed secondary buffers with 8-bit samples. ADD_CONSTANT(DSCAPS_SECONDARY8BIT); ! // @const directsound|DSCAPS_SECONDARY16BIT|The device supports hardware-mixed secondary sound buffers with 16-bit samples. ! ADD_CONSTANT(DSBPLAY_LOOPING); // @const directsound|DSBPLAY_LOOPING|text. ADD_CONSTANT(DSBSTATUS_PLAYING); *************** *** 212,237 **** --- 225,277 ---- ADD_CONSTANT(DS3DMODE_HEADRELATIVE); ADD_CONSTANT(DS3DMODE_DISABLE); + + // @topic DSCAPS constants| + + // @const directsound|DSBCAPS_PRIMARYBUFFER|Indicates that the buffer is a primary sound buffer. If this value is not specified, a secondary sound buffer will be created. ADD_CONSTANT(DSBCAPS_PRIMARYBUFFER); + // @const directsound|DSBCAPS_STATIC|Indicates that the buffer will be used for static sound data. Typically, these buffers are loaded once and played many times. These buffers are candidates for hardware memory. ADD_CONSTANT(DSBCAPS_STATIC); + // @const directsound|DSBCAPS_LOCHARDWARE|The buffer is in hardware memory and uses hardware mixing. ADD_CONSTANT(DSBCAPS_LOCHARDWARE); + // @const directsound|DSBCAPS_LOCSOFTWARE|The buffer is in software memory and uses software mixing. ADD_CONSTANT(DSBCAPS_LOCSOFTWARE); + // @const directsound|DSBCAPS_CTRL3D|The buffer is either a primary buffer or a secondary buffer that uses 3-D control. To create a primary buffer, the dwFlags member of the DSBUFFERDESC structure should include the DSBCAPS_PRIMARYBUFFER flag. ADD_CONSTANT(DSBCAPS_CTRL3D); + // @const directsound|DSBCAPS_CTRLFREQUENCY|The buffer must have frequency control capability. ADD_CONSTANT(DSBCAPS_CTRLFREQUENCY); + // @const directsound|DSBCAPS_CTRLPAN|The buffer must have pan control capability. ADD_CONSTANT(DSBCAPS_CTRLPAN); + // @const directsound|DSBCAPS_CTRLVOLUME|The buffer must have volume control capability. ADD_CONSTANT(DSBCAPS_CTRLVOLUME); + // @const directsound|DSBCAPS_CTRLPOSITIONNOTIFY|The buffer must have control position notify capability. ADD_CONSTANT(DSBCAPS_CTRLPOSITIONNOTIFY); + // @const directsound|DSBCAPS_STICKYFOCUS|Changes the focus behavior of the sound buffer. This flag can be specified in an IDirectSound::CreateSoundBuffer call. With this flag set, an application using DirectSound can continue to play its sticky focus buffers if the user switches to another application not using DirectSound. In this situation, the application's normal buffers are muted, but the sticky focus buffers are still audible. This is useful for nongame applications, such as movie playback (DirectShow), when the user wants to hear the soundtrack while typing in Microsoft Word or Microsoft® Excel, for example. However, if the user switches to another DirectSound application, all sound buffers, both normal and sticky focus, in the previous application are muted. ADD_CONSTANT(DSBCAPS_STICKYFOCUS); + // @const directsound|DSBCAPS_GLOBALFOCUS|The buffer is a global sound buffer. With this flag set, an application using DirectSound can continue to play its buffers if the user switches focus to another application, even if the new application uses DirectSound. The one exception is if you switch focus to a DirectSound application that uses the DSSCL_EXCLUSIVE or DSSCL_WRITEPRIMARY flag for its cooperative level. In this case, the global sounds from other applications will not be audible. ADD_CONSTANT(DSBCAPS_GLOBALFOCUS); + // @const directsound|DSBCAPS_GETCURRENTPOSITION2|Indicates that IDirectSoundBuffer::GetCurrentPosition should use the new behavior of the play cursor. In DirectSound in DirectX 1, the play cursor was significantly ahead of the actual playing sound on emulated sound cards; it was directly behind the write cursor. Now, if the DSBCAPS_GETCURRENTPOSITION2 flag is specified, the application can get a more accurate play position. If this flag is not specified, the old behavior is preserved for compatibility. Note that this flag affects only emulated sound cards; if a DirectSound driver is present, the play cursor is accurate for DirectSound in all versions of DirectX. ADD_CONSTANT(DSBCAPS_GETCURRENTPOSITION2); + // @const directsound|DSBCAPS_MUTE3DATMAXDISTANCE|The sound is reduced to silence at the maximum distance. The buffer will stop playing when the maximum distance is exceeded, so that processor time is not wasted. ADD_CONSTANT(DSBCAPS_MUTE3DATMAXDISTANCE); + ADD_CONSTANT(DSCBCAPS_WAVEMAPPED); + + // @const directsound|DSSPEAKER_HEADPHONE|The speakers are headphones. ADD_CONSTANT(DSSPEAKER_HEADPHONE); + // @const directsound|DSSPEAKER_MONO|The speakers are monaural. ADD_CONSTANT(DSSPEAKER_MONO); + // @const directsound|DSSPEAKER_QUAD|The speakers are quadraphonic. ADD_CONSTANT(DSSPEAKER_QUAD); + // @const directsound|DSSPEAKER_STEREO|The speakers are stereo (default value). ADD_CONSTANT(DSSPEAKER_STEREO); + // @const directsound|DSSPEAKER_SURROUND|The speakers are surround sound. ADD_CONSTANT(DSSPEAKER_SURROUND); + // @const directsound|DSSPEAKER_GEOMETRY_MIN|The speakers are directed over an arc of 5 degrees. ADD_CONSTANT(DSSPEAKER_GEOMETRY_MIN); + // @const directsound|DSSPEAKER_GEOMETRY_NARROW|The speakers are directed over an arc of 10 degrees. ADD_CONSTANT(DSSPEAKER_GEOMETRY_NARROW); + // @const directsound|DSSPEAKER_GEOMETRY_WIDE|The speakers are directed over an arc of 20 degrees. ADD_CONSTANT(DSSPEAKER_GEOMETRY_WIDE); + // @const directsound|DSSPEAKER_GEOMETRY_MAX|The speakers are directed over an arc of 180 degrees. ADD_CONSTANT(DSSPEAKER_GEOMETRY_MAX); // real macros - todo if can be bothered *************** *** 260,261 **** --- 300,357 ---- PyDict_SetItemString(dict, "DSBUFFERDESCType", (PyObject *)&PyDSBUFFERDESCType); } + + /* @topic DirectSound examples| + + @ex Our raison d'etre - playing sounds:| + + WAV_HEADER_SIZE = struct.calcsize('<4sl4s4slhhllhh4sl') + + def wav_header_unpack(data): + '''Unpack a wav header and stuff it into a WAVEFORMATEX structure''' + (riff, riffsize, wave, fmt, fmtsize, format, nchannels, samplespersecond, + datarate, blockalign, bitspersample, data, datalength) \ + = struct.unpack('<4sl4s4slhhllhh4sl', data) + + if riff != 'RIFF' or fmtsize != 16 or fmt != 'fmt ' or data != 'data': + raise ValueError, 'illegal wav header' + + wfx = pywintypes.WAVEFORMATEX() + wfx.wFormatTag = format + wfx.nChannels = nchannels + wfx.nSamplesPerSec = samplespersecond + wfx.nAvgBytesPerSec = datarate + wfx.nBlockAlign = blockalign + wfx.wBitsPerSample = bitspersample + + return wfx, datalength + + # Play a wav file and wait until it's finished + + fname=os.path.join(os.path.dirname(__file__), "01-Intro.wav") + f = open(fname, 'rb') + + # Read and unpack the wav header + hdr = f.read(WAV_HEADER_SIZE) + wfx, size = wav_header_unpack(hdr) + + d = ds.DirectSoundCreate(None, None) + d.SetCooperativeLevel(None, ds.DSSCL_PRIORITY) + + sdesc = ds.DSBUFFERDESC() + sdesc.dwFlags = ds.DSBCAPS_STICKYFOCUS | ds.DSBCAPS_CTRLPOSITIONNOTIFY + sdesc.dwBufferBytes = size + sdesc.lpwfxFormat = wfx + + buffer = d.CreateSoundBuffer(sdesc, None) + + event = win32event.CreateEvent(None, 0, 0, None) + notify = buffer.QueryInterface(ds.IID_IDirectSoundNotify) + + notify.SetNotificationPositions((ds.DSBPN_OFFSETSTOP, event)) + + buffer.Update(0, f.read(size)) + + buffer.Play(0) + + win32event.WaitForSingleObject(event, -1) + */ |
From: Lars I. <lar...@us...> - 2004-12-06 20:08:13
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10187 Modified Files: ds_test.py Log Message: Removed primary buffer from testPlay() - was not necessary. Index: ds_test.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/test/ds_test.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ds_test.py 2 Dec 2004 09:52:52 -0000 1.2 --- ds_test.py 6 Dec 2004 20:08:00 -0000 1.3 *************** *** 191,215 **** sdesc = ds.DSBUFFERDESC() - sdesc.dwFlags = ds.DSBCAPS_PRIMARYBUFFER - sdesc.dwBufferBytes = 0 - sdesc.lpwfxFormat = None - - # create primary buffer - primary = d.CreateSoundBuffer(sdesc, None) - sdesc.dwFlags = ds.DSBCAPS_STICKYFOCUS | ds.DSBCAPS_CTRLPOSITIONNOTIFY sdesc.dwBufferBytes = size sdesc.lpwfxFormat = wfx ! secondary = d.CreateSoundBuffer(sdesc, None) event = win32event.CreateEvent(None, 0, 0, None) ! notify = secondary.QueryInterface(ds.IID_IDirectSoundNotify) notify.SetNotificationPositions((ds.DSBPN_OFFSETSTOP, event)) ! secondary.Update(0, f.read(size)) ! secondary.Play(0) win32event.WaitForSingleObject(event, -1) --- 191,208 ---- sdesc = ds.DSBUFFERDESC() sdesc.dwFlags = ds.DSBCAPS_STICKYFOCUS | ds.DSBCAPS_CTRLPOSITIONNOTIFY sdesc.dwBufferBytes = size sdesc.lpwfxFormat = wfx ! buffer = d.CreateSoundBuffer(sdesc, None) event = win32event.CreateEvent(None, 0, 0, None) ! notify = buffer.QueryInterface(ds.IID_IDirectSoundNotify) notify.SetNotificationPositions((ds.DSBPN_OFFSETSTOP, event)) ! buffer.Update(0, f.read(size)) ! buffer.Play(0) win32event.WaitForSingleObject(event, -1) |
From: Mark H. <mha...@us...> - 2004-12-06 00:28:46
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21555 Modified Files: win32con.py Log Message: New VK_, REG_, WS_EX_, ULW_ and LWA_ constants. Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32con.py 22 Sep 2004 09:11:10 -0000 1.7 --- win32con.py 6 Dec 2004 00:28:30 -0000 1.8 *************** *** 1066,1069 **** --- 1066,1083 ---- VK_PA1 = 253 VK_OEM_CLEAR = 254 + # multi-media related "keys" + MOUSEEVENTF_XDOWN = 0x0080 + MOUSEEVENTF_XUP = 0x0100 + MOUSEEVENTF_WHEEL = 0x0800 + VK_XBUTTON1 = 0x05 + VK_XBUTTON2 = 0x06 + VK_VOLUME_MUTE = 0xAD + VK_VOLUME_DOWN = 0xAE + VK_VOLUME_UP = 0xAF + VK_MEDIA_NEXT_TRACK = 0xB0 + VK_MEDIA_PREV_TRACK = 0xB1 + VK_MEDIA_PLAY_PAUSE = 0xB3 + VK_BROWSER_BACK = 0xA6 + VK_BROWSER_FORWARD = 0xA7 WH_MIN = (-1) WH_MSGFILTER = (-1) *************** *** 1548,1551 **** --- 1562,1571 ---- WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE) WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST) + WS_EX_LAYERED = 0x00080000 + WS_EX_NOINHERITLAYOUT = 0x00100000 + WS_EX_LAYOUTRTL = 0x00400000 + WS_EX_COMPOSITED = 0x02000000 + WS_EX_NOACTIVATE = 0x08000000 + CS_VREDRAW = 1 CS_HREDRAW = 2 *************** *** 2285,2288 **** --- 2305,2312 ---- REG_RESOURCE_LIST = ( 8 ) # Resource list in the resource map REG_FULL_RESOURCE_DESCRIPTOR =( 9 ) # Resource list in the hardware description + REG_RESOURCE_REQUIREMENTS_LIST = ( 10 ) + REG_QWORD = ( 11 ) # 64-bit number + REG_QWORD_LITTLE_ENDIAN = ( 11 ) # 64-bit number (same as REG_QWORD) + # Generated by h2py from \msvc20\include\winnt.h *************** *** 4519,4520 **** --- 4543,4551 ---- ComputerNamePhysicalDnsDomain = 6 ComputerNamePhysicalDnsFullyQualified = 7 + + LWA_COLORKEY = 0x00000001 + LWA_ALPHA = 0x00000002 + ULW_COLORKEY = 0x00000001 + ULW_ALPHA = 0x00000002 + ULW_OPAQUE = 0x00000004 + |
From: Mark H. <mha...@us...> - 2004-12-02 09:53:01
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv382 Modified Files: ds_test.py Log Message: Remove hard-coded directory Index: ds_test.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/test/ds_test.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ds_test.py 30 Nov 2004 21:30:28 -0000 1.1 --- ds_test.py 2 Dec 2004 09:52:52 -0000 1.2 *************** *** 2,8 **** import struct import sys import pywintypes import win32event - # sys.path = ['.'] + sys.path import win32com.directsound.directsound as ds # next two lines are for for debugging: --- 2,8 ---- import struct import sys + import os import pywintypes import win32event import win32com.directsound.directsound as ds # next two lines are for for debugging: *************** *** 182,187 **** def testPlay(self): '''Play a file''' ! ! f = open('d:/temp/01-Intro.wav', 'rb') hdr = f.read(WAV_HEADER_SIZE) wfx, size = wav_header_unpack(hdr) --- 182,187 ---- def testPlay(self): '''Play a file''' ! fname=os.path.join(os.path.dirname(__file__), "01-Intro.wav") ! f = open(fname, 'rb') hdr = f.read(WAV_HEADER_SIZE) wfx, size = wav_header_unpack(hdr) |
From: Mark H. <mha...@us...> - 2004-12-02 09:48:46
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31926/src Modified Files: PyIDirectSoundBuffer.cpp directsound.cpp Log Message: Remove compiler warning and remove constants that don't appear in vc7 Index: PyIDirectSoundBuffer.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyIDirectSoundBuffer.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIDirectSoundBuffer.cpp 1 Dec 2004 23:13:57 -0000 1.3 --- PyIDirectSoundBuffer.cpp 2 Dec 2004 09:48:36 -0000 1.4 *************** *** 363,367 **** // Raise error if assumption isn't met ! if (dwAudioBytes1 + dwAudioBytes2 != PyString_Size(obData)) { PY_INTERFACE_PRECALL; --- 363,367 ---- // Raise error if assumption isn't met ! if (dwAudioBytes1 + dwAudioBytes2 != (DWORD)PyString_Size(obData)) { PY_INTERFACE_PRECALL; Index: directsound.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/directsound.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** directsound.cpp 1 Dec 2004 23:13:57 -0000 1.2 --- directsound.cpp 2 Dec 2004 09:48:36 -0000 1.3 *************** *** 221,226 **** ADD_CONSTANT(DSBCAPS_CTRLVOLUME); ADD_CONSTANT(DSBCAPS_CTRLPOSITIONNOTIFY); - ADD_CONSTANT(DSBCAPS_CTRLDEFAULT); - ADD_CONSTANT(DSBCAPS_CTRLALL); ADD_CONSTANT(DSBCAPS_STICKYFOCUS); ADD_CONSTANT(DSBCAPS_GLOBALFOCUS); --- 221,224 ---- |
From: Lars I. <lar...@us...> - 2004-12-01 23:14:22
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29038/win32/src Modified Files: PyWAVEFORMATEX.cpp Log Message: Minor documentation improvements. Index: PyWAVEFORMATEX.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWAVEFORMATEX.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyWAVEFORMATEX.cpp 30 Nov 2004 21:30:29 -0000 1.1 --- PyWAVEFORMATEX.cpp 1 Dec 2004 23:13:57 -0000 1.2 *************** *** 90,94 **** {"wFormatTag", T_SHORT, OFF(m_wfx.wFormatTag), 0, "Format as an integer. WAVE_FORMAT_PCM (1) is very common."}, // @prop integer|wFormatTag|Waveform-audio format type. pywintypes only defines WAVE_FORMAT_PCM as a constant. Other values must be looked up in the mmsystem.h header file. {"nChannels", T_SHORT, OFF(m_wfx.nChannels), 0, "Number of channels" }, // @prop integer|nChannels|Number of channels. 1 for Mono, 2 for Stereo, anything, but never 5.1. ! {"nSamplesPerSec", T_INT, OFF(m_wfx.nSamplesPerSec), 0, "Sample rate in seconds" }, // @prop integer|Sample rate, in samples per second (hertz), that each channel should be played or recorded. If wFormatTag is WAVE_FORMAT_PCM, then common values for nSamplesPerSec are 8000, 11025, 22050, and 44100 Hz {"nAvgBytesPerSec", T_INT, OFF(m_wfx.nAvgBytesPerSec), 0, "Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign." }, // @prop integer|nAvgBytesPerSec|Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign. {"nBlockAlign", T_SHORT, OFF(m_wfx.nBlockAlign), 0, "Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, nBlockAlign should be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte)."}, // @prop integer|nBlockAlign|Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, nBlockAlign should be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte). For non-PCM formats, this member must be computed according to the manufacturers specification of the format tag. --- 90,94 ---- {"wFormatTag", T_SHORT, OFF(m_wfx.wFormatTag), 0, "Format as an integer. WAVE_FORMAT_PCM (1) is very common."}, // @prop integer|wFormatTag|Waveform-audio format type. pywintypes only defines WAVE_FORMAT_PCM as a constant. Other values must be looked up in the mmsystem.h header file. {"nChannels", T_SHORT, OFF(m_wfx.nChannels), 0, "Number of channels" }, // @prop integer|nChannels|Number of channels. 1 for Mono, 2 for Stereo, anything, but never 5.1. ! {"nSamplesPerSec", T_INT, OFF(m_wfx.nSamplesPerSec), 0, "Sample rate in seconds" }, // @prop integer|nSamplesPerSec|Sample rate, in samples per second (hertz), that each channel should be played or recorded. If wFormatTag is WAVE_FORMAT_PCM, then common values for nSamplesPerSec are 8000, 11025, 22050, and 44100 Hz {"nAvgBytesPerSec", T_INT, OFF(m_wfx.nAvgBytesPerSec), 0, "Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign." }, // @prop integer|nAvgBytesPerSec|Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign. {"nBlockAlign", T_SHORT, OFF(m_wfx.nBlockAlign), 0, "Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, nBlockAlign should be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte)."}, // @prop integer|nBlockAlign|Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, nBlockAlign should be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte). For non-PCM formats, this member must be computed according to the manufacturers specification of the format tag. |
From: Lars I. <lar...@us...> - 2004-12-01 23:14:21
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29038/com/win32comext/directsound/src Modified Files: PyDSCAPS.cpp PyIDirectSoundBuffer.cpp directsound.cpp Log Message: Minor documentation improvements. Index: PyDSCAPS.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyDSCAPS.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDSCAPS.cpp 30 Nov 2004 21:30:28 -0000 1.1 --- PyDSCAPS.cpp 1 Dec 2004 23:13:57 -0000 1.2 *************** *** 130,134 **** {"dwPlayCpuOverheadSwBuffers", T_INT, OFF(m_caps.dwPlayCpuOverheadSwBuffers), 0, "Description of the processing overhead, as a percentage of the central processing unit, needed to mix software buffers (those located in main system memory). This varies according to the bus type, the processor type, and the clock speed. The unlock transfer rate for software buffers is 0 because the data need not be transferred anywhere. Similarly, the play processing overhead for hardware buffers is 0 because the mixing is done by the sound device."}, // @prop integer|dwPlayCpuOverheadSwBuffers|Description of the processing overhead, as a percentage of the central processing unit, needed to mix software buffers (those located in main system memory). This varies according to the bus type, the processor type, and the clock speed. The unlock transfer rate for software buffers is 0 because the data need not be transferred anywhere. Similarly, the play processing overhead for hardware buffers is 0 because the mixing is done by the sound device. ! {NULL} /* Sentinel */ }; --- 130,134 ---- {"dwPlayCpuOverheadSwBuffers", T_INT, OFF(m_caps.dwPlayCpuOverheadSwBuffers), 0, "Description of the processing overhead, as a percentage of the central processing unit, needed to mix software buffers (those located in main system memory). This varies according to the bus type, the processor type, and the clock speed. The unlock transfer rate for software buffers is 0 because the data need not be transferred anywhere. Similarly, the play processing overhead for hardware buffers is 0 because the mixing is done by the sound device."}, // @prop integer|dwPlayCpuOverheadSwBuffers|Description of the processing overhead, as a percentage of the central processing unit, needed to mix software buffers (those located in main system memory). This varies according to the bus type, the processor type, and the clock speed. The unlock transfer rate for software buffers is 0 because the data need not be transferred anywhere. Similarly, the play processing overhead for hardware buffers is 0 because the mixing is done by the sound device. ! {NULL} }; Index: PyIDirectSoundBuffer.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyIDirectSoundBuffer.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyIDirectSoundBuffer.cpp 30 Nov 2004 21:47:02 -0000 1.2 --- PyIDirectSoundBuffer.cpp 1 Dec 2004 23:13:57 -0000 1.3 *************** *** 45,50 **** // This is a workaround for a reference counting bug in IDirectSound: ! // If IDirectSound->Release() is called before IDirectSoundBuffer->Release() ! // or IDirectSoundNotify->->Release(), we will get an Access Violation // We work around this by manipulating the reference count on the Python objects --- 45,50 ---- // This is a workaround for a reference counting bug in IDirectSound: ! // If IDirectSound::Release() is called before IDirectSoundBuffer::Release() ! // or IDirectSoundNotify::Release(), we will get an Access Violation // We work around this by manipulating the reference count on the Python objects Index: directsound.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/directsound.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** directsound.cpp 30 Nov 2004 21:30:28 -0000 1.1 --- directsound.cpp 1 Dec 2004 23:13:57 -0000 1.2 *************** *** 32,37 **** if (!PyArg_ParseTuple(args, "|OO:DirectSoundCreate", ! &obGUID, // @pyparm <o PyIID>||guid|The identifier of the interface describing the type of interface pointer to return ! &obUnk)) // @pyparm <o PyIUknown>|unk||The IUnknown for COM aggregation. { return NULL; --- 32,37 ---- if (!PyArg_ParseTuple(args, "|OO:DirectSoundCreate", ! &obGUID, // @pyparm <o PyIID>|guid|None|Address of the GUID that identifies the sound device. The value of this parameter must be one of the GUIDs returned by DirectSoundEnumerate, or None for the default device. ! &obUnk)) // @pyparm <o PyIUknown>|unk|None|The IUnknown for COM aggregation. { return NULL; *************** *** 105,109 **** } ! // @pymethod <o list|directsound|DirectSoundEnumerate|Enumerates DirectSound drivers installed in the system. static PyObject *directsound_DirectSoundEnumerate(PyObject *, PyObject *args) { --- 105,109 ---- } ! // @pymethod <o list>|directsound|DirectSoundEnumerate|Enumerates DirectSound drivers installed in the system. static PyObject *directsound_DirectSoundEnumerate(PyObject *, PyObject *args) { *************** *** 138,147 **** /* List of module functions */ ! // @module directsound|A module, encapsulating the DirectSound interfaces static struct PyMethodDef directsound_methods[]= { { "DirectSoundCreate", directsound_DirectSoundCreate, 1 }, // @pymeth DirectSoundCreate|Creates and initializes a new object that supports the IDirectSound interface. { "DirectSoundEnumerate", directsound_DirectSoundEnumerate, 1 }, // @pymeth DirectSoundEnumerate|The DirectSoundEnumerate function enumerates the DirectSound drivers installed in the system. ! // { "DirectSoundCaptureCreate", directsound_DirectSoundCaptureCreate, 1}, // @pymeth DirectSoundCaptureCreate|The DirectSoundCaptureCreate function creates and initializes an object that supports the IDirectSoundCapture interface // { "DirectSoundCaptureEnumerate", directsound_DirectSoundCaptureEnumerate, 1}, // @pymeth DirectSoundCaptureEnumerate|The DirectSoundCaptureEnumerate function enumerates the DirectSoundCapture objects installed in the system. {"DSCAPS", PyWinMethod_NewDSCAPS, 1 }, // @pymeth DSCAPS|Creates a new <o PyDSCAPS> object. --- 138,148 ---- /* List of module functions */ ! // @module directsound|A module encapsulating the DirectSound interfaces static struct PyMethodDef directsound_methods[]= { { "DirectSoundCreate", directsound_DirectSoundCreate, 1 }, // @pymeth DirectSoundCreate|Creates and initializes a new object that supports the IDirectSound interface. { "DirectSoundEnumerate", directsound_DirectSoundEnumerate, 1 }, // @pymeth DirectSoundEnumerate|The DirectSoundEnumerate function enumerates the DirectSound drivers installed in the system. ! ! // { "DirectSoundCaptureCreate", directsound_DirectSoundCaptureCreate, 1}, // @pymeth DirectSoundCaptureCreate|The DirectSoundCaptureCreate function creates and initializes an object that supports the IDirectSoundCapture interface. // { "DirectSoundCaptureEnumerate", directsound_DirectSoundCaptureEnumerate, 1}, // @pymeth DirectSoundCaptureEnumerate|The DirectSoundCaptureEnumerate function enumerates the DirectSoundCapture objects installed in the system. {"DSCAPS", PyWinMethod_NewDSCAPS, 1 }, // @pymeth DSCAPS|Creates a new <o PyDSCAPS> object. |
From: Lars I. <lar...@us...> - 2004-12-01 23:13:28
|
Update of /cvsroot/pywin32/pywin32/AutoDuck In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28827/AutoDuck Modified Files: pywin32.mak Log Message: Added help generation for DirectSound. Index: pywin32.mak =================================================================== RCS file: /cvsroot/pywin32/pywin32/AutoDuck/pywin32.mak,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pywin32.mak 8 Nov 2004 02:59:06 -0000 1.9 --- pywin32.mak 1 Dec 2004 23:13:01 -0000 1.10 *************** *** 56,59 **** --- 56,60 ---- $(WIN32COMEXT_DIR)\internet\src\*.cpp \ $(WIN32COMEXT_DIR)\taskscheduler\src\*.cpp \ + $(WIN32COMEXT_DIR)\directsound\src\*.cpp \ $(WIN32COM_DIR)\src\include\*.h \ $(MAPI_DIR)\src\*.cpp \ |
From: Mark H. <mha...@us...> - 2004-12-01 00:07:13
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11682 Modified Files: win32gui.i Log Message: Add BeginPaint, EndPaint and CreateIconIndirect Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** win32gui.i 9 Oct 2004 00:36:57 -0000 1.52 --- win32gui.i 1 Dec 2004 00:07:03 -0000 1.53 *************** *** 303,306 **** --- 303,319 ---- } + %typemap(python,in) ICONINFO *INPUT { + ICONINFO s; + if (PyTuple_Check($source)) { + if (PyArg_ParseTuple($source, "lllll", &s.fIcon, &s.xHotspot, &s.yHotspot, + &s.hbmMask, &s.hbmColor) == 0) { + return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); + } + $target = &s; + } else { + return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); + } + } + %typemap(python,argout) ICONINFO *OUTPUT { PyObject *o; *************** *** 343,346 **** --- 356,417 ---- } + %typemap(python,argout) PAINTSTRUCT *OUTPUT { + PyObject *o; + o = Py_BuildValue("(ll(iiii)lls#)", + $source->hdc, + $source->fErase, + $source->rcPaint.left, $source->rcPaint.top, $source->rcPaint.right, $source->rcPaint.bottom, + $source->fRestore, + $source->fIncUpdate, + (char *)$source->rgbReserved, + sizeof($source->rgbReserved)); + if (!$target) { + $target = o; + } else if ($target == Py_None) { + Py_DECREF(Py_None); + $target = o; + } else { + if (!PyList_Check($target)) { + PyObject *o2 = $target; + $target = PyList_New(0); + PyList_Append($target,o2); + Py_XDECREF(o2); + } + PyList_Append($target,o); + Py_XDECREF(o); + } + } + + %typemap(python,ignore) PAINTSTRUCT *OUTPUT(PAINTSTRUCT temp) + { + $target = &temp; + } + + %typemap(python,in) PAINTSTRUCT *INPUT { + PAINTSTRUCT r; + char *szReserved; + int lenReserved; + if (PyTuple_Check($source)) { + if (!PyArg_ParseTuple($source, + "ll(iiii)lls#", + &r.hdc, + &r.fErase, + &r.rcPaint.left, &r.rcPaint.top, &r.rcPaint.right, &r.rcPaint.bottom, + &r.fRestore, + &r.fIncUpdate, + &szReserved, + &lenReserved)) { + return NULL; + } + if (lenReserved != sizeof(r.rgbReserved)) + return PyErr_Format(PyExc_ValueError, "%s: last element must be string of %d bytes", + "$name", sizeof(r.rgbReserved)); + memcpy(&r.rgbReserved, szReserved, sizeof(r.rgbReserved)); + $target = &r; + } else { + return PyErr_Format(PyExc_TypeError, "%s: a PAINTSTRUCT must be a tuple", "$name"); + } + } + %typemap(python,except) LRESULT { Py_BEGIN_ALLOW_THREADS *************** *** 1829,1832 **** --- 1900,1905 ---- ); + // @pyswig int|CreateIconIndirect|Creates an icon or cursor from an ICONINFO structure. + HICON CreateIconIndirect(ICONINFO *INPUT); // @pyswig HANDLE|LoadImage|Loads a bitmap, cursor or icon *************** *** 2703,2710 **** int FrameRect(HDC hDC, RECT *INPUT, HBRUSH hbr); int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase); ! /* ! HDC BeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint); ! BOOLAPI EndPaint(HWND hWnd, PAINTSTRUCT *lpPaint); ! */ // @pyswig int|CreateWindowEx|Creates a new window with Extended Style. --- 2776,2787 ---- int FrameRect(HDC hDC, RECT *INPUT, HBRUSH hbr); int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase); ! ! // @pyswig hdc, paintstruct|BeginPaint| ! HDC BeginPaint(HWND hwnd, PAINTSTRUCT *OUTPUT); ! ! // @pyswig |EndPaint| ! // @pyparm int|hwnd|| ! // @pyparm paintstruct|ps||As returned from <om win32gui.BeginPaint> ! BOOLAPI EndPaint(HWND hWnd, PAINTSTRUCT *INPUT); // @pyswig int|CreateWindowEx|Creates a new window with Extended Style. |
From: Lars I. <lar...@us...> - 2004-11-30 21:47:56
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12333 Modified Files: PyIDirectSoundNotify.cpp Log Message: Fixed typo. Index: PyIDirectSoundNotify.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyIDirectSoundNotify.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIDirectSoundNotify.cpp 30 Nov 2004 21:30:28 -0000 1.1 --- PyIDirectSoundNotify.cpp 30 Nov 2004 21:47:47 -0000 1.2 *************** *** 22,26 **** SafeRelease(this); ! // This may trigger IDirectSOund::Release if (m_DS) Py_DECREF(m_DS); --- 22,26 ---- SafeRelease(this); ! // This may trigger IDirectSound::Release if (m_DS) Py_DECREF(m_DS); |
From: Lars I. <lar...@us...> - 2004-11-30 21:47:19
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12056 Modified Files: PyIDirectSoundBuffer.cpp Log Message: Make sure IDirectSound::Release() is called after IDirectSoundBuffer::Release(). Index: PyIDirectSoundBuffer.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyIDirectSoundBuffer.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIDirectSoundBuffer.cpp 30 Nov 2004 21:30:28 -0000 1.1 --- PyIDirectSoundBuffer.cpp 30 Nov 2004 21:47:02 -0000 1.2 *************** *** 19,22 **** --- 19,27 ---- PyIDirectSoundBuffer::~PyIDirectSoundBuffer() { + // Release should be called before IDirectSound::Release, which may be + // triggered below + SafeRelease(this); + + // This may trigger IDirectSound::Release if (m_DS) Py_DECREF(m_DS); |
From: Lars I. <lar...@us...> - 2004-11-30 21:34:49
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9011/com/win32comext/directsound Added Files: __init__.py Log Message: Part of the directsound extensions. --- NEW FILE: __init__.py --- # See if we have a special directory for the binaries (for developers) import win32com win32com.__PackageSupportBuildPath__(__path__) |
From: Lars I. <lar...@us...> - 2004-11-30 21:30:43
|
Update of /cvsroot/pywin32/pywin32/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6405/win32 Modified Files: PyWinTypes.dsp Log Message: Added (some) DirectSound support. The bulk is in com/win32comext/directsound, including a test directory with a sample soundfile and a unittest-based test script. Supported are: - IDirectSound - IDirectSoundBuffer - IDirectSoundNotify. Also added support for: - WAVEFORMATEX (in PyWinTypes) - DSBUFFERDESC - DSBCAPS - DSCAPS - various constants used in these structures Missing is: - IDirectSoundCapture - complete documentation Index: PyWinTypes.dsp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/PyWinTypes.dsp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PyWinTypes.dsp 7 Sep 2004 09:43:46 -0000 1.16 --- PyWinTypes.dsp 30 Nov 2004 21:30:28 -0000 1.17 *************** *** 156,159 **** --- 156,163 ---- # Begin Source File + SOURCE=.\src\PySoundObjects.h + # End Source File + # Begin Source File + SOURCE=.\src\PyTime.cpp # End Source File *************** *** 164,167 **** --- 168,175 ---- # Begin Source File + SOURCE=.\src\PyWAVEFORMATEX.cpp + # End Source File + # Begin Source File + SOURCE=.\src\PyWinObjects.h # End Source File |
From: Lars I. <lar...@us...> - 2004-11-30 21:30:40
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6405/win32/src Modified Files: PyWinTypes.h PyWinTypesmodule.cpp Added Files: PySoundObjects.h PyWAVEFORMATEX.cpp Log Message: Added (some) DirectSound support. The bulk is in com/win32comext/directsound, including a test directory with a sample soundfile and a unittest-based test script. Supported are: - IDirectSound - IDirectSoundBuffer - IDirectSoundNotify. Also added support for: - WAVEFORMATEX (in PyWinTypes) - DSBUFFERDESC - DSBCAPS - DSCAPS - various constants used in these structures Missing is: - IDirectSoundCapture - complete documentation --- NEW FILE: PySoundObjects.h --- #ifndef __PYSOUNDOBJECTS_H__ #define __PYSOUNDOBJECTS_H__ #include <windows.h> #include <dsound.h> class PYWINTYPES_EXPORT PyWAVEFORMATEX : public PyObject { public: PyWAVEFORMATEX(void); PyWAVEFORMATEX(const WAVEFORMATEX &); ~PyWAVEFORMATEX(); /* Python support */ static void deallocFunc(PyObject *ob); #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER WAVEFORMATEX m_wfx; }; #endif Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PyWinTypesmodule.cpp 7 Sep 2004 04:27:04 -0000 1.17 --- PyWinTypesmodule.cpp 30 Nov 2004 21:30:29 -0000 1.18 *************** *** 452,455 **** --- 452,456 ---- {"_GetLockStats", _GetLockStats, 1}, #endif /* TRACE_THREADSTATE */ + {"WAVEFORMATEX", PyWinMethod_NewWAVEFORMATEX, 1 }, // @pymeth WAVEFORMATEX|Creates a new <o PyWAVEFORMATEX> object. {NULL, NULL} }; *************** *** 497,500 **** --- 498,515 ---- } + static int AddConstant(PyObject *dict, const char *key, long value) + { + PyObject *oval = PyInt_FromLong(value); + if (!oval) + { + return 1; + } + int rc = PyDict_SetItemString(dict, (char*)key, oval); + Py_DECREF(oval); + return rc; + } + + #define ADD_CONSTANT(tok) AddConstant(dict, #tok, tok) + extern "C" __declspec(dllexport) void initpywintypes(void) *************** *** 520,523 **** --- 535,539 ---- PyDict_SetItemString(dict, "TRUE", Py_True); PyDict_SetItemString(dict, "FALSE", Py_False); + ADD_CONSTANT(WAVE_FORMAT_PCM); // Add a few types. *************** *** 537,541 **** PyDict_SetItemString(dict, "OVERLAPPEDType", (PyObject *)&PyHANDLEType); PyDict_SetItemString(dict, "DEVMODEType", (PyObject *)&PyDEVMODEType); ! } --- 553,557 ---- PyDict_SetItemString(dict, "OVERLAPPEDType", (PyObject *)&PyHANDLEType); PyDict_SetItemString(dict, "DEVMODEType", (PyObject *)&PyDEVMODEType); ! PyDict_SetItemString(dict, "WAVEFORMATEXType", (PyObject *)&PyWAVEFORMATEXType); } Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PyWinTypes.h 7 Sep 2004 10:04:35 -0000 1.24 --- PyWinTypes.h 30 Nov 2004 21:30:29 -0000 1.25 *************** *** 14,17 **** --- 14,21 ---- #include "Python.h" #include "windows.h" + + // Lars: for WAVEFORMATEX + #include "mmsystem.h" + // Do we want to use the builtin Unicode object? // If defined, we use the standard builtin type. *************** *** 312,315 **** --- 316,330 ---- /* + ** WAVEFORMATEX support + */ + + PYWINTYPES_EXPORT PyObject *PyWinMethod_NewWAVEFORMATEX(PyObject *self, PyObject *args); + PYWINTYPES_EXPORT PyObject *PyWinObject_FromWAVEFROMATEX(const WAVEFORMATEX &wfx); + PYWINTYPES_EXPORT BOOL PyWinObject_AsWAVEFORMATEX(PyObject *ob, WAVEFORMATEX **ppWAVEFORMATEX, BOOL bNoneOK = TRUE); + extern PYWINTYPES_EXPORT PyTypeObject PyWAVEFORMATEXType; + #define PyWAVEFORMATEX_Check(ob) ((ob)->ob_type == &PyWAVEFORMATEXType) + + + /* ** SECURITY_DESCRIPTOR support */ --- NEW FILE: PyWAVEFORMATEX.cpp --- // // @doc #include "Python.h" #include "PyWinTypes.h" #include "PyWinObjects.h" #include "PySoundObjects.h" #include "structmember.h" // @pymethod <o PyWAVEFORMATEX>|pywintypes|WAVEFORMATEX|Creates a new WAVEFORMATEX object PyObject *PyWinMethod_NewWAVEFORMATEX(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":WAVEFORMATEX")) return NULL; return new PyWAVEFORMATEX(); } PyObject *PyWinObject_FromWAVEFORMATEX(const WAVEFORMATEX &wfx) { return new PyWAVEFORMATEX(wfx); } BOOL PyWinObject_AsWAVEFORMATEX(PyObject *ob, WAVEFORMATEX **ppWAVEFORMATEX, BOOL bNoneOK /*= TRUE*/) { if (bNoneOK && ob==Py_None) { *ppWAVEFORMATEX = NULL; } else if (!PyWAVEFORMATEX_Check(ob)) { PyErr_SetString(PyExc_TypeError, "The object is not a PyWAVEFORMATEX object"); return FALSE; } else { PyWAVEFORMATEX *pywfx= (PyWAVEFORMATEX *)ob; *ppWAVEFORMATEX = &pywfx->m_wfx; } return TRUE; } // @object PyWAVEFORMATEX|A Python object, representing a WAVEFORMATEX structure static struct PyMethodDef PyWAVEFORMATEX_methods[] = { {NULL} }; PYWINTYPES_EXPORT PyTypeObject PyWAVEFORMATEXType = { PyObject_HEAD_INIT(&PyType_Type) 0, "PyWAVEFORMATEX", sizeof(PyWAVEFORMATEX), 0, PyWAVEFORMATEX::deallocFunc, 0, // tp_print; 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number 0, // tp_as_sequence 0, // tp_as_mapping 0, 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, PyObject_GenericSetAttr, 0, // tp_as_buffer; Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags; 0, // tp_doc; /* Documentation string */ 0, // traverseproc tp_traverse; 0, // tp_clear; 0, // tp_richcompare; 0, // tp_weaklistoffset; 0, // tp_iter 0, // iternextfunc tp_iternext 0, // methods PyWAVEFORMATEX::members, 0, // tp_getset; 0, // tp_base; 0, // tp_dict; 0, // tp_descr_get; 0, // tp_descr_set; 0, // tp_dictoffset; 0, // tp_init; 0, // tp_alloc; 0 // newfunc tp_new; }; #define OFF(e) offsetof(PyWAVEFORMATEX, e) /*static*/ struct PyMemberDef PyWAVEFORMATEX::members[] = { {"wFormatTag", T_SHORT, OFF(m_wfx.wFormatTag), 0, "Format as an integer. WAVE_FORMAT_PCM (1) is very common."}, // @prop integer|wFormatTag|Waveform-audio format type. pywintypes only defines WAVE_FORMAT_PCM as a constant. Other values must be looked up in the mmsystem.h header file. {"nChannels", T_SHORT, OFF(m_wfx.nChannels), 0, "Number of channels" }, // @prop integer|nChannels|Number of channels. 1 for Mono, 2 for Stereo, anything, but never 5.1. {"nSamplesPerSec", T_INT, OFF(m_wfx.nSamplesPerSec), 0, "Sample rate in seconds" }, // @prop integer|Sample rate, in samples per second (hertz), that each channel should be played or recorded. If wFormatTag is WAVE_FORMAT_PCM, then common values for nSamplesPerSec are 8000, 11025, 22050, and 44100 Hz {"nAvgBytesPerSec", T_INT, OFF(m_wfx.nAvgBytesPerSec), 0, "Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign." }, // @prop integer|nAvgBytesPerSec|Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign. {"nBlockAlign", T_SHORT, OFF(m_wfx.nBlockAlign), 0, "Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, nBlockAlign should be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte)."}, // @prop integer|nBlockAlign|Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, nBlockAlign should be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte). For non-PCM formats, this member must be computed according to the manufacturers specification of the format tag. {"wBitsPerSample", T_SHORT, OFF(m_wfx.wBitsPerSample), 0, "Bits per sample for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, then wBitsPerSample should be equal to 8 or 16."}, // @prop integer|wBitsPerSample|Bits per sample for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, then wBitsPerSample should be equal to 8 or 16. {NULL} /* Sentinel */ }; PyWAVEFORMATEX::PyWAVEFORMATEX(void) { ob_type = &PyWAVEFORMATEXType; _Py_NewReference(this); memset(&m_wfx, 0, sizeof(m_wfx)); } PyWAVEFORMATEX::PyWAVEFORMATEX(const WAVEFORMATEX &wfx) { ob_type = &PyWAVEFORMATEXType; _Py_NewReference(this); m_wfx = wfx; m_wfx.cbSize = 0; } PyWAVEFORMATEX::~PyWAVEFORMATEX() { } /*static*/ void PyWAVEFORMATEX::deallocFunc(PyObject *ob) { delete (PyWAVEFORMATEX *)ob; } |
From: Lars I. <lar...@us...> - 2004-11-30 21:30:38
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6405 Modified Files: Python and Extensions.dsw setup.py Log Message: Added (some) DirectSound support. The bulk is in com/win32comext/directsound, including a test directory with a sample soundfile and a unittest-based test script. Supported are: - IDirectSound - IDirectSoundBuffer - IDirectSoundNotify. Also added support for: - WAVEFORMATEX (in PyWinTypes) - DSBUFFERDESC - DSBCAPS - DSCAPS - various constants used in these structures Missing is: - IDirectSoundCapture - complete documentation Index: Python and Extensions.dsw =================================================================== RCS file: /cvsroot/pywin32/pywin32/Python and Extensions.dsw,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Python and Extensions.dsw 22 Jun 2004 00:55:40 -0000 1.18 --- Python and Extensions.dsw 30 Nov 2004 21:30:27 -0000 1.19 *************** *** 322,325 **** --- 322,340 ---- ############################################################################### + Project: "directsound"=.\com\directsound.dsp - Package Owner=<4> + + Package=<5> + {{{ + }}} + + Package=<4> + {{{ + Begin Project Dependency + Project_Dep_Name win32com + End Project Dependency + }}} + + ############################################################################### + Project: "exchange"=.\com\exchange.dsp - Package Owner=<4> Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** setup.py 8 Nov 2004 02:57:36 -0000 1.3 --- setup.py 30 Nov 2004 21:30:27 -0000 1.4 *************** *** 919,922 **** --- 919,924 ---- WinExt_win32com('taskscheduler', libraries='mstask'), WinExt_win32com('ifilter', libraries='ntquery'), + WinExt_win32com('directsound', pch_header='directsound_pch.h', + libraries='user32 dsound dxguid'), ] *************** *** 1077,1080 **** --- 1079,1083 ---- 'win32comext.axcontrol', 'win32comext.taskscheduler', + 'win32comext.directsound', 'pythonwin.pywin', |
From: Lars I. <lar...@us...> - 2004-11-30 21:30:38
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6405/com/win32comext/directsound/test Added Files: 01-Intro.wav ds_test.py Log Message: Added (some) DirectSound support. The bulk is in com/win32comext/directsound, including a test directory with a sample soundfile and a unittest-based test script. Supported are: - IDirectSound - IDirectSoundBuffer - IDirectSoundNotify. Also added support for: - WAVEFORMATEX (in PyWinTypes) - DSBUFFERDESC - DSBCAPS - DSCAPS - various constants used in these structures Missing is: - IDirectSoundCapture - complete documentation --- NEW FILE: ds_test.py --- import unittest import struct import sys import pywintypes import win32event # sys.path = ['.'] + sys.path import win32com.directsound.directsound as ds # next two lines are for for debugging: # import win32com # import directsound as ds WAV_FORMAT_PCM = 1 WAV_HEADER_SIZE = struct.calcsize('<4sl4s4slhhllhh4sl') def wav_header_unpack(data): (riff, riffsize, wave, fmt, fmtsize, format, nchannels, samplespersecond, datarate, blockalign, bitspersample, data, datalength) \ = struct.unpack('<4sl4s4slhhllhh4sl', data) if riff != 'RIFF' or fmtsize != 16 or fmt != 'fmt ' or data != 'data': raise ValueError, 'illegal wav header' wfx = pywintypes.WAVEFORMATEX() wfx.wFormatTag = format wfx.nChannels = nchannels wfx.nSamplesPerSec = samplespersecond wfx.nAvgBytesPerSec = datarate wfx.nBlockAlign = blockalign wfx.wBitsPerSample = bitspersample return wfx, datalength class WAVEFORMATTest(unittest.TestCase): def test_1_Type(self): 'WAVEFORMATEX type' w = pywintypes.WAVEFORMATEX() self.failUnless(type(w) == pywintypes.WAVEFORMATEXType) def test_2_Attr(self): 'WAVEFORMATEX attribute access' # A wav header for a soundfile from a CD should look like this... w = pywintypes.WAVEFORMATEX() w.wFormatTag = pywintypes.WAVE_FORMAT_PCM w.nChannels = 2 w.nSamplesPerSec = 44100 w.nAvgBytesPerSec = 176400 w.nBlockAlign = 4 w.wBitsPerSample = 16 self.failUnless(w.wFormatTag == 1) self.failUnless(w.nChannels == 2) self.failUnless(w.nSamplesPerSec == 44100) self.failUnless(w.nAvgBytesPerSec == 176400) self.failUnless(w.nBlockAlign == 4) self.failUnless(w.wBitsPerSample == 16) class DSCAPSTest(unittest.TestCase): def test_1_Type(self): 'DSCAPS type' c = ds.DSCAPS() self.failUnless(type(c) == ds.DSCAPSType) def test_2_Attr(self): 'DSCAPS attribute access' c = ds.DSCAPS() c.dwFlags = 1 c.dwMinSecondarySampleRate = 2 c.dwMaxSecondarySampleRate = 3 c.dwPrimaryBuffers = 4 c.dwMaxHwMixingAllBuffers = 5 c.dwMaxHwMixingStaticBuffers = 6 c.dwMaxHwMixingStreamingBuffers = 7 c.dwFreeHwMixingAllBuffers = 8 c.dwFreeHwMixingStaticBuffers = 9 c.dwFreeHwMixingStreamingBuffers = 10 c.dwMaxHw3DAllBuffers = 11 c.dwMaxHw3DStaticBuffers = 12 c.dwMaxHw3DStreamingBuffers = 13 c.dwFreeHw3DAllBuffers = 14 c.dwFreeHw3DStaticBuffers = 15 c.dwFreeHw3DStreamingBuffers = 16 c.dwTotalHwMemBytes = 17 c.dwFreeHwMemBytes = 18 c.dwMaxContigFreeHwMemBytes = 19 c.dwUnlockTransferRateHwBuffers = 20 c.dwPlayCpuOverheadSwBuffers = 21 self.failUnless(c.dwFlags == 1) self.failUnless(c.dwMinSecondarySampleRate == 2) self.failUnless(c.dwMaxSecondarySampleRate == 3) self.failUnless(c.dwPrimaryBuffers == 4) self.failUnless(c.dwMaxHwMixingAllBuffers == 5) self.failUnless(c.dwMaxHwMixingStaticBuffers == 6) self.failUnless(c.dwMaxHwMixingStreamingBuffers == 7) self.failUnless(c.dwFreeHwMixingAllBuffers == 8) self.failUnless(c.dwFreeHwMixingStaticBuffers == 9) self.failUnless(c.dwFreeHwMixingStreamingBuffers == 10) self.failUnless(c.dwMaxHw3DAllBuffers == 11) self.failUnless(c.dwMaxHw3DStaticBuffers == 12) self.failUnless(c.dwMaxHw3DStreamingBuffers == 13) self.failUnless(c.dwFreeHw3DAllBuffers == 14) self.failUnless(c.dwFreeHw3DStaticBuffers == 15) self.failUnless(c.dwFreeHw3DStreamingBuffers == 16) self.failUnless(c.dwTotalHwMemBytes == 17) self.failUnless(c.dwFreeHwMemBytes == 18) self.failUnless(c.dwMaxContigFreeHwMemBytes == 19) self.failUnless(c.dwUnlockTransferRateHwBuffers == 20) self.failUnless(c.dwPlayCpuOverheadSwBuffers == 21) class DSBCAPSTest(unittest.TestCase): def test_1_Type(self): 'DSBCAPS type' c = ds.DSBCAPS() self.failUnless(type(c) == ds.DSBCAPSType) def test_2_Attr(self): 'DSBCAPS attribute access' c = ds.DSBCAPS() c.dwFlags = 1 c.dwBufferBytes = 2 c.dwUnlockTransferRate = 3 c.dwPlayCpuOverhead = 4 self.failUnless(c.dwFlags == 1) self.failUnless(c.dwBufferBytes == 2) self.failUnless(c.dwUnlockTransferRate == 3) self.failUnless(c.dwPlayCpuOverhead == 4) class DSBUFFERDESCTest(unittest.TestCase): def test_1_Type(self): 'DSBUFFERDESC type' c = ds.DSBUFFERDESC() self.failUnless(type(c) == ds.DSBUFFERDESCType) def test_2_Attr(self): 'DSBUFFERDESC attribute access' c = ds.DSBUFFERDESC() c.dwFlags = 1 c.dwBufferBytes = 2 c.lpwfxFormat = pywintypes.WAVEFORMATEX() c.lpwfxFormat.wFormatTag = pywintypes.WAVE_FORMAT_PCM c.lpwfxFormat.nChannels = 2 c.lpwfxFormat.nSamplesPerSec = 44100 c.lpwfxFormat.nAvgBytesPerSec = 176400 c.lpwfxFormat.nBlockAlign = 4 c.lpwfxFormat.wBitsPerSample = 16 self.failUnless(c.dwFlags == 1) self.failUnless(c.dwBufferBytes == 2) self.failUnless(c.lpwfxFormat.wFormatTag == 1) self.failUnless(c.lpwfxFormat.nChannels == 2) self.failUnless(c.lpwfxFormat.nSamplesPerSec == 44100) self.failUnless(c.lpwfxFormat.nAvgBytesPerSec == 176400) self.failUnless(c.lpwfxFormat.nBlockAlign == 4) self.failUnless(c.lpwfxFormat.wBitsPerSample == 16) def invalid_format(self, c): c.lpwfxFormat = 17 def test_3_invalid_format(self): 'DSBUFFERDESC invalid lpwfxFormat assignment' c = ds.DSBUFFERDESC() self.failUnlessRaises(ValueError, self.invalid_format, c) class DirectSoundTest(unittest.TestCase): # basic tests - mostly just exercise the functions def testEnumerate(self): '''DirectSoundEnumerate() sanity tests''' devices = ds.DirectSoundEnumerate() # this might fail on machines without a sound card self.failUnless(len(devices)) # if we have an entry, it must be a tuple of size 3 self.failUnless(len(devices[0]) == 3) def testCreate(self): '''DirectSoundCreate()''' d = ds.DirectSoundCreate(None, None) def testPlay(self): '''Play a file''' f = open('d:/temp/01-Intro.wav', 'rb') hdr = f.read(WAV_HEADER_SIZE) wfx, size = wav_header_unpack(hdr) d = ds.DirectSoundCreate(None, None) d.SetCooperativeLevel(None, ds.DSSCL_PRIORITY) sdesc = ds.DSBUFFERDESC() sdesc.dwFlags = ds.DSBCAPS_PRIMARYBUFFER sdesc.dwBufferBytes = 0 sdesc.lpwfxFormat = None # create primary buffer primary = d.CreateSoundBuffer(sdesc, None) sdesc.dwFlags = ds.DSBCAPS_STICKYFOCUS | ds.DSBCAPS_CTRLPOSITIONNOTIFY sdesc.dwBufferBytes = size sdesc.lpwfxFormat = wfx secondary = d.CreateSoundBuffer(sdesc, None) event = win32event.CreateEvent(None, 0, 0, None) notify = secondary.QueryInterface(ds.IID_IDirectSoundNotify) notify.SetNotificationPositions((ds.DSBPN_OFFSETSTOP, event)) secondary.Update(0, f.read(size)) secondary.Play(0) win32event.WaitForSingleObject(event, -1) if __name__ == '__main__': unittest.main() --- NEW FILE: 01-Intro.wav --- (This appears to be a binary file; contents omitted.) |
From: Lars I. <lar...@us...> - 2004-11-30 21:30:37
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6405/com/win32com/src Modified Files: PythonCOM.cpp Log Message: Added (some) DirectSound support. The bulk is in com/win32comext/directsound, including a test directory with a sample soundfile and a unittest-based test script. Supported are: - IDirectSound - IDirectSoundBuffer - IDirectSoundNotify. Also added support for: - WAVEFORMATEX (in PyWinTypes) - DSBUFFERDESC - DSBCAPS - DSCAPS - various constants used in these structures Missing is: - IDirectSoundCapture - complete documentation Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** PythonCOM.cpp 28 Aug 2004 22:07:22 -0000 1.32 --- PythonCOM.cpp 30 Nov 2004 21:30:27 -0000 1.33 *************** *** 499,506 **** IDispatch *disp = NULL; SCODE sc; ! Py_BEGIN_ALLOW_THREADS; // Cant use the INTERFACE macros twice :-( ! sc = unk->QueryInterface(IID_IDispatch, (void**)&disp); ! unk->Release(); ! Py_END_ALLOW_THREADS; if (FAILED(sc) || disp == NULL) return PyCom_BuildPyException(sc); --- 499,509 ---- IDispatch *disp = NULL; SCODE sc; ! // local scope for macro PY_INTERFACE_PRECALL local variables ! { ! PY_INTERFACE_PRECALL; ! sc = unk->QueryInterface(IID_IDispatch, (void**)&disp); ! unk->Release(); ! PY_INTERFACE_POSTCALL; ! } if (FAILED(sc) || disp == NULL) return PyCom_BuildPyException(sc); |
From: Lars I. <lar...@us...> - 2004-11-30 21:30:37
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6405/com/win32comext/directsound/src Added Files: PyDSBCAPS.cpp PyDSBUFFERDESC.cpp PyDSCAPS.cpp PyIDirectSound.cpp PyIDirectSound.h PyIDirectSoundBuffer.cpp PyIDirectSoundBuffer.h PyIDirectSoundNotify.cpp PyIDirectSoundNotify.h directsound.cpp directsound_pch.h Log Message: Added (some) DirectSound support. The bulk is in com/win32comext/directsound, including a test directory with a sample soundfile and a unittest-based test script. Supported are: - IDirectSound - IDirectSoundBuffer - IDirectSoundNotify. Also added support for: - WAVEFORMATEX (in PyWinTypes) - DSBUFFERDESC - DSBCAPS - DSCAPS - various constants used in these structures Missing is: - IDirectSoundCapture - complete documentation --- NEW FILE: PyIDirectSound.h --- // This file declares the IDirectSound Interface for Python. // --------------------------------------------------- // // Interface Declaration class PyIDirectSound : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIDirectSound); static IDirectSound *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *Initialize(PyObject *self, PyObject *args); static PyObject *SetCooperativeLevel(PyObject *self, PyObject *args); static PyObject *CreateSoundBuffer(PyObject *self, PyObject *args); static PyObject *Compact(PyObject *self, PyObject *args); static PyObject *GetCaps(PyObject *self, PyObject *args); static PyObject *GetSpeakerConfig(PyObject *self, PyObject *args); static PyObject *SetSpeakerConfig(PyObject *self, PyObject *args); PyIDirectSound(IUnknown *pdisp); ~PyIDirectSound(); }; --- NEW FILE: PyIDirectSound.cpp --- // This file implements the IDirectSound Interface for Python. #include "directsound_pch.h" #include "PySoundObjects.h" #include "PyIDirectSound.h" #include "PyIDirectSoundBuffer.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIDirectSound::PyIDirectSound(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIDirectSound::~PyIDirectSound() { } /* static */ IDirectSound *PyIDirectSound::GetI(PyObject *self) { return (IDirectSound *)PyIUnknown::GetI(self); } // @pymethod |PyIDirectSound|Initialize|Description of Initialize. PyObject *PyIDirectSound::Initialize(PyObject *self, PyObject *args) { PyObject *obGUID; IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "|O:Initialize", &obGUID) ) return NULL; GUID guid; LPGUID pguid = NULL; if (!obGUID && obGUID != Py_None) { if (!PyWinObject_AsIID(obGUID, &guid)) return NULL; pguid = &guid; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDS->Initialize(pguid); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("Initialize", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSound|SetCooperativeLevel|Description of SetCooperativeLevel. PyObject *PyIDirectSound::SetCooperativeLevel(PyObject *self, PyObject *args) { int level; PyObject *obHWND = NULL; HWND hwnd; IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "Oi:SetCooperativeLevel", &obHWND, &level) ) return NULL; if (obHWND == Py_None) { hwnd = GetForegroundWindow(); if (hwnd == NULL) { hwnd = GetDesktopWindow(); } } else if (PyInt_Check(obHWND)) { hwnd = (HWND)PyInt_AS_LONG(obHWND); } else { PyErr_SetString(PyExc_TypeError, "argument 1 must be a window handle or None"); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDS->SetCooperativeLevel(hwnd, level); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetCooperativeLevel", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSound|CreateSoundBuffer|Description of CreateSoundBuffer. PyObject *PyIDirectSound::CreateSoundBuffer(PyObject *self, PyObject *args) { PyObject *obDSBD = NULL; PyObject *obUnk = NULL; IUnknown *pUnkIn = NULL; IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "O|O:CreateSoundBuffer", &obDSBD, &obUnk) ) return NULL; if (!PyDSBUFFERDESC_Check(obDSBD)) { PyErr_SetString(PyExc_TypeError, "Argument 1 must be of type PyDSBUFFERDESC"); return NULL; } if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&pUnkIn, TRUE)) { return NULL; } DSBUFFERDESC *pdsbd = &((PyDSBUFFERDESC*)obDSBD)->m_dsbd; HRESULT hr; IDirectSoundBuffer *buffer; PY_INTERFACE_PRECALL; hr = pIDS->CreateSoundBuffer(pdsbd, &buffer, pUnkIn); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("CreateSoundBuffer", hr); return NULL; } PyIDirectSoundBuffer *rc = new PyIDirectSoundBuffer(buffer); Py_INCREF(self); rc->m_DS = self; return rc; } // @pymethod |PyIDirectSound|GetCaps|Description of GetCaps. PyObject *PyIDirectSound::GetCaps(PyObject *self, PyObject *args) { IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetCaps") ) return NULL; HRESULT hr; PyDSCAPS *caps = new PyDSCAPS(); PY_INTERFACE_PRECALL; hr = pIDS->GetCaps(caps->GetCAPS()); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetCaps", hr); return NULL; } Py_INCREF(caps); return caps; } // @pymethod |PyIDirectSound|Compact|Description of Compact. PyObject *PyIDirectSound::Compact(PyObject *self, PyObject *args) { IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Compact") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDS->Compact(); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetCaps", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSound|GetSpeakerConfig|Description of GetSpeakerConfig. PyObject *PyIDirectSound::GetSpeakerConfig(PyObject *self, PyObject *args) { IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetSpeakerConfig") ) return NULL; HRESULT hr; DWORD config; PY_INTERFACE_PRECALL; hr = pIDS->GetSpeakerConfig(&config); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetSpeakerConfig", hr); return NULL; } return PyInt_FromLong(config); } // @pymethod |PyIDirectSound|SetSpeakerConfig|Description of SetSpeakerConfig. PyObject *PyIDirectSound::SetSpeakerConfig(PyObject *self, PyObject *args) { DWORD config; IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "i:SetSpeakerConfig", &config) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDS->SetSpeakerConfig(config); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetSpeakerConfig", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @object PyIDirectSound|Description of the interface static struct PyMethodDef PyIDirectSound_methods[] = { { "Initialize", PyIDirectSound::Initialize, 1 }, // @pymeth Initialize|Description of Initialize. { "SetCooperativeLevel", PyIDirectSound::SetCooperativeLevel, 1 }, // @pymeth SetCooperativeLevel|Description of SetCooperativeLevel. { "CreateSoundBuffer", PyIDirectSound::CreateSoundBuffer, 1 }, // @pymeth CreateSoundBuffer|Description of CreateSoundBuffer. { "GetCaps", PyIDirectSound::GetCaps, 1 }, // @pymeth GetCaps|Description of GetCaps. { "Compact", PyIDirectSound::Compact, 1 }, // @pymeth Compact|Description of Compact. { NULL } }; PyComTypeObject PyIDirectSound::type("PyIDirectSound", &PyIUnknown::type, sizeof(PyIDirectSound), PyIDirectSound_methods, GET_PYCOM_CTOR(PyIDirectSound)); --- NEW FILE: PyIDirectSoundBuffer.cpp --- // This file implements the IDirectSound Interface for Python. #include "directsound_pch.h" #include "PySoundObjects.h" #include "PyIDirectSoundBuffer.h" #include "PyIDirectSoundNotify.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIDirectSoundBuffer::PyIDirectSoundBuffer(IUnknown *pdisp): PyIUnknown(pdisp), m_DS(NULL) { ob_type = &type; } PyIDirectSoundBuffer::~PyIDirectSoundBuffer() { if (m_DS) Py_DECREF(m_DS); } /* static */ IDirectSoundBuffer *PyIDirectSoundBuffer::GetI(PyObject *self) { return (IDirectSoundBuffer*)PyIUnknown::GetI(self); } /* static */ PyObject *PyIDirectSoundBuffer::QueryInterface(PyObject *self, PyObject *args) { PyObject *obiid; PyObject *obUseIID = NULL; if (!PyArg_ParseTuple(args, "O|O:QueryInterface", &obiid, &obUseIID )) return NULL; PyObject *rc = PyIUnknown::QueryInterface(self, args); // Special treatment for PyIDirectSoundNotify // This is a workaround for a reference counting bug in IDirectSound: // If IDirectSound->Release() is called before IDirectSoundBuffer->Release() // or IDirectSoundNotify->->Release(), we will get an Access Violation // We work around this by manipulating the reference count on the Python objects // that encapsulate them if (PyIBase::is_object(rc, &PyIDirectSoundNotify::type)) { PyIDirectSoundNotify *notify = (PyIDirectSoundNotify*)rc; PyIDirectSoundBuffer *me = (PyIDirectSoundBuffer*)self; Py_INCREF(me->m_DS); notify->m_DS = me->m_DS; } return rc; } // @pymethod |PyIDirectSoundBuffer|GetCaps|Description of GetCaps. PyObject *PyIDirectSoundBuffer::GetCaps(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetCaps") ) return NULL; HRESULT hr; PyDSBCAPS *caps = new PyDSBCAPS(); PY_INTERFACE_PRECALL; hr = pIDSB->GetCaps(caps->GetCAPS()); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetCaps", hr); return NULL; } Py_INCREF(caps); return caps; } // @pymethod |PyIDirectSoundBuffer|GetFormat|Description of GetFormat. PyObject *PyIDirectSoundBuffer::GetFormat(PyObject *self, PyObject *args) { int level; HWND hwnd; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetFormat", &hwnd, &level) ) return NULL; HRESULT hr; PyWAVEFORMATEX *wfx = new PyWAVEFORMATEX(); PY_INTERFACE_PRECALL; // We don't support getting more than standard wave headers hr = pIDSB->GetFormat(&wfx->m_wfx, sizeof(WAVEFORMATEX), NULL); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetFormat", hr); return NULL; } Py_INCREF(wfx); return wfx; } // @pymethod |PyIDirectSoundBuffer|GetStatus|Description of GetStatus. PyObject *PyIDirectSoundBuffer::GetStatus(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetStatus") ) return NULL; HRESULT hr; DWORD dwStatus; PY_INTERFACE_PRECALL; hr = pIDSB->GetStatus(&dwStatus); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetStatus", hr); return NULL; } return PyInt_FromLong(dwStatus); } // @pymethod |PyIDirectSoundBuffer|SetFormat|Description of SetFormat. PyObject *PyIDirectSoundBuffer::SetFormat(PyObject *self, PyObject *args) { PyObject *obWfx; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "O:SetFormat", &obWfx) ) return NULL; if (!PyWAVEFORMATEX_Check(obWfx)) { PyErr_SetString(PyExc_TypeError, "Argument 1 must be of type PyWAVEFORMATEX"); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->SetFormat(&((PyWAVEFORMATEX*)obWfx)->m_wfx); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetFormat", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|Initialize|Description of Initialize. PyObject *PyIDirectSoundBuffer::Initialize(PyObject *self, PyObject *args) { PyObject *obDSBD = NULL; PyObject *obDS = NULL; IDirectSound *pIDS = NULL; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "OO:Initialize", &obDS, &obDSBD) ) return NULL; // Todo - check and initialize pIDS if (!PyDSBUFFERDESC_Check(obDSBD)) { PyErr_SetString(PyExc_TypeError, "Argument 2 must be of type PyDSBUFFERDESC"); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->Initialize(pIDS, &((PyDSBUFFERDESC*)obDSBD)->m_dsbd); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("Initialize", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|Restore|Description of Initialize. PyObject *PyIDirectSoundBuffer::Restore(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Restore") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->Restore(); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("Restore", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|GetCurrentPosition|Description of GetCurrentPosition. PyObject *PyIDirectSoundBuffer::GetCurrentPosition(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetCurrentPosition") ) return NULL; HRESULT hr; DWORD dwPlay = 0, dwWrite = 0; PY_INTERFACE_PRECALL; hr = pIDSB->GetCurrentPosition(&dwPlay, &dwWrite); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetCurrentPosition", hr); return NULL; } PyObject *result = PyTuple_New(2); if (!result) return NULL; PyTuple_SetItem(result, 0, PyInt_FromLong(dwPlay)); PyTuple_SetItem(result, 1, PyInt_FromLong(dwWrite)); return result; } // @pymethod |PyIDirectSoundBuffer|Play|Description of Play. PyObject *PyIDirectSoundBuffer::Play(PyObject *self, PyObject *args) { DWORD dwFlags; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "i:Play", &dwFlags) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->Play(0, 0, dwFlags); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("Play", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|SetCurrentPosition|Description of SetCurrentPosition. PyObject *PyIDirectSoundBuffer::SetCurrentPosition(PyObject *self, PyObject *args) { DWORD dwNewPosition; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "i:SetCurrentPosition", &dwNewPosition) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->SetCurrentPosition(dwNewPosition); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetCurrentPosition", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|Stop|Description of Stop. PyObject *PyIDirectSoundBuffer::Stop(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Stop") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->Stop(); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("Stop", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|Update|Description of Update. PyObject *PyIDirectSoundBuffer::Update(PyObject *self, PyObject *args) { DWORD dwWriteCursor = 0; DWORD dwFlags = 0; PyObject *obData = NULL; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "iS|i:Update", &dwWriteCursor, &obData, &dwFlags) ) return NULL; HRESULT hr; LPVOID lpAudioPtr1 = NULL; DWORD dwAudioBytes1 = 0; LPVOID lpAudioPtr2 = NULL; DWORD dwAudioBytes2 = 0; PY_INTERFACE_PRECALL; hr = pIDSB->Lock(dwWriteCursor, PyString_Size(obData), &lpAudioPtr1, &dwAudioBytes1, &lpAudioPtr2, &dwAudioBytes2, dwFlags); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("Update(Lock)", hr); return NULL; } // The play buffer is circular, so we may get two pointers and have to // do the wrap-around ourselves. // Raise error if assumption isn't met if (dwAudioBytes1 + dwAudioBytes2 != PyString_Size(obData)) { PY_INTERFACE_PRECALL; hr = pIDSB->Unlock(lpAudioPtr1, dwAudioBytes1, lpAudioPtr2, dwAudioBytes2); PY_INTERFACE_POSTCALL; PyErr_SetString(PyExc_RuntimeError, "Size mismatch from Unlock"); return NULL; } memcpy(lpAudioPtr1, PyString_AsString(obData), dwAudioBytes1); if (dwAudioBytes2) { memcpy(lpAudioPtr2, PyString_AsString(obData) + dwAudioBytes1, dwAudioBytes2); } { // need extra block for local variables from PY_INTERFACE_UPCALL macro PY_INTERFACE_PRECALL; hr = pIDSB->Unlock(lpAudioPtr1, dwAudioBytes1, lpAudioPtr2, dwAudioBytes2); PY_INTERFACE_POSTCALL; } if (FAILED(hr)) { PyWin_SetAPIError("Update(Unlock)", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|GetFrequency|Description of GetFrequency. PyObject *PyIDirectSoundBuffer::GetFrequency(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetFrequency") ) return NULL; HRESULT hr; DWORD dwFrequency; PY_INTERFACE_PRECALL; hr = pIDSB->GetFrequency(&dwFrequency); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetFrequency", hr); return NULL; } return PyInt_FromLong(dwFrequency); } // @pymethod |PyIDirectSoundBuffer|GetPan|Description of GetPan. PyObject *PyIDirectSoundBuffer::GetPan(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetPan") ) return NULL; HRESULT hr; LONG pan; PY_INTERFACE_PRECALL; hr = pIDSB->GetPan(&pan); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetPan", hr); return NULL; } return PyInt_FromLong(pan); } // @pymethod |PyIDirectSoundBuffer|GetVolume|Description of GetVolume. PyObject *PyIDirectSoundBuffer::GetVolume(PyObject *self, PyObject *args) { IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetVolume") ) return NULL; HRESULT hr; LONG pan; PY_INTERFACE_PRECALL; hr = pIDSB->GetVolume(&pan); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetVolume", hr); return NULL; } return PyInt_FromLong(pan); } // @pymethod |PyIDirectSoundBuffer|SetFrequency|Description of SetFrequency. PyObject *PyIDirectSoundBuffer::SetFrequency(PyObject *self, PyObject *args) { DWORD dwNewFrequency; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "i:SetFrequency", &dwNewFrequency) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->SetFrequency(dwNewFrequency); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetFrequency", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|SetPan|Description of SetPan. PyObject *PyIDirectSoundBuffer::SetPan(PyObject *self, PyObject *args) { LONG dwNewPan; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "i:SetPan", &dwNewPan) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->SetPan(dwNewPan); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetPan", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDirectSoundBuffer|SetVolume|Description of SetVolume. PyObject *PyIDirectSoundBuffer::SetVolume(PyObject *self, PyObject *args) { LONG dwNewVolume; IDirectSoundBuffer *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "i:SetVolume", &dwNewVolume) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDSB->SetVolume(dwNewVolume); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetVolume", hr); return NULL; } Py_INCREF(Py_None); return Py_None; } // @object PyIDirectSoundBuffer|Description of the interface static struct PyMethodDef PyIDirectSoundBuffer_methods[] = { { "QueryInterface", PyIDirectSoundBuffer::QueryInterface, 1 }, { "GetCaps", PyIDirectSoundBuffer::GetCaps, 1 }, // @pymeth Initialize|Description of Initialize. { "GetFormat", PyIDirectSoundBuffer::GetFormat, 1 }, // @pymeth SetCooperativeLevel|Description of SetCooperativeLevel. { "GetStatus", PyIDirectSoundBuffer::GetStatus, 1 }, // @pymeth GetStatus|Description of GetStatus. { "SetFormat", PyIDirectSoundBuffer::SetFormat, 1 }, // @pymeth GetCaps|Description of GetCaps. { "Initialize", PyIDirectSoundBuffer::Initialize, 1 }, // @pymeth Initialize|Description of GetCaps. { "Restore", PyIDirectSoundBuffer::Restore, 1 }, // @pymeth Restore|Description of Restore. { "GetCurrentPosition", PyIDirectSoundBuffer::GetCurrentPosition, 1 }, // @pymeth GetCurrentPosition|Description of GetCaps. { "Play", PyIDirectSoundBuffer::Play, 1 }, // @pymeth Play|Description of GetCaps. { "SetCurrentPosition", PyIDirectSoundBuffer::SetCurrentPosition, 1 }, // @pymeth SetCurrentPosition|Description of GetCaps. { "Stop", PyIDirectSoundBuffer::Stop, 1 }, // @pymeth Stop|Description of GetCaps. { "Update", PyIDirectSoundBuffer::Update, 1 }, // @pymeth Unlock|Description of Unlock. { "GetFrequency", PyIDirectSoundBuffer::GetFrequency, 1 }, // @pymeth GetFrequency|Description of GetCaps. { "GetPan", PyIDirectSoundBuffer::GetPan, 1 }, // @pymeth GetPan|Description of GetCaps. { "GetVolume", PyIDirectSoundBuffer::GetVolume, 1 }, // @pymeth GetVolume|Description of GetCaps. { "SetFrequency", PyIDirectSoundBuffer::SetFrequency, 1 }, // @pymeth SetFrequency|Description of GetCaps. { "SetPan", PyIDirectSoundBuffer::SetPan, 1 }, // @pymeth SetPan|Description of GetCaps. { "SetVolume", PyIDirectSoundBuffer::SetVolume, 1 }, // @pymeth SetVolume|Description of GetCaps. { NULL } }; PyComTypeObject PyIDirectSoundBuffer::type("PyIDirectSoundBuffer", &PyIUnknown::type, sizeof(PyIDirectSoundBuffer), PyIDirectSoundBuffer_methods, GET_PYCOM_CTOR(PyIDirectSoundBuffer)); --- NEW FILE: PyDSCAPS.cpp --- // // @doc #include "PyWinTypes.h" #include "PyWinObjects.h" #include "PySoundObjects.h" #include "structmember.h" #include "directsound_pch.h" // @pymethod <o PyDSCAPS>|pywintypes|DSCAPS|Creates a new DSCAPS object PyObject *PyWinMethod_NewDSCAPS(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":DSCAPS")) return NULL; return new PyDSCAPS(); } PyObject *PyWinObject_FromDSCAPS(const DSCAPS &caps) { return new PyDSCAPS(caps); } BOOL PyWinObject_AsDSCAPS(PyObject *ob, DSCAPS **ppDSCAPS, BOOL bNoneOK /*= TRUE*/) { if (bNoneOK && ob==Py_None) { *ppDSCAPS = NULL; } else if (!PyDSCAPS_Check(ob)) { PyErr_SetString(PyExc_TypeError, "The object is not a PyDSCAPS object"); return FALSE; } else { PyDSCAPS *pycaps= (PyDSCAPS *)ob; *ppDSCAPS = pycaps->GetCAPS(); } return TRUE; } // @object PyDSCAPS|A Python object, representing a DSCAPS structure static struct PyMethodDef PyDSCAPS_methods[] = { {NULL} }; PyTypeObject PyDSCAPSType = { PyObject_HEAD_INIT(&PyType_Type) 0, "PyDSCAPSType", sizeof(PyDSCAPSType), 0, PyDSCAPS::deallocFunc, 0, // tp_print; 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number 0, // tp_as_sequence 0, // tp_as_mapping 0, 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, PyObject_GenericSetAttr, 0, // tp_as_buffer; Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags; 0, // tp_doc; /* Documentation string */ 0, // traverseproc tp_traverse; 0, // tp_clear; 0, // tp_richcompare; 0, // tp_weaklistoffset; 0, // tp_iter 0, // iternextfunc tp_iternext 0, // methods PyDSCAPS::members, 0, // tp_getset; 0, // tp_base; 0, // tp_dict; 0, // tp_descr_get; 0, // tp_descr_set; 0, // tp_dictoffset; 0, // tp_init; 0, // tp_alloc; 0 // newfunc tp_new; }; #define OFF(e) offsetof(PyDSCAPS, e) /*static*/ struct PyMemberDef PyDSCAPS::members[] = { {"dwFlags", T_INT, OFF(m_caps.dwFlags), 0, "Specifies device capabilities."}, // @prop integer|dwFlags|Specifies device capabilities. {"dwMinSecondarySampleRate", T_INT, OFF(m_caps.dwMinSecondarySampleRate), 0, "Minimum sample rate supported by this device's hardware secondary sound buffers."}, // @prop integer|dwMinSecondarySampleRate|Minimum sample rate supported by this device's hardware secondary sound buffers. {"dwMaxSecondarySampleRate", T_INT, OFF(m_caps.dwMaxSecondarySampleRate), 0, "Maximum sample rate supported by this device's hardware secondary sound buffers."}, // @prop integer|dwMaxSecondarySampleRate|Maximum sample rate supported by this device's hardware secondary sound buffers. {"dwPrimaryBuffers", T_INT, OFF(m_caps.dwPrimaryBuffers), 0, "Number of primary buffers supported. This value will always be 1."}, // @prop integer|dwPrimaryBuffers|Number of primary buffers supported. This value will always be 1. {"dwMaxHwMixingAllBuffers", T_INT, OFF(m_caps.dwMaxHwMixingAllBuffers), 0, "Specifies the total number of buffers that can be mixed in hardware. This member can be less than the sum of dwMaxHwMixingStaticBuffers and dwMaxHwMixingStreamingBuffers. Resource tradeoffs frequently occur."}, // @prop integer|dwMaxHwMixingAllBuffers|Specifies the total number of buffers that can be mixed in hardware. This member can be less than the sum of dwMaxHwMixingStaticBuffers and dwMaxHwMixingStreamingBuffers. Resource tradeoffs frequently occur. {"dwMaxHwMixingStaticBuffers", T_INT, OFF(m_caps.dwMaxHwMixingStaticBuffers), 0, "Specifies the maximum number of static sound buffers."}, // @prop integer|dwMaxHwMixingStaticBuffers|Specifies the maximum number of static sound buffers. {"dwMaxHwMixingStreamingBuffers", T_INT, OFF(m_caps.dwMaxHwMixingStreamingBuffers), 0, "Specifies the maximum number of streaming sound buffers."}, // @prop integer|dwMaxHwMixingStreamingBuffers|Specifies the maximum number of streaming sound buffers. {"dwFreeHwMixingAllBuffers", T_INT, OFF(m_caps.dwFreeHwMixingAllBuffers), 0, "Description of the free mixing hardware capabilities of the device. An application can use these values to determine whether hardware resources are available for allocation to a secondary sound buffer. Also, by comparing this value to the members that specify maximum mixing capabilities, the resources that are already allocated can be determined. "}, // @prop integer|dwFreeHwMixingAllBuffers|Description of the free hardware mixing capabilities of the device. An application can use this value to determine whether hardware resources are available for allocation to a secondary sound buffer. Also, by comparing these values to the members that specify maximum mixing capabilities, the resources that are already allocated can be determined. {"dwFreeHwMixingStaticBuffers", T_INT, OFF(m_caps.dwFreeHwMixingStaticBuffers), 0, "Description of the free hardware mixing capabilities of the device. An application can use this value to determine whether hardware resources are available for allocation to a secondary sound buffer. Also, by comparing these values to the members that specify maximum mixing capabilities, the resources that are already allocated can be determined."}, // @prop integer|dwFreeHwMixingStaticBuffers|Description of the free hardware mixing capabilities of the device. An application can use this value to determine whether hardware resources are available for allocation to a secondary sound buffer. Also, by comparing these values to the members that specify maximum mixing capabilities, the resources that are already allocated can be determined. {"dwFreeHwMixingStreamingBuffers", T_INT, OFF(m_caps.dwFreeHwMixingStreamingBuffers), 0, "Description of the free hardware mixing capabilities of the device. An application can use this value to determine whether hardware resources are available for allocation to a secondary sound buffer. Also, by comparing these values to the members that specify maximum mixing capabilities, the resources that are already allocated can be determined."}, // @prop integer|dwFreeHwMixingStreamingBuffers|Description of the free hardware mixing capabilities of the device. An application can use this value to determine whether hardware resources are available for allocation to a secondary sound buffer. Also, by comparing these values to the members that specify maximum mixing capabilities, the resources that are already allocated can be determined. {"dwMaxHw3DAllBuffers", T_INT, OFF(m_caps.dwMaxHw3DAllBuffers), 0, "Description of the hardware 3-D positional capabilities of the device."}, // @prop integer|dwMaxHw3DAllBuffers|Description of the hardware 3-D positional capabilities of the device. {"dwMaxHw3DStaticBuffers", T_INT, OFF(m_caps.dwMaxHw3DStaticBuffers), 0, "Description of the hardware 3-D positional capabilities of the device. "}, // @prop integer|dwMaxHw3DStaticBuffers|Description of the hardware 3-D positional capabilities of the device. {"dwMaxHw3DStreamingBuffers", T_INT, OFF(m_caps.dwMaxHw3DStreamingBuffers), 0, "Description of the hardware 3-D positional capabilities of the device."}, // @prop integer|dwMaxHw3DStreamingBuffers|Description of the hardware 3-D positional capabilities of the device. {"dwFreeHw3DAllBuffers", T_INT, OFF(m_caps.dwFreeHw3DAllBuffers), 0, "Description of the free, or unallocated, hardware 3-D positional capabilities of the device."}, // @prop integer|dwFreeHw3DAllBuffers|Description of the free, or unallocated, hardware 3-D positional capabilities of the device. {"dwFreeHw3DStaticBuffers", T_INT, OFF(m_caps.dwFreeHw3DStaticBuffers), 0, "Description of the free, or unallocated, hardware 3-D positional capabilities of the device."}, // @prop integer|dwFreeHw3DStaticBuffers|Description of the free, or unallocated, hardware 3-D positional capabilities of the device. {"dwFreeHw3DStreamingBuffers", T_INT, OFF(m_caps.dwFreeHw3DStreamingBuffers), 0, "Description of the free, or unallocated, hardware 3-D positional capabilities of the device."}, // @prop integer|dwFreeHw3DStreamingBuffers|Description of the free, or unallocated, hardware 3-D positional capabilities of the device. {"dwTotalHwMemBytes", T_INT, OFF(m_caps.dwTotalHwMemBytes), 0, "Size, in bytes, of the amount of memory on the sound card that stores static sound buffers."}, // @prop integer|dwTotalHwMemBytes|Size, in bytes, of the amount of memory on the sound card that stores static sound buffers. {"dwFreeHwMemBytes", T_INT, OFF(m_caps.dwFreeHwMemBytes), 0, "Size, in bytes, of the free memory on the sound card."}, // @prop integer|dwFreeHwMemBytes|Size, in bytes, of the free memory on the sound card. {"dwMaxContigFreeHwMemBytes", T_INT, OFF(m_caps.dwMaxContigFreeHwMemBytes), 0, "Size, in bytes, of the largest contiguous block of free memory on the sound card."}, // @prop integer|dwMaxContigFreeHwMemBytes|Size, in bytes, of the largest contiguous block of free memory on the sound card. {"dwUnlockTransferRateHwBuffers", T_INT, OFF(m_caps.dwUnlockTransferRateHwBuffers), 0, "Description of the rate, in kilobytes per second, at which data can be transferred to hardware static sound buffers. This and the number of bytes transferred determines the duration of a call to the IDirectSoundBuffer::Update method."}, // @prop integer|dwUnlockTransferRateHwBuffers|Description of the rate, in kilobytes per second, at which data can be transferred to hardware static sound buffers. This and the number of bytes transferred determines the duration of a call to the IDirectSoundBuffer::Update method. {"dwPlayCpuOverheadSwBuffers", T_INT, OFF(m_caps.dwPlayCpuOverheadSwBuffers), 0, "Description of the processing overhead, as a percentage of the central processing unit, needed to mix software buffers (those located in main system memory). This varies according to the bus type, the processor type, and the clock speed. The unlock transfer rate for software buffers is 0 because the data need not be transferred anywhere. Similarly, the play processing overhead for hardware buffers is 0 because the mixing is done by the sound device."}, // @prop integer|dwPlayCpuOverheadSwBuffers|Description of the processing overhead, as a percentage of the central processing unit, needed to mix software buffers (those located in main system memory). This varies according to the bus type, the processor type, and the clock speed. The unlock transfer rate for software buffers is 0 because the data need not be transferred anywhere. Similarly, the play processing overhead for hardware buffers is 0 because the mixing is done by the sound device. {NULL} /* Sentinel */ }; PyDSCAPS::PyDSCAPS(void) { ob_type = &PyDSCAPSType; _Py_NewReference(this); memset(&m_caps, 0, sizeof(m_caps)); } PyDSCAPS::PyDSCAPS(const DSCAPS &caps) { ob_type = &PyDSCAPSType; _Py_NewReference(this); m_caps = caps; m_caps.dwSize = sizeof(DSCAPS); } PyDSCAPS::~PyDSCAPS() { } /*static*/ void PyDSCAPS::deallocFunc(PyObject *ob) { delete (PyDSCAPS *)ob; } --- NEW FILE: PyIDirectSoundBuffer.h --- // This file declares the IDirectSound Interface for Python. // --------------------------------------------------- // // Interface Declaration class PyIDirectSoundBuffer : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIDirectSoundBuffer); static IDirectSoundBuffer *GetI(PyObject *self); static PyComTypeObject type; static PyObject *QueryInterface(PyObject *self, PyObject *args); // The Python methods // Information methods static PyObject *GetCaps(PyObject *self, PyObject *args); static PyObject *GetFormat(PyObject *self, PyObject *args); static PyObject *GetStatus(PyObject *self, PyObject *args); static PyObject *SetFormat(PyObject *self, PyObject *args); // Memory management static PyObject *Initialize(PyObject *self, PyObject *args); static PyObject *Restore(PyObject *self, PyObject *args); // Play management static PyObject *GetCurrentPosition(PyObject *self, PyObject *args); static PyObject *Play(PyObject *self, PyObject *args); static PyObject *SetCurrentPosition(PyObject *self, PyObject *args); static PyObject *Stop(PyObject *self, PyObject *args); static PyObject *Update(PyObject *self, PyObject *args); // Sound management static PyObject *GetFrequency(PyObject *self, PyObject *args); static PyObject *GetPan(PyObject *self, PyObject *args); static PyObject *GetVolume(PyObject *self, PyObject *args); static PyObject *SetFrequency(PyObject *self, PyObject *args); static PyObject *SetPan(PyObject *self, PyObject *args); static PyObject *SetVolume(PyObject *self, PyObject *args); PyIDirectSoundBuffer(IUnknown *pdisp); ~PyIDirectSoundBuffer(); PyObject *m_DS; }; --- NEW FILE: directsound.cpp --- // directsound.cpp : // $Id: directsound.cpp,v 1.1 2004/11/30 21:30:28 larsimmisch Exp $ // directsound wrapper contributed by Lars Immisch <la...@ib...> /*** Note that this source file contains embedded documentation. This documentation consists of marked up text inside the C comments, and is prefixed with an '@' symbol. The source files are processed by a tool called "autoduck" which generates Windows .hlp files. @doc ***/ #include "directsound_pch.h" #include "stddef.h" // for offsetof #include "PythonCOMRegister.h" // For simpler registration of IIDs etc. #include "PyIDirectSound.h" #include "PyIDirectSoundBuffer.h" #include "PyIDirectSoundNotify.h" // @pymethod <o PyIUnknown>|directsound|DirectSoundCreate|Creates and initializes a new object that supports the IDirectSound interface. static PyObject *directsound_DirectSoundCreate(PyObject *, PyObject *args) { PyObject *ret = NULL; PyObject *obGUID = NULL, *obUnk = NULL; IUnknown *pUnkIn = NULL; GUID guid, *pguid = NULL; LPDIRECTSOUND ds; HRESULT hr; if (!PyArg_ParseTuple(args, "|OO:DirectSoundCreate", &obGUID, // @pyparm <o PyIID>||guid|The identifier of the interface describing the type of interface pointer to return &obUnk)) // @pyparm <o PyIUknown>|unk||The IUnknown for COM aggregation. { return NULL; } if (obUnk) { if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&pUnkIn, TRUE)) goto done; } if (obGUID && obGUID != Py_None) { if (!PyWinObject_AsIID(obGUID, &guid)) goto done; pguid = &guid; } Py_BEGIN_ALLOW_THREADS hr = ::DirectSoundCreate(pguid, &ds, pUnkIn); Py_END_ALLOW_THREADS if (FAILED(hr)) { PyCom_BuildPyException(hr); goto done; } ret = new PyIDirectSound(ds); done: if (pUnkIn) pUnkIn->Release(); return ret; } BOOL CALLBACK dsEnumCallback(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOID context) { PyObject *list = (PyObject*)context; PyObject *item = PyTuple_New(3); PyObject *oguid; // abort enumeration if we cannot create a tuple if (!item) { return FALSE; } if (guid) { oguid = PyWinObject_FromIID(*guid); } else { Py_INCREF(Py_None); oguid = Py_None; } if (PyTuple_SetItem(item, 0, oguid)) return FALSE; if (PyTuple_SetItem(item, 1, desc ? PyString_FromString(desc) : PyString_FromString(""))) return FALSE; if (PyTuple_SetItem(item, 2, module ? PyString_FromString(module) : PyString_FromString(""))) return FALSE; if (PyList_Append(list, item)) return FALSE; return TRUE; } // @pymethod <o list|directsound|DirectSoundEnumerate|Enumerates DirectSound drivers installed in the system. static PyObject *directsound_DirectSoundEnumerate(PyObject *, PyObject *args) { if (!PyArg_ParseTuple(args, ":DirectSoundEnumerate")) { return NULL; } PyObject *list = PyList_New(0); if (!list) { return NULL; } HRESULT hr; Py_BEGIN_ALLOW_THREADS hr = ::DirectSoundEnumerate(dsEnumCallback, list); Py_END_ALLOW_THREADS if (PyErr_Occurred()) { return NULL; } if (FAILED(hr)) { PyCom_BuildPyException(hr); return NULL; } return list; } /* List of module functions */ // @module directsound|A module, encapsulating the DirectSound interfaces static struct PyMethodDef directsound_methods[]= { { "DirectSoundCreate", directsound_DirectSoundCreate, 1 }, // @pymeth DirectSoundCreate|Creates and initializes a new object that supports the IDirectSound interface. { "DirectSoundEnumerate", directsound_DirectSoundEnumerate, 1 }, // @pymeth DirectSoundEnumerate|The DirectSoundEnumerate function enumerates the DirectSound drivers installed in the system. // { "DirectSoundCaptureCreate", directsound_DirectSoundCaptureCreate, 1}, // @pymeth DirectSoundCaptureCreate|The DirectSoundCaptureCreate function creates and initializes an object that supports the IDirectSoundCapture interface // { "DirectSoundCaptureEnumerate", directsound_DirectSoundCaptureEnumerate, 1}, // @pymeth DirectSoundCaptureEnumerate|The DirectSoundCaptureEnumerate function enumerates the DirectSoundCapture objects installed in the system. {"DSCAPS", PyWinMethod_NewDSCAPS, 1 }, // @pymeth DSCAPS|Creates a new <o PyDSCAPS> object. {"DSBCAPS", PyWinMethod_NewDSBCAPS, 1 }, // @pymeth DSBCAPS|Creates a new <o PyDSBCAPS> object. {"DSBUFFERDESC", PyWinMethod_NewDSBUFFERDESC, 1 }, // @pymeth DSBUFFERDESC|Creates a new <o PyDSBUFFERDESC> object. { NULL, NULL }, }; static int AddConstant(PyObject *dict, const char *key, long value) { PyObject *oval = PyInt_FromLong(value); if (!oval) { return 1; } int rc = PyDict_SetItemString(dict, (char*)key, oval); Py_DECREF(oval); return rc; } #define ADD_CONSTANT(tok) AddConstant(dict, #tok, tok) static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] = { PYCOM_INTERFACE_CLIENT_ONLY (DirectSound), PYCOM_INTERFACE_CLIENT_ONLY (DirectSoundBuffer), PYCOM_INTERFACE_CLIENT_ONLY (DirectSoundNotify), }; /* Module initialisation */ extern "C" __declspec(dllexport) void initdirectsound() { char *modName = "directsound"; PyObject *oModule; // Create the module and add the functions oModule = Py_InitModule(modName, directsound_methods); if (!oModule) /* Eeek - some serious error! */ return; PyObject *dict = PyModule_GetDict(oModule); if (!dict) return; /* Another serious error!*/ // Register all of our interfaces, gateways and IIDs. PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(g_interfaceSupportData[0])); ADD_CONSTANT(DSCAPS_PRIMARYMONO); ADD_CONSTANT(DSCAPS_PRIMARYSTEREO); ADD_CONSTANT(DSCAPS_PRIMARY8BIT); ADD_CONSTANT(DSCAPS_PRIMARY16BIT); ADD_CONSTANT(DSCAPS_CONTINUOUSRATE); ADD_CONSTANT(DSCAPS_EMULDRIVER); ADD_CONSTANT(DSCAPS_CERTIFIED); ADD_CONSTANT(DSCAPS_SECONDARYMONO); ADD_CONSTANT(DSCAPS_SECONDARYSTEREO); ADD_CONSTANT(DSCAPS_SECONDARY8BIT); ADD_CONSTANT(DSCAPS_SECONDARY16BIT); ADD_CONSTANT(DSBPLAY_LOOPING); // @const directsound|DSBPLAY_LOOPING|text. ADD_CONSTANT(DSBSTATUS_PLAYING); ADD_CONSTANT(DSBSTATUS_BUFFERLOST); ADD_CONSTANT(DSBSTATUS_LOOPING); ADD_CONSTANT(DSBLOCK_FROMWRITECURSOR); ADD_CONSTANT(DSBLOCK_ENTIREBUFFER); ADD_CONSTANT(DSSCL_NORMAL); ADD_CONSTANT(DSSCL_PRIORITY); ADD_CONSTANT(DSSCL_EXCLUSIVE); ADD_CONSTANT(DSSCL_WRITEPRIMARY); ADD_CONSTANT(DS3DMODE_NORMAL); ADD_CONSTANT(DS3DMODE_HEADRELATIVE); ADD_CONSTANT(DS3DMODE_DISABLE); ADD_CONSTANT(DSBCAPS_PRIMARYBUFFER); ADD_CONSTANT(DSBCAPS_STATIC); ADD_CONSTANT(DSBCAPS_LOCHARDWARE); ADD_CONSTANT(DSBCAPS_LOCSOFTWARE); ADD_CONSTANT(DSBCAPS_CTRL3D); ADD_CONSTANT(DSBCAPS_CTRLFREQUENCY); ADD_CONSTANT(DSBCAPS_CTRLPAN); ADD_CONSTANT(DSBCAPS_CTRLVOLUME); ADD_CONSTANT(DSBCAPS_CTRLPOSITIONNOTIFY); ADD_CONSTANT(DSBCAPS_CTRLDEFAULT); ADD_CONSTANT(DSBCAPS_CTRLALL); ADD_CONSTANT(DSBCAPS_STICKYFOCUS); ADD_CONSTANT(DSBCAPS_GLOBALFOCUS); ADD_CONSTANT(DSBCAPS_GETCURRENTPOSITION2); ADD_CONSTANT(DSBCAPS_MUTE3DATMAXDISTANCE); ADD_CONSTANT(DSCBCAPS_WAVEMAPPED); ADD_CONSTANT(DSSPEAKER_HEADPHONE); ADD_CONSTANT(DSSPEAKER_MONO); ADD_CONSTANT(DSSPEAKER_QUAD); ADD_CONSTANT(DSSPEAKER_STEREO); ADD_CONSTANT(DSSPEAKER_SURROUND); ADD_CONSTANT(DSSPEAKER_GEOMETRY_MIN); ADD_CONSTANT(DSSPEAKER_GEOMETRY_NARROW); ADD_CONSTANT(DSSPEAKER_GEOMETRY_WIDE); ADD_CONSTANT(DSSPEAKER_GEOMETRY_MAX); // real macros - todo if can be bothered // ADD_CONSTANT(DSSPEAKER_COMBINED); // ADD_CONSTANT(DSSPEAKER_CONFIG); // ADD_CONSTANT(DSSPEAKER_GEOMETRY); ADD_CONSTANT(DSBFREQUENCY_MIN); ADD_CONSTANT(DSBFREQUENCY_MAX); ADD_CONSTANT(DSBFREQUENCY_ORIGINAL); ADD_CONSTANT(DSBPAN_LEFT); ADD_CONSTANT(DSBPAN_CENTER); ADD_CONSTANT(DSBPAN_RIGHT); ADD_CONSTANT(DSBVOLUME_MIN); ADD_CONSTANT(DSBVOLUME_MAX); ADD_CONSTANT(DSBSIZE_MIN); ADD_CONSTANT(DSBSIZE_MAX); ADD_CONSTANT(DSCCAPS_EMULDRIVER); ADD_CONSTANT(DSCBLOCK_ENTIREBUFFER); ADD_CONSTANT(DSCBSTATUS_CAPTURING); ADD_CONSTANT(DSCBSTATUS_LOOPING); ADD_CONSTANT(DSCBSTART_LOOPING); ADD_CONSTANT(DSBPN_OFFSETSTOP); PyDict_SetItemString(dict, "DSCAPSType", (PyObject *)&PyDSCAPSType); PyDict_SetItemString(dict, "DSBCAPSType", (PyObject *)&PyDSBCAPSType); PyDict_SetItemString(dict, "DSBUFFERDESCType", (PyObject *)&PyDSBUFFERDESCType); } --- NEW FILE: directsound_pch.h --- // directsound_pch.h : header file for PCH generation for the directsound COM extension #include <windows.h> #include <Python.h> #include <PythonCOM.h> #include <dsound.h> /* ** DSBUFFERDESC support */ PyObject *PyWinMethod_NewDSBUFFERDESC(PyObject *self, PyObject *args); PyObject *PyWinObject_FromWAVEFROMATEX(const DSBUFFERDESC &dsbd); BOOL PyWinObject_AsDSBUFFERDESC(PyObject *ob, DSBUFFERDESC **ppDSBUFFERDESC, BOOL bNoneOK = TRUE); extern PyTypeObject PyDSBUFFERDESCType; #define PyDSBUFFERDESC_Check(ob) ((ob)->ob_type == &PyDSBUFFERDESCType) /* ** DSCAPS support */ PyObject *PyWinMethod_NewDSCAPS(PyObject *self, PyObject *args); PyObject *PyWinObject_FromDSCAPS(const DSBUFFERDESC &dsbd); BOOL PyWinObject_AsDSCAPS(PyObject *ob, DSCAPS **ppDSCAPS, BOOL bNoneOK = TRUE); extern PyTypeObject PyDSCAPSType; #define PyDSCAPS_Check(ob) ((ob)->ob_type == &PyDSCAPSType) /* ** DSBCAPS support */ PyObject *PyWinMethod_NewDSBCAPS(PyObject *self, PyObject *args); PyObject *PyWinObject_FromDSBCAPS(const DSBUFFERDESC &dsbd); BOOL PyWinObject_AsDSBCAPS(PyObject *ob, DSBCAPS **ppDSBCAPS, BOOL bNoneOK = TRUE); extern PyTypeObject PyDSBCAPSType; #define PyDSBCAPS_Check(ob) ((ob)->ob_type == &PyDSBCAPSType) class PyDSBUFFERDESC : public PyObject { public: PyDSBUFFERDESC(void); PyDSBUFFERDESC(const DSBUFFERDESC &); ~PyDSBUFFERDESC(); /* Python support */ static void deallocFunc(PyObject *ob); static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue); PyObject *m_obWFX; #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER DSBUFFERDESC m_dsbd; }; class PyDSCAPS : public PyObject { public: DSCAPS *GetCAPS() {return &m_caps;} PyDSCAPS(void); PyDSCAPS(const DSCAPS &); ~PyDSCAPS(); /* Python support */ static void deallocFunc(PyObject *ob); #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER DSCAPS m_caps; }; class PyDSBCAPS : public PyObject { public: DSBCAPS *GetCAPS() {return &m_caps;} PyDSBCAPS(void); PyDSBCAPS(const DSBCAPS &); ~PyDSBCAPS(); /* Python support */ static void deallocFunc(PyObject *ob); #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER DSBCAPS m_caps; }; --- NEW FILE: PyDSBUFFERDESC.cpp --- // // @doc #include "PyWinTypes.h" #include "PyWinObjects.h" #include "PySoundObjects.h" #include "structmember.h" #include "directsound_pch.h" // @pymethod <o PyDSBUFFERDESC>|pywintypes|DSBUFFERDESC|Creates a new DSBUFFERDESC object PyObject *PyWinMethod_NewDSBUFFERDESC(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":DSBUFFERDESC")) return NULL; return new PyDSBUFFERDESC(); } PyObject *PyWinObject_FromDSBUFFERDESC(const DSBUFFERDESC &dsbd) { return new PyDSBUFFERDESC(dsbd); } BOOL PyWinObject_AsDSBUFFERDESC(PyObject *ob, DSBUFFERDESC **ppDSBUFFERDESC, BOOL bNoneOK /*= TRUE*/) { if (bNoneOK && ob==Py_None) { *ppDSBUFFERDESC = NULL; } else if (!PyDSBUFFERDESC_Check(ob)) { PyErr_SetString(PyExc_TypeError, "The object is not a PyDSBUFFERDESC object"); return FALSE; } else { PyDSBUFFERDESC *pydsbd= (PyDSBUFFERDESC *)ob; *ppDSBUFFERDESC = &pydsbd->m_dsbd; // in case the PyWAVEFORMATEX has been manipulated and points to a different address now ((DSBUFFERDESC *)*ppDSBUFFERDESC)->lpwfxFormat = &((PyWAVEFORMATEX *)pydsbd->m_obWFX)->m_wfx; } return TRUE; } // @object PyDSBUFFERDESC|A Python object, representing a DSBUFFERDESC structure static struct PyMethodDef PyDSBUFFERDESC_methods[] = { {NULL} }; PyTypeObject PyDSBUFFERDESCType = { PyObject_HEAD_INIT(&PyType_Type) 0, "PyDSBUFFERDESC", sizeof(PyDSBUFFERDESC), 0, PyDSBUFFERDESC::deallocFunc, 0, // tp_print; 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number 0, // tp_as_sequence 0, // tp_as_mapping 0, 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, PyDSBUFFERDESC::setattro, 0, // tp_as_buffer; Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags; 0, // tp_doc; /* Documentation string */ 0, // traverseproc tp_traverse; 0, // tp_clear; 0, // tp_richcompare; 0, // tp_weaklistoffset; 0, // tp_iter 0, // iternextfunc tp_iternext 0, // methods PyDSBUFFERDESC::members, 0, // tp_getset; 0, // tp_base; 0, // tp_dict; 0, // tp_descr_get; 0, // tp_descr_set; 0, // tp_dictoffset; 0, // tp_init; 0, // tp_alloc; 0 // newfunc tp_new; }; #define OFF(e) offsetof(PyDSBUFFERDESC, e) /*static*/ struct PyMemberDef PyDSBUFFERDESC::members[] = { {"dwFlags", T_INT, OFF(m_dsbd.dwFlags), 0, "Identifies the capabilities to include when creating a new DirectSoundBuffer object"}, // @prop integer|dwFlags|Identifies the capabilities to include when creating a new DirectSoundBuffer object. {"dwBufferBytes", T_INT, OFF(m_dsbd.dwBufferBytes), 0, "Size of the new buffer, in bytes. This value must be 0 when creating primary buffers. For secondary buffers, the minimum and maximum sizes allowed are specified by DSBSIZE_MIN and DSBSIZE_MAX"}, // @prop integer|dwBufferBytes|Size of the new buffer, in bytes. This value must be 0 when creating primary buffers. For secondary buffers, the minimum and maximum sizes allowed are specified by DSBSIZE_MIN and DSBSIZE_MAX. {"lpwfxFormat", T_OBJECT, OFF(m_obWFX), 0, "Structure specifying the waveform format for the buffer. This value must be None for primary buffers. The application can use IDirectSoundBuffer::SetFormat to set the format of the primary buffer."}, // @prop WAVEFORMATEX|lpwfxFormat|Structure specifying the waveform format for the buffer. This value must be None for primary buffers. The application can use IDirectSoundBuffer::SetFormat to set the format of the primary buffer. {NULL} /* Sentinel */ }; PyDSBUFFERDESC::PyDSBUFFERDESC(void) { ob_type = &PyDSBUFFERDESCType; _Py_NewReference(this); memset(&m_dsbd, 0, sizeof(m_dsbd)); m_dsbd.dwSize = sizeof(DSBUFFERDESC); Py_INCREF(Py_None); m_obWFX = Py_None; } PyDSBUFFERDESC::PyDSBUFFERDESC(const DSBUFFERDESC &dsbd) { m_dsbd.dwSize = sizeof(DSBUFFERDESC); ob_type = &PyDSBUFFERDESCType; _Py_NewReference(this); m_dsbd = dsbd; if (dsbd.lpwfxFormat) { m_obWFX = new PyWAVEFORMATEX(*dsbd.lpwfxFormat); m_dsbd.lpwfxFormat = &((PyWAVEFORMATEX*)m_obWFX)->m_wfx; } else { Py_INCREF(Py_None); m_obWFX = Py_None; } } PyDSBUFFERDESC::~PyDSBUFFERDESC() { Py_XDECREF( m_obWFX ); } /*static*/ void PyDSBUFFERDESC::deallocFunc(PyObject *ob) { delete (PyDSBUFFERDESC *)ob; } int PyDSBUFFERDESC::setattro(PyObject *self, PyObject *obname, PyObject *obvalue) { PyDSBUFFERDESC *obself = (PyDSBUFFERDESC*)self; char *name=PyString_AsString(obname); if (name==NULL) return -1; if (strcmp(name,"lpwfxFormat") == 0) { if (obvalue == Py_None) { obself->m_dsbd.lpwfxFormat = NULL; } else if (!PyWAVEFORMATEX_Check(obvalue)) { PyErr_SetString(PyExc_ValueError,"lpwfxFormat must be a WAVEFORMATEX instance"); return -1; } else { obself->m_dsbd.lpwfxFormat = &((PyWAVEFORMATEX*)obvalue)->m_wfx; } } return PyObject_GenericSetAttr(self, obname, obvalue); } --- NEW FILE: PyIDirectSoundNotify.h --- // This file declares the IDirectSoundNotify Interface for Python. // --------------------------------------------------- // // Interface Declaration class PyIDirectSoundNotify : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIDirectSoundNotify); static IDirectSoundNotify *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *SetNotificationPositions(PyObject *self, PyObject *args); PyIDirectSoundNotify(IUnknown *pdisp); ~PyIDirectSoundNotify(); PyObject *m_DS; }; --- NEW FILE: PyDSBCAPS.cpp --- // // @doc #include "PyWinTypes.h" #include "PyWinObjects.h" #include "structmember.h" #include "directsound_pch.h" // @pymethod <o PyDSBCAPS>|pywintypes|DSBCAPS|Creates a new DSBCAPS object PyObject *PyWinMethod_NewDSBCAPS(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":DSBCAPS")) return NULL; return new PyDSBCAPS(); } PyObject *PyWinObject_FromDSBCAPS(const DSBCAPS &caps) { return new PyDSBCAPS(caps); } BOOL PyWinObject_AsDSBCAPS(PyObject *ob, DSBCAPS **ppDSBCAPS, BOOL bNoneOK /*= TRUE*/) { if (bNoneOK && ob==Py_None) { *ppDSBCAPS = NULL; } else if (!PyDSBCAPS_Check(ob)) { PyErr_SetString(PyExc_TypeError, "The object is not a PyDSBCAPS object"); return FALSE; } else { PyDSBCAPS *pycaps= (PyDSBCAPS *)ob; *ppDSBCAPS = pycaps->GetCAPS(); } return TRUE; } // @object PyDSBCAPS|A Python object, representing a DSBCAPS structure static struct PyMethodDef PyDSBCAPS_methods[] = { {NULL} }; PyTypeObject PyDSBCAPSType = { PyObject_HEAD_INIT(&PyType_Type) 0, "PyDSBCAPS", sizeof(PyDSBCAPS), 0, PyDSBCAPS::deallocFunc, 0, // tp_print; 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number 0, // tp_as_sequence 0, // tp_as_mapping 0, 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, PyObject_GenericSetAttr, 0, // tp_as_buffer; Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags; 0, // tp_doc; /* Documentation string */ 0, // traverseproc tp_traverse; 0, // tp_clear; 0, // tp_richcompare; 0, // tp_weaklistoffset; 0, // tp_iter 0, // iternextfunc tp_iternext 0, // methods PyDSBCAPS::members, 0, // tp_getset; 0, // tp_base; 0, // tp_dict; 0, // tp_descr_get; 0, // tp_descr_set; 0, // tp_dictoffset; 0, // tp_init; 0, // tp_alloc; 0 // newfunc tp_new; }; #define OFF(e) offsetof(PyDSBCAPS, e) /*static*/ struct PyMemberDef PyDSBCAPS::members[] = { {"dwFlags", T_INT, OFF(m_caps.dwFlags), 0, "Flags that specify buffer-object capabilities."}, // @prop integer|dwFlags|Flags that specify buffer-object capabilities. {"dwBufferBytes", T_INT, OFF(m_caps.dwBufferBytes), 0, "Size of the buffer, in bytes"}, // @prop integer|nChannels|Size of the buffer, in bytes. {"dwUnlockTransferRate", T_INT, OFF(m_caps.dwUnlockTransferRate), 0, "Specifies the rate, in kilobytes per second, at which data is transferred to the buffer memory when IDirectSoundBuffer::Update is called. High-performance applications can use this value to determine the time required for IDirectSoundBuffer::Update to execute. For software buffers located in system memory, the rate will be very high because no processing is required. For hardware buffers, the rate might be slower because the buffer might have to be downloaded to the sound card, which might have a limited transfer rate."}, // @prop integer|dwUnlockTransferRate|Specifies the rate, in kilobytes per second, at which data is transferred to the buffer memory when IDirectSoundBuffer::Unlock is called. High-performance applications can use this value to determine the time required for IDirectSoundBuffer::Unlock to execute. For software buffers located in system memory, the rate will be very high because no processing is required. For hardware buffers, the rate might be slower because the buffer might have to be downloaded to the sound card, which might have a limited transfer rate. {"dwPlayCpuOverhead", T_INT, OFF(m_caps.dwPlayCpuOverhead)}, // @prop integer|nAvgBytesPerSec|Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle. {NULL} /* Sentinel */ }; PyDSBCAPS::PyDSBCAPS(void) { ob_type = &PyDSBCAPSType; _Py_NewReference(this); memset(&m_caps, 0, sizeof(m_caps)); m_caps.dwSize = sizeof(DSBCAPS); } PyDSBCAPS::PyDSBCAPS(const DSBCAPS &caps) { ob_type = &PyDSBCAPSType; _Py_NewReference(this); m_caps = caps; m_caps.dwSize = sizeof(DSBCAPS); } PyDSBCAPS::~PyDSBCAPS() { } /*static*/ void PyDSBCAPS::deallocFunc(PyObject *ob) { delete (PyDSBCAPS *)ob; } --- NEW FILE: PyIDirectSoundNotify.cpp --- // This file implements the IDirectSoundNotify Interface for Python. #include "directsound_pch.h" #include "PySoundObjects.h" #include "PyIDirectSoundNotify.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIDirectSoundNotify::PyIDirectSoundNotify(IUnknown *pdisp): PyIUnknown(pdisp), m_DS(NULL) { ob_type = &type; } PyIDirectSoundNotify::~PyIDirectSoundNotify() { // Release should be called before IDirectSound::Release, which may be // triggered below SafeRelease(this); // This may trigger IDirectSOund::Release if (m_DS) Py_DECREF(m_DS); } /* static */ IDirectSoundNotify *PyIDirectSoundNotify::GetI(PyObject *self) { return (IDirectSoundNotify*)PyIUnknown::GetI(self); } static BOOL unpack(PyObject *tuple, DSBPOSITIONNOTIFY *¬ify, int pos) { if (!PyTuple_Check(tuple) || PyTuple_Size(tuple) < 2) return FALSE; PyObject *o0 = PyTuple_GET_ITEM(tuple, 0); PyObject *o1 = PyTuple_GET_ITEM(tuple, 1); if (!o0 || !PyInt_Check(o0) || !o1 || !PyHANDLE_Check(o1)) return FALSE; notify[pos].dwOffset = PyInt_AS_LONG(o0); if (!PyWinObject_AsHANDLE(o1, ¬ify[pos].hEventNotify)) return FALSE; return TRUE; } // @pymethod |PyIDirectSoundNotify|SetNotificationPositions|Description of GetCaps. PyObject *PyIDirectSoundNotify::SetNotificationPositions(PyObject *self, PyObject *args) { int i; PyObject *obPos = NULL; IDirectSoundNotify *pIDSB = GetI(self); if ( pIDSB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "O:SetNotificationPositions", &obPos) ) return NULL; int size = 0; DSBPOSITIONNOTIFY *notify = NULL; if (PyTuple_Check(obPos)){ size = PyTuple_Size(obPos); if (size < 1) goto argerror; if (PyTuple_Check(PyTuple_GET_ITEM(obPos, 0))) { // nested tuples notify = new DSBPOSITIONNOTIFY[size]; for (i = 0; i < size; ++i) { if (!unpack(PyTuple_GET_ITEM(obPos, i), notify, i)) goto argerror; } } else { notify = new DSBPOSITIONNOTIFY[1]; size = 1; if (!unpack(obPos, notify, 0)) goto argerror; } } else if (PyList_Check(obPos)) { size = PyList_Size(obPos); if (size < 1) goto argerror; notify = new DSBPOSITIONNOTIFY[size]; for (i = 0; i < size; ++i) { if (!unpack(PyList_GET_ITEM(obPos, i), notify, i)) goto argerror; } } else goto argerror; HRESULT hr; { PY_INTERFACE_PRECALL; hr = pIDSB->SetNotificationPositions(size, notify); PY_INTERFACE_POSTCALL; } delete[] notify; if (FAILED(hr)) { PyWin_SetAPIError("SetNotificationPositions", hr); return NULL; } Py_INCREF(Py_None); return Py_None; argerror: delete[] notify; PyErr_SetString(PyExc_TypeError, "Argument must be a tuple (or a list of tuples) with two items: position and win32 Event handle"); return NULL; } // @object PyIDirectSoundNotify|Description of the interface static struct PyMethodDef PyIDirectSoundNotify_methods[] = { { "SetNotificationPositions", PyIDirectSoundNotify::SetNotificationPositions, 1 }, // @pymeth Initialize|Description of SetNotificationPositions. { NULL } }; PyComTypeObject PyIDirectSoundNotify::type("PyIDirectSoundNotify", &PyIUnknown::type, sizeof(PyIDirectSoundNotify), PyIDirectSoundNotify_methods, GET_PYCOM_CTOR(PyIDirectSoundNotify)); |
From: Lars I. <lar...@us...> - 2004-11-30 21:30:36
|
Update of /cvsroot/pywin32/pywin32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6405/com Added Files: directsound.dsp Log Message: Added (some) DirectSound support. The bulk is in com/win32comext/directsound, including a test directory with a sample soundfile and a unittest-based test script. Supported are: - IDirectSound - IDirectSoundBuffer - IDirectSoundNotify. Also added support for: - WAVEFORMATEX (in PyWinTypes) - DSBUFFERDESC - DSBCAPS - DSCAPS - various constants used in these structures Missing is: - IDirectSoundCapture - complete documentation --- NEW FILE: directsound.dsp --- # Microsoft Developer Studio Project File - Name="directsound" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=directsound - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "directsound.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "directsound.mak" CFG="directsound - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "directsound - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "directsound - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "directsound - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Build" # PROP Intermediate_Dir "Build\Temp\directsound\Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DIRECTSOUND_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\com\win32com\src\include" /I "..\win32\src" /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "STRICT" /YX"directsound_pch.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 odbccp32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib dsound.lib dxguid.lib /nologo /dll /pdb:"Build/directsound_d.pdb" /debug /machine:I386 /out:"Build\directsound.pyd" /libpath:"..\win32\build" # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "directsound - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Build" # PROP Intermediate_Dir "Build\Temp\directsound\debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DIRECTSOUND_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\com\win32com\src\include" /I "..\win32\src" /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "STRICT" /FR /YX"directsound_pch.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib dsound.lib dxguid.lib /nologo /dll /debug /machine:I386 /out:"Build\directsound_d.pyd" /pdbtype:sept /libpath:"..\win32\build" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "directsound - Win32 Release" # Name "directsound - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\win32comext\directsound\src\directsound.cpp # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyDSBCAPS.cpp # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyDSBUFFERDESC.cpp # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyDSCAPS.cpp # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyIDirectSound.cpp # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyIDirectSoundBuffer.cpp # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyIDirectSoundNotify.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\win32comext\directsound\src\directsound_pch.h # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyIDirectSound.h # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyIDirectSoundBuffer.h # End Source File # Begin Source File SOURCE=.\win32comext\directsound\src\PyIDirectSoundNotify.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project |
From: Lars I. <lar...@us...> - 2004-11-30 21:09:23
|
Update of /cvsroot/pywin32/pywin32/com/help In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3444 Modified Files: cpp.d Log Message: Fixed trivial typo. Index: cpp.d =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/help/cpp.d,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cpp.d 30 Mar 2000 15:22:48 -0000 1.1 --- cpp.d 30 Nov 2004 21:09:14 -0000 1.2 *************** *** 9,13 **** just that.Python offers easy, fast development, yet is still close enough to C++ to be recognizable. For example, compare python's class ! mechanism and exception handeling. With the perspective of being a light overview, we'll look at some details of development of a raw C++ COM component and compare that to python development. What is --- 9,13 ---- just that.Python offers easy, fast development, yet is still close enough to C++ to be recognizable. For example, compare python's class ! mechanism and exception handling. With the perspective of being a light overview, we'll look at some details of development of a raw C++ COM component and compare that to python development. What is |
From: Lars I. <lar...@us...> - 2004-11-30 20:58:13
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv389/src Log Message: Directory /cvsroot/pywin32/pywin32/com/win32comext/directsound/src added to the repository |
From: Lars I. <lar...@us...> - 2004-11-30 20:58:12
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv389/test Log Message: Directory /cvsroot/pywin32/pywin32/com/win32comext/directsound/test added to the repository |