dmime: Reimplement IPersistStream_Load() for DMSegment.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bf7b21ec7b
commit
b73c4ec440
|
@ -40,6 +40,26 @@ HRESULT stream_chunk_get_data(IStream *stream, const struct chunk_entry *chunk,
|
||||||
HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, WCHAR *str,
|
HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, WCHAR *str,
|
||||||
ULONG size) DECLSPEC_HIDDEN;
|
ULONG size) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
static inline HRESULT stream_reset_chunk_data(IStream *stream, const struct chunk_entry *chunk)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER offset;
|
||||||
|
|
||||||
|
offset.QuadPart = chunk->offset.QuadPart + sizeof(FOURCC) + sizeof(DWORD);
|
||||||
|
if (chunk->id == FOURCC_RIFF || chunk->id == FOURCC_LIST)
|
||||||
|
offset.QuadPart += sizeof(FOURCC);
|
||||||
|
|
||||||
|
return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HRESULT stream_reset_chunk_start(IStream *stream, const struct chunk_entry *chunk)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER offset;
|
||||||
|
|
||||||
|
offset.QuadPart = chunk->offset.QuadPart;
|
||||||
|
|
||||||
|
return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
const char *debugstr_chunk(const struct chunk_entry *chunk) DECLSPEC_HIDDEN;
|
const char *debugstr_chunk(const struct chunk_entry *chunk) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -873,20 +873,14 @@ static HRESULT parse_track_list(IDirectMusicSegment8Impl *This, DMUS_PRIVATE_CHU
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT parse_segment_form(IDirectMusicSegment8Impl *This, DMUS_PRIVATE_CHUNK *pChunk,
|
static HRESULT parse_segment_form(IDirectMusicSegment8Impl *This, DWORD StreamSize, IStream *pStm)
|
||||||
IStream *pStm)
|
|
||||||
{
|
{
|
||||||
HRESULT hr = E_FAIL;
|
HRESULT hr = E_FAIL;
|
||||||
DMUS_PRIVATE_CHUNK Chunk;
|
DMUS_PRIVATE_CHUNK Chunk;
|
||||||
DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
|
DWORD StreamCount, ListSize[3], ListCount[3];
|
||||||
LARGE_INTEGER liMove; /* used when skipping chunks */
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
||||||
|
|
||||||
if (pChunk->fccID != DMUS_FOURCC_SEGMENT_FORM) {
|
StreamSize -= sizeof(FOURCC);
|
||||||
ERR_(dmfile)(": %s chunk should be a segment form\n", debugstr_fourcc (pChunk->fccID));
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
StreamSize = pChunk->dwSize - sizeof(FOURCC);
|
|
||||||
StreamCount = 0;
|
StreamCount = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -1006,57 +1000,35 @@ static inline IDirectMusicSegment8Impl *impl_from_IPersistStream(IPersistStream
|
||||||
return CONTAINING_RECORD(iface, IDirectMusicSegment8Impl, dmobj.IPersistStream_iface);
|
return CONTAINING_RECORD(iface, IDirectMusicSegment8Impl, dmobj.IPersistStream_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI seg_IPersistStream_Load(IPersistStream *iface, IStream *pStm)
|
static HRESULT WINAPI seg_IPersistStream_Load(IPersistStream *iface, IStream *stream)
|
||||||
{
|
{
|
||||||
IDirectMusicSegment8Impl *This = impl_from_IPersistStream(iface);
|
IDirectMusicSegment8Impl *This = impl_from_IPersistStream(iface);
|
||||||
HRESULT hr;
|
struct chunk_entry riff = {0};
|
||||||
DMUS_PRIVATE_CHUNK Chunk;
|
HRESULT hr;
|
||||||
DWORD StreamSize;
|
|
||||||
/*DWORD ListSize[3], ListCount[3];*/
|
|
||||||
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
||||||
|
|
||||||
TRACE("(%p, %p): Loading\n", This, pStm);
|
TRACE("(%p, %p): Loading\n", This, stream);
|
||||||
hr = IStream_Read (pStm, &Chunk, sizeof(Chunk), NULL);
|
|
||||||
if(hr != S_OK){
|
if (!stream)
|
||||||
WARN("IStream_Read failed: %08x\n", hr);
|
return E_POINTER;
|
||||||
return DMUS_E_UNSUPPORTED_STREAM;
|
|
||||||
}
|
if (stream_get_chunk(stream, &riff) != S_OK || riff.id != FOURCC_RIFF)
|
||||||
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
return DMUS_E_UNSUPPORTED_STREAM;
|
||||||
switch (Chunk.fccID) {
|
|
||||||
case FOURCC_RIFF: {
|
stream_reset_chunk_start(stream, &riff);
|
||||||
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
hr = IDirectMusicObject_ParseDescriptor(&This->dmobj.IDirectMusicObject_iface, stream,
|
||||||
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
&This->dmobj.desc);
|
||||||
StreamSize = Chunk.dwSize - sizeof(FOURCC);
|
if (FAILED(hr))
|
||||||
switch (Chunk.fccID) {
|
return hr;
|
||||||
case DMUS_FOURCC_SEGMENT_FORM: {
|
stream_reset_chunk_data(stream, &riff);
|
||||||
TRACE_(dmfile)(": segment form\n");
|
|
||||||
hr = parse_segment_form(This, &Chunk, pStm);
|
if (riff.type == DMUS_FOURCC_SEGMENT_FORM)
|
||||||
if (FAILED(hr)) return hr;
|
hr = parse_segment_form(This, riff.size, stream);
|
||||||
break;
|
else {
|
||||||
|
FIXME("WAVE form loading not implemented\n");
|
||||||
|
hr = S_OK;
|
||||||
}
|
}
|
||||||
case mmioFOURCC('W','A','V','E'): {
|
|
||||||
FIXME(": WAVE form loading not implemented\n");
|
return hr;
|
||||||
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 DMUS_E_UNSUPPORTED_STREAM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TRACE_(dmfile)(": reading finished\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
||||||
return DMUS_E_UNSUPPORTED_STREAM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const IPersistStreamVtbl persiststream_vtbl = {
|
static const IPersistStreamVtbl persiststream_vtbl = {
|
||||||
|
|
Loading…
Reference in New Issue