Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/dmime/lyricstrack.c | 121 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 119 insertions(+), 2 deletions(-)
diff --git a/dlls/dmime/lyricstrack.c b/dlls/dmime/lyricstrack.c
index 49f44f52a34..17d3c3f26c4 100644
--- a/dlls/dmime/lyricstrack.c
+++ b/dlls/dmime/lyricstrack.c
@@ -37,6 +37,11 @@ static inline IDirectMusicLyricsTrack *impl_from_IDirectMusicTrack8(IDirectMusic
return CONTAINING_RECORD(iface, IDirectMusicLyricsTrack, IDirectMusicTrack8_iface);
}
+static inline IDirectMusicLyricsTrack *impl_from_IPersistStream(IPersistStream *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicLyricsTrack, dmobj.IPersistStream_iface);
+}
+
static HRESULT WINAPI lyrics_track_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
void **ret_iface)
{
@@ -236,10 +241,122 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
lyrics_track_Join
};
+static HRESULT parse_lyrics_track_event(IDirectMusicLyricsTrack *This, IStream *stream, struct chunk_entry *lyric)
+{
+ HRESULT hr;
+ struct chunk_entry chunk = {.parent = lyric};
+
+ TRACE("Parsing segment form in %p: %s\n", stream, debugstr_chunk(lyric));
+
+ while ((hr = stream_next_chunk(stream, &chunk)) == S_OK) {
+ switch (chunk.id) {
+ case DMUS_FOURCC_LYRICSTRACKEVENTHEADER_CHUNK:
+ {
+ DMUS_IO_LYRICSTRACK_EVENTHEADER header;
+
+ if (FAILED(hr = stream_chunk_get_data(stream, &chunk, &header, chunk.size))) {
+ WARN("Failed to read data of %s\n", debugstr_chunk(&chunk));
+ return hr;
+ }
+
+ TRACE("Found DMUS_IO_LYRICSTRACK_EVENTHEADER\n");
+ TRACE(" - dwFlags 0x%08x\n", header.dwFlags);
+ TRACE(" - dwTimingFlags 0x%08x\n", header.dwTimingFlags);
+ TRACE(" - lTimeLogical %g\n", header.lTimeLogical);
+ TRACE(" - lTimePhysical %g\n", header.lTimePhysical);
+ break;
+ }
+ case DMUS_FOURCC_LYRICSTRACKEVENTTEXT_CHUNK:
+ {
+ WCHAR name[256];
+
+ if (FAILED(hr = stream_chunk_get_data(stream, &chunk, &name, chunk.size))) {
+ WARN("Failed to read data of %s\n", debugstr_chunk(&chunk));
+ return hr;
+ }
+
+ TRACE("Found DMUS_FOURCC_LYRICSTRACKEVENTTEXT_CHUNK\n");
+ TRACE(" - name %s\n", debugstr_w(name));
+
+ break;
+ }
+ default:
+ FIXME("Parsing %s\n", debugstr_fourcc(chunk.id));
+ }
+ }
+
+ return SUCCEEDED(hr) ? S_OK : hr;
+}
+
+static HRESULT parse_lyrics_track_events(IDirectMusicLyricsTrack *This, IStream *stream, struct chunk_entry *lyric)
+{
+ HRESULT hr;
+ struct chunk_entry chunk = {.parent = lyric};
+
+ TRACE("Parsing segment form in %p: %s\n", stream, debugstr_chunk(lyric));
+
+ while ((hr = stream_next_chunk(stream, &chunk)) == S_OK) {
+ switch (chunk.id) {
+ case FOURCC_LIST:
+ if (chunk.type == DMUS_FOURCC_LYRICSTRACKEVENT_LIST) {
+ if (FAILED(hr = parse_lyrics_track_event(This, stream, &chunk)))
+ return hr;
+ }
+ break;
+ default:
+ FIXME("Parsing %s\n", debugstr_fourcc(chunk.id));
+ }
+ }
+
+ return SUCCEEDED(hr) ? S_OK : hr;
+}
+
+static HRESULT parse_lyricstrack_list(IDirectMusicLyricsTrack *This, IStream *stream, struct chunk_entry *lyric)
+{
+ HRESULT hr;
+ struct chunk_entry chunk = {.parent = lyric};
+
+ TRACE("Parsing segment form in %p: %s\n", stream, debugstr_chunk(lyric));
+
+ while ((hr = stream_next_chunk(stream, &chunk)) == S_OK) {
+ switch (chunk.id) {
+ case FOURCC_LIST:
+ if (chunk.type == DMUS_FOURCC_LYRICSTRACKEVENTS_LIST) {
+ if (FAILED(hr = parse_lyrics_track_events(This, stream, &chunk)))
+ return hr;
+ }
+ break;
+ default:
+ FIXME("Parsing %s\n", debugstr_fourcc(chunk.id));
+ }
+ }
+
+ return SUCCEEDED(hr) ? S_OK : hr;
+}
+
static HRESULT WINAPI lyrics_IPersistStream_Load(IPersistStream *iface, IStream *stream)
{
- FIXME(": Loading not implemented yet\n");
- return S_OK;
+ IDirectMusicLyricsTrack *This = impl_from_IPersistStream(iface);
+ HRESULT hr;
+ struct chunk_entry chunk = {0};
+
+ TRACE("%p, %p\n", This, stream);
+
+ if (!stream)
+ return E_POINTER;
+
+ if ((hr = stream_get_chunk(stream, &chunk) != S_OK))
+ return hr;
+
+ if (chunk.id == FOURCC_LIST && chunk.type == DMUS_FOURCC_LYRICSTRACK_LIST) {
+ hr = parse_lyricstrack_list(This, stream, &chunk);
+ }
+ else {
+ FIXME("Unsupported id %s\n", debugstr_fourcc (chunk.id));
+ hr = DMUS_E_UNSUPPORTED_STREAM;
+ }
+
+ return hr;
}
static const IPersistStreamVtbl persiststream_vtbl = {
--
2.26.1