mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
155 lines
5.2 KiB
Diff
155 lines
5.2 KiB
Diff
From d32988c911aae73ec81242cd8f6ae37e078d212f Mon Sep 17 00:00:00 2001
|
|
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
|
Date: Fri, 2 Dec 2022 14:41:30 +1100
|
|
Subject: [PATCH] dmime: Implement IDirectMusicSegment8 Download
|
|
|
|
---
|
|
dlls/dmime/dmime_private.h | 1 +
|
|
dlls/dmime/performance.c | 7 ++++
|
|
dlls/dmime/segment.c | 84 +++++++++++++++++++++++++++++++++++++-
|
|
3 files changed, 91 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h
|
|
index c35c52eb066..ca8323fc525 100644
|
|
--- a/dlls/dmime/dmime_private.h
|
|
+++ b/dlls/dmime/dmime_private.h
|
|
@@ -72,6 +72,7 @@ extern void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath*,IDirectSo
|
|
|
|
extern HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time,
|
|
IDirectMusicSegmentState **ret_iface);
|
|
+extern IDirectSound *get_dsound_interface(IDirectMusicPerformance8*);
|
|
|
|
/*****************************************************************************
|
|
* Auxiliary definitions
|
|
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c
|
|
index 9f293358ca6..3658c16c187 100644
|
|
--- a/dlls/dmime/performance.c
|
|
+++ b/dlls/dmime/performance.c
|
|
@@ -251,6 +251,13 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi
|
|
return CONTAINING_RECORD(iface, struct performance, IDirectMusicPerformance8_iface);
|
|
}
|
|
|
|
+IDirectSound *get_dsound_interface(IDirectMusicPerformance8* iface)
|
|
+{
|
|
+ struct performance *This = impl_from_IDirectMusicPerformance8(iface);
|
|
+ return This->dsound;
|
|
+}
|
|
+
|
|
+
|
|
/* IDirectMusicPerformance8 IUnknown part: */
|
|
static HRESULT WINAPI performance_QueryInterface(IDirectMusicPerformance8 *iface, REFIID riid, void **ret_iface)
|
|
{
|
|
diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c
|
|
index af7729f34b9..284564749df 100644
|
|
--- a/dlls/dmime/segment.c
|
|
+++ b/dlls/dmime/segment.c
|
|
@@ -54,6 +54,7 @@ struct segment
|
|
PCMWAVEFORMAT wave_format;
|
|
void *wave_data;
|
|
int data_size;
|
|
+ IDirectSoundBuffer *buffer;
|
|
};
|
|
|
|
static struct segment *segment_create(void);
|
|
@@ -114,6 +115,8 @@ static ULONG WINAPI segment_Release(IDirectMusicSegment8 *iface)
|
|
track_entry_destroy(entry);
|
|
}
|
|
|
|
+ if (This->buffer)
|
|
+ IDirectSoundBuffer_Release(This->buffer);
|
|
if (This->wave_data)
|
|
free(This->wave_data);
|
|
|
|
@@ -533,8 +536,87 @@ static HRESULT WINAPI segment_Compose(IDirectMusicSegment8 *iface, MUSIC_TIME mt
|
|
static HRESULT WINAPI segment_Download(IDirectMusicSegment8 *iface, IUnknown *audio_path)
|
|
{
|
|
struct segment *This = impl_from_IDirectMusicSegment8(iface);
|
|
+ IDirectMusicPerformance8 *perf;
|
|
+ IDirectMusicAudioPath *audio;
|
|
+ IDirectSound *dsound;
|
|
+ HRESULT hr;
|
|
+ DSBUFFERDESC dsbd = {.dwSize = sizeof(dsbd)};
|
|
+ void *data;
|
|
+ DWORD size;
|
|
+ DWORD buffer = 0;
|
|
+
|
|
TRACE("(%p, %p)\n", This, audio_path);
|
|
- return IDirectMusicSegment8_SetParam(iface, &GUID_DownloadToAudioPath, -1, DMUS_SEG_ALLTRACKS, 0, audio_path);
|
|
+
|
|
+ if (!audio_path)
|
|
+ return E_INVALIDARG;
|
|
+
|
|
+ hr = IDirectMusicSegment8_SetParam(iface, &GUID_DownloadToAudioPath, -1, DMUS_SEG_ALLTRACKS, 0, audio_path);
|
|
+ if (FAILED(hr))
|
|
+ return hr;
|
|
+
|
|
+ if (This->buffer)
|
|
+ {
|
|
+ TRACE("Using Cached buffer\n");
|
|
+ return S_OK;
|
|
+ }
|
|
+
|
|
+ /* pAudioPath can either be IDirectMusicAudioPath or IDirectMusicPerformance */
|
|
+ hr = IUnknown_QueryInterface(audio_path, &IID_IDirectMusicPerformance8, (void**)&perf);
|
|
+ if (FAILED(hr))
|
|
+ {
|
|
+ TRACE("Checking for IDirectMusicAudioPath interface\n");
|
|
+ hr = IUnknown_QueryInterface(audio_path, &IID_IDirectMusicAudioPath, (void**)&audio);
|
|
+ if (FAILED(hr))
|
|
+ {
|
|
+ WARN("Cannot query for IDirectMusicAudioPath\n");
|
|
+ return E_INVALIDARG;
|
|
+ }
|
|
+
|
|
+ IDirectMusicAudioPath_GetObjectInPath(audio, DMUS_PCHANNEL_ALL, DMUS_PATH_PERFORMANCE, buffer, &GUID_NULL,
|
|
+ 0, &IID_IDirectMusicPerformance, (void**)&perf);
|
|
+ IDirectMusicAudioPath_Release(audio);
|
|
+ }
|
|
+
|
|
+ if (!perf)
|
|
+ {
|
|
+ ERR("Failed to get IDirectMusicPerformance interface\n");
|
|
+ return E_INVALIDARG;
|
|
+ }
|
|
+
|
|
+ dsound = get_dsound_interface(perf);
|
|
+ if (!dsound)
|
|
+ {
|
|
+ ERR("Failed get_dsound_interface\n");
|
|
+ return E_INVALIDARG;
|
|
+ }
|
|
+
|
|
+ if (This->data_size == 0)
|
|
+ {
|
|
+ FIXME("No wave data skipping\n");
|
|
+ return S_OK;
|
|
+ }
|
|
+
|
|
+ dsbd.dwBufferBytes = This->data_size;
|
|
+ dsbd.lpwfxFormat = (WAVEFORMATEX*)&This->wave_format;
|
|
+
|
|
+ hr = IDirectSound_CreateSoundBuffer(dsound, &dsbd, &This->buffer, NULL);
|
|
+ if (FAILED(hr))
|
|
+ {
|
|
+ ERR("IDirectSound_CreateSoundBuffer failed 0x%08lx\n", hr);
|
|
+ return E_INVALIDARG;
|
|
+ }
|
|
+
|
|
+ TRACE("CreateSoundBuffer successful\n");
|
|
+
|
|
+ hr = IDirectSoundBuffer_Lock(This->buffer, 0, This->data_size, &data, &size, NULL, 0, 0);
|
|
+ TRACE("IDirectSoundBuffer_Lock hr 0x%08lx\n", hr);
|
|
+
|
|
+ memcpy(data, This->wave_data, This->data_size);
|
|
+
|
|
+ hr = IDirectSoundBuffer_Unlock(This->buffer, data, This->data_size, NULL, 0);
|
|
+ TRACE("IDirectSoundBuffer_Unlock hr 0x%08lx\n", hr);
|
|
+
|
|
+ return S_OK;
|
|
}
|
|
|
|
static HRESULT WINAPI segment_Unload(IDirectMusicSegment8 *iface, IUnknown *audio_path)
|
|
--
|
|
2.42.0
|
|
|