Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
3ee58034
Commit
3ee58034
authored
Jul 11, 2018
by
Michael Stefaniuc
Committed by
Alexandre Julliard
Jul 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dmime: Reimplement the track form parser.
Signed-off-by:
Michael Stefaniuc
<
mstefani@winehq.org
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
23629d06
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
174 deletions
+55
-174
segment.c
dlls/dmime/segment.c
+55
-174
No files found.
dlls/dmime/segment.c
View file @
3ee58034
...
...
@@ -22,7 +22,6 @@
#include "dmobject.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
dmime
);
WINE_DECLARE_DEBUG_CHANNEL
(
dmfile
);
/*****************************************************************************
* IDirectMusicSegmentImpl implementation
...
...
@@ -622,195 +621,77 @@ static const IDirectMusicObjectVtbl dmobject_vtbl = {
};
/* IDirectMusicSegment8Impl IPersistStream part: */
static
HRESULT
load_track
(
IDirectMusicSegment8Impl
*
This
,
IStream
*
pClonedS
tream
,
IDirectMusicTrack
**
ppTrack
,
DMUS_IO_TRACK_HEADER
*
pTrack_hdr
)
static
HRESULT
parse_track_form
(
IDirectMusicSegment8Impl
*
This
,
IStream
*
s
tream
,
const
struct
chunk_entry
*
riff
)
{
HRESULT
hr
=
E_FAIL
;
IPersistStream
*
pPersistStream
=
NULL
;
struct
chunk_entry
chunk
=
{.
parent
=
riff
};
IDirectMusicTrack
*
track
=
NULL
;
IPersistStream
*
ps
=
NULL
;
IStream
*
clone
;
DMUS_IO_TRACK_HEADER
thdr
;
HRESULT
hr
;
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
"
);
TRACE
(
"Parsing track form in %p: %s
\n
"
,
stream
,
debugstr_chunk
(
riff
));
/* First chunk must be the track header */
if
(
FAILED
(
hr
=
stream_get_chunk
(
stream
,
&
chunk
)))
return
hr
;
}
/* load */
hr
=
IPersistStream_Load
(
pPersistStream
,
pClonedStream
);
if
(
FAILED
(
hr
))
{
ERR
(
": failed to load object
\n
"
);
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
;
}
/* release all loading-related stuff */
IPersistStream_Release
(
pPersistStream
);
TRACE
(
"Found DMUS_IO_TRACK_HEADER
\n
"
);
TRACE
(
"
\t
class: %s
\n
"
,
debugstr_guid
(
&
thdr
.
guidClassID
));
TRACE
(
"
\t
dwGroup: %d
\n
"
,
thdr
.
dwGroup
);
TRACE
(
"
\t
ckid: %s
\n
"
,
debugstr_fourcc
(
thdr
.
ckid
));
TRACE
(
"
\t
fccType: %s
\n
"
,
debugstr_fourcc
(
thdr
.
fccType
));
hr
=
IDirectMusicSegment8_InsertTrack
(
&
This
->
IDirectMusicSegment8_iface
,
*
ppTrack
,
pTrack_hdr
->
dwGroup
);
/* at dsPosition */
if
(
FAILED
(
hr
))
{
ERR
(
": could not insert track
\n
"
);
return
hr
;
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
;
}
return
S_OK
;
}
static
HRESULT
parse_track_form
(
IDirectMusicSegment8Impl
*
This
,
DWORD
size
,
IStream
*
pStm
)
{
HRESULT
hr
=
E_FAIL
;
DMUS_PRIVATE_CHUNK
Chunk
;
DWORD
StreamSize
,
StreamCount
,
ListSize
[
3
];
LARGE_INTEGER
liMove
;
/* used when skipping chunks */
DMUS_IO_TRACK_HEADER
track_hdr
;
DMUS_IO_TRACK_EXTRAS_HEADER
track_xhdr
;
IDirectMusicTrack
*
pTrack
=
NULL
;
StreamSize
=
size
-
sizeof
(
FOURCC
);
StreamCount
=
0
;
do
{
IStream_Read
(
pStm
,
&
Chunk
,
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
),
NULL
);
StreamCount
+=
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
)
+
Chunk
.
dwSize
;
TRACE_
(
dmfile
)(
": %s chunk (size = %d)"
,
debugstr_fourcc
(
Chunk
.
fccID
),
Chunk
.
dwSize
);
switch
(
Chunk
.
fccID
)
{
case
DMUS_FOURCC_TRACK_CHUNK
:
{
TRACE_
(
dmfile
)(
": track chunk
\n
"
);
IStream_Read
(
pStm
,
&
track_hdr
,
sizeof
(
DMUS_IO_TRACK_HEADER
),
NULL
);
TRACE_
(
dmfile
)(
" - class: %s
\n
"
,
debugstr_guid
(
&
track_hdr
.
guidClassID
));
TRACE_
(
dmfile
)(
" - dwGroup: %d
\n
"
,
track_hdr
.
dwGroup
);
TRACE_
(
dmfile
)(
" - ckid: %s
\n
"
,
debugstr_fourcc
(
track_hdr
.
ckid
));
TRACE_
(
dmfile
)(
" - fccType: %s
\n
"
,
debugstr_fourcc
(
track_hdr
.
fccType
));
break
;
}
case
DMUS_FOURCC_TRACK_EXTRAS_CHUNK
:
{
TRACE_
(
dmfile
)(
": track extras chunk
\n
"
);
IStream_Read
(
pStm
,
&
track_xhdr
,
sizeof
(
DMUS_IO_TRACK_EXTRAS_HEADER
),
NULL
);
/* 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
;
}
case
DMUS_FOURCC_COMMANDTRACK_CHUNK
:
{
TRACE_
(
dmfile
)(
": COMMANDTRACK track
\n
"
);
liMove
.
QuadPart
=
Chunk
.
dwSize
;
IStream_Seek
(
pStm
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
if
(
chunk
.
id
==
DMUS_FOURCC_TRACK_EXTRAS_CHUNK
)
FIXME
(
"DMUS_IO_TRACK_EXTRAS_HEADER chunk not handled
\n
"
);
}
if
(
hr
!=
S_OK
)
return
hr
==
S_FALSE
?
DMUS_E_TRACK_NOT_FOUND
:
hr
;
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
);
if
(
Chunk
.
fccID
==
track_hdr
.
fccType
&&
0
==
track_hdr
.
ckid
)
{
LPSTREAM
pClonedStream
=
NULL
;
TRACE_
(
dmfile
)(
": TRACK list
\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
=
load_track
(
This
,
pClonedStream
,
&
pTrack
,
&
track_hdr
);
if
(
FAILED
(
hr
))
{
ERR
(
": could not load track
\n
"
);
/* Some DirectMusicTrack implementation expect the stream to start with their data chunk */
if
(
FAILED
(
hr
=
IStream_Clone
(
stream
,
&
clone
)))
return
hr
;
}
IStream_Release
(
pClonedStream
);
stream_reset_chunk_start
(
clone
,
&
chunk
);
IDirectMusicTrack_Release
(
pTrack
);
pTrack
=
NULL
;
/* now we can release at as it inserted */
liMove
.
QuadPart
=
ListSize
[
0
];
IStream_Seek
(
pStm
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
}
else
{
TRACE_
(
dmfile
)(
": unknown (skipping)
\n
"
);
liMove
.
QuadPart
=
Chunk
.
dwSize
;
IStream_Seek
(
pStm
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
}
break
;
}
case
FOURCC_RIFF
:
{
IStream_Read
(
pStm
,
&
Chunk
.
fccID
,
sizeof
(
FOURCC
),
NULL
);
TRACE_
(
dmfile
)(
": RIFF chunk of type %s
\n
"
,
debugstr_fourcc
(
Chunk
.
fccID
));
ListSize
[
0
]
=
Chunk
.
dwSize
-
sizeof
(
FOURCC
);
if
(
Chunk
.
fccID
==
track_hdr
.
fccType
&&
0
==
track_hdr
.
ckid
)
{
LPSTREAM
pClonedStream
=
NULL
;
TRACE_
(
dmfile
)(
": TRACK RIFF
\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
=
load_track
(
This
,
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
);
}
else
{
TRACE_
(
dmfile
)(
": unknown RIFF fmt (skipping)
\n
"
);
liMove
.
QuadPart
=
ListSize
[
0
];
IStream_Seek
(
pStm
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
}
break
;
}
default:
{
if
(
0
==
track_hdr
.
fccType
&&
Chunk
.
fccID
==
track_hdr
.
ckid
)
{
LPSTREAM
pClonedStream
=
NULL
;
TRACE_
(
dmfile
)(
": TRACK solo
\n
"
);
/* 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
;
IStream_Clone
(
pStm
,
&
pClonedStream
);
hr
=
IDirectMusicSegment8_InsertTrack
(
&
This
->
IDirectMusicSegment8_iface
,
track
,
thdr
.
dwGroup
);
liMove
.
QuadPart
=
0
;
liMove
.
QuadPart
-=
(
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
));
IStream_Seek
(
pClonedStream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
done:
if
(
ps
)
IPersistStream_Release
(
ps
);
if
(
track
)
IDirectMusicTrack_Release
(
track
);
IStream_Release
(
clone
);
hr
=
load_track
(
This
,
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 (irrelevant & skipping)
\n
"
);
liMove
.
QuadPart
=
Chunk
.
dwSize
;
IStream_Seek
(
pStm
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
}
TRACE_
(
dmfile
)(
": StreamCount[0] = %d < StreamSize[0] = %d
\n
"
,
StreamCount
,
StreamSize
);
}
while
(
StreamCount
<
StreamSize
);
return
S_OK
;
}
static
HRESULT
parse_track_list
(
IDirectMusicSegment8Impl
*
This
,
IStream
*
stream
,
...
...
@@ -823,7 +704,7 @@ static HRESULT parse_track_list(IDirectMusicSegment8Impl *This, IStream *stream,
while
((
hr
=
stream_next_chunk
(
stream
,
&
chunk
))
==
S_OK
)
if
(
chunk
.
id
==
FOURCC_RIFF
&&
chunk
.
type
==
DMUS_FOURCC_TRACK_FORM
)
hr
=
parse_track_form
(
This
,
chunk
.
size
,
stream
);
hr
=
parse_track_form
(
This
,
stream
,
&
chunk
);
return
SUCCEEDED
(
hr
)
?
S_OK
:
hr
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment