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; }
// @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) { 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, // @pyparm <o PyDSCBUFFERDESC>|lpDSCBufferDesc||a DSBUFFERDESC structure containing values for the sound buffer being created. &obUnk) ) // @pyparm <o PyIUknown>|unk|None|The IUnknown for COM aggregation. return NULL; if (!PyDSBUFFERDESC_Check(obDSBD)) { PyErr_SetString(PyExc_TypeError, "Argument 1 must be of type DSBUFFERDESC"); return NULL; } if (obUnk && !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; }