From b3d1b1f239a5b534cd1b9a50fbfef32733b1911f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 27 Apr 2015 01:49:04 +0300 Subject: [PATCH] dmime: Don't expose IDirectMusicAudioPath impl details. --- dlls/dmime/audiopath.c | 38 +++++++++++++++++++++++++++++++++++++ dlls/dmime/dmime_private.h | 25 +++--------------------- dlls/dmime/performance.c | 39 +++++++++++++++----------------------- 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/dlls/dmime/audiopath.c b/dlls/dmime/audiopath.c index 66e218c985a..bd789c2c895 100644 --- a/dlls/dmime/audiopath.c +++ b/dlls/dmime/audiopath.c @@ -22,6 +22,43 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmime); WINE_DECLARE_DEBUG_CHANNEL(dmfile); +struct IDirectMusicAudioPathImpl { + /* IUnknown fields */ + const IUnknownVtbl *UnknownVtbl; + const IDirectMusicAudioPathVtbl *AudioPathVtbl; + const IDirectMusicObjectVtbl *ObjectVtbl; + const IPersistStreamVtbl *PersistStreamVtbl; + LONG ref; + + /* IDirectMusicAudioPathImpl fields */ + LPDMUS_OBJECTDESC pDesc; + + IDirectMusicPerformance8* pPerf; + IDirectMusicGraph* pToolGraph; + IDirectSoundBuffer* pDSBuffer; + IDirectSoundBuffer* pPrimary; + + BOOL fActive; +}; + +void set_audiopath_perf_pointer(IDirectMusicAudioPath *iface, IDirectMusicPerformance8 *performance) +{ + ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface); + This->pPerf = performance; +} + +void set_audiopath_dsound_buffer(IDirectMusicAudioPath *iface, IDirectSoundBuffer *buffer) +{ + ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface); + This->pDSBuffer = buffer; +} + +void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath *iface, IDirectSoundBuffer *buffer) +{ + ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface); + This->pPrimary = buffer; +} + /***************************************************************************** * IDirectMusicAudioPathImpl implementation */ @@ -72,6 +109,7 @@ static ULONG WINAPI IDirectMusicAudioPathImpl_IUnknown_Release (LPUNKNOWN iface) if (This->pDSBuffer) { IDirectSoundBuffer8_Release(This->pDSBuffer); } + This->pPerf = NULL; HeapFree(GetProcessHeap(), 0, This); } diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h index 35b51a251fe..fa44a4dcfe1 100644 --- a/dlls/dmime/dmime_private.h +++ b/dlls/dmime/dmime_private.h @@ -78,6 +78,9 @@ extern HRESULT WINAPI create_dmtempotrack(REFIID riid, void **ret_iface) DECLSPE extern HRESULT WINAPI create_dmtimesigtrack(REFIID riid, void **ret_iface) DECLSPEC_HIDDEN; extern HRESULT WINAPI create_dmwavetrack(REFIID riid, void **ret_iface) DECLSPEC_HIDDEN; +extern void set_audiopath_perf_pointer(IDirectMusicAudioPath*,IDirectMusicPerformance8*) DECLSPEC_HIDDEN; +extern void set_audiopath_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffer*) DECLSPEC_HIDDEN; +extern void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffer*) DECLSPEC_HIDDEN; /***************************************************************************** * Auxiliary definitions @@ -120,28 +123,6 @@ typedef struct DMUSIC_PRIVATE_PCHANNEL_ { IDirectMusicPort *port; /* ... at this port */ } DMUSIC_PRIVATE_PCHANNEL, *LPDMUSIC_PRIVATE_PCHANNEL; -/***************************************************************************** - * IDirectMusicAudioPathImpl implementation structure - */ -struct IDirectMusicAudioPathImpl { - /* IUnknown fields */ - const IUnknownVtbl *UnknownVtbl; - const IDirectMusicAudioPathVtbl *AudioPathVtbl; - const IDirectMusicObjectVtbl *ObjectVtbl; - const IPersistStreamVtbl *PersistStreamVtbl; - LONG ref; - - /* IDirectMusicAudioPathImpl fields */ - LPDMUS_OBJECTDESC pDesc; - - IDirectMusicPerformance8* pPerf; - IDirectMusicGraph* pToolGraph; - IDirectSoundBuffer* pDSBuffer; - IDirectSoundBuffer* pPrimary; - - BOOL fActive; -}; - /***************************************************************************** * IDirectMusicLyricsTrack implementation structure */ diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 25e86f9a15c..b8c37b0dcc6 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -987,7 +987,6 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath(IDirectMusicP IUnknown *pSourceConfig, BOOL fActivate, IDirectMusicAudioPath **ppNewPath) { IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface); - IDirectMusicAudioPathImpl *default_path; IDirectMusicAudioPath *pPath; FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath); @@ -997,8 +996,7 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath(IDirectMusicP } create_dmaudiopath(&IID_IDirectMusicAudioPath, (void**)&pPath); - default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl)); - default_path->pPerf = &This->IDirectMusicPerformance8_iface; + set_audiopath_perf_pointer(pPath, iface); /** TODO */ @@ -1011,11 +1009,10 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDire DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath **ppNewPath) { IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface); - IDirectMusicAudioPathImpl *default_path; IDirectMusicAudioPath *pPath; DSBUFFERDESC desc; WAVEFORMATEX format; - LPDIRECTSOUNDBUFFER buffer; + IDirectSoundBuffer *buffer, *primary_buffer; HRESULT hr = S_OK; FIXME("(%p)->(%d, %d, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath); @@ -1024,9 +1021,7 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDire return E_POINTER; } - create_dmaudiopath(&IID_IDirectMusicAudioPath, (void**)&pPath); - default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl)); - default_path->pPerf = &This->IDirectMusicPerformance8_iface; + *ppNewPath = NULL; /* Secondary buffer description */ memset(&format, 0, sizeof(format)); @@ -1064,33 +1059,29 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDire format.nAvgBytesPerSec *=2; break; default: - HeapFree(GetProcessHeap(), 0, default_path); - *ppNewPath = NULL; return E_INVALIDARG; } /* FIXME: Should we create one secondary buffer for each PChannel? */ hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL); - if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, default_path); - *ppNewPath = NULL; + if (FAILED(hr)) return DSERR_BUFFERLOST; - } - default_path->pDSBuffer = buffer; /* Update description for creating primary buffer */ desc.dwFlags |= DSBCAPS_PRIMARYBUFFER; desc.dwBufferBytes = 0; desc.lpwfxFormat = NULL; - hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL); + hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &primary_buffer, NULL); if (FAILED(hr)) { - IDirectSoundBuffer_Release(default_path->pDSBuffer); - HeapFree(GetProcessHeap(), 0, default_path); - *ppNewPath = NULL; + IDirectSoundBuffer_Release(buffer); return DSERR_BUFFERLOST; } - default_path->pPrimary = buffer; + + create_dmaudiopath(&IID_IDirectMusicAudioPath, (void**)&pPath); + set_audiopath_perf_pointer(pPath, iface); + set_audiopath_dsound_buffer(pPath, buffer); + set_audiopath_primary_dsound_buffer(pPath, buffer); *ppNewPath = pPath; @@ -1105,15 +1096,15 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_SetDefaultAudioPath(IDirectMu IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface); FIXME("(%p, %p): semi-stub\n", This, pAudioPath); - if (NULL != This->pDefaultPath) { + + if (This->pDefaultPath) { IDirectMusicAudioPath_Release(This->pDefaultPath); - ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = NULL; This->pDefaultPath = NULL; } This->pDefaultPath = pAudioPath; - if (NULL != This->pDefaultPath) { + if (This->pDefaultPath) { IDirectMusicAudioPath_AddRef(This->pDefaultPath); - ((IDirectMusicAudioPathImpl*)This->pDefaultPath)->pPerf = &This->IDirectMusicPerformance8_iface; + set_audiopath_perf_pointer(This->pDefaultPath, iface); } return S_OK;