Subject: winex/dlls/dsound buffer.c,1.36,1.37 dsound_private.h,1.34,1.35Update of /var/lib/cvsd/cvsroot/winex/dlls/dsound
In directory agravaine:/tmp/cvs-serv22956/dlls/dsound
Modified Files:
buffer.c dsound_private.h
Log Message:
Implement proper aggregation for DSoundNotify object
Index: buffer.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dsound/buffer.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- buffer.c 28 Mar 2007 18:39:26 -0000 1.36
+++ buffer.c 30 Mar 2007 21:19:27 -0000 1.37
@@ -49,27 +49,31 @@
static ULONG WINAPI IDirectSoundNotifyImpl_AddRef(LPDIRECTSOUNDNOTIFY iface) {
ICOM_THIS(IDirectSoundNotifyImpl,iface);
- DWORD ref;
+ ULONG ulReturn;
TRACE("(%p) ref was %ld\n", This, This->ref);
+
+ IDirectSoundBufferImpl_AddRefAggregate((LPDIRECTSOUNDBUFFER8)This->dsb);
- ref = InterlockedIncrement(&(This->ref));
- return ref;
+ ulReturn = InterlockedIncrement(&(This->ref));
+
+ return ulReturn;
}
static ULONG WINAPI IDirectSoundNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface) {
ICOM_THIS(IDirectSoundNotifyImpl,iface);
- DWORD ref;
+ ULONG ulReturn=0;
TRACE("(%p) ref was %ld\n", This, This->ref);
-
- ref = InterlockedDecrement(&(This->ref));
- if (!ref) {
- IDirectSoundBuffer8_Release((LPDIRECTSOUNDBUFFER8)This->dsb);
- HeapFree(dsound_heap,0,This);
- return 0;
- }
- return ref;
+ /* NOTE: due to the aggregation of SoundBuffers and Sound3DBuffers, it is possible
+ that there are aggregate refs, but no actual refs on this buffer, so to
+ prevent negative refcounts... */
+ if( This->ref > 0 )
+ ulReturn = InterlockedDecrement(&(This->ref));
+
+ IDirectSoundBufferImpl_ReleaseAggregate((LPDIRECTSOUNDBUFFER8)This->dsb);
+
+ return ulReturn;
}
static HRESULT WINAPI IDirectSoundNotifyImpl_SetNotificationPositions(
@@ -103,6 +107,21 @@
IDirectSoundNotifyImpl_SetNotificationPositions,
};
+HRESULT WINAPI IDirectSoundNotifyImpl_Create(
+ IDirectSoundBufferImpl *This,
+ IDirectSoundNotifyImpl **pnotify)
+{
+ IDirectSoundNotifyImpl *dsn;
+
+ dsn = (IDirectSoundNotifyImpl*)HeapAlloc(dsound_heap,0,sizeof(*dsn));
+ dsn->ref = 0;
+ dsn->dsb = This;
+ ICOM_VTBL(dsn) = &dsnvt;
+
+ *pnotify = dsn;
+ return S_OK;
+}
+
/*******************************************************************************
* IDirectSoundBuffer
*/
@@ -351,6 +370,9 @@
DeleteCriticalSection(&This->ds3db->lock);
HeapFree(dsound_heap, 0, This->ds3db);
}
+ if (This->dsn) {
+ HeapFree(dsound_heap, 0, This->dsn);
+ }
if (This->iks) {
HeapFree(dsound_heap, 0, This->iks);
}
@@ -981,15 +1003,21 @@
}
if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) {
- IDirectSoundNotifyImpl *dsn;
-
- dsn = (IDirectSoundNotifyImpl*)HeapAlloc(dsound_heap,0,sizeof(*dsn));
- dsn->ref = 1;
- dsn->dsb = This;
- IDirectSoundBuffer8_AddRef(iface);
- ICOM_VTBL(dsn) = &dsnvt;
- *ppobj = (LPVOID)dsn;
- return S_OK;
+ if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY)) {
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+ }
+ if (!This->dsn) {
+ ERR("DirectSoundNotifier should have been created in SecondaryBuffer_Create\n");
+ *ppobj = NULL;
+ return E_FAIL;
+ }
+ *ppobj = This->dsn;
+ if (*ppobj) {
+ IDirectSoundNotifyImpl_AddRef((LPDIRECTSOUNDNOTIFY)*ppobj);
+ return S_OK;
+ }
+ return E_FAIL;
}
if ( IsEqualGUID( &IID_IDirectSound3DBuffer, riid ) ) {
@@ -1161,6 +1189,10 @@
else
DSOUND_RecalcVolPan(&(dsb->volpan));
+ if (dsbd->dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY) {
+ IDirectSoundNotifyImpl_Create(dsb, &dsb->dsn);
+ }
+
InitializeCriticalSection(&(dsb->lock));
/* register buffer */
Index: dsound_private.h
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dsound/dsound_private.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- dsound_private.h 28 Mar 2007 16:27:10 -0000 1.34
+++ dsound_private.h 30 Mar 2007 21:19:27 -0000 1.35
@@ -102,6 +102,7 @@
DWORD primary_mixpos, buf_mixpos;
BOOL need_remix;
/* IDirectSoundNotifyImpl fields */
+ IDirectSoundNotifyImpl* dsn;
LPDSBPOSITIONNOTIFY notifies;
int nrofnotifies;
/* when we mix sounds, for which amplifications have changed, we try to smooth it out
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.