2003-07-22 00:10:14 +02:00
|
|
|
/* IDirectMusicSegment8 Implementation
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
2004-01-20 01:21:40 +01:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2004-05-12 00:18:43 +02:00
|
|
|
* Copyright (C) 2003-2004 Raphael Junqueira
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-05-30 12:54:07 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-04-08 23:42:00 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-22 00:10:14 +02:00
|
|
|
#include "dmime_private.h"
|
2015-06-15 01:18:57 +02:00
|
|
|
#include "dmobject.h"
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmime);
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
/*****************************************************************************
|
2004-01-20 01:21:40 +01:00
|
|
|
* IDirectMusicSegmentImpl implementation
|
2003-08-23 01:53:27 +02:00
|
|
|
*/
|
2014-06-09 13:27:04 +02:00
|
|
|
typedef struct IDirectMusicSegment8Impl {
|
|
|
|
IDirectMusicSegment8 IDirectMusicSegment8_iface;
|
2015-06-15 01:18:57 +02:00
|
|
|
struct dmobject dmobj;
|
2014-06-09 13:27:04 +02:00
|
|
|
LONG ref;
|
|
|
|
DMUS_IO_SEGMENT_HEADER header;
|
|
|
|
IDirectMusicGraph *pGraph;
|
|
|
|
struct list Tracks;
|
|
|
|
} IDirectMusicSegment8Impl;
|
|
|
|
|
2014-01-07 10:45:38 +01:00
|
|
|
static inline IDirectMusicSegment8Impl *impl_from_IDirectMusicSegment8(IDirectMusicSegment8 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicSegment8Impl, IDirectMusicSegment8_iface);
|
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_QueryInterface(IDirectMusicSegment8 *iface,
|
2014-01-07 10:56:25 +01:00
|
|
|
REFIID riid, void **ret_iface)
|
2014-01-07 10:37:48 +01:00
|
|
|
{
|
2014-01-07 10:56:25 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2017-06-28 08:50:51 +02:00
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
|
|
|
|
|
2014-01-07 10:56:25 +01:00
|
|
|
*ret_iface = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IDirectMusicSegment) ||
|
|
|
|
IsEqualIID(riid, &IID_IDirectMusicSegment2) ||
|
|
|
|
IsEqualIID (riid, &IID_IDirectMusicSegment8))
|
|
|
|
*ret_iface = iface;
|
|
|
|
else if (IsEqualIID (riid, &IID_IDirectMusicObject))
|
2015-06-15 01:18:57 +02:00
|
|
|
*ret_iface = &This->dmobj.IDirectMusicObject_iface;
|
2014-01-07 10:56:25 +01:00
|
|
|
else if (IsEqualIID (riid, &IID_IPersistStream))
|
2015-06-15 01:18:57 +02:00
|
|
|
*ret_iface = &This->dmobj.IPersistStream_iface;
|
2014-01-07 10:56:25 +01:00
|
|
|
else {
|
|
|
|
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ret_iface);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static ULONG WINAPI IDirectMusicSegment8Impl_AddRef(IDirectMusicSegment8 *iface)
|
|
|
|
{
|
2014-01-07 10:56:25 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static ULONG WINAPI IDirectMusicSegment8Impl_Release(IDirectMusicSegment8 *iface)
|
|
|
|
{
|
2014-01-07 10:56:25 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
DMIME_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetLength(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME *pmtLength)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pmtLength);
|
|
|
|
if (NULL == pmtLength) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
*pmtLength = This->header.mtLength;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetLength(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME mtLength)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
TRACE("(%p, %d)\n", This, mtLength);
|
2004-05-10 21:56:17 +02:00
|
|
|
This->header.mtLength = mtLength;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetRepeats(IDirectMusicSegment8 *iface,
|
|
|
|
DWORD *pdwRepeats)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pdwRepeats);
|
|
|
|
if (NULL == pdwRepeats) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
*pdwRepeats = This->header.dwRepeats;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetRepeats(IDirectMusicSegment8 *iface,
|
|
|
|
DWORD dwRepeats)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %d)\n", This, dwRepeats);
|
2004-05-10 21:56:17 +02:00
|
|
|
This->header.dwRepeats = dwRepeats;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetDefaultResolution(IDirectMusicSegment8 *iface,
|
|
|
|
DWORD *pdwResolution)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pdwResolution);
|
|
|
|
if (NULL == pdwResolution) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
*pdwResolution = This->header.dwResolution;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetDefaultResolution(IDirectMusicSegment8 *iface,
|
|
|
|
DWORD dwResolution)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %d)\n", This, dwResolution);
|
2004-05-10 21:56:17 +02:00
|
|
|
This->header.dwResolution = dwResolution;
|
|
|
|
return S_OK;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetTrack(IDirectMusicSegment8 *iface,
|
|
|
|
REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, IDirectMusicTrack **ppTrack)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-17 21:48:49 +02:00
|
|
|
CLSID pIt_clsid;
|
|
|
|
struct list* pEntry = NULL;
|
|
|
|
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL;
|
|
|
|
IPersistStream* pCLSIDStream = NULL;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %s, %d, 0x%x, %p)\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, ppTrack);
|
2004-05-17 21:48:49 +02:00
|
|
|
|
|
|
|
if (NULL == ppTrack) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH (pEntry, &This->Tracks) {
|
|
|
|
pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_SEGMENT_TRACK, entry);
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE(" - %p -> 0x%x,%p\n", pIt, pIt->dwGroupBits, pIt->pTrack);
|
2004-05-17 21:48:49 +02:00
|
|
|
if (0xFFFFFFFF != dwGroupBits && 0 == (pIt->dwGroupBits & dwGroupBits)) continue ;
|
|
|
|
if (FALSE == IsEqualGUID(&GUID_NULL, rguidType)) {
|
|
|
|
/**
|
2014-04-30 15:42:10 +02:00
|
|
|
* it rguidType is not null we must check if CLSIDs are equal
|
2008-03-27 18:57:17 +01:00
|
|
|
* and the unique way to get it is using IPersistStream Interface
|
2004-05-17 21:48:49 +02:00
|
|
|
*/
|
|
|
|
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 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetTrackGroup(IDirectMusicSegment8 *iface,
|
|
|
|
IDirectMusicTrack *pTrack, DWORD *pdwGroupBits)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-17 21:48:49 +02: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-10 01:07:26 +02:00
|
|
|
TRACE(" - %p -> %d,%p\n", pIt, pIt->dwGroupBits, pIt->pTrack);
|
2004-05-17 21:48:49 +02:00
|
|
|
if (NULL != pIt && pIt->pTrack == pTrack) {
|
|
|
|
*pdwGroupBits = pIt->dwGroupBits;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DMUS_E_NOT_FOUND;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_InsertTrack(IDirectMusicSegment8 *iface,
|
|
|
|
IDirectMusicTrack *pTrack, DWORD dwGroupBits)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-14 23:36:15 +02:00
|
|
|
DWORD i = 0;
|
2004-05-17 21:48:49 +02:00
|
|
|
struct list* pEntry = NULL;
|
2004-05-14 23:36:15 +02:00
|
|
|
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL;
|
2004-05-17 21:48:49 +02:00
|
|
|
LPDMUS_PRIVATE_SEGMENT_TRACK pNewSegTrack = NULL;
|
2004-05-14 23:36:15 +02:00
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %p, %d)\n", This, pTrack, dwGroupBits);
|
2004-05-14 23:36:15 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH (pEntry, &This->Tracks) {
|
|
|
|
i++;
|
|
|
|
pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_SEGMENT_TRACK, entry);
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE(" - #%u: %p -> %d,%p\n", i, pIt, pIt->dwGroupBits, pIt->pTrack);
|
2004-05-14 23:36:15 +02: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));
|
2013-02-08 10:51:54 +01:00
|
|
|
if (NULL == pNewSegTrack)
|
2004-05-14 23:36:15 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2013-02-08 10:51:54 +01:00
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
pNewSegTrack->dwGroupBits = dwGroupBits;
|
|
|
|
pNewSegTrack->pTrack = pTrack;
|
2005-07-26 20:32:53 +02:00
|
|
|
IDirectMusicTrack_Init(pTrack, (IDirectMusicSegment *)iface);
|
2004-05-14 23:36:15 +02:00
|
|
|
IDirectMusicTrack_AddRef(pTrack);
|
|
|
|
list_add_tail (&This->Tracks, &pNewSegTrack->entry);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_RemoveTrack(IDirectMusicSegment8 *iface,
|
|
|
|
IDirectMusicTrack *pTrack)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-17 21:48:49 +02:00
|
|
|
struct list* pEntry = NULL;
|
2004-05-14 23:36:15 +02:00
|
|
|
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL;
|
|
|
|
|
2004-05-17 21:48:49 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pTrack);
|
2004-05-14 23:36:15 +02: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 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_InitPlay(IDirectMusicSegment8 *iface,
|
|
|
|
IDirectMusicSegmentState **ppSegState, IDirectMusicPerformance *pPerformance, DWORD dwFlags)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
HRESULT hr;
|
2014-01-07 10:45:38 +01:00
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %p, %p, %d): semi-stub\n", This, ppSegState, pPerformance, dwFlags);
|
2004-05-10 21:56:17 +02:00
|
|
|
if (NULL == ppSegState) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
2014-01-10 10:41:27 +01:00
|
|
|
hr = create_dmsegmentstate(&IID_IDirectMusicSegmentState,(void**) ppSegState);
|
2004-05-10 21:56:17 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
/* TODO: DMUS_SEGF_FLAGS */
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetGraph(IDirectMusicSegment8 *iface,
|
|
|
|
IDirectMusicGraph **ppGraph)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
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
|
|
|
|
* "...The segment object implements IDirectMusicGraph directly..."
|
|
|
|
*/
|
|
|
|
*ppGraph = This->pGraph;
|
|
|
|
IDirectMusicGraph_AddRef(This->pGraph);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetGraph(IDirectMusicSegment8 *iface,
|
|
|
|
IDirectMusicGraph *pGraph)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
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 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_AddNotificationType(IDirectMusicSegment8 *iface,
|
|
|
|
REFGUID rguidNotificationType)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-17 21:48:49 +02:00
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_RemoveNotificationType(IDirectMusicSegment8 *iface,
|
|
|
|
REFGUID rguidNotificationType)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-17 21:48:49 +02:00
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetParam(IDirectMusicSegment8 *iface,
|
|
|
|
REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME *pmtNext,
|
|
|
|
void *pParam)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2004-05-17 21:48:49 +02:00
|
|
|
CLSID pIt_clsid;
|
|
|
|
struct list* pEntry = NULL;
|
|
|
|
IDirectMusicTrack* pTrack = NULL;
|
|
|
|
IPersistStream* pCLSIDStream = NULL;
|
|
|
|
LPDMUS_PRIVATE_SEGMENT_TRACK pIt = NULL;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %s, 0x%x, %d, %d, %p, %p)\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
|
2004-05-17 21:48:49 +02:00
|
|
|
|
|
|
|
if (DMUS_SEG_ANYTRACK == dwIndex) {
|
|
|
|
|
|
|
|
LIST_FOR_EACH (pEntry, &This->Tracks) {
|
|
|
|
pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_SEGMENT_TRACK, entry);
|
|
|
|
|
2009-12-11 00:04:40 +01:00
|
|
|
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 ;
|
|
|
|
}
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE(" - %p -> 0x%x,%p\n", pIt, pIt->dwGroupBits, pIt->pTrack);
|
2004-05-17 21:48:49 +02: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;
|
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
hr = IDirectMusicSegment8Impl_GetTrack(iface, &GUID_NULL, dwGroupBits, dwIndex, &pTrack);
|
2004-05-17 21:48:49 +02:00
|
|
|
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 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetParam(IDirectMusicSegment8 *iface,
|
|
|
|
REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void *pParam)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %s, %d, %d, %d, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
|
2004-05-17 21:48:49 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_Clone(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicSegment **ppSegment)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppSegment);
|
2004-05-17 21:48:49 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetStartPoint(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME mtStart)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
TRACE("(%p, %d)\n", This, mtStart);
|
2004-05-10 21:56:17 +02:00
|
|
|
if (mtStart >= This->header.mtLength) {
|
|
|
|
return DMUS_E_OUT_OF_RANGE;
|
|
|
|
}
|
|
|
|
This->header.mtPlayStart = mtStart;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetStartPoint(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME *pmtStart)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pmtStart);
|
|
|
|
if (NULL == pmtStart) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
*pmtStart = This->header.mtPlayStart;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetLoopPoints(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME mtStart, MUSIC_TIME mtEnd)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
TRACE("(%p, %d, %d)\n", This, mtStart, mtEnd);
|
2004-05-10 21:56:17 +02:00
|
|
|
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 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetLoopPoints(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME *pmtStart, MUSIC_TIME *pmtEnd)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
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 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetPChannelsUsed(IDirectMusicSegment8 *iface,
|
|
|
|
DWORD dwNumPChannels, DWORD *paPChannels)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwNumPChannels, paPChannels);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_SetTrackConfig(IDirectMusicSegment8 *iface,
|
|
|
|
REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn,
|
|
|
|
DWORD dwFlagsOff)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %s, %d, %d, %d, %d): stub\n", This, debugstr_dmguid(rguidTrackClassID), dwGroupBits, dwIndex, dwFlagsOn, dwFlagsOff);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_GetAudioPathConfig(IDirectMusicSegment8 *iface,
|
|
|
|
IUnknown **ppAudioPathConfig)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, ppAudioPathConfig);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_Compose(IDirectMusicSegment8 *iface,
|
|
|
|
MUSIC_TIME mtTime, IDirectMusicSegment *pFromSegment, IDirectMusicSegment *pToSegment,
|
|
|
|
IDirectMusicSegment **ppComposedSegment)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %d, %p, %p, %p): stub\n", This, mtTime, pFromSegment, pToSegment, ppComposedSegment);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_Download(IDirectMusicSegment8 *iface,
|
|
|
|
IUnknown *pAudioPath)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, pAudioPath);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:37:48 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSegment8Impl_Unload(IDirectMusicSegment8 *iface,
|
|
|
|
IUnknown *pAudioPath)
|
|
|
|
{
|
2014-01-07 10:45:38 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, pAudioPath);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 10:45:38 +01:00
|
|
|
static const IDirectMusicSegment8Vtbl dmsegment8_vtbl = {
|
2014-01-07 10:37:48 +01:00
|
|
|
IDirectMusicSegment8Impl_QueryInterface,
|
|
|
|
IDirectMusicSegment8Impl_AddRef,
|
|
|
|
IDirectMusicSegment8Impl_Release,
|
|
|
|
IDirectMusicSegment8Impl_GetLength,
|
|
|
|
IDirectMusicSegment8Impl_SetLength,
|
|
|
|
IDirectMusicSegment8Impl_GetRepeats,
|
|
|
|
IDirectMusicSegment8Impl_SetRepeats,
|
|
|
|
IDirectMusicSegment8Impl_GetDefaultResolution,
|
|
|
|
IDirectMusicSegment8Impl_SetDefaultResolution,
|
|
|
|
IDirectMusicSegment8Impl_GetTrack,
|
|
|
|
IDirectMusicSegment8Impl_GetTrackGroup,
|
|
|
|
IDirectMusicSegment8Impl_InsertTrack,
|
|
|
|
IDirectMusicSegment8Impl_RemoveTrack,
|
|
|
|
IDirectMusicSegment8Impl_InitPlay,
|
|
|
|
IDirectMusicSegment8Impl_GetGraph,
|
|
|
|
IDirectMusicSegment8Impl_SetGraph,
|
|
|
|
IDirectMusicSegment8Impl_AddNotificationType,
|
|
|
|
IDirectMusicSegment8Impl_RemoveNotificationType,
|
|
|
|
IDirectMusicSegment8Impl_GetParam,
|
|
|
|
IDirectMusicSegment8Impl_SetParam,
|
|
|
|
IDirectMusicSegment8Impl_Clone,
|
|
|
|
IDirectMusicSegment8Impl_SetStartPoint,
|
|
|
|
IDirectMusicSegment8Impl_GetStartPoint,
|
|
|
|
IDirectMusicSegment8Impl_SetLoopPoints,
|
|
|
|
IDirectMusicSegment8Impl_GetLoopPoints,
|
|
|
|
IDirectMusicSegment8Impl_SetPChannelsUsed,
|
|
|
|
IDirectMusicSegment8Impl_SetTrackConfig,
|
|
|
|
IDirectMusicSegment8Impl_GetAudioPathConfig,
|
|
|
|
IDirectMusicSegment8Impl_Compose,
|
|
|
|
IDirectMusicSegment8Impl_Download,
|
|
|
|
IDirectMusicSegment8Impl_Unload
|
2003-04-08 23:42:00 +02:00
|
|
|
};
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicSegment8Impl IDirectMusicObject part: */
|
2018-03-11 22:20:40 +01:00
|
|
|
static HRESULT WINAPI seg_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface,
|
|
|
|
IStream *stream, DMUS_OBJECTDESC *desc)
|
|
|
|
{
|
|
|
|
struct chunk_entry riff = {0};
|
|
|
|
DWORD supported = DMUS_OBJ_OBJECT | DMUS_OBJ_VERSION;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", iface, stream, desc);
|
|
|
|
|
|
|
|
if (!stream || !desc)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if ((hr = stream_get_chunk(stream, &riff)) != S_OK)
|
|
|
|
return hr;
|
|
|
|
if (riff.id != FOURCC_RIFF || !(riff.type == DMUS_FOURCC_SEGMENT_FORM ||
|
|
|
|
riff.type == mmioFOURCC('W','A','V','E'))) {
|
|
|
|
TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
|
|
|
|
stream_skip_chunk(stream, &riff);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (riff.type == DMUS_FOURCC_SEGMENT_FORM)
|
|
|
|
supported |= DMUS_OBJ_NAME | DMUS_OBJ_CATEGORY;
|
|
|
|
else
|
|
|
|
supported |= DMUS_OBJ_NAME_INFO;
|
|
|
|
hr = dmobj_parsedescriptor(stream, &riff, desc, supported);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
desc->guidClass = CLSID_DirectMusicSegment;
|
|
|
|
desc->dwValidData |= DMUS_OBJ_CLASS;
|
|
|
|
|
2019-09-30 20:35:59 +02:00
|
|
|
dump_DMUS_OBJECTDESC(desc);
|
2018-03-11 22:20:40 +01:00
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2015-06-15 01:18:57 +02:00
|
|
|
static const IDirectMusicObjectVtbl dmobject_vtbl = {
|
|
|
|
dmobj_IDirectMusicObject_QueryInterface,
|
|
|
|
dmobj_IDirectMusicObject_AddRef,
|
|
|
|
dmobj_IDirectMusicObject_Release,
|
|
|
|
dmobj_IDirectMusicObject_GetDescriptor,
|
|
|
|
dmobj_IDirectMusicObject_SetDescriptor,
|
2018-03-11 22:20:40 +01:00
|
|
|
seg_IDirectMusicObject_ParseDescriptor
|
2004-01-20 01:21:40 +01:00
|
|
|
};
|
2003-08-23 01:53:27 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicSegment8Impl IPersistStream part: */
|
2018-07-11 23:44:36 +02:00
|
|
|
static HRESULT parse_track_form(IDirectMusicSegment8Impl *This, IStream *stream,
|
|
|
|
const struct chunk_entry *riff)
|
|
|
|
{
|
|
|
|
struct chunk_entry chunk = {.parent = riff};
|
|
|
|
IDirectMusicTrack *track = NULL;
|
|
|
|
IPersistStream *ps = NULL;
|
|
|
|
IStream *clone;
|
|
|
|
DMUS_IO_TRACK_HEADER thdr;
|
|
|
|
HRESULT hr;
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
TRACE("Parsing track form in %p: %s\n", stream, debugstr_chunk(riff));
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
/* First chunk must be the track header */
|
|
|
|
if (FAILED(hr = stream_get_chunk(stream, &chunk)))
|
|
|
|
return hr;
|
|
|
|
if (chunk.id != DMUS_FOURCC_TRACK_CHUNK)
|
|
|
|
return DMUS_E_TRACK_HDR_NOT_FIRST_CK;
|
|
|
|
if (FAILED(hr = stream_chunk_get_data(stream, &chunk, &thdr, sizeof(thdr))))
|
|
|
|
return hr;
|
|
|
|
TRACE("Found DMUS_IO_TRACK_HEADER\n");
|
|
|
|
TRACE("\tclass: %s\n", debugstr_guid (&thdr.guidClassID));
|
|
|
|
TRACE("\tdwGroup: %d\n", thdr.dwGroup);
|
|
|
|
TRACE("\tckid: %s\n", debugstr_fourcc (thdr.ckid));
|
|
|
|
TRACE("\tfccType: %s\n", debugstr_fourcc (thdr.fccType));
|
|
|
|
|
|
|
|
if (!!thdr.ckid == !!thdr.fccType) {
|
|
|
|
WARN("One and only one of the ckid (%s) and fccType (%s) need to be set\n",
|
|
|
|
debugstr_fourcc(thdr.ckid), debugstr_fourcc(thdr.fccType));
|
|
|
|
return DMUS_E_INVALID_TRACK_HDR;
|
2004-05-05 03:32:55 +02:00
|
|
|
}
|
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
/* Optional chunks */
|
|
|
|
while ((hr = stream_next_chunk(stream, &chunk)) == S_OK) {
|
|
|
|
if ((thdr.ckid && chunk.id == thdr.ckid) ||
|
|
|
|
(!thdr.ckid && (chunk.id == FOURCC_LIST || chunk.id == FOURCC_RIFF) &&
|
|
|
|
chunk.type == thdr.fccType))
|
|
|
|
break;
|
2004-05-11 06:27:23 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
if (chunk.id == DMUS_FOURCC_TRACK_EXTRAS_CHUNK)
|
|
|
|
FIXME("DMUS_IO_TRACK_EXTRAS_HEADER chunk not handled\n");
|
2004-05-05 03:32:55 +02:00
|
|
|
}
|
2018-07-11 23:44:36 +02:00
|
|
|
if (hr != S_OK)
|
|
|
|
return hr == S_FALSE ? DMUS_E_TRACK_NOT_FOUND : hr;
|
2004-05-11 06:27:23 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
/* Some DirectMusicTrack implementation expect the stream to start with their data chunk */
|
|
|
|
if (FAILED(hr = IStream_Clone(stream, &clone)))
|
|
|
|
return hr;
|
|
|
|
stream_reset_chunk_start(clone, &chunk);
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
/* Load the track */
|
|
|
|
hr = CoCreateInstance(&thdr.guidClassID, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicTrack,
|
|
|
|
(void **)&track);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
hr = IDirectMusicTrack_QueryInterface(track, &IID_IPersistStream, (void **)&ps);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
hr = IPersistStream_Load(ps, clone);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
hr = IDirectMusicSegment8_InsertTrack(&This->IDirectMusicSegment8_iface, track, thdr.dwGroup);
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
done:
|
|
|
|
if (ps)
|
|
|
|
IPersistStream_Release(ps);
|
|
|
|
if (track)
|
|
|
|
IDirectMusicTrack_Release(track);
|
|
|
|
IStream_Release(clone);
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:44:36 +02:00
|
|
|
return hr;
|
2004-05-05 03:32:55 +02:00
|
|
|
}
|
|
|
|
|
2018-07-11 23:43:28 +02:00
|
|
|
static HRESULT parse_track_list(IDirectMusicSegment8Impl *This, IStream *stream,
|
|
|
|
const struct chunk_entry *trkl)
|
2015-06-15 01:14:47 +02:00
|
|
|
{
|
2018-07-11 23:43:28 +02:00
|
|
|
struct chunk_entry chunk = {.parent = trkl};
|
|
|
|
HRESULT hr;
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:43:28 +02:00
|
|
|
TRACE("Parsing track list in %p: %s\n", stream, debugstr_chunk(trkl));
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:43:28 +02:00
|
|
|
while ((hr = stream_next_chunk(stream, &chunk)) == S_OK)
|
|
|
|
if (chunk.id == FOURCC_RIFF && chunk.type == DMUS_FOURCC_TRACK_FORM)
|
2018-07-11 23:44:36 +02:00
|
|
|
hr = parse_track_form(This, stream, &chunk);
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-07-11 23:43:28 +02:00
|
|
|
return SUCCEEDED(hr) ? S_OK : hr;
|
2004-05-05 03:32:55 +02:00
|
|
|
}
|
|
|
|
|
2018-03-16 01:32:26 +01:00
|
|
|
static inline void dump_segment_header(DMUS_IO_SEGMENT_HEADER *h, DWORD size)
|
|
|
|
{
|
|
|
|
unsigned int dx = 9;
|
|
|
|
|
|
|
|
if (size == offsetof(DMUS_IO_SEGMENT_HEADER, rtLength))
|
|
|
|
dx = 7;
|
|
|
|
else if (size == offsetof(DMUS_IO_SEGMENT_HEADER, rtLoopStart))
|
|
|
|
dx = 8;
|
|
|
|
TRACE("Found DirectX%d DMUS_IO_SEGMENT_HEADER\n", dx);
|
|
|
|
TRACE("\tdwRepeats: %u\n", h->dwRepeats);
|
|
|
|
TRACE("\tmtLength: %u\n", h->mtLength);
|
|
|
|
TRACE("\tmtPlayStart: %u\n", h->mtPlayStart);
|
|
|
|
TRACE("\tmtLoopStart: %u\n", h->mtLoopStart);
|
|
|
|
TRACE("\tmtLoopEnd: %u\n", h->mtLoopEnd);
|
|
|
|
TRACE("\tdwResolution: %u\n", h->dwResolution);
|
|
|
|
if (dx >= 8) {
|
|
|
|
TRACE("\trtLength: %s\n", wine_dbgstr_longlong(h->rtLength));
|
|
|
|
TRACE("\tdwFlags: %u\n", h->dwFlags);
|
|
|
|
TRACE("\tdwReserved: %u\n", h->dwReserved);
|
|
|
|
}
|
|
|
|
if (dx == 9) {
|
|
|
|
TRACE("\trtLoopStart: %s\n", wine_dbgstr_longlong(h->rtLoopStart));
|
|
|
|
TRACE("\trtLoopEnd: %s\n", wine_dbgstr_longlong(h->rtLoopEnd));
|
|
|
|
TRACE("\trtPlayStart: %s\n", wine_dbgstr_longlong(h->rtPlayStart));
|
|
|
|
}
|
|
|
|
}
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2018-03-16 01:32:26 +01:00
|
|
|
static HRESULT parse_segment_form(IDirectMusicSegment8Impl *This, IStream *stream,
|
|
|
|
const struct chunk_entry *riff)
|
|
|
|
{
|
|
|
|
struct chunk_entry chunk = {.parent = riff};
|
|
|
|
HRESULT hr;
|
2015-06-15 01:18:57 +02:00
|
|
|
|
2018-03-16 01:32:26 +01:00
|
|
|
TRACE("Parsing segment form in %p: %s\n", stream, debugstr_chunk(riff));
|
|
|
|
|
|
|
|
while ((hr = stream_next_chunk(stream, &chunk)) == S_OK) {
|
|
|
|
switch (chunk.id) {
|
|
|
|
case DMUS_FOURCC_SEGMENT_CHUNK:
|
|
|
|
/* DX7, DX8 and DX9 structure sizes */
|
|
|
|
if (chunk.size != offsetof(DMUS_IO_SEGMENT_HEADER, rtLength) &&
|
|
|
|
chunk.size != offsetof(DMUS_IO_SEGMENT_HEADER, rtLoopStart) &&
|
|
|
|
chunk.size != sizeof(DMUS_IO_SEGMENT_HEADER)) {
|
|
|
|
WARN("Invalid size of %s\n", debugstr_chunk(&chunk));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (FAILED(hr = stream_chunk_get_data(stream, &chunk, &This->header, chunk.size))) {
|
|
|
|
WARN("Failed to read data of %s\n", debugstr_chunk(&chunk));
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
dump_segment_header(&This->header, chunk.size);
|
|
|
|
break;
|
|
|
|
case FOURCC_LIST:
|
|
|
|
if (chunk.type == DMUS_FOURCC_TRACK_LIST)
|
2018-07-11 23:43:28 +02:00
|
|
|
if (FAILED(hr = parse_track_list(This, stream, &chunk)))
|
2018-03-16 01:32:26 +01:00
|
|
|
return hr;
|
|
|
|
break;
|
|
|
|
case FOURCC_RIFF:
|
2018-04-18 03:27:03 +02:00
|
|
|
FIXME("Loading of embedded RIFF form %s\n", debugstr_fourcc(chunk.type));
|
2018-03-16 01:32:26 +01:00
|
|
|
break;
|
|
|
|
}
|
2004-05-05 03:32:55 +02:00
|
|
|
}
|
|
|
|
|
2018-03-16 01:32:26 +01:00
|
|
|
return SUCCEEDED(hr) ? S_OK : hr;
|
2004-05-05 03:32:55 +02:00
|
|
|
}
|
|
|
|
|
2015-06-15 01:18:57 +02:00
|
|
|
static inline IDirectMusicSegment8Impl *impl_from_IPersistStream(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicSegment8Impl, dmobj.IPersistStream_iface);
|
|
|
|
}
|
2008-04-15 22:33:30 +02:00
|
|
|
|
2018-03-16 01:32:24 +01:00
|
|
|
static HRESULT WINAPI seg_IPersistStream_Load(IPersistStream *iface, IStream *stream)
|
2015-06-15 01:18:57 +02:00
|
|
|
{
|
2018-03-16 01:32:24 +01:00
|
|
|
IDirectMusicSegment8Impl *This = impl_from_IPersistStream(iface);
|
|
|
|
struct chunk_entry riff = {0};
|
|
|
|
HRESULT hr;
|
2008-04-15 22:33:30 +02:00
|
|
|
|
2018-03-16 01:32:24 +01:00
|
|
|
TRACE("(%p, %p): Loading\n", This, stream);
|
|
|
|
|
|
|
|
if (!stream)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2018-07-16 23:39:01 +02:00
|
|
|
if (stream_get_chunk(stream, &riff) != S_OK ||
|
|
|
|
(riff.id != FOURCC_RIFF && riff.id != mmioFOURCC('M','T','h','d')))
|
2018-03-16 01:32:24 +01:00
|
|
|
return DMUS_E_UNSUPPORTED_STREAM;
|
|
|
|
stream_reset_chunk_start(stream, &riff);
|
2018-07-16 23:39:01 +02:00
|
|
|
|
|
|
|
if (riff.id == mmioFOURCC('M','T','h','d')) {
|
|
|
|
FIXME("MIDI file loading not supported\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-03-16 01:32:24 +01:00
|
|
|
hr = IDirectMusicObject_ParseDescriptor(&This->dmobj.IDirectMusicObject_iface, stream,
|
|
|
|
&This->dmobj.desc);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
stream_reset_chunk_data(stream, &riff);
|
|
|
|
|
|
|
|
if (riff.type == DMUS_FOURCC_SEGMENT_FORM)
|
2018-03-16 01:32:26 +01:00
|
|
|
hr = parse_segment_form(This, stream, &riff);
|
2018-03-16 01:32:24 +01:00
|
|
|
else {
|
|
|
|
FIXME("WAVE form loading not implemented\n");
|
|
|
|
hr = S_OK;
|
2004-05-05 03:32:55 +02:00
|
|
|
}
|
2018-03-16 01:32:24 +01:00
|
|
|
|
|
|
|
return hr;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2015-06-15 01:18:57 +02:00
|
|
|
static const IPersistStreamVtbl persiststream_vtbl = {
|
|
|
|
dmobj_IPersistStream_QueryInterface,
|
|
|
|
dmobj_IPersistStream_AddRef,
|
|
|
|
dmobj_IPersistStream_Release,
|
|
|
|
dmobj_IPersistStream_GetClassID,
|
|
|
|
unimpl_IPersistStream_IsDirty,
|
2017-07-05 11:26:38 +02:00
|
|
|
seg_IPersistStream_Load,
|
2015-06-15 01:18:57 +02:00
|
|
|
unimpl_IPersistStream_Save,
|
|
|
|
unimpl_IPersistStream_GetSizeMax
|
2003-08-23 01:53:27 +02:00
|
|
|
};
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
/* for ClassFactory */
|
2014-01-10 10:41:27 +01:00
|
|
|
HRESULT WINAPI create_dmsegment(REFIID lpcGUID, void **ppobj)
|
|
|
|
{
|
2004-05-05 03:32:55 +02:00
|
|
|
IDirectMusicSegment8Impl* obj;
|
2014-01-07 10:56:25 +01:00
|
|
|
HRESULT hr;
|
2012-04-06 00:15:24 +02:00
|
|
|
|
2004-05-05 03:32:55 +02:00
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSegment8Impl));
|
|
|
|
if (NULL == obj) {
|
2004-12-22 16:13:20 +01:00
|
|
|
*ppobj = NULL;
|
2004-05-05 03:32:55 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2014-01-07 10:45:38 +01:00
|
|
|
obj->IDirectMusicSegment8_iface.lpVtbl = &dmsegment8_vtbl;
|
2014-01-07 10:56:25 +01:00
|
|
|
obj->ref = 1;
|
2015-06-15 01:18:57 +02:00
|
|
|
dmobject_init(&obj->dmobj, &CLSID_DirectMusicSegment,
|
|
|
|
(IUnknown *)&obj->IDirectMusicSegment8_iface);
|
|
|
|
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
|
|
|
|
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
|
2004-05-14 23:36:15 +02:00
|
|
|
list_init (&obj->Tracks);
|
2008-02-23 16:19:10 +01:00
|
|
|
|
2014-01-07 10:56:25 +01:00
|
|
|
DMIME_LockModule();
|
|
|
|
hr = IDirectMusicSegment8_QueryInterface(&obj->IDirectMusicSegment8_iface, lpcGUID, ppobj);
|
|
|
|
IDirectMusicSegment8_Release(&obj->IDirectMusicSegment8_iface);
|
|
|
|
|
|
|
|
return hr;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|