winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
August 2012
----- 2025 -----
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
541 discussions
Start a n
N
ew thread
Michael Stefaniuc : dsound: Add COM aggregation to DirectSoundCapture for internal use.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: 850b294efa1d1c80915b43685664ee9550b5e121 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=850b294efa1d1c80915b43685…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:49:10 2012 +0200 dsound: Add COM aggregation to DirectSoundCapture for internal use. --- dlls/dsound/capture.c | 27 +++++++++++++++++---------- dlls/dsound/dsound_private.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index 23668e9..8d0fc65 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -997,9 +997,10 @@ static HRESULT DirectSoundCaptureDevice_Initialize( */ typedef struct IDirectSoundCaptureImpl { - IUnknown IUnknown_iface; /* Separate refcount */ + IUnknown IUnknown_inner; IDirectSoundCapture IDirectSoundCapture_iface; LONG ref, refdsc, numIfaces; + IUnknown *outer_unk; /* internal */ DirectSoundCaptureDevice *device; BOOL has_dsc8; } IDirectSoundCaptureImpl; @@ -1017,7 +1018,7 @@ static void capture_destroy(IDirectSoundCaptureImpl *This) */ static inline IDirectSoundCaptureImpl *impl_from_IUnknown(IUnknown *iface) { - return CONTAINING_RECORD(iface, IDirectSoundCaptureImpl, IUnknown_iface); + return CONTAINING_RECORD(iface, IDirectSoundCaptureImpl, IUnknown_inner); } static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) @@ -1033,7 +1034,7 @@ static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown)) - *ppv = &This->IUnknown_iface; + *ppv = &This->IUnknown_inner; else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) *ppv = &This->IDirectSoundCapture_iface; else { @@ -1089,7 +1090,7 @@ static HRESULT WINAPI IDirectSoundCaptureImpl_QueryInterface(IDirectSoundCapture { IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(iface); TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv); - return IUnknown_QueryInterface(&This->IUnknown_iface, riid, ppv); + return IUnknown_QueryInterface(This->outer_unk, riid, ppv); } static ULONG WINAPI IDirectSoundCaptureImpl_AddRef(IDirectSoundCapture *iface) @@ -1219,7 +1220,7 @@ static const IDirectSoundCaptureVtbl dscvt = IDirectSoundCaptureImpl_Initialize }; -static HRESULT IDirectSoundCaptureImpl_Create(REFIID riid, void **ppv, BOOL has_dsc8) +HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_dsc8) { IDirectSoundCaptureImpl *obj; HRESULT hr; @@ -1235,7 +1236,7 @@ static HRESULT IDirectSoundCaptureImpl_Create(REFIID riid, void **ppv, BOOL has_ setup_dsound_options(); - obj->IUnknown_iface.lpVtbl = &unk_vtbl; + obj->IUnknown_inner.lpVtbl = &unk_vtbl; obj->IDirectSoundCapture_iface.lpVtbl = &dscvt; obj->ref = 1; obj->refdsc = 0; @@ -1243,20 +1244,26 @@ static HRESULT IDirectSoundCaptureImpl_Create(REFIID riid, void **ppv, BOOL has_ obj->device = NULL; obj->has_dsc8 = has_dsc8; - hr = IUnknown_QueryInterface(&obj->IUnknown_iface, riid, ppv); - IUnknown_Release(&obj->IUnknown_iface); + /* COM aggregation supported only internally */ + if (outer_unk) + obj->outer_unk = outer_unk; + else + obj->outer_unk = &obj->IUnknown_inner; + + hr = IUnknown_QueryInterface(&obj->IUnknown_inner, riid, ppv); + IUnknown_Release(&obj->IUnknown_inner); return hr; } HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv) { - return IDirectSoundCaptureImpl_Create(riid, ppv, FALSE); + return IDirectSoundCaptureImpl_Create(NULL, riid, ppv, FALSE); } HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv) { - return IDirectSoundCaptureImpl_Create(riid, ppv, TRUE); + return IDirectSoundCaptureImpl_Create(NULL, riid, ppv, TRUE); } /*************************************************************************** diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index d9139be..8419a7f 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -301,6 +301,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN; HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN; HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv) DECLSPEC_HIDDEN; +HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_dsc8) DECLSPEC_HIDDEN; #define STATE_STOPPED 0 #define STATE_STARTING 1
1
0
0
0
Michael Stefaniuc : dsound: Aggregate IDirectSound8 instead of wrapping it.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: ac3cd73ca2f19aa2a8244432a8450dd7b28b6e93 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ac3cd73ca2f19aa2a8244432a…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:47:44 2012 +0200 dsound: Aggregate IDirectSound8 instead of wrapping it. --- dlls/dsound/duplex.c | 240 ++++++-------------------------------------------- 1 files changed, 29 insertions(+), 211 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=ac3cd73ca2f19aa2a8244…
1
0
0
0
Michael Stefaniuc : dsound: Add COM aggregation to DirectSound for internal use.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: 9cb53818e85513cd73f621d65fa581abab981a2f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9cb53818e85513cd73f621d65…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:45:29 2012 +0200 dsound: Add COM aggregation to DirectSound for internal use. --- dlls/dsound/dsound.c | 27 +++++++++++++++++---------- dlls/dsound/dsound_private.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c index ad41f59..3847a18 100644 --- a/dlls/dsound/dsound.c +++ b/dlls/dsound/dsound.c @@ -42,8 +42,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound); typedef struct IDirectSoundImpl { - IUnknown IUnknown_iface; /* Separate refcount, not for COM aggregation */ + IUnknown IUnknown_inner; IDirectSound8 IDirectSound8_iface; + IUnknown *outer_unk; /* internal */ LONG ref, refds, numIfaces; DirectSoundDevice *device; BOOL has_ds8; @@ -129,7 +130,7 @@ static void directsound_destroy(IDirectSoundImpl *This) */ static inline IDirectSoundImpl *impl_from_IUnknown(IUnknown *iface) { - return CONTAINING_RECORD(iface, IDirectSoundImpl, IUnknown_iface); + return CONTAINING_RECORD(iface, IDirectSoundImpl, IUnknown_inner); } static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) @@ -145,7 +146,7 @@ static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown)) - *ppv = &This->IUnknown_iface; + *ppv = &This->IUnknown_inner; else if (IsEqualIID(riid, &IID_IDirectSound) || (IsEqualIID(riid, &IID_IDirectSound8) && This->has_ds8)) *ppv = &This->IDirectSound8_iface; @@ -204,7 +205,7 @@ static HRESULT WINAPI IDirectSound8Impl_QueryInterface(IDirectSound8 *iface, REF { IDirectSoundImpl *This = impl_from_IDirectSound8(iface); TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv); - return IUnknown_QueryInterface(&This->IUnknown_iface, riid, ppv); + return IUnknown_QueryInterface(This->outer_unk, riid, ppv); } static ULONG WINAPI IDirectSound8Impl_AddRef(IDirectSound8 *iface) @@ -317,7 +318,7 @@ static const IDirectSound8Vtbl ds8_vtbl = IDirectSound8Impl_VerifyCertification }; -static HRESULT IDirectSoundImpl_Create(REFIID riid, void **ppv, BOOL has_ds8) +HRESULT IDirectSoundImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_ds8) { IDirectSoundImpl *obj; HRESULT hr; @@ -333,7 +334,7 @@ static HRESULT IDirectSoundImpl_Create(REFIID riid, void **ppv, BOOL has_ds8) setup_dsound_options(); - obj->IUnknown_iface.lpVtbl = &unk_vtbl; + obj->IUnknown_inner.lpVtbl = &unk_vtbl; obj->IDirectSound8_iface.lpVtbl = &ds8_vtbl; obj->ref = 1; obj->refds = 0; @@ -341,20 +342,26 @@ static HRESULT IDirectSoundImpl_Create(REFIID riid, void **ppv, BOOL has_ds8) obj->device = NULL; obj->has_ds8 = has_ds8; - hr = IUnknown_QueryInterface(&obj->IUnknown_iface, riid, ppv); - IUnknown_Release(&obj->IUnknown_iface); + /* COM aggregation supported only internally */ + if (outer_unk) + obj->outer_unk = outer_unk; + else + obj->outer_unk = &obj->IUnknown_inner; + + hr = IUnknown_QueryInterface(&obj->IUnknown_inner, riid, ppv); + IUnknown_Release(&obj->IUnknown_inner); return hr; } HRESULT DSOUND_Create(REFIID riid, void **ppv) { - return IDirectSoundImpl_Create(riid, ppv, FALSE); + return IDirectSoundImpl_Create(NULL, riid, ppv, FALSE); } HRESULT DSOUND_Create8(REFIID riid, void **ppv) { - return IDirectSoundImpl_Create(riid, ppv, TRUE); + return IDirectSoundImpl_Create(NULL, riid, ppv, TRUE); } /******************************************************************************* diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index 1855319..d9139be 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -263,6 +263,7 @@ HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DEC HRESULT DSOUND_Create(REFIID riid, void **ppv) DECLSPEC_HIDDEN; HRESULT DSOUND_Create8(REFIID riid, void **ppv) DECLSPEC_HIDDEN; +HRESULT IDirectSoundImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_ds8) DECLSPEC_HIDDEN; /* primary.c */
1
0
0
0
Michael Stefaniuc : dsound: Merge IUnknown into the main DirectSoundFullDuplex object.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: bd4c67396bd9ce964d631e25688801ce46f37126 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bd4c67396bd9ce964d631e256…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:43:25 2012 +0200 dsound: Merge IUnknown into the main DirectSoundFullDuplex object. --- dlls/dsound/duplex.c | 121 ++++++++++++++++---------------------------------- 1 files changed, 39 insertions(+), 82 deletions(-) diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c index 0e9320a..7ec8590 100644 --- a/dlls/dsound/duplex.c +++ b/dlls/dsound/duplex.c @@ -42,23 +42,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound); */ typedef struct IDirectSoundFullDuplexImpl { + IUnknown IUnknown_iface; IDirectSoundFullDuplex IDirectSoundFullDuplex_iface; - LONG ref, numIfaces; + LONG ref, refdsfd, numIfaces; /* IDirectSoundFullDuplexImpl fields */ IDirectSound8 *renderer_device; IDirectSoundCapture *capture_device; - - LPUNKNOWN pUnknown; LPDIRECTSOUND8 pDS8; LPDIRECTSOUNDCAPTURE pDSC; } IDirectSoundFullDuplexImpl; -typedef struct IDirectSoundFullDuplex_IUnknown { - const IUnknownVtbl *lpVtbl; - LONG ref; - IDirectSoundFullDuplexImpl *pdsfd; -} IDirectSoundFullDuplex_IUnknown; - typedef struct IDirectSoundFullDuplex_IDirectSound8 { const IDirectSound8Vtbl *lpVtbl; LONG ref; @@ -82,81 +75,51 @@ static void fullduplex_destroy(IDirectSoundFullDuplexImpl *This) } /******************************************************************************* - * IUnknown + * IUnknown implemetation for DirectSoundFullDuplex */ -static HRESULT WINAPI IDirectSoundFullDuplex_IUnknown_QueryInterface( - LPUNKNOWN iface, - REFIID riid, - LPVOID * ppobj) +static inline IDirectSoundFullDuplexImpl *impl_from_IUnknown(IUnknown *iface) { - IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface; - TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); - return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj); + return CONTAINING_RECORD(iface, IDirectSoundFullDuplexImpl, IUnknown_iface); } -static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_AddRef( - LPUNKNOWN iface) +static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) { - IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface; - ULONG ref = InterlockedIncrement(&(This->ref)); - TRACE("(%p) ref was %d\n", This, ref - 1); - return ref; + IDirectSoundFullDuplexImpl *This = impl_from_IUnknown(iface); + TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv); + return IDirectSoundFullDuplex_QueryInterface(&This->IDirectSoundFullDuplex_iface, riid, ppv); } -static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_Release( - LPUNKNOWN iface) +static ULONG WINAPI IUnknownImpl_AddRef(IUnknown *iface) { - IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface; - ULONG ref = InterlockedDecrement(&(This->ref)); - TRACE("(%p) ref was %d\n", This, ref + 1); - if (!ref) { - This->pdsfd->pUnknown = NULL; - HeapFree(GetProcessHeap(), 0, This); - TRACE("(%p) released\n", This); - } + IDirectSoundFullDuplexImpl *This = impl_from_IUnknown(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(ref == 1) + InterlockedIncrement(&This->numIfaces); return ref; } -static const IUnknownVtbl DirectSoundFullDuplex_Unknown_Vtbl = -{ - IDirectSoundFullDuplex_IUnknown_QueryInterface, - IDirectSoundFullDuplex_IUnknown_AddRef, - IDirectSoundFullDuplex_IUnknown_Release -}; - -static HRESULT IDirectSoundFullDuplex_IUnknown_Create( - LPDIRECTSOUNDFULLDUPLEX pdsfd, - LPUNKNOWN * ppunk) +static ULONG WINAPI IUnknownImpl_Release(IUnknown *iface) { - IDirectSoundFullDuplex_IUnknown * pdsfdunk; - TRACE("(%p,%p)\n",pdsfd,ppunk); - - if (pdsfd == NULL) { - ERR("invalid parameter: pdsfd == NULL\n"); - return DSERR_INVALIDPARAM; - } - - if (ppunk == NULL) { - ERR("invalid parameter: ppunk == NULL\n"); - return DSERR_INVALIDPARAM; - } + IDirectSoundFullDuplexImpl *This = impl_from_IUnknown(iface); + ULONG ref = InterlockedDecrement(&This->ref); - pdsfdunk = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdunk)); - if (pdsfdunk == NULL) { - WARN("out of memory\n"); - *ppunk = NULL; - return DSERR_OUTOFMEMORY; - } - - pdsfdunk->lpVtbl = &DirectSoundFullDuplex_Unknown_Vtbl; - pdsfdunk->ref = 0; - pdsfdunk->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd; - - *ppunk = (LPUNKNOWN)pdsfdunk; + TRACE("(%p) ref=%d\n", This, ref); - return DS_OK; + if (!ref && !InterlockedDecrement(&This->numIfaces)) + fullduplex_destroy(This); + return ref; } +static const IUnknownVtbl unk_vtbl = +{ + IUnknownImpl_QueryInterface, + IUnknownImpl_AddRef, + IUnknownImpl_Release +}; + /******************************************************************************* * IDirectSoundFullDuplex_IDirectSound8 */ @@ -457,7 +420,7 @@ static inline IDirectSoundFullDuplexImpl *impl_from_IDirectSoundFullDuplex(IDire static ULONG WINAPI IDirectSoundFullDuplexImpl_AddRef(IDirectSoundFullDuplex *iface) { IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); - ULONG ref = InterlockedIncrement(&(This->ref)); + ULONG ref = InterlockedIncrement(&This->refdsfd); TRACE("(%p) ref=%d\n", This, ref); @@ -480,16 +443,8 @@ static HRESULT WINAPI IDirectSoundFullDuplexImpl_QueryInterface(IDirectSoundFull *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown)) { - if (!This->pUnknown) { - IDirectSoundFullDuplex_IUnknown_Create(iface, &This->pUnknown); - if (!This->pUnknown) { - WARN("IDirectSoundFullDuplex_IUnknown_Create() failed\n"); - *ppv = NULL; - return E_NOINTERFACE; - } - } - IDirectSoundFullDuplex_IUnknown_AddRef(This->pUnknown); - *ppv = This->pUnknown; + IUnknown_AddRef(&This->IUnknown_iface); + *ppv = &This->IUnknown_iface; return S_OK; } else if (IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) { IDirectSoundFullDuplexImpl_AddRef(iface); @@ -528,7 +483,7 @@ static HRESULT WINAPI IDirectSoundFullDuplexImpl_QueryInterface(IDirectSoundFull static ULONG WINAPI IDirectSoundFullDuplexImpl_Release(IDirectSoundFullDuplex *iface) { IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); - ULONG ref = InterlockedDecrement(&(This->ref)); + ULONG ref = InterlockedDecrement(&This->refdsfd); TRACE("(%p) ref=%d\n", This, ref); @@ -641,11 +596,13 @@ HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv) setup_dsound_options(); obj->IDirectSoundFullDuplex_iface.lpVtbl = &dsfd_vtbl; + obj->IUnknown_iface.lpVtbl = &unk_vtbl; obj->ref = 1; + obj->refdsfd = 0; obj->numIfaces = 1; - hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv); - IUnknown_Release((IUnknown*)obj); + hr = IUnknown_QueryInterface(&obj->IUnknown_iface, riid, ppv); + IUnknown_Release(&obj->IUnknown_iface); return hr; }
1
0
0
0
Michael Stefaniuc : dsound: Add an object refcount for DirectSoundFullDuplex.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: 6692f97e01b6c06c247f11e51b327f9ca4b277c0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6692f97e01b6c06c247f11e51…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:40:59 2012 +0200 dsound: Add an object refcount for DirectSoundFullDuplex. --- dlls/dsound/duplex.c | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c index c9f08c4..0e9320a 100644 --- a/dlls/dsound/duplex.c +++ b/dlls/dsound/duplex.c @@ -43,8 +43,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound); typedef struct IDirectSoundFullDuplexImpl { IDirectSoundFullDuplex IDirectSoundFullDuplex_iface; - LONG ref; - + LONG ref, numIfaces; /* IDirectSoundFullDuplexImpl fields */ IDirectSound8 *renderer_device; IDirectSoundCapture *capture_device; @@ -72,6 +71,16 @@ typedef struct IDirectSoundFullDuplex_IDirectSoundCapture { IDirectSoundFullDuplexImpl *pdsfd; } IDirectSoundFullDuplex_IDirectSoundCapture; +static void fullduplex_destroy(IDirectSoundFullDuplexImpl *This) +{ + if (This->capture_device) + IDirectSoundCapture_Release(This->capture_device); + if (This->renderer_device) + IDirectSound_Release(This->renderer_device); + HeapFree(GetProcessHeap(), 0, This); + TRACE("(%p) released\n", This); +} + /******************************************************************************* * IUnknown */ @@ -449,7 +458,11 @@ static ULONG WINAPI IDirectSoundFullDuplexImpl_AddRef(IDirectSoundFullDuplex *if { IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); ULONG ref = InterlockedIncrement(&(This->ref)); - TRACE("(%p) ref was %d\n", This, ref - 1); + + TRACE("(%p) ref=%d\n", This, ref); + + if(ref == 1) + InterlockedIncrement(&This->numIfaces); return ref; } @@ -516,16 +529,11 @@ static ULONG WINAPI IDirectSoundFullDuplexImpl_Release(IDirectSoundFullDuplex *i { IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); ULONG ref = InterlockedDecrement(&(This->ref)); - TRACE("(%p) ref was %d\n", This, ref - 1); - if (!ref) { - if (This->capture_device) - IDirectSoundCapture_Release(This->capture_device); - if (This->renderer_device) - IDirectSound_Release(This->renderer_device); - HeapFree( GetProcessHeap(), 0, This ); - TRACE("(%p) released\n", This); - } + TRACE("(%p) ref=%d\n", This, ref); + + if (!ref && !InterlockedDecrement(&This->numIfaces)) + fullduplex_destroy(This); return ref; } @@ -634,6 +642,7 @@ HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv) obj->IDirectSoundFullDuplex_iface.lpVtbl = &dsfd_vtbl; obj->ref = 1; + obj->numIfaces = 1; hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv); IUnknown_Release((IUnknown*)obj);
1
0
0
0
Michael Stefaniuc : dsound: Pass the object instead of ifaces to helpers.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: 023a19d931d295cba21d92d1986ffb20bb140b24 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=023a19d931d295cba21d92d19…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:38:52 2012 +0200 dsound: Pass the object instead of ifaces to helpers. --- dlls/dsound/duplex.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c index 2b25ee8..c9f08c4 100644 --- a/dlls/dsound/duplex.c +++ b/dlls/dsound/duplex.c @@ -285,7 +285,7 @@ static const IDirectSound8Vtbl DirectSoundFullDuplex_DirectSound8_Vtbl = }; static HRESULT IDirectSoundFullDuplex_IDirectSound8_Create( - LPDIRECTSOUNDFULLDUPLEX pdsfd, + IDirectSoundFullDuplexImpl *pdsfd, LPDIRECTSOUND8 * ppds8) { IDirectSoundFullDuplex_IDirectSound8 * pdsfdds8; @@ -301,7 +301,7 @@ static HRESULT IDirectSoundFullDuplex_IDirectSound8_Create( return DSERR_INVALIDPARAM; } - if (((IDirectSoundFullDuplexImpl*)pdsfd)->renderer_device == NULL) { + if (pdsfd->renderer_device == NULL) { WARN("not initialized\n"); *ppds8 = NULL; return DSERR_UNINITIALIZED; @@ -316,7 +316,7 @@ static HRESULT IDirectSoundFullDuplex_IDirectSound8_Create( pdsfdds8->lpVtbl = &DirectSoundFullDuplex_DirectSound8_Vtbl; pdsfdds8->ref = 0; - pdsfdds8->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd; + pdsfdds8->pdsfd = pdsfd; *ppds8 = (LPDIRECTSOUND8)pdsfdds8; @@ -399,7 +399,7 @@ static const IDirectSoundCaptureVtbl DirectSoundFullDuplex_DirectSoundCapture_Vt }; static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create( - LPDIRECTSOUNDFULLDUPLEX pdsfd, + IDirectSoundFullDuplexImpl *pdsfd, LPDIRECTSOUNDCAPTURE8 * ppdsc8) { IDirectSoundFullDuplex_IDirectSoundCapture * pdsfddsc; @@ -415,7 +415,7 @@ static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create( return DSERR_INVALIDPARAM; } - if (((IDirectSoundFullDuplexImpl*)pdsfd)->capture_device == NULL) { + if (pdsfd->capture_device == NULL) { WARN("not initialized\n"); *ppdsc8 = NULL; return DSERR_UNINITIALIZED; @@ -430,7 +430,7 @@ static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create( pdsfddsc->lpVtbl = &DirectSoundFullDuplex_DirectSoundCapture_Vtbl; pdsfddsc->ref = 0; - pdsfddsc->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd; + pdsfddsc->pdsfd = pdsfd; *ppdsc8 = (LPDIRECTSOUNDCAPTURE)pdsfddsc; @@ -485,7 +485,7 @@ static HRESULT WINAPI IDirectSoundFullDuplexImpl_QueryInterface(IDirectSoundFull } else if (IsEqualIID(riid, &IID_IDirectSound) || IsEqualIID(riid, &IID_IDirectSound8)) { if (!This->pDS8) { - IDirectSoundFullDuplex_IDirectSound8_Create(iface, &This->pDS8); + IDirectSoundFullDuplex_IDirectSound8_Create(This, &This->pDS8); if (!This->pDS8) { WARN("IDirectSoundFullDuplex_IDirectSound8_Create() failed\n"); *ppv = NULL; @@ -497,7 +497,7 @@ static HRESULT WINAPI IDirectSoundFullDuplexImpl_QueryInterface(IDirectSoundFull return S_OK; } else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) { if (!This->pDSC) { - IDirectSoundFullDuplex_IDirectSoundCapture_Create(iface, &This->pDSC); + IDirectSoundFullDuplex_IDirectSoundCapture_Create(This, &This->pDSC); if (!This->pDSC) { WARN("IDirectSoundFullDuplex_IDirectSoundCapture_Create() failed\n"); *ppv = NULL;
1
0
0
0
Michael Stefaniuc : dsound: COM cleanup for the IDirectSoundFullDuplex iface.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: 8588260eeff1ef91f9fac1c137a064869d38800c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8588260eeff1ef91f9fac1c13…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:31:52 2012 +0200 dsound: COM cleanup for the IDirectSoundFullDuplex iface. --- dlls/dsound/duplex.c | 59 ++++++++++++++++++++++++------------------------- 1 files changed, 29 insertions(+), 30 deletions(-) diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c index 49cba9f..2b25ee8 100644 --- a/dlls/dsound/duplex.c +++ b/dlls/dsound/duplex.c @@ -42,8 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound); */ typedef struct IDirectSoundFullDuplexImpl { - /* IUnknown fields */ - const IDirectSoundFullDuplexVtbl *lpVtbl; + IDirectSoundFullDuplex IDirectSoundFullDuplex_iface; LONG ref; /* IDirectSoundFullDuplexImpl fields */ @@ -159,7 +158,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_QueryInterface( { IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface; TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); - return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj); + return IDirectSoundFullDuplex_QueryInterface(&This->pdsfd->IDirectSoundFullDuplex_iface, riid, ppobj); } static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_AddRef( @@ -334,7 +333,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface( { IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface; TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); - return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj); + return IDirectSoundFullDuplex_QueryInterface(&This->pdsfd->IDirectSoundFullDuplex_iface, riid, ppobj); } static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_AddRef( @@ -439,48 +438,49 @@ static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create( } /*************************************************************************** - * IDirectSoundFullDuplexImpl + * IDirectSoundFullDuplex implementation */ -static ULONG WINAPI -IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface ) +static inline IDirectSoundFullDuplexImpl *impl_from_IDirectSoundFullDuplex(IDirectSoundFullDuplex *iface) { - IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; + return CONTAINING_RECORD(iface, IDirectSoundFullDuplexImpl, IDirectSoundFullDuplex_iface); +} + +static ULONG WINAPI IDirectSoundFullDuplexImpl_AddRef(IDirectSoundFullDuplex *iface) +{ + IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); ULONG ref = InterlockedIncrement(&(This->ref)); TRACE("(%p) ref was %d\n", This, ref - 1); return ref; } -static HRESULT WINAPI -IDirectSoundFullDuplexImpl_QueryInterface( - LPDIRECTSOUNDFULLDUPLEX iface, - REFIID riid, - LPVOID* ppobj ) +static HRESULT WINAPI IDirectSoundFullDuplexImpl_QueryInterface(IDirectSoundFullDuplex *iface, + REFIID riid, void **ppv) { - IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; - TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj ); + IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); + TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv); - if (ppobj == NULL) { + if (ppv == NULL) { WARN("invalid parameter\n"); return E_INVALIDARG; } - *ppobj = NULL; + *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown)) { if (!This->pUnknown) { IDirectSoundFullDuplex_IUnknown_Create(iface, &This->pUnknown); if (!This->pUnknown) { WARN("IDirectSoundFullDuplex_IUnknown_Create() failed\n"); - *ppobj = NULL; + *ppv = NULL; return E_NOINTERFACE; } } IDirectSoundFullDuplex_IUnknown_AddRef(This->pUnknown); - *ppobj = This->pUnknown; + *ppv = This->pUnknown; return S_OK; } else if (IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) { IDirectSoundFullDuplexImpl_AddRef(iface); - *ppobj = This; + *ppv = &This->IDirectSoundFullDuplex_iface; return S_OK; } else if (IsEqualIID(riid, &IID_IDirectSound) || IsEqualIID(riid, &IID_IDirectSound8)) { @@ -488,34 +488,33 @@ IDirectSoundFullDuplexImpl_QueryInterface( IDirectSoundFullDuplex_IDirectSound8_Create(iface, &This->pDS8); if (!This->pDS8) { WARN("IDirectSoundFullDuplex_IDirectSound8_Create() failed\n"); - *ppobj = NULL; + *ppv = NULL; return E_NOINTERFACE; } } IDirectSoundFullDuplex_IDirectSound8_AddRef(This->pDS8); - *ppobj = This->pDS8; + *ppv = This->pDS8; return S_OK; } else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) { if (!This->pDSC) { IDirectSoundFullDuplex_IDirectSoundCapture_Create(iface, &This->pDSC); if (!This->pDSC) { WARN("IDirectSoundFullDuplex_IDirectSoundCapture_Create() failed\n"); - *ppobj = NULL; + *ppv = NULL; return E_NOINTERFACE; } } IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(This->pDSC); - *ppobj = This->pDSC; + *ppv = This->pDSC; return S_OK; } return E_NOINTERFACE; } -static ULONG WINAPI -IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface ) +static ULONG WINAPI IDirectSoundFullDuplexImpl_Release(IDirectSoundFullDuplex *iface) { - IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; + IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); ULONG ref = InterlockedDecrement(&(This->ref)); TRACE("(%p) ref was %d\n", This, ref - 1); @@ -535,8 +534,8 @@ static HRESULT WINAPI IDirectSoundFullDuplexImpl_Initialize(IDirectSoundFullDupl const DSBUFFERDESC *bufdesc, HWND hwnd, DWORD level, IDirectSoundCaptureBuffer8 **dscb8, IDirectSoundBuffer8 **dsb8) { + IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface); HRESULT hr; - IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This, debugstr_guid(capture_dev), debugstr_guid(render_dev), cbufdesc, bufdesc, hwnd, level, dscb8, dsb8); @@ -606,7 +605,7 @@ error: return hr; } -static const IDirectSoundFullDuplexVtbl dsfdvt = +static const IDirectSoundFullDuplexVtbl dsfd_vtbl = { /* IUnknown methods */ IDirectSoundFullDuplexImpl_QueryInterface, @@ -633,7 +632,7 @@ HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv) setup_dsound_options(); - obj->lpVtbl = &dsfdvt; + obj->IDirectSoundFullDuplex_iface.lpVtbl = &dsfd_vtbl; obj->ref = 1; hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv);
1
0
0
0
Michael Stefaniuc : dsound: Cleanup error handling in IDirectSoundFullDuplex::Initialize().
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: f6f8123c6b2c87e4953809b987d39c003703fb33 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f6f8123c6b2c87e4953809b98…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:30:16 2012 +0200 dsound: Cleanup error handling in IDirectSoundFullDuplex::Initialize(). --- dlls/dsound/duplex.c | 80 +++++++++++++++++++++++--------------------- dlls/dsound/tests/duplex.c | 4 ++ 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c index 6972a52..49cba9f 100644 --- a/dlls/dsound/duplex.c +++ b/dlls/dsound/duplex.c @@ -530,75 +530,79 @@ IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface ) return ref; } -static HRESULT WINAPI -IDirectSoundFullDuplexImpl_Initialize( - LPDIRECTSOUNDFULLDUPLEX iface, - LPCGUID pCaptureGuid, - LPCGUID pRendererGuid, - LPCDSCBUFFERDESC lpDscBufferDesc, - LPCDSBUFFERDESC lpDsBufferDesc, - HWND hWnd, - DWORD dwLevel, - LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, - LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 ) +static HRESULT WINAPI IDirectSoundFullDuplexImpl_Initialize(IDirectSoundFullDuplex *iface, + const GUID *capture_dev, const GUID *render_dev, const DSCBUFFERDESC *cbufdesc, + const DSBUFFERDESC *bufdesc, HWND hwnd, DWORD level, IDirectSoundCaptureBuffer8 **dscb8, + IDirectSoundBuffer8 **dsb8) { HRESULT hr; IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; - TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This, - debugstr_guid(pCaptureGuid), debugstr_guid(pRendererGuid), - lpDscBufferDesc, lpDsBufferDesc, hWnd, dwLevel, - lplpDirectSoundCaptureBuffer8, lplpDirectSoundBuffer8); + TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This, debugstr_guid(capture_dev), + debugstr_guid(render_dev), cbufdesc, bufdesc, hwnd, level, dscb8, dsb8); + + if (!dscb8 || !dsb8) + return E_INVALIDARG; + + *dscb8 = NULL; + *dsb8 = NULL; if (This->renderer_device != NULL || This->capture_device != NULL) { WARN("already initialized\n"); - *lplpDirectSoundCaptureBuffer8 = NULL; - *lplpDirectSoundBuffer8 = NULL; return DSERR_ALREADYINITIALIZED; } hr = DSOUND_Create8(&IID_IDirectSound8, (void **)&This->renderer_device); if (SUCCEEDED(hr)) - hr = IDirectSound_Initialize(This->renderer_device, pRendererGuid); + hr = IDirectSound_Initialize(This->renderer_device, render_dev); if (hr != DS_OK) { WARN("DirectSoundDevice_Initialize() failed\n"); - *lplpDirectSoundCaptureBuffer8 = NULL; - *lplpDirectSoundBuffer8 = NULL; - return hr; + goto error; } - IDirectSound8_SetCooperativeLevel(This->renderer_device, hWnd, dwLevel); + IDirectSound8_SetCooperativeLevel(This->renderer_device, hwnd, level); - hr = IDirectSound8_CreateSoundBuffer(This->renderer_device, lpDsBufferDesc, - (IDirectSoundBuffer**)lplpDirectSoundBuffer8, NULL); + hr = IDirectSound8_CreateSoundBuffer(This->renderer_device, bufdesc, + (IDirectSoundBuffer**)dsb8, NULL); if (hr != DS_OK) { WARN("IDirectSoundBufferImpl_Create() failed\n"); - *lplpDirectSoundCaptureBuffer8 = NULL; - *lplpDirectSoundBuffer8 = NULL; - return hr; + goto error; } hr = DSOUND_CaptureCreate8(&IID_IDirectSoundCapture8, (void**)&This->capture_device); if (SUCCEEDED(hr)) - hr = IDirectSoundCapture_Initialize(This->capture_device, pCaptureGuid); + hr = IDirectSoundCapture_Initialize(This->capture_device, capture_dev); if (hr != DS_OK) { WARN("DirectSoundCaptureDevice_Initialize() failed\n"); - *lplpDirectSoundCaptureBuffer8 = NULL; - *lplpDirectSoundBuffer8 = NULL; - return hr; + goto error; } - hr = IDirectSoundCapture_CreateCaptureBuffer(This->capture_device, - lpDscBufferDesc, - (IDirectSoundCaptureBuffer**)lplpDirectSoundCaptureBuffer8, - NULL); + hr = IDirectSoundCapture_CreateCaptureBuffer(This->capture_device, cbufdesc, + (IDirectSoundCaptureBuffer**)dscb8, NULL); if (hr != DS_OK) { WARN("IDirectSoundCaptureBufferImpl_Create() failed\n"); - *lplpDirectSoundCaptureBuffer8 = NULL; - *lplpDirectSoundBuffer8 = NULL; - return hr; + goto error; } + return DS_OK; + +error: + if (*dsb8) { + IDirectSoundBuffer8_Release(*dsb8); + *dsb8 = NULL; + } + if (This->renderer_device) { + IDirectSound8_Release(This->renderer_device); + This->renderer_device = NULL; + } + if (*dscb8) { + IDirectSoundCaptureBuffer8_Release(*dscb8); + *dscb8 = NULL; + } + if (This->capture_device) { + IDirectSoundCapture_Release(This->capture_device); + This->capture_device = NULL; + } return hr; } diff --git a/dlls/dsound/tests/duplex.c b/dlls/dsound/tests/duplex.c index 3015db0..170b552 100644 --- a/dlls/dsound/tests/duplex.c +++ b/dlls/dsound/tests/duplex.c @@ -280,6 +280,10 @@ static void test_COM(void) cbufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; cbufdesc.lpwfxFormat = &wfx; hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc, get_hwnd(), + DSSCL_EXCLUSIVE, NULL, NULL); + ok(hr == E_INVALIDARG, + "IDirectSoundFullDuplex_Initialize failed: %08x, expected E_INVALIDARG\n", hr); + hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc, get_hwnd(), DSSCL_EXCLUSIVE, &dscb8, &dsb8); if (hr == DSERR_NODRIVER) { skip("No driver\n");
1
0
0
0
Michael Stefaniuc : dsound: Cleanup the DirectSoundFullDuplex create functions.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: 885e205adea1cc7f4920aae5c7f537b7cd4ac38a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=885e205adea1cc7f4920aae5c…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:27:12 2012 +0200 dsound: Cleanup the DirectSoundFullDuplex create functions. --- dlls/dsound/dsound_main.c | 2 +- dlls/dsound/dsound_private.h | 4 +- dlls/dsound/duplex.c | 152 +++++++++++++----------------------------- 3 files changed, 50 insertions(+), 108 deletions(-) diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 34b23a5..f5199fd 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -723,7 +723,7 @@ static IClassFactoryImpl DSOUND_CF[] = { { { &DSCF_Vtbl }, &CLSID_DirectSound8, DSOUND_Create8 }, { { &DSCF_Vtbl }, &CLSID_DirectSoundCapture, DSOUND_CaptureCreate }, { { &DSCF_Vtbl }, &CLSID_DirectSoundCapture8, DSOUND_CaptureCreate8 }, - { { &DSCF_Vtbl }, &CLSID_DirectSoundFullDuplex, (FnCreateInstance)DSOUND_FullDuplexCreate }, + { { &DSCF_Vtbl }, &CLSID_DirectSoundFullDuplex, DSOUND_FullDuplexCreate }, { { &DSCF_Vtbl }, &CLSID_DirectSoundPrivate, (FnCreateInstance)IKsPrivatePropertySetImpl_Create }, { { NULL }, NULL, NULL } }; diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index c8498d3..1855319 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -280,8 +280,8 @@ HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) LONG capped_refcount_dec(LONG *ref) DECLSPEC_HIDDEN; /* duplex.c */ - -HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD) DECLSPEC_HIDDEN; + +HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN; /* mixer.c */ void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN; diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c index b473c03..6972a52 100644 --- a/dlls/dsound/duplex.c +++ b/dlls/dsound/duplex.c @@ -613,44 +613,29 @@ static const IDirectSoundFullDuplexVtbl dsfdvt = IDirectSoundFullDuplexImpl_Initialize }; -HRESULT DSOUND_FullDuplexCreate( - REFIID riid, - LPDIRECTSOUNDFULLDUPLEX* ppDSFD) +HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv) { - IDirectSoundFullDuplexImpl *This = NULL; - TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSFD); - - if (ppDSFD == NULL) { - WARN("invalid parameter: ppDSFD == NULL\n"); - return DSERR_INVALIDPARAM; - } - - if (!IsEqualIID(riid, &IID_IUnknown) && - !IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) { - *ppDSFD = 0; - return E_NOINTERFACE; - } - - /* Get dsound configuration */ - setup_dsound_options(); + IDirectSoundFullDuplexImpl *obj; + HRESULT hr; - This = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, sizeof(IDirectSoundFullDuplexImpl)); + TRACE("(%s, %p)\n", debugstr_guid(riid), ppv); - if (This == NULL) { + *ppv = NULL; + obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj)); + if (!obj) { WARN("out of memory\n"); - *ppDSFD = NULL; return DSERR_OUTOFMEMORY; } - This->lpVtbl = &dsfdvt; - This->ref = 1; - This->capture_device = NULL; - This->renderer_device = NULL; + setup_dsound_options(); + + obj->lpVtbl = &dsfdvt; + obj->ref = 1; - *ppDSFD = (LPDIRECTSOUNDFULLDUPLEX)This; + hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv); + IUnknown_Release((IUnknown*)obj); - return DS_OK; + return hr; } /*************************************************************************** @@ -659,93 +644,50 @@ HRESULT DSOUND_FullDuplexCreate( * Create and initialize a DirectSoundFullDuplex interface. * * PARAMS - * pcGuidCaptureDevice [I] Address of sound capture device GUID. - * pcGuidRenderDevice [I] Address of sound render device GUID. - * pcDSCBufferDesc [I] Address of capture buffer description. - * pcDSBufferDesc [I] Address of render buffer description. - * hWnd [I] Handle to application window. - * dwLevel [I] Cooperative level. - * ppDSFD [O] Address where full duplex interface returned. - * ppDSCBuffer8 [0] Address where capture buffer interface returned. - * ppDSBuffer8 [0] Address where render buffer interface returned. - * pUnkOuter [I] Must be NULL. + * capture_dev [I] Address of sound capture device GUID. + * render_dev [I] Address of sound render device GUID. + * cbufdesc [I] Address of capture buffer description. + * bufdesc [I] Address of render buffer description. + * hwnd [I] Handle to application window. + * level [I] Cooperative level. + * dsfd [O] Address where full duplex interface returned. + * dscb8 [0] Address where capture buffer interface returned. + * dsb8 [0] Address where render buffer interface returned. + * outer_unk [I] Must be NULL. * * RETURNS * Success: DS_OK * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM, * DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER */ -HRESULT WINAPI -DirectSoundFullDuplexCreate( - LPCGUID pcGuidCaptureDevice, - LPCGUID pcGuidRenderDevice, - LPCDSCBUFFERDESC pcDSCBufferDesc, - LPCDSBUFFERDESC pcDSBufferDesc, - HWND hWnd, - DWORD dwLevel, - LPDIRECTSOUNDFULLDUPLEX *ppDSFD, - LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, - LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, - LPUNKNOWN pUnkOuter) -{ - HRESULT hres; - IDirectSoundFullDuplexImpl *This = NULL; - TRACE("(%s,%s,%p,%p,%p,%x,%p,%p,%p,%p)\n", - debugstr_guid(pcGuidCaptureDevice), debugstr_guid(pcGuidRenderDevice), - pcDSCBufferDesc, pcDSBufferDesc, hWnd, dwLevel, ppDSFD, ppDSCBuffer8, - ppDSBuffer8, pUnkOuter); - - if (pUnkOuter) { - WARN("pUnkOuter != 0\n"); - *ppDSFD = NULL; - return DSERR_NOAGGREGATION; - } - - if (pcDSCBufferDesc == NULL) { - WARN("invalid parameter: pcDSCBufferDesc == NULL\n"); - *ppDSFD = NULL; - return DSERR_INVALIDPARAM; - } - - if (pcDSBufferDesc == NULL) { - WARN("invalid parameter: pcDSBufferDesc == NULL\n"); - *ppDSFD = NULL; - return DSERR_INVALIDPARAM; - } +HRESULT WINAPI DirectSoundFullDuplexCreate(const GUID *capture_dev, const GUID *render_dev, + const DSCBUFFERDESC *cbufdesc, const DSBUFFERDESC *bufdesc, HWND hwnd, DWORD level, + IDirectSoundFullDuplex **dsfd, IDirectSoundCaptureBuffer8 **dscb8, + IDirectSoundBuffer8 **dsb8, IUnknown *outer_unk) +{ + HRESULT hr; - if (ppDSFD == NULL) { - WARN("invalid parameter: ppDSFD == NULL\n"); - return DSERR_INVALIDPARAM; - } + TRACE("(%s,%s,%p,%p,%p,%x,%p,%p,%p,%p)\n", debugstr_guid(capture_dev), + debugstr_guid(render_dev), cbufdesc, bufdesc, hwnd, level, dsfd, dscb8, dsb8, + outer_unk); - if (ppDSCBuffer8 == NULL) { - WARN("invalid parameter: ppDSCBuffer8 == NULL\n"); - *ppDSFD = NULL; + if (!dsfd) return DSERR_INVALIDPARAM; + if (outer_unk) { + *dsfd = NULL; + return DSERR_NOAGGREGATION; } - if (ppDSBuffer8 == NULL) { - WARN("invalid parameter: ppDSBuffer8 == NULL\n"); - *ppDSFD = NULL; - return DSERR_INVALIDPARAM; + hr = DSOUND_FullDuplexCreate(&IID_IDirectSoundFullDuplex, (void**)dsfd); + if (hr == DS_OK) { + hr = IDirectSoundFullDuplex_Initialize(*dsfd, capture_dev, render_dev, cbufdesc, bufdesc, + hwnd, level, dscb8, dsb8); + if (hr != DS_OK) { + IDirectSoundFullDuplex_Release(*dsfd); + *dsfd = NULL; + WARN("IDirectSoundFullDuplexImpl_Initialize failed\n"); + } } - hres = DSOUND_FullDuplexCreate(&IID_IDirectSoundFullDuplex, (LPDIRECTSOUNDFULLDUPLEX*)&This); - if (FAILED(hres)) return hres; - - hres = IDirectSoundFullDuplexImpl_Initialize((LPDIRECTSOUNDFULLDUPLEX)This, - pcGuidCaptureDevice, - pcGuidRenderDevice, - pcDSCBufferDesc, - pcDSBufferDesc, - hWnd, dwLevel, ppDSCBuffer8, - ppDSBuffer8); - if (hres != DS_OK) { - IUnknown_Release((LPDIRECTSOUNDFULLDUPLEX)This); - WARN("IDirectSoundFullDuplexImpl_Initialize failed\n"); - *ppDSFD = NULL; - } else - *ppDSFD = (LPDIRECTSOUNDFULLDUPLEX)This; - - return hres; + return hr; }
1
0
0
0
Michael Stefaniuc : dsound/tests: Add DirectSoundFullDuplex COM tests.
by Alexandre Julliard
16 Aug '12
16 Aug '12
Module: wine Branch: master Commit: 0aeaa83a22a31e1466759e9562362c03a147f767 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0aeaa83a22a31e1466759e956…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Thu Aug 16 01:24:23 2012 +0200 dsound/tests: Add DirectSoundFullDuplex COM tests. --- dlls/dsound/tests/duplex.c | 114 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 111 insertions(+), 3 deletions(-) diff --git a/dlls/dsound/tests/duplex.c b/dlls/dsound/tests/duplex.c index 055bf09..3015db0 100644 --- a/dlls/dsound/tests/duplex.c +++ b/dlls/dsound/tests/duplex.c @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#define COBJMACROS #include <windows.h> - #include <stdio.h> #include "wine/test.h" @@ -223,6 +223,113 @@ static void IDirectSoundFullDuplex_tests(void) IDirectSoundFullDuplex_Release(dsfdo); } +static void test_COM(void) +{ + IDirectSoundFullDuplex *dsfd = (IDirectSoundFullDuplex*)0xdeadbeef; + IDirectSound *ds; + IDirectSound8 *ds8; + IDirectSoundCapture *dsc; + IUnknown *unk, *unk8; + IDirectSoundBuffer8 *dsb8; + IDirectSoundCaptureBuffer8 *dscb8; + DSBUFFERDESC bufdesc; + DSCBUFFERDESC cbufdesc; + WAVEFORMATEX wfx; + ULONG refcount; + HRESULT hr; + + /* COM aggregation */ + hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, (IUnknown*)&dsfd, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void**)&dsfd); + ok(hr == CLASS_E_NOAGGREGATION, + "DirectSoundFullDuplex create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); + ok(!dsfd, "dsfd = %p\n", dsfd); + + /* Invalid RIID */ + hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectSound3DBuffer, (void**)&dsfd); + ok(hr == E_NOINTERFACE, + "DirectSoundFullDuplex create failed: %08x, expected E_NOINTERFACE\n", hr); + + /* Different refcount for IDirectSoundFullDuplex and for IUnknown */ + hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectSoundFullDuplex, (void**)&dsfd); + ok(hr == S_OK, "DirectSoundFullDuplex create failed: %08x, expected S_OK\n", hr); + refcount = IDirectSoundFullDuplex_AddRef(dsfd); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IUnknown, (void**)&unk); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + refcount = IUnknown_AddRef(unk); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + + /* Not initialized */ + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8, (void**)&ds8); + ok(hr == E_NOINTERFACE, + "QueryInterface for IID_IDirectSound8 failed: %08x, expected E_NOINTERFACE\n", hr); + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture, (void**)&dsc); + ok(hr == E_NOINTERFACE, + "QueryInterface for IID_IDirectSoundCapture failed: %08x, expected E_NOINTERFACE\n", hr); + + init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1); + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize = sizeof(bufdesc); + bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; + bufdesc.lpwfxFormat = &wfx; + ZeroMemory(&cbufdesc, sizeof(cbufdesc)); + cbufdesc.dwSize = sizeof(cbufdesc); + cbufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; + cbufdesc.lpwfxFormat = &wfx; + hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc, get_hwnd(), + DSSCL_EXCLUSIVE, &dscb8, &dsb8); + if (hr == DSERR_NODRIVER) { + skip("No driver\n"); + return; + } + ok(hr == S_OK, "IDirectSoundFullDuplex_Initialize failed: %08x\n", hr); + + /* IDirectSound and IDirectSound8 */ + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8, (void**)&ds8); + ok(hr == S_OK, "QueryInterface for IID_IDirectSound8 failed: %08x\n", hr); + refcount = IDirectSound8_AddRef(ds8); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound, (void**)&ds); + ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr); + refcount = IDirectSound8_AddRef(ds8); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + refcount = IDirectSound_AddRef(ds); + ok(refcount == 5, "refcount == %u, expected 5\n", refcount); + hr = IDirectSound8_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + ok(unk == unk8, "Got different IUnknown when QI'ing IDirectSoundFullDuplex and IDirectSound\n"); + refcount = IUnknown_AddRef(unk8); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + refcount = IDirectSound_AddRef(ds); + ok(refcount == 6, "refcount == %u, expected 6\n", refcount); + refcount = IDirectSoundFullDuplex_AddRef(dsfd); + ok(refcount == 3, "refcount == %u, expected 3\n", refcount); + + /* IDirectSoundCapture */ + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture, (void**)&dsc); + ok(hr == S_OK, "QueryInterface for IID_IDirectSoundCapture failed: %08x\n", hr); + refcount = IDirectSoundCapture_AddRef(dsc); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + refcount = IDirectSoundFullDuplex_AddRef(dsfd); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + hr = IDirectSoundCapture_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + ok(unk == unk8, + "Got different IUnknown when QI'ing IDirectSoundFullDuplex and IDirectSoundCapture\n"); + refcount = IUnknown_AddRef(unk8); + ok(refcount == 6, "refcount == %u, expected 6\n", refcount); + + IDirectSoundBuffer8_Release(dsb8); + IDirectSoundCaptureBuffer8_Release(dscb8); + while (IDirectSound8_Release(ds8)); + while (IDirectSoundCapture_Release(dsc)); + while (IDirectSoundFullDuplex_Release(dsfd)); + while (IUnknown_Release(unk)); +} + START_TEST(duplex) { HMODULE hDsound; @@ -235,9 +342,10 @@ START_TEST(duplex) pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound, "DirectSoundFullDuplexCreate"); - if (pDirectSoundFullDuplexCreate) + if (pDirectSoundFullDuplexCreate) { + test_COM(); IDirectSoundFullDuplex_tests(); - else + } else skip("DirectSoundFullDuplexCreate missing - skipping all tests\n"); FreeLibrary(hDsound);
1
0
0
0
← Newer
1
...
32
33
34
35
36
37
38
...
55
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Results per page:
10
25
50
100
200