2003-07-21 22:10:14 +00:00
/* IDirectMusicSegment8 Implementation
2003-04-08 21:42:00 +00:00
*
2004-01-20 00:21:40 +00:00
* Copyright ( C ) 2003 - 2004 Rok Mandeljc
2004-05-11 22:18:43 +00:00
* Copyright ( C ) 2003 - 2004 Raphael Junqueira
2003-04-08 21:42:00 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Library General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2006-05-18 12:49:52 +00:00
* Foundation , Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2003-04-08 21:42:00 +00:00
*/
2003-07-21 22:10:14 +00:00
# include "dmime_private.h"
2003-04-08 21:42:00 +00:00
2003-08-22 23:53:27 +00:00
WINE_DEFAULT_DEBUG_CHANNEL ( dmime ) ;
WINE_DECLARE_DEBUG_CHANNEL ( dmfile ) ;
2003-04-08 21:42:00 +00:00
2003-08-22 23:53:27 +00:00
/*****************************************************************************
2004-01-20 00:21:40 +00:00
* IDirectMusicSegmentImpl implementation
2003-08-22 23:53:27 +00:00
*/
2004-01-20 00:21:40 +00:00
/* IDirectMusicSegment IUnknown part: */
2005-06-21 09:44:28 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IUnknown_QueryInterface ( LPUNKNOWN iface , REFIID riid , LPVOID * ppobj ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , UnknownVtbl , iface ) ;
2004-02-25 01:30:03 +00:00
TRACE ( " (%p, %s, %p) \n " , This , debugstr_dmguid ( riid ) , ppobj ) ;
2004-01-20 00:21:40 +00:00
if ( IsEqualIID ( riid , & IID_IUnknown ) ) {
* ppobj = ( LPVOID ) & This - > UnknownVtbl ;
2005-06-21 09:44:28 +00:00
IUnknown_AddRef ( iface ) ;
2004-01-20 00:21:40 +00:00
return S_OK ;
} else if ( IsEqualIID ( riid , & IID_IDirectMusicSegment )
| | IsEqualIID ( riid , & IID_IDirectMusicSegment2 )
| | IsEqualIID ( riid , & IID_IDirectMusicSegment8 ) ) {
* ppobj = ( LPVOID ) & This - > SegmentVtbl ;
2005-06-21 09:44:28 +00:00
IUnknown_AddRef ( iface ) ;
2004-01-20 00:21:40 +00:00
return S_OK ;
} else if ( IsEqualIID ( riid , & IID_IDirectMusicObject ) ) {
* ppobj = ( LPVOID ) & This - > ObjectVtbl ;
2005-06-21 09:44:28 +00:00
IUnknown_AddRef ( iface ) ;
2004-01-20 00:21:40 +00:00
return S_OK ;
} else if ( IsEqualIID ( riid , & IID_IPersistStream ) ) {
* ppobj = ( LPVOID ) & This - > PersistStreamVtbl ;
2005-06-21 09:44:28 +00:00
IUnknown_AddRef ( iface ) ;
2003-06-07 00:39:18 +00:00
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2003-08-22 23:53:27 +00:00
2004-02-25 01:30:03 +00:00
WARN ( " (%p, %s, %p): not found \n " , This , debugstr_dmguid ( riid ) , ppobj ) ;
2003-04-08 21:42:00 +00:00
return E_NOINTERFACE ;
}
2005-06-21 09:44:28 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IUnknown_AddRef ( LPUNKNOWN iface ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , UnknownVtbl , iface ) ;
2005-01-11 16:02:21 +00:00
ULONG ref = InterlockedIncrement ( & This - > ref ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " (%p): AddRef from %d \n " , This , ref - 1 ) ;
2005-01-11 16:02:21 +00:00
2005-02-02 09:31:06 +00:00
DMIME_LockModule ( ) ;
2005-01-11 16:02:21 +00:00
return ref ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IUnknown_Release ( LPUNKNOWN iface ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , UnknownVtbl , iface ) ;
2005-01-11 16:02:21 +00:00
ULONG ref = InterlockedDecrement ( & This - > ref ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " (%p): ReleaseRef to %d \n " , This , ref ) ;
2005-02-02 09:31:06 +00:00
2003-08-22 23:53:27 +00:00
if ( ref = = 0 ) {
2003-04-08 21:42:00 +00:00
HeapFree ( GetProcessHeap ( ) , 0 , This ) ;
}
2005-02-02 09:31:06 +00:00
DMIME_UnlockModule ( ) ;
2003-04-08 21:42:00 +00:00
return ref ;
}
2005-05-30 10:01:08 +00:00
static const IUnknownVtbl DirectMusicSegment8_Unknown_Vtbl = {
2004-05-10 19:56:17 +00:00
IDirectMusicSegment8Impl_IUnknown_QueryInterface ,
IDirectMusicSegment8Impl_IUnknown_AddRef ,
IDirectMusicSegment8Impl_IUnknown_Release
2004-01-20 00:21:40 +00:00
} ;
2003-06-07 00:39:18 +00:00
2004-01-20 00:21:40 +00:00
/* IDirectMusicSegmentImpl IDirectMusicSegment part: */
2005-06-21 09:44:28 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_QueryInterface ( LPDIRECTMUSICSEGMENT8 iface , REFIID riid , LPVOID * ppobj ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_QueryInterface ( ( LPUNKNOWN ) & This - > UnknownVtbl , riid , ppobj ) ;
2003-04-08 21:42:00 +00:00
}
2005-06-21 09:44:28 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_AddRef ( LPDIRECTMUSICSEGMENT8 iface ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_AddRef ( ( LPUNKNOWN ) & This - > UnknownVtbl ) ;
2004-01-20 00:21:40 +00:00
}
2003-06-07 00:39:18 +00:00
2005-06-20 16:01:04 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_Release ( LPDIRECTMUSICSEGMENT8 iface ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_Release ( ( LPUNKNOWN ) & This - > UnknownVtbl ) ;
2004-01-20 00:21:40 +00:00
}
2003-06-07 00:39:18 +00:00
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLength ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME * pmtLength ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %p) \n " , This , pmtLength ) ;
if ( NULL = = pmtLength ) {
return E_POINTER ;
}
* pmtLength = This - > header . mtLength ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLength ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME mtLength ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %ld) \n " , This , mtLength ) ;
This - > header . mtLength = mtLength ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetRepeats ( LPDIRECTMUSICSEGMENT8 iface , DWORD * pdwRepeats ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %p) \n " , This , pdwRepeats ) ;
if ( NULL = = pdwRepeats ) {
return E_POINTER ;
}
* pdwRepeats = This - > header . dwRepeats ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetRepeats ( LPDIRECTMUSICSEGMENT8 iface , DWORD dwRepeats ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " (%p, %d) \n " , This , dwRepeats ) ;
2004-05-10 19:56:17 +00:00
This - > header . dwRepeats = dwRepeats ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetDefaultResolution ( LPDIRECTMUSICSEGMENT8 iface , DWORD * pdwResolution ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %p) \n " , This , pdwResolution ) ;
if ( NULL = = pdwResolution ) {
return E_POINTER ;
}
* pdwResolution = This - > header . dwResolution ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetDefaultResolution ( LPDIRECTMUSICSEGMENT8 iface , DWORD dwResolution ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " (%p, %d) \n " , This , dwResolution ) ;
2004-05-10 19:56:17 +00:00
This - > header . dwResolution = dwResolution ;
return S_OK ;
2004-01-20 00:21:40 +00:00
}
2003-06-07 00:39:18 +00:00
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrack ( LPDIRECTMUSICSEGMENT8 iface , REFGUID rguidType , DWORD dwGroupBits , DWORD dwIndex , IDirectMusicTrack * * ppTrack ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2004-05-17 19:48:49 +00:00
CLSID pIt_clsid ;
struct list * pEntry = NULL ;
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL ;
IPersistStream * pCLSIDStream = NULL ;
HRESULT hr = S_OK ;
2006-10-09 23:07:26 +00:00
TRACE ( " (%p, %s, %d, 0x%x, %p) \n " , This , debugstr_dmguid ( rguidType ) , dwGroupBits , dwIndex , ppTrack ) ;
2004-05-17 19:48:49 +00:00
if ( NULL = = ppTrack ) {
return E_POINTER ;
}
LIST_FOR_EACH ( pEntry , & This - > Tracks ) {
pIt = LIST_ENTRY ( pEntry , DMUS_PRIVATE_SEGMENT_TRACK , entry ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " - %p -> 0x%x,%p \n " , pIt , pIt - > dwGroupBits , pIt - > pTrack ) ;
2004-05-17 19:48:49 +00:00
if ( 0xFFFFFFFF ! = dwGroupBits & & 0 = = ( pIt - > dwGroupBits & dwGroupBits ) ) continue ;
if ( FALSE = = IsEqualGUID ( & GUID_NULL , rguidType ) ) {
/**
* it rguidType is not null we must check if CLSID are equals
* and the unqiue way to get it its using IPersistStream Interface
*/
hr = IDirectMusicTrack_QueryInterface ( pIt - > pTrack , & IID_IPersistStream , ( void * * ) & pCLSIDStream ) ;
if ( FAILED ( hr ) ) {
ERR ( " (%p): object %p don't implement IPersistStream Interface. Expect a crash (critical problem) \n " , This , pIt - > pTrack ) ;
continue ;
}
hr = IPersistStream_GetClassID ( pCLSIDStream , & pIt_clsid ) ;
IPersistStream_Release ( pCLSIDStream ) ; pCLSIDStream = NULL ;
if ( FAILED ( hr ) ) {
ERR ( " (%p): non-implemented GetClassID for object %p \n " , This , pIt - > pTrack ) ;
continue ;
}
TRACE ( " - %p -> %s \n " , pIt , debugstr_dmguid ( & pIt_clsid ) ) ;
if ( FALSE = = IsEqualGUID ( & pIt_clsid , rguidType ) ) continue ;
}
if ( 0 = = dwIndex ) {
* ppTrack = pIt - > pTrack ;
IDirectMusicTrack_AddRef ( * ppTrack ) ;
return S_OK ;
}
- - dwIndex ;
}
return DMUS_E_NOT_FOUND ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrackGroup ( LPDIRECTMUSICSEGMENT8 iface , IDirectMusicTrack * pTrack , DWORD * pdwGroupBits ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2004-05-17 19:48:49 +00:00
struct list * pEntry = NULL ;
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL ;
TRACE ( " (%p, %p, %p) \n " , This , pTrack , pdwGroupBits ) ;
if ( NULL = = pdwGroupBits ) {
return E_POINTER ;
}
LIST_FOR_EACH ( pEntry , & This - > Tracks ) {
pIt = LIST_ENTRY ( pEntry , DMUS_PRIVATE_SEGMENT_TRACK , entry ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " - %p -> %d,%p \n " , pIt , pIt - > dwGroupBits , pIt - > pTrack ) ;
2004-05-17 19:48:49 +00:00
if ( NULL ! = pIt & & pIt - > pTrack = = pTrack ) {
* pdwGroupBits = pIt - > dwGroupBits ;
return S_OK ;
}
}
return DMUS_E_NOT_FOUND ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack ( LPDIRECTMUSICSEGMENT8 iface , IDirectMusicTrack * pTrack , DWORD dwGroupBits ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2004-05-14 21:36:15 +00:00
DWORD i = 0 ;
2004-05-17 19:48:49 +00:00
struct list * pEntry = NULL ;
2004-05-14 21:36:15 +00:00
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL ;
2004-05-17 19:48:49 +00:00
LPDMUS_PRIVATE_SEGMENT_TRACK pNewSegTrack = NULL ;
2004-05-14 21:36:15 +00:00
2006-10-09 23:07:26 +00:00
TRACE ( " (%p, %p, %d) \n " , This , pTrack , dwGroupBits ) ;
2004-05-14 21:36:15 +00:00
LIST_FOR_EACH ( pEntry , & This - > Tracks ) {
i + + ;
pIt = LIST_ENTRY ( pEntry , DMUS_PRIVATE_SEGMENT_TRACK , entry ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " - #%u: %p -> %d,%p \n " , i , pIt , pIt - > dwGroupBits , pIt - > pTrack ) ;
2004-05-14 21:36:15 +00:00
if ( NULL ! = pIt & & pIt - > pTrack = = pTrack ) {
ERR ( " (%p, %p): track is already in list \n " , This , pTrack ) ;
return E_FAIL ;
}
}
pNewSegTrack = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( DMUS_PRIVATE_SEGMENT_TRACK ) ) ;
if ( NULL = = pNewSegTrack ) {
ERR ( " : no more memory \n " ) ;
return E_OUTOFMEMORY ;
}
pNewSegTrack - > dwGroupBits = dwGroupBits ;
pNewSegTrack - > pTrack = pTrack ;
2005-07-26 18:32:53 +00:00
IDirectMusicTrack_Init ( pTrack , ( IDirectMusicSegment * ) iface ) ;
2004-05-14 21:36:15 +00:00
IDirectMusicTrack_AddRef ( pTrack ) ;
list_add_tail ( & This - > Tracks , & pNewSegTrack - > entry ) ;
2004-05-10 19:56:17 +00:00
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveTrack ( LPDIRECTMUSICSEGMENT8 iface , IDirectMusicTrack * pTrack ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2004-05-14 21:36:15 +00:00
2004-05-17 19:48:49 +00:00
struct list * pEntry = NULL ;
2004-05-14 21:36:15 +00:00
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL ;
2004-05-17 19:48:49 +00:00
TRACE ( " (%p, %p) \n " , This , pTrack ) ;
2004-05-14 21:36:15 +00:00
LIST_FOR_EACH ( pEntry , & This - > Tracks ) {
pIt = LIST_ENTRY ( pEntry , DMUS_PRIVATE_SEGMENT_TRACK , entry ) ;
if ( pIt - > pTrack = = pTrack ) {
TRACE ( " (%p, %p): track in list \n " , This , pTrack ) ;
list_remove ( & pIt - > entry ) ;
IDirectMusicTrack_Init ( pIt - > pTrack , NULL ) ;
IDirectMusicTrack_Release ( pIt - > pTrack ) ;
HeapFree ( GetProcessHeap ( ) , 0 , pIt ) ;
return S_OK ;
}
}
return S_FALSE ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_InitPlay ( LPDIRECTMUSICSEGMENT8 iface , IDirectMusicSegmentState * * ppSegState , IDirectMusicPerformance * pPerformance , DWORD dwFlags ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
HRESULT hr ;
2006-10-09 23:07:26 +00:00
FIXME ( " (%p, %p, %p, %d): semi-stub \n " , This , ppSegState , pPerformance , dwFlags ) ;
2004-05-10 19:56:17 +00:00
if ( NULL = = ppSegState ) {
return E_POINTER ;
}
hr = DMUSIC_CreateDirectMusicSegmentStateImpl ( & IID_IDirectMusicSegmentState , ( void * * ) ppSegState , NULL ) ;
if ( FAILED ( hr ) ) {
return hr ;
}
/* TODO: DMUS_SEGF_FLAGS */
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetGraph ( LPDIRECTMUSICSEGMENT8 iface , IDirectMusicGraph * * ppGraph ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
FIXME ( " (%p, %p): semi-stub \n " , This , ppGraph ) ;
if ( NULL = = ppGraph ) {
return E_POINTER ;
}
if ( NULL = = This - > pGraph ) {
return DMUS_E_NOT_FOUND ;
}
/**
* should return This , as seen in msdn
* http : //msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/idirectmusicsegment8getgraph.asp
* " ...The segment object implements IDirectMusicGraph directly... "
*/
* ppGraph = This - > pGraph ;
IDirectMusicGraph_AddRef ( This - > pGraph ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetGraph ( LPDIRECTMUSICSEGMENT8 iface , IDirectMusicGraph * pGraph ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
FIXME ( " (%p, %p): to complete \n " , This , pGraph ) ;
if ( NULL ! = This - > pGraph ) {
IDirectMusicGraph_Release ( This - > pGraph ) ;
}
This - > pGraph = pGraph ;
if ( NULL ! = This - > pGraph ) {
IDirectMusicGraph_AddRef ( This - > pGraph ) ;
}
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_AddNotificationType ( LPDIRECTMUSICSEGMENT8 iface , REFGUID rguidNotificationType ) {
2004-05-17 19:48:49 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
FIXME ( " (%p, %s): stub \n " , This , debugstr_dmguid ( rguidNotificationType ) ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveNotificationType ( LPDIRECTMUSICSEGMENT8 iface , REFGUID rguidNotificationType ) {
2004-05-17 19:48:49 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
FIXME ( " (%p, %s): stub \n " , This , debugstr_dmguid ( rguidNotificationType ) ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetParam ( LPDIRECTMUSICSEGMENT8 iface , REFGUID rguidType , DWORD dwGroupBits , DWORD dwIndex , MUSIC_TIME mtTime , MUSIC_TIME * pmtNext , void * pParam ) {
2004-05-17 19:48:49 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
CLSID pIt_clsid ;
struct list * pEntry = NULL ;
IDirectMusicTrack * pTrack = NULL ;
IPersistStream * pCLSIDStream = NULL ;
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL ;
HRESULT hr = S_OK ;
2006-10-09 23:07:26 +00:00
FIXME ( " (%p, %s, 0x%x, %d, %ld, %p, %p) \n " , This , debugstr_dmguid ( rguidType ) , dwGroupBits , dwIndex , mtTime , pmtNext , pParam ) ;
2004-05-17 19:48:49 +00:00
if ( DMUS_SEG_ANYTRACK = = dwIndex ) {
LIST_FOR_EACH ( pEntry , & This - > Tracks ) {
pIt = LIST_ENTRY ( pEntry , DMUS_PRIVATE_SEGMENT_TRACK , entry ) ;
2006-10-09 23:07:26 +00:00
TRACE ( " - %p -> 0x%x,%p \n " , pIt , pIt - > dwGroupBits , pIt - > pTrack ) ;
2004-05-17 19:48:49 +00:00
if ( 0xFFFFFFFF ! = dwGroupBits & & 0 = = ( pIt - > dwGroupBits & dwGroupBits ) ) continue ;
hr = IPersistStream_GetClassID ( pCLSIDStream , & pIt_clsid ) ;
IPersistStream_Release ( pCLSIDStream ) ; pCLSIDStream = NULL ;
if ( FAILED ( hr ) ) {
ERR ( " (%p): non-implemented GetClassID for object %p \n " , This , pIt - > pTrack ) ;
continue ;
}
if ( FALSE = = IsEqualGUID ( & pIt_clsid , rguidType ) ) continue ;
if ( FAILED ( IDirectMusicTrack_IsParamSupported ( pIt - > pTrack , rguidType ) ) ) continue ;
hr = IDirectMusicTrack_GetParam ( pIt - > pTrack , rguidType , mtTime , pmtNext , pParam ) ;
if ( SUCCEEDED ( hr ) ) return hr ;
}
ERR ( " (%p): not found \n " , This ) ;
return DMUS_E_TRACK_NOT_FOUND ;
}
hr = IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrack ( iface , & GUID_NULL , dwGroupBits , dwIndex , & pTrack ) ;
if ( FAILED ( hr ) ) {
ERR ( " (%p): not found \n " , This ) ;
return DMUS_E_TRACK_NOT_FOUND ;
}
hr = IDirectMusicTrack_GetParam ( pTrack , rguidType , mtTime , pmtNext , pParam ) ;
IDirectMusicTrack_Release ( pTrack ) ; pTrack = NULL ;
return hr ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetParam ( LPDIRECTMUSICSEGMENT8 iface , REFGUID rguidType , DWORD dwGroupBits , DWORD dwIndex , MUSIC_TIME mtTime , void * pParam ) {
2004-05-17 19:48:49 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2006-10-09 23:07:26 +00:00
FIXME ( " (%p, %s, %d, %d, %ld, %p): stub \n " , This , debugstr_dmguid ( rguidType ) , dwGroupBits , dwIndex , mtTime , pParam ) ;
2004-05-17 19:48:49 +00:00
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_Clone ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME mtStart , MUSIC_TIME mtEnd , IDirectMusicSegment * * ppSegment ) {
2004-05-17 19:48:49 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
FIXME ( " (%p, %ld, %ld, %p): stub \n " , This , mtStart , mtEnd , ppSegment ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetStartPoint ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME mtStart ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %ld) \n " , This , mtStart ) ;
if ( mtStart > = This - > header . mtLength ) {
return DMUS_E_OUT_OF_RANGE ;
}
This - > header . mtPlayStart = mtStart ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetStartPoint ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME * pmtStart ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %p) \n " , This , pmtStart ) ;
if ( NULL = = pmtStart ) {
return E_POINTER ;
}
* pmtStart = This - > header . mtPlayStart ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLoopPoints ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME mtStart , MUSIC_TIME mtEnd ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %ld, %ld) \n " , This , mtStart , mtEnd ) ;
if ( mtStart > = This - > header . mtLength | | mtEnd > This - > header . mtLength | | mtStart > mtEnd ) {
return DMUS_E_OUT_OF_RANGE ;
}
This - > header . mtLoopStart = mtStart ;
This - > header . mtLoopEnd = mtEnd ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLoopPoints ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME * pmtStart , MUSIC_TIME * pmtEnd ) {
2004-05-10 19:56:17 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
TRACE ( " (%p, %p, %p) \n " , This , pmtStart , pmtEnd ) ;
if ( NULL = = pmtStart | | NULL = = pmtEnd ) {
return E_POINTER ;
}
* pmtStart = This - > header . mtLoopStart ;
* pmtEnd = This - > header . mtLoopEnd ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetPChannelsUsed ( LPDIRECTMUSICSEGMENT8 iface , DWORD dwNumPChannels , DWORD * paPChannels ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2006-10-09 23:07:26 +00:00
FIXME ( " (%p, %d, %p): stub \n " , This , dwNumPChannels , paPChannels ) ;
2003-06-07 00:39:18 +00:00
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetTrackConfig ( LPDIRECTMUSICSEGMENT8 iface , REFGUID rguidTrackClassID , DWORD dwGroupBits , DWORD dwIndex , DWORD dwFlagsOn , DWORD dwFlagsOff ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2006-10-09 23:07:26 +00:00
FIXME ( " (%p, %s, %d, %d, %d, %d): stub \n " , This , debugstr_dmguid ( rguidTrackClassID ) , dwGroupBits , dwIndex , dwFlagsOn , dwFlagsOff ) ;
2003-06-07 00:39:18 +00:00
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetAudioPathConfig ( LPDIRECTMUSICSEGMENT8 iface , IUnknown * * ppAudioPathConfig ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2003-06-07 00:39:18 +00:00
FIXME ( " (%p, %p): stub \n " , This , ppAudioPathConfig ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_Compose ( LPDIRECTMUSICSEGMENT8 iface , MUSIC_TIME mtTime , IDirectMusicSegment * pFromSegment , IDirectMusicSegment * pToSegment , IDirectMusicSegment * * ppComposedSegment ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2003-06-07 00:39:18 +00:00
FIXME ( " (%p, %ld, %p, %p, %p): stub \n " , This , mtTime , pFromSegment , pToSegment , ppComposedSegment ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_Download ( LPDIRECTMUSICSEGMENT8 iface , IUnknown * pAudioPath ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2003-06-07 00:39:18 +00:00
FIXME ( " (%p, %p): stub \n " , This , pAudioPath ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_Unload ( LPDIRECTMUSICSEGMENT8 iface , IUnknown * pAudioPath ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , SegmentVtbl , iface ) ;
2003-06-07 00:39:18 +00:00
FIXME ( " (%p, %p): stub \n " , This , pAudioPath ) ;
return S_OK ;
2003-04-08 21:42:00 +00:00
}
2005-05-30 10:01:08 +00:00
static const IDirectMusicSegment8Vtbl DirectMusicSegment8_Segment_Vtbl = {
2004-01-20 00:21:40 +00:00
IDirectMusicSegment8Impl_IDirectMusicSegment8_QueryInterface ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_AddRef ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_Release ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLength ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLength ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetRepeats ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetRepeats ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetDefaultResolution ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetDefaultResolution ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrack ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrackGroup ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveTrack ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_InitPlay ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetGraph ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetGraph ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_AddNotificationType ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveNotificationType ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetParam ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetParam ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_Clone ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetStartPoint ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetStartPoint ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLoopPoints ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLoopPoints ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetPChannelsUsed ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetTrackConfig ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetAudioPathConfig ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_Compose ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_Download ,
IDirectMusicSegment8Impl_IDirectMusicSegment8_Unload
2003-04-08 21:42:00 +00:00
} ;
2004-01-20 00:21:40 +00:00
/* IDirectMusicSegment8Impl IDirectMusicObject part: */
2005-06-21 09:44:28 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_QueryInterface ( LPDIRECTMUSICOBJECT iface , REFIID riid , LPVOID * ppobj ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , ObjectVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_QueryInterface ( ( LPUNKNOWN ) & This - > UnknownVtbl , riid , ppobj ) ;
2003-08-22 23:53:27 +00:00
}
2005-06-21 09:44:28 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_AddRef ( LPDIRECTMUSICOBJECT iface ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , ObjectVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_AddRef ( ( LPUNKNOWN ) & This - > UnknownVtbl ) ;
2003-08-22 23:53:27 +00:00
}
2005-06-20 16:01:04 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_Release ( LPDIRECTMUSICOBJECT iface ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , ObjectVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_Release ( ( LPUNKNOWN ) & This - > UnknownVtbl ) ;
2003-08-22 23:53:27 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_GetDescriptor ( LPDIRECTMUSICOBJECT iface , LPDMUS_OBJECTDESC pDesc ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , ObjectVtbl , iface ) ;
2003-08-22 23:53:27 +00:00
TRACE ( " (%p, %p) \n " , This , pDesc ) ;
2004-01-20 00:21:40 +00:00
/* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
memcpy ( pDesc , This - > pDesc , This - > pDesc - > dwSize ) ;
2003-08-22 23:53:27 +00:00
return S_OK ;
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_SetDescriptor ( LPDIRECTMUSICOBJECT iface , LPDMUS_OBJECTDESC pDesc ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , ObjectVtbl , iface ) ;
2004-02-25 01:30:03 +00:00
TRACE ( " (%p, %p): setting descriptor: \n %s \n " , This , pDesc , debugstr_DMUS_OBJECTDESC ( pDesc ) ) ;
2004-01-20 00:21:40 +00:00
/* According to MSDN, we should copy only given values, not whole struct */
if ( pDesc - > dwValidData & DMUS_OBJ_OBJECT )
memcpy ( & This - > pDesc - > guidObject , & pDesc - > guidObject , sizeof ( pDesc - > guidObject ) ) ;
if ( pDesc - > dwValidData & DMUS_OBJ_CLASS )
memcpy ( & This - > pDesc - > guidClass , & pDesc - > guidClass , sizeof ( pDesc - > guidClass ) ) ;
if ( pDesc - > dwValidData & DMUS_OBJ_NAME )
2005-04-18 10:30:55 +00:00
lstrcpynW ( This - > pDesc - > wszName , pDesc - > wszName , DMUS_MAX_NAME ) ;
2004-01-20 00:21:40 +00:00
if ( pDesc - > dwValidData & DMUS_OBJ_CATEGORY )
2005-04-18 10:30:55 +00:00
lstrcpynW ( This - > pDesc - > wszCategory , pDesc - > wszCategory , DMUS_MAX_CATEGORY ) ;
2004-01-20 00:21:40 +00:00
if ( pDesc - > dwValidData & DMUS_OBJ_FILENAME )
2005-04-18 10:30:55 +00:00
lstrcpynW ( This - > pDesc - > wszFileName , pDesc - > wszFileName , DMUS_MAX_FILENAME ) ;
2004-01-20 00:21:40 +00:00
if ( pDesc - > dwValidData & DMUS_OBJ_VERSION )
memcpy ( & This - > pDesc - > vVersion , & pDesc - > vVersion , sizeof ( pDesc - > vVersion ) ) ;
if ( pDesc - > dwValidData & DMUS_OBJ_DATE )
memcpy ( & This - > pDesc - > ftDate , & pDesc - > ftDate , sizeof ( pDesc - > ftDate ) ) ;
if ( pDesc - > dwValidData & DMUS_OBJ_MEMORY ) {
memcpy ( & This - > pDesc - > llMemLength , & pDesc - > llMemLength , sizeof ( pDesc - > llMemLength ) ) ;
memcpy ( This - > pDesc - > pbMemData , pDesc - > pbMemData , sizeof ( pDesc - > pbMemData ) ) ;
}
if ( pDesc - > dwValidData & DMUS_OBJ_STREAM ) {
/* according to MSDN, we copy the stream */
IStream_Clone ( pDesc - > pStream , & This - > pDesc - > pStream ) ;
}
/* add new flags */
This - > pDesc - > dwValidData | = pDesc - > dwValidData ;
2003-08-22 23:53:27 +00:00
return S_OK ;
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicObject_ParseDescriptor ( LPDIRECTMUSICOBJECT iface , LPSTREAM pStream , LPDMUS_OBJECTDESC pDesc ) {
2004-01-20 00:21:40 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , ObjectVtbl , iface ) ;
DMUS_PRIVATE_CHUNK Chunk ;
DWORD StreamSize , StreamCount , ListSize [ 1 ] , ListCount [ 1 ] ;
LARGE_INTEGER liMove ; /* used when skipping chunks */
2003-08-22 23:53:27 +00:00
2004-01-20 00:21:40 +00:00
TRACE ( " (%p,%p, %p) \n " , This , pStream , pDesc ) ;
/* FIXME: should this be determined from stream? */
pDesc - > dwValidData | = DMUS_OBJ_CLASS ;
memcpy ( & pDesc - > guidClass , & CLSID_DirectMusicSegment , sizeof ( CLSID ) ) ;
2003-08-22 23:53:27 +00:00
2004-01-20 00:21:40 +00:00
IStream_Read ( pStream , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = 0x%04x) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-01-20 00:21:40 +00:00
switch ( Chunk . fccID ) {
case FOURCC_RIFF : {
IStream_Read ( pStream , & Chunk . fccID , sizeof ( FOURCC ) , NULL ) ;
TRACE_ ( dmfile ) ( " : RIFF chunk of type %s " , debugstr_fourcc ( Chunk . fccID ) ) ;
StreamSize = Chunk . dwSize - sizeof ( FOURCC ) ;
StreamCount = 0 ;
if ( Chunk . fccID = = DMUS_FOURCC_SEGMENT_FORM ) {
TRACE_ ( dmfile ) ( " : segment form \n " ) ;
do {
IStream_Read ( pStream , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
StreamCount + = sizeof ( FOURCC ) + sizeof ( DWORD ) + Chunk . dwSize ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = 0x%04x) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-01-20 00:21:40 +00:00
switch ( Chunk . fccID ) {
case DMUS_FOURCC_GUID_CHUNK : {
TRACE_ ( dmfile ) ( " : GUID chunk \n " ) ;
pDesc - > dwValidData | = DMUS_OBJ_OBJECT ;
IStream_Read ( pStream , & pDesc - > guidObject , Chunk . dwSize , NULL ) ;
break ;
}
case DMUS_FOURCC_VERSION_CHUNK : {
TRACE_ ( dmfile ) ( " : version chunk \n " ) ;
pDesc - > dwValidData | = DMUS_OBJ_VERSION ;
IStream_Read ( pStream , & pDesc - > vVersion , Chunk . dwSize , NULL ) ;
break ;
}
case DMUS_FOURCC_CATEGORY_CHUNK : {
TRACE_ ( dmfile ) ( " : category chunk \n " ) ;
pDesc - > dwValidData | = DMUS_OBJ_CATEGORY ;
IStream_Read ( pStream , pDesc - > wszCategory , Chunk . dwSize , NULL ) ;
break ;
}
case FOURCC_LIST : {
IStream_Read ( pStream , & Chunk . fccID , sizeof ( FOURCC ) , NULL ) ;
TRACE_ ( dmfile ) ( " : LIST chunk of type %s " , debugstr_fourcc ( Chunk . fccID ) ) ;
ListSize [ 0 ] = Chunk . dwSize - sizeof ( FOURCC ) ;
ListCount [ 0 ] = 0 ;
switch ( Chunk . fccID ) {
/* evil M$ UNFO list, which can (!?) contain INFO elements */
case DMUS_FOURCC_UNFO_LIST : {
TRACE_ ( dmfile ) ( " : UNFO list \n " ) ;
do {
IStream_Read ( pStream , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
ListCount [ 0 ] + = sizeof ( FOURCC ) + sizeof ( DWORD ) + Chunk . dwSize ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = 0x%04x) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-01-20 00:21:40 +00:00
switch ( Chunk . fccID ) {
/* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
2004-03-12 01:53:05 +00:00
( though strings seem to be valid unicode ) */
2004-01-20 00:21:40 +00:00
case mmioFOURCC ( ' I ' , ' N ' , ' A ' , ' M ' ) :
case DMUS_FOURCC_UNAM_CHUNK : {
TRACE_ ( dmfile ) ( " : name chunk \n " ) ;
pDesc - > dwValidData | = DMUS_OBJ_NAME ;
IStream_Read ( pStream , pDesc - > wszName , Chunk . dwSize , NULL ) ;
break ;
}
case mmioFOURCC ( ' I ' , ' A ' , ' R ' , ' T ' ) :
case DMUS_FOURCC_UART_CHUNK : {
TRACE_ ( dmfile ) ( " : artist chunk (ignored) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
case mmioFOURCC ( ' I ' , ' C ' , ' O ' , ' P ' ) :
case DMUS_FOURCC_UCOP_CHUNK : {
TRACE_ ( dmfile ) ( " : copyright chunk (ignored) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
case mmioFOURCC ( ' I ' , ' S ' , ' B ' , ' J ' ) :
case DMUS_FOURCC_USBJ_CHUNK : {
TRACE_ ( dmfile ) ( " : subject chunk (ignored) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
case mmioFOURCC ( ' I ' , ' C ' , ' M ' , ' T ' ) :
case DMUS_FOURCC_UCMT_CHUNK : {
TRACE_ ( dmfile ) ( " : comment chunk (ignored) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : ListCount[0] = %d < ListSize[0] = %d \n " , ListCount [ 0 ] , ListSize [ 0 ] ) ;
2004-01-20 00:21:40 +00:00
} while ( ListCount [ 0 ] < ListSize [ 0 ] ) ;
break ;
}
2004-03-12 01:53:05 +00:00
case DMUS_FOURCC_TRACK_LIST : {
TRACE_ ( dmfile ) ( " : TRACK list \n " ) ;
do {
IStream_Read ( pStream , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
ListCount [ 0 ] + = sizeof ( FOURCC ) + sizeof ( DWORD ) + Chunk . dwSize ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = %d) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-03-12 01:53:05 +00:00
switch ( Chunk . fccID ) {
default : {
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : ListCount[0] = %d < ListSize[0] = %d \n " , ListCount [ 0 ] , ListSize [ 0 ] ) ;
2004-03-12 01:53:05 +00:00
} while ( ListCount [ 0 ] < ListSize [ 0 ] ) ;
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unknown (skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize - sizeof ( FOURCC ) ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
2004-01-20 00:21:40 +00:00
}
}
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : StreamCount[0] = %d < StreamSize[0] = %d \n " , StreamCount , StreamSize ) ;
2004-01-20 00:21:40 +00:00
} while ( StreamCount < StreamSize ) ;
break ;
2004-03-12 01:53:05 +00:00
} else if ( Chunk . fccID = = mmioFOURCC ( ' W ' , ' A ' , ' V ' , ' E ' ) ) {
2004-05-05 01:32:55 +00:00
TRACE_ ( dmfile ) ( " : wave form (loading not yet implemented) \n " ) ;
2004-03-12 01:53:05 +00:00
liMove . QuadPart = StreamSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ; /* skip the rest of the chunk */
2004-01-20 00:21:40 +00:00
} else {
2004-05-05 01:32:55 +00:00
TRACE_ ( dmfile ) ( " : unexpected chunk (loading failed) \n " ) ;
2004-01-20 00:21:40 +00:00
liMove . QuadPart = StreamSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ; /* skip the rest of the chunk */
return E_FAIL ;
}
TRACE_ ( dmfile ) ( " : reading finished \n " ) ;
break ;
2003-08-22 23:53:27 +00:00
}
2004-01-20 00:21:40 +00:00
default : {
TRACE_ ( dmfile ) ( " : unexpected chunk; loading failed) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStream , liMove , STREAM_SEEK_CUR , NULL ) ; /* skip the rest of the chunk */
return DMUS_E_INVALIDFILE ;
}
}
2004-02-25 01:30:03 +00:00
TRACE ( " : returning descriptor: \n %s \n " , debugstr_DMUS_OBJECTDESC ( pDesc ) ) ;
2003-07-21 22:10:14 +00:00
2004-01-20 00:21:40 +00:00
return S_OK ;
2003-08-22 23:53:27 +00:00
}
2005-05-30 10:01:08 +00:00
static const IDirectMusicObjectVtbl DirectMusicSegment8_Object_Vtbl = {
2004-05-17 19:48:49 +00:00
IDirectMusicSegment8Impl_IDirectMusicObject_QueryInterface ,
IDirectMusicSegment8Impl_IDirectMusicObject_AddRef ,
IDirectMusicSegment8Impl_IDirectMusicObject_Release ,
IDirectMusicSegment8Impl_IDirectMusicObject_GetDescriptor ,
IDirectMusicSegment8Impl_IDirectMusicObject_SetDescriptor ,
IDirectMusicSegment8Impl_IDirectMusicObject_ParseDescriptor
2004-01-20 00:21:40 +00:00
} ;
2003-08-22 23:53:27 +00:00
2004-01-20 00:21:40 +00:00
/* IDirectMusicSegment8Impl IPersistStream part: */
2005-06-21 09:44:28 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_QueryInterface ( LPPERSISTSTREAM iface , REFIID riid , LPVOID * ppobj ) {
2004-05-05 01:32:55 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_QueryInterface ( ( LPUNKNOWN ) & This - > UnknownVtbl , riid , ppobj ) ;
2003-04-08 21:42:00 +00:00
}
2003-08-22 23:53:27 +00:00
2005-06-21 09:44:28 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IPersistStream_AddRef ( LPPERSISTSTREAM iface ) {
2004-05-05 01:32:55 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_AddRef ( ( LPUNKNOWN ) & This - > UnknownVtbl ) ;
2003-08-22 23:53:27 +00:00
}
2005-06-20 16:01:04 +00:00
static ULONG WINAPI IDirectMusicSegment8Impl_IPersistStream_Release ( LPPERSISTSTREAM iface ) {
2004-05-05 01:32:55 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
2005-06-21 09:44:28 +00:00
return IUnknown_Release ( ( LPUNKNOWN ) & This - > UnknownVtbl ) ;
2003-08-22 23:53:27 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_GetClassID ( LPPERSISTSTREAM iface , CLSID * pClassID ) {
2004-05-05 01:32:55 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
TRACE ( " (%p, %p) \n " , This , pClassID ) ;
2004-05-17 19:48:49 +00:00
memcpy ( pClassID , & CLSID_DirectMusicSegment , sizeof ( CLSID ) ) ;
2004-05-05 01:32:55 +00:00
return S_OK ;
2003-08-22 23:53:27 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_IsDirty ( LPPERSISTSTREAM iface ) {
2004-05-05 01:32:55 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
FIXME ( " (%p): stub, always S_FALSE \n " , This ) ;
return S_FALSE ;
2003-08-22 23:53:27 +00:00
}
2004-05-05 01:32:55 +00:00
static HRESULT IDirectMusicSegment8Impl_IPersistStream_LoadTrack ( LPPERSISTSTREAM iface , IStream * pClonedStream , IDirectMusicTrack * * ppTrack ,
DMUS_IO_TRACK_HEADER * pTrack_hdr ) {
2004-05-12 23:18:22 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
2004-05-05 01:32:55 +00:00
HRESULT hr = E_FAIL ;
IPersistStream * pPersistStream = NULL ;
hr = CoCreateInstance ( & pTrack_hdr - > guidClassID , NULL , CLSCTX_INPROC_SERVER , & IID_IDirectMusicTrack , ( LPVOID * ) ppTrack ) ;
if ( FAILED ( hr ) ) {
ERR ( " : could not create object \n " ) ;
return hr ;
}
/* acquire PersistStream interface */
hr = IDirectMusicTrack_QueryInterface ( * ppTrack , & IID_IPersistStream , ( LPVOID * ) & pPersistStream ) ;
if ( FAILED ( hr ) ) {
ERR ( " : could not acquire IPersistStream \n " ) ;
return hr ;
}
/* load */
hr = IPersistStream_Load ( pPersistStream , pClonedStream ) ;
if ( FAILED ( hr ) ) {
ERR ( " : failed to load object \n " ) ;
return hr ;
}
/* release all loading-related stuff */
IPersistStream_Release ( pPersistStream ) ;
2004-05-14 21:36:15 +00:00
hr = IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack ( ( LPDIRECTMUSICSEGMENT8 ) & This - > SegmentVtbl , * ppTrack , pTrack_hdr - > dwGroup ) ; /* at dsPosition */
2004-05-12 23:18:22 +00:00
if ( FAILED ( hr ) ) {
ERR ( " : could not insert track \n " ) ;
return hr ;
}
2004-05-05 01:32:55 +00:00
return S_OK ;
}
2004-05-12 23:18:22 +00:00
static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseTrackForm ( LPPERSISTSTREAM iface , DMUS_PRIVATE_CHUNK * pChunk , IStream * pStm ) {
2004-05-05 01:32:55 +00:00
2004-05-12 23:18:22 +00:00
/*ICOM_THIS_MULTI(IDirectMusicSegment8Impl, PersistStreamVtbl, iface);*/
2004-05-05 01:32:55 +00:00
HRESULT hr = E_FAIL ;
DMUS_PRIVATE_CHUNK Chunk ;
DWORD StreamSize , StreamCount , ListSize [ 3 ] , ListCount [ 3 ] ;
LARGE_INTEGER liMove ; /* used when skipping chunks */
DMUS_IO_TRACK_HEADER track_hdr ;
DMUS_IO_TRACK_EXTRAS_HEADER track_xhdr ;
IDirectMusicTrack * pTrack = NULL ;
if ( pChunk - > fccID ! = DMUS_FOURCC_TRACK_FORM ) {
ERR_ ( dmfile ) ( " : %s chunk should be a TRACK form \n " , debugstr_fourcc ( pChunk - > fccID ) ) ;
return E_FAIL ;
}
StreamSize = pChunk - > dwSize - sizeof ( FOURCC ) ;
StreamCount = 0 ;
do {
IStream_Read ( pStm , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
StreamCount + = sizeof ( FOURCC ) + sizeof ( DWORD ) + Chunk . dwSize ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = %d) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-05-05 01:32:55 +00:00
switch ( Chunk . fccID ) {
case DMUS_FOURCC_TRACK_CHUNK : {
TRACE_ ( dmfile ) ( " : track chunck \n " ) ;
IStream_Read ( pStm , & track_hdr , sizeof ( DMUS_IO_TRACK_HEADER ) , NULL ) ;
2004-05-11 22:18:43 +00:00
TRACE_ ( dmfile ) ( " - class: %s \n " , debugstr_guid ( & track_hdr . guidClassID ) ) ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " - dwGroup: %d \n " , track_hdr . dwGroup ) ;
2004-05-11 22:18:43 +00:00
TRACE_ ( dmfile ) ( " - ckid: %s \n " , debugstr_fourcc ( track_hdr . ckid ) ) ;
TRACE_ ( dmfile ) ( " - fccType: %s \n " , debugstr_fourcc ( track_hdr . fccType ) ) ;
2004-05-05 01:32:55 +00:00
break ;
}
case DMUS_FOURCC_TRACK_EXTRAS_CHUNK : {
TRACE_ ( dmfile ) ( " : track extras chunck \n " ) ;
IStream_Read ( pStm , & track_xhdr , sizeof ( DMUS_IO_TRACK_EXTRAS_HEADER ) , NULL ) ;
break ;
}
case DMUS_FOURCC_COMMANDTRACK_CHUNK : {
TRACE_ ( dmfile ) ( " : COMMANDTRACK track \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
case FOURCC_LIST : {
IStream_Read ( pStm , & Chunk . fccID , sizeof ( FOURCC ) , NULL ) ;
TRACE_ ( dmfile ) ( " : LIST chunk of type %s " , debugstr_fourcc ( Chunk . fccID ) ) ;
ListSize [ 0 ] = Chunk . dwSize - sizeof ( FOURCC ) ;
ListCount [ 0 ] = 0 ;
if ( Chunk . fccID = = track_hdr . fccType & & 0 = = track_hdr . ckid ) {
LPSTREAM pClonedStream = NULL ;
TRACE_ ( dmfile ) ( " : TRACK list \n " ) ;
IStream_Clone ( pStm , & pClonedStream ) ;
2004-05-11 04:27:23 +00:00
2004-05-05 01:32:55 +00:00
liMove . QuadPart = 0 ;
2004-05-11 04:27:23 +00:00
liMove . QuadPart - = sizeof ( FOURCC ) + ( sizeof ( FOURCC ) + sizeof ( DWORD ) ) ;
2004-05-05 01:32:55 +00:00
IStream_Seek ( pClonedStream , liMove , STREAM_SEEK_CUR , NULL ) ;
2004-05-11 04:27:23 +00:00
2004-05-05 01:32:55 +00:00
hr = IDirectMusicSegment8Impl_IPersistStream_LoadTrack ( iface , pClonedStream , & pTrack , & track_hdr ) ;
if ( FAILED ( hr ) ) {
ERR ( " : could not load track \n " ) ;
return hr ;
2003-08-22 23:53:27 +00:00
}
2004-05-12 23:18:22 +00:00
IStream_Release ( pClonedStream ) ;
2004-05-05 01:32:55 +00:00
IDirectMusicTrack_Release ( pTrack ) ; pTrack = NULL ; /* now we can release at as it inserted */
2004-05-11 04:27:23 +00:00
liMove . QuadPart = ListSize [ 0 ] ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
2004-05-05 01:32:55 +00:00
} else {
TRACE_ ( dmfile ) ( " : unknown (skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
}
break ;
}
2004-05-11 04:27:23 +00:00
2004-05-05 01:32:55 +00:00
case FOURCC_RIFF : {
IStream_Read ( pStm , & Chunk . fccID , sizeof ( FOURCC ) , NULL ) ;
2004-05-13 05:19:47 +00:00
TRACE_ ( dmfile ) ( " : RIFF chunk of type %s \n " , debugstr_fourcc ( Chunk . fccID ) ) ;
2004-05-11 04:27:23 +00:00
2004-05-05 01:32:55 +00:00
ListSize [ 0 ] = Chunk . dwSize - sizeof ( FOURCC ) ;
2004-05-11 04:27:23 +00:00
2004-05-05 01:32:55 +00:00
if ( Chunk . fccID = = track_hdr . fccType & & 0 = = track_hdr . ckid ) {
2004-05-11 04:27:23 +00:00
LPSTREAM pClonedStream = NULL ;
2004-05-05 01:32:55 +00:00
TRACE_ ( dmfile ) ( " : TRACK RIFF \n " ) ;
2004-05-11 04:27:23 +00:00
IStream_Clone ( pStm , & pClonedStream ) ;
liMove . QuadPart = 0 ;
2004-05-12 23:18:22 +00:00
liMove . QuadPart - = sizeof ( FOURCC ) + ( sizeof ( FOURCC ) + sizeof ( DWORD ) ) ;
2004-05-11 04:27:23 +00:00
IStream_Seek ( pClonedStream , liMove , STREAM_SEEK_CUR , NULL ) ;
2004-05-05 01:32:55 +00:00
2004-05-11 04:27:23 +00:00
hr = IDirectMusicSegment8Impl_IPersistStream_LoadTrack ( iface , pClonedStream , & pTrack , & track_hdr ) ;
if ( FAILED ( hr ) ) {
ERR ( " : could not load track \n " ) ;
return hr ;
}
IStream_Release ( pClonedStream ) ;
IDirectMusicTrack_Release ( pTrack ) ; pTrack = NULL ; /* now we can release at as it inserted */
/** now safe move the cursor */
liMove . QuadPart = ListSize [ 0 ] ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
2004-05-05 01:32:55 +00:00
} else {
2004-05-11 04:27:23 +00:00
TRACE_ ( dmfile ) ( " : unknown RIFF fmt (skipping) \n " ) ;
liMove . QuadPart = ListSize [ 0 ] ;
2004-05-05 01:32:55 +00:00
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
}
break ;
}
2004-05-11 04:27:23 +00:00
2004-05-05 01:32:55 +00:00
default : {
if ( 0 = = track_hdr . fccType & & Chunk . fccID = = track_hdr . ckid ) {
LPSTREAM pClonedStream = NULL ;
TRACE_ ( dmfile ) ( " : TRACK solo \n " ) ;
IStream_Clone ( pStm , & pClonedStream ) ;
liMove . QuadPart = 0 ;
liMove . QuadPart - = ( sizeof ( FOURCC ) + sizeof ( DWORD ) ) ;
IStream_Seek ( pClonedStream , liMove , STREAM_SEEK_CUR , NULL ) ;
hr = IDirectMusicSegment8Impl_IPersistStream_LoadTrack ( iface , pClonedStream , & pTrack , & track_hdr ) ;
if ( FAILED ( hr ) ) {
ERR ( " : could not load track \n " ) ;
return hr ;
}
IStream_Release ( pClonedStream ) ;
IDirectMusicTrack_Release ( pTrack ) ; pTrack = NULL ; /* now we can release at as it inserted */
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : StreamCount[0] = %d < StreamSize[0] = %d \n " , StreamCount , StreamSize ) ;
2004-05-05 01:32:55 +00:00
} while ( StreamCount < StreamSize ) ;
return S_OK ;
}
static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseTrackList ( LPPERSISTSTREAM iface , DMUS_PRIVATE_CHUNK * pChunk , IStream * pStm , IDirectMusicSegment8Impl * This ) {
HRESULT hr = E_FAIL ;
DMUS_PRIVATE_CHUNK Chunk ;
DWORD StreamSize , StreamCount , ListSize [ 3 ] , ListCount [ 3 ] ;
LARGE_INTEGER liMove ; /* used when skipping chunks */
if ( pChunk - > fccID ! = DMUS_FOURCC_TRACK_LIST ) {
ERR_ ( dmfile ) ( " : %s chunk should be a TRACK list \n " , debugstr_fourcc ( pChunk - > fccID ) ) ;
return E_FAIL ;
}
2004-05-11 04:27:23 +00:00
ListSize [ 0 ] = pChunk - > dwSize - sizeof ( FOURCC ) ;
2004-05-05 01:32:55 +00:00
ListCount [ 0 ] = 0 ;
do {
IStream_Read ( pStm , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
ListCount [ 0 ] + = sizeof ( FOURCC ) + sizeof ( DWORD ) + Chunk . dwSize ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = %d) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-05-05 01:32:55 +00:00
switch ( Chunk . fccID ) {
case FOURCC_RIFF : {
IStream_Read ( pStm , & Chunk . fccID , sizeof ( FOURCC ) , NULL ) ;
TRACE_ ( dmfile ) ( " : RIFF chunk of type %s " , debugstr_fourcc ( Chunk . fccID ) ) ;
StreamSize = Chunk . dwSize - sizeof ( FOURCC ) ;
StreamCount = 0 ;
switch ( Chunk . fccID ) {
case DMUS_FOURCC_TRACK_FORM : {
TRACE_ ( dmfile ) ( " : TRACK form \n " ) ;
2004-05-12 23:18:22 +00:00
hr = IDirectMusicSegment8Impl_IPersistStream_ParseTrackForm ( iface , & Chunk , pStm ) ;
2004-05-05 01:32:55 +00:00
if ( FAILED ( hr ) ) return hr ;
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = StreamSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : ListCount[0] = %d < ListSize[0] = %d \n " , ListCount [ 0 ] , ListSize [ 0 ] ) ;
2004-05-05 01:32:55 +00:00
} while ( ListCount [ 0 ] < ListSize [ 0 ] ) ;
return S_OK ;
}
static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm ( LPPERSISTSTREAM iface , DMUS_PRIVATE_CHUNK * pChunk , IStream * pStm , IDirectMusicSegment8Impl * This ) {
HRESULT hr = E_FAIL ;
DMUS_PRIVATE_CHUNK Chunk ;
DWORD StreamSize , StreamCount , ListSize [ 3 ] , ListCount [ 3 ] ;
LARGE_INTEGER liMove ; /* used when skipping chunks */
if ( pChunk - > fccID ! = DMUS_FOURCC_SEGMENT_FORM ) {
ERR_ ( dmfile ) ( " : %s chunk should be a segment form \n " , debugstr_fourcc ( pChunk - > fccID ) ) ;
return E_FAIL ;
}
StreamSize = pChunk - > dwSize - sizeof ( FOURCC ) ;
StreamCount = 0 ;
do {
IStream_Read ( pStm , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
StreamCount + = sizeof ( FOURCC ) + sizeof ( DWORD ) + Chunk . dwSize ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = %d) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-05-05 01:32:55 +00:00
2004-05-14 04:57:02 +00:00
hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric ( & Chunk , pStm , This - > pDesc ) ;
2004-05-05 01:32:55 +00:00
if ( FAILED ( hr ) ) return hr ;
if ( hr = = S_FALSE ) {
switch ( Chunk . fccID ) {
case DMUS_FOURCC_SEGMENT_CHUNK : {
2004-05-11 04:27:23 +00:00
DWORD checkSz = sizeof ( FOURCC ) ;
2004-05-12 23:18:22 +00:00
TRACE_ ( dmfile ) ( " : segment chunk \n " ) ;
2004-05-11 04:27:23 +00:00
# if 1
2004-05-10 19:56:17 +00:00
/** DX 7 */
IStream_Read ( pStm , & This - > header . dwRepeats , sizeof ( This - > header . dwRepeats ) , NULL ) ;
checkSz + = sizeof ( This - > header . dwRepeats ) ;
IStream_Read ( pStm , & This - > header . mtLength , sizeof ( This - > header . mtLength ) , NULL ) ;
checkSz + = sizeof ( This - > header . mtLength ) ;
IStream_Read ( pStm , & This - > header . mtPlayStart , sizeof ( This - > header . mtPlayStart ) , NULL ) ;
checkSz + = sizeof ( This - > header . mtPlayStart ) ;
IStream_Read ( pStm , & This - > header . mtLoopStart , sizeof ( This - > header . mtLoopStart ) , NULL ) ;
checkSz + = sizeof ( This - > header . mtLoopStart ) ;
IStream_Read ( pStm , & This - > header . mtLoopEnd , sizeof ( This - > header . mtLoopEnd ) , NULL ) ;
checkSz + = sizeof ( This - > header . mtLoopEnd ) ;
IStream_Read ( pStm , & This - > header . dwResolution , sizeof ( This - > header . dwResolution ) , NULL ) ;
checkSz + = sizeof ( This - > header . dwResolution ) ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " dwRepeats: %u \n " , This - > header . dwRepeats ) ;
2004-05-11 04:27:23 +00:00
TRACE_ ( dmfile ) ( " mtLength: %lu \n " , This - > header . mtLength ) ;
TRACE_ ( dmfile ) ( " mtPlayStart: %lu \n " , This - > header . mtPlayStart ) ;
TRACE_ ( dmfile ) ( " mtLoopStart: %lu \n " , This - > header . mtLoopStart ) ;
TRACE_ ( dmfile ) ( " mtLoopEnd: %lu \n " , This - > header . mtLoopEnd ) ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " dwResolution: %u \n " , This - > header . dwResolution ) ;
2004-05-10 19:56:17 +00:00
/** DX 8 */
if ( Chunk . dwSize > checkSz ) {
IStream_Read ( pStm , & This - > header . rtLength , sizeof ( This - > header . rtLength ) , NULL ) ;
checkSz + = sizeof ( This - > header . rtLength ) ;
IStream_Read ( pStm , & This - > header . dwFlags , sizeof ( This - > header . dwFlags ) , NULL ) ;
checkSz + = sizeof ( This - > header . dwFlags ) ;
}
/** DX 9 */
if ( Chunk . dwSize > checkSz ) {
IStream_Read ( pStm , & This - > header . rtLoopStart , sizeof ( This - > header . rtLoopStart ) , NULL ) ;
checkSz + = sizeof ( This - > header . rtLoopStart ) ;
IStream_Read ( pStm , & This - > header . rtLoopEnd , sizeof ( This - > header . rtLoopEnd ) , NULL ) ;
checkSz + = sizeof ( This - > header . rtLoopEnd ) ;
IStream_Read ( pStm , & This - > header . rtPlayStart , sizeof ( This - > header . rtPlayStart ) , NULL ) ;
checkSz + = sizeof ( This - > header . rtPlayStart ) ;
}
2004-05-11 04:27:23 +00:00
# endif
liMove . QuadPart = Chunk . dwSize - checkSz + sizeof ( FOURCC ) ;
2004-05-05 01:32:55 +00:00
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
case FOURCC_LIST : {
IStream_Read ( pStm , & Chunk . fccID , sizeof ( FOURCC ) , NULL ) ;
TRACE_ ( dmfile ) ( " : LIST chunk of type %s " , debugstr_fourcc ( Chunk . fccID ) ) ;
ListSize [ 0 ] = Chunk . dwSize - sizeof ( FOURCC ) ;
ListCount [ 0 ] = 0 ;
switch ( Chunk . fccID ) {
case DMUS_FOURCC_UNFO_LIST : {
TRACE_ ( dmfile ) ( " : UNFO list \n " ) ;
do {
IStream_Read ( pStm , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
ListCount [ 0 ] + = sizeof ( FOURCC ) + sizeof ( DWORD ) + Chunk . dwSize ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = %d) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-05-05 01:32:55 +00:00
2004-05-14 04:57:02 +00:00
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric ( & Chunk , pStm , This - > pDesc ) ;
2004-05-05 01:32:55 +00:00
if ( FAILED ( hr ) ) return hr ;
if ( hr = = S_FALSE ) {
switch ( Chunk . fccID ) {
default : {
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
}
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : ListCount[0] = %d < ListSize[0] = %d \n " , ListCount [ 0 ] , ListSize [ 0 ] ) ;
2004-05-05 01:32:55 +00:00
} while ( ListCount [ 0 ] < ListSize [ 0 ] ) ;
break ;
}
case DMUS_FOURCC_TRACK_LIST : {
TRACE_ ( dmfile ) ( " : TRACK list \n " ) ;
hr = IDirectMusicSegment8Impl_IPersistStream_ParseTrackList ( iface , & Chunk , pStm , This ) ;
if ( FAILED ( hr ) ) return hr ;
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unknown (skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize - sizeof ( FOURCC ) ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unknown chunk (irrevelant & skipping) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ;
break ;
}
}
}
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : StreamCount[0] = %d < StreamSize[0] = %d \n " , StreamCount , StreamSize ) ;
2004-05-05 01:32:55 +00:00
} while ( StreamCount < StreamSize ) ;
return S_OK ;
}
2004-05-27 01:54:59 +00:00
static HRESULT IDirectMusicSegment8Impl_IPersistStream_LoadWave ( LPPERSISTSTREAM iface , IStream * pClonedStream , IDirectMusicObject * * ppWaveObject ) {
HRESULT hr = E_FAIL ;
IPersistStream * pPersistStream = NULL ;
hr = CoCreateInstance ( & CLSID_DirectSoundWave , NULL , CLSCTX_INPROC_SERVER , & IID_IDirectMusicObject , ( LPVOID * ) ppWaveObject ) ;
if ( FAILED ( hr ) ) {
ERR ( " : could not create object \n " ) ;
return hr ;
}
/* acquire PersistStream interface */
2004-06-01 19:44:01 +00:00
hr = IDirectMusicObject_QueryInterface ( * ppWaveObject , & IID_IPersistStream , ( LPVOID * ) & pPersistStream ) ;
2004-05-27 01:54:59 +00:00
if ( FAILED ( hr ) ) {
ERR ( " : could not acquire IPersistStream \n " ) ;
return hr ;
}
/* load */
hr = IPersistStream_Load ( pPersistStream , pClonedStream ) ;
if ( FAILED ( hr ) ) {
ERR ( " : failed to load object \n " ) ;
return hr ;
}
/* release all loading-related stuff */
IPersistStream_Release ( pPersistStream ) ;
return S_OK ;
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_Load ( LPPERSISTSTREAM iface , IStream * pStm ) {
2004-05-05 01:32:55 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
HRESULT hr ;
DMUS_PRIVATE_CHUNK Chunk ;
DWORD StreamSize , StreamCount ;
/*DWORD ListSize[3], ListCount[3];*/
LARGE_INTEGER liMove ; /* used when skipping chunks */
2004-05-13 05:19:47 +00:00
TRACE ( " (%p, %p): Loading \n " , This , pStm ) ;
2004-05-05 01:32:55 +00:00
IStream_Read ( pStm , & Chunk , sizeof ( FOURCC ) + sizeof ( DWORD ) , NULL ) ;
2006-10-09 23:07:26 +00:00
TRACE_ ( dmfile ) ( " : %s chunk (size = %d) " , debugstr_fourcc ( Chunk . fccID ) , Chunk . dwSize ) ;
2004-05-05 01:32:55 +00:00
switch ( Chunk . fccID ) {
case FOURCC_RIFF : {
IStream_Read ( pStm , & Chunk . fccID , sizeof ( FOURCC ) , NULL ) ;
TRACE_ ( dmfile ) ( " : RIFF chunk of type %s " , debugstr_fourcc ( Chunk . fccID ) ) ;
StreamSize = Chunk . dwSize - sizeof ( FOURCC ) ;
StreamCount = 0 ;
switch ( Chunk . fccID ) {
case DMUS_FOURCC_SEGMENT_FORM : {
TRACE_ ( dmfile ) ( " : segment form \n " ) ;
hr = IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm ( iface , & Chunk , pStm , This ) ;
if ( FAILED ( hr ) ) return hr ;
break ;
}
case mmioFOURCC ( ' W ' , ' A ' , ' V ' , ' E ' ) : {
2004-05-27 01:54:59 +00:00
LPSTREAM pClonedStream = NULL ;
IDirectMusicObject * pWave = NULL ;
FIXME_ ( dmfile ) ( " : WAVE form (loading to be checked) \n " ) ;
IStream_Clone ( pStm , & pClonedStream ) ;
liMove . QuadPart = 0 ;
liMove . QuadPart - = sizeof ( FOURCC ) + ( sizeof ( FOURCC ) + sizeof ( DWORD ) ) ;
IStream_Seek ( pClonedStream , liMove , STREAM_SEEK_CUR , NULL ) ;
hr = IDirectMusicSegment8Impl_IPersistStream_LoadWave ( iface , pClonedStream , & pWave ) ;
if ( FAILED ( hr ) ) {
ERR ( " : could not load track \n " ) ;
return hr ;
}
IStream_Release ( pClonedStream ) ;
IDirectMusicTrack_Release ( pWave ) ; pWave = NULL ; /* now we can release at as it inserted */
2004-05-05 01:32:55 +00:00
liMove . QuadPart = StreamSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ; /* skip the rest of the chunk */
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unexpected chunk (loading failed) \n " ) ;
liMove . QuadPart = StreamSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ; /* skip the rest of the chunk */
return E_FAIL ;
}
}
TRACE_ ( dmfile ) ( " : reading finished \n " ) ;
break ;
}
default : {
TRACE_ ( dmfile ) ( " : unexpected chunk; loading failed) \n " ) ;
liMove . QuadPart = Chunk . dwSize ;
IStream_Seek ( pStm , liMove , STREAM_SEEK_CUR , NULL ) ; /* skip the rest of the chunk */
return E_FAIL ;
}
}
return S_OK ;
2003-08-22 23:53:27 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_Save ( LPPERSISTSTREAM iface , IStream * pStm , BOOL fClearDirty ) {
2004-05-17 19:48:49 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
FIXME ( " (%p): Saving not implemented yet \n " , This ) ;
2004-05-11 04:27:23 +00:00
return E_NOTIMPL ;
2003-08-22 23:53:27 +00:00
}
2005-06-20 16:01:04 +00:00
static HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_GetSizeMax ( LPPERSISTSTREAM iface , ULARGE_INTEGER * pcbSize ) {
2004-05-17 19:48:49 +00:00
ICOM_THIS_MULTI ( IDirectMusicSegment8Impl , PersistStreamVtbl , iface ) ;
FIXME ( " (%p, %p): stub \n " , This , pcbSize ) ;
2004-05-05 01:32:55 +00:00
return E_NOTIMPL ;
2003-08-22 23:53:27 +00:00
}
2005-05-30 10:01:08 +00:00
static const IPersistStreamVtbl DirectMusicSegment8_PersistStream_Vtbl = {
2004-05-05 01:32:55 +00:00
IDirectMusicSegment8Impl_IPersistStream_QueryInterface ,
IDirectMusicSegment8Impl_IPersistStream_AddRef ,
IDirectMusicSegment8Impl_IPersistStream_Release ,
IDirectMusicSegment8Impl_IPersistStream_GetClassID ,
IDirectMusicSegment8Impl_IPersistStream_IsDirty ,
IDirectMusicSegment8Impl_IPersistStream_Load ,
IDirectMusicSegment8Impl_IPersistStream_Save ,
IDirectMusicSegment8Impl_IPersistStream_GetSizeMax
2003-08-22 23:53:27 +00:00
} ;
2004-01-20 00:21:40 +00:00
/* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicSegmentImpl ( LPCGUID lpcGUID , LPVOID * ppobj , LPUNKNOWN pUnkOuter ) {
2004-05-05 01:32:55 +00:00
IDirectMusicSegment8Impl * obj ;
obj = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( IDirectMusicSegment8Impl ) ) ;
if ( NULL = = obj ) {
2004-12-22 15:13:20 +00:00
* ppobj = NULL ;
2004-05-05 01:32:55 +00:00
return E_OUTOFMEMORY ;
}
obj - > UnknownVtbl = & DirectMusicSegment8_Unknown_Vtbl ;
obj - > SegmentVtbl = & DirectMusicSegment8_Segment_Vtbl ;
obj - > ObjectVtbl = & DirectMusicSegment8_Object_Vtbl ;
obj - > PersistStreamVtbl = & DirectMusicSegment8_PersistStream_Vtbl ;
obj - > pDesc = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( DMUS_OBJECTDESC ) ) ;
DM_STRUCT_INIT ( obj - > pDesc ) ;
obj - > pDesc - > dwValidData | = DMUS_OBJ_CLASS ;
memcpy ( & obj - > pDesc - > guidClass , & CLSID_DirectMusicSegment , sizeof ( CLSID ) ) ;
obj - > ref = 0 ; /* will be inited by QueryInterface */
2004-05-14 21:36:15 +00:00
list_init ( & obj - > Tracks ) ;
2004-05-05 01:32:55 +00:00
return IDirectMusicSegment8Impl_IUnknown_QueryInterface ( ( LPUNKNOWN ) & obj - > UnknownVtbl , lpcGUID , ppobj ) ;
2004-01-20 00:21:40 +00:00
}