2023-10-04 16:20:15 -07:00
|
|
|
From d32988c911aae73ec81242cd8f6ae37e078d212f Mon Sep 17 00:00:00 2001
|
2023-02-07 00:38:06 -08:00
|
|
|
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
|
|
|
Date: Fri, 2 Dec 2022 14:41:30 +1100
|
|
|
|
Subject: [PATCH] dmime: Implement IDirectMusicSegment8 Download
|
|
|
|
|
|
|
|
---
|
2023-10-04 16:20:15 -07:00
|
|
|
dlls/dmime/dmime_private.h | 1 +
|
2023-09-19 15:16:07 -07:00
|
|
|
dlls/dmime/performance.c | 7 ++++
|
2023-09-29 15:20:32 -07:00
|
|
|
dlls/dmime/segment.c | 84 +++++++++++++++++++++++++++++++++++++-
|
2023-10-04 16:20:15 -07:00
|
|
|
3 files changed, 91 insertions(+), 1 deletion(-)
|
2023-02-07 00:38:06 -08:00
|
|
|
|
|
|
|
diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h
|
2023-10-04 16:20:15 -07:00
|
|
|
index c35c52eb066..ca8323fc525 100644
|
2023-02-07 00:38:06 -08:00
|
|
|
--- a/dlls/dmime/dmime_private.h
|
|
|
|
+++ b/dlls/dmime/dmime_private.h
|
2023-10-04 16:20:15 -07:00
|
|
|
@@ -72,6 +72,7 @@ extern void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath*,IDirectSo
|
2023-02-07 00:38:06 -08:00
|
|
|
|
2023-10-04 16:20:15 -07:00
|
|
|
extern HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time,
|
|
|
|
IDirectMusicSegmentState **ret_iface);
|
2023-06-29 14:59:45 -07:00
|
|
|
+extern IDirectSound *get_dsound_interface(IDirectMusicPerformance8*);
|
2023-10-04 16:20:15 -07:00
|
|
|
|
2023-02-07 00:38:06 -08:00
|
|
|
/*****************************************************************************
|
|
|
|
* Auxiliary definitions
|
|
|
|
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c
|
2023-10-04 16:20:15 -07:00
|
|
|
index 9f293358ca6..3658c16c187 100644
|
2023-02-07 00:38:06 -08:00
|
|
|
--- a/dlls/dmime/performance.c
|
|
|
|
+++ b/dlls/dmime/performance.c
|
2023-09-19 15:16:07 -07:00
|
|
|
@@ -251,6 +251,13 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi
|
2023-09-11 14:54:37 -07:00
|
|
|
return CONTAINING_RECORD(iface, struct performance, IDirectMusicPerformance8_iface);
|
2023-02-07 00:38:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
+IDirectSound *get_dsound_interface(IDirectMusicPerformance8* iface)
|
|
|
|
+{
|
2023-09-11 14:54:37 -07:00
|
|
|
+ struct performance *This = impl_from_IDirectMusicPerformance8(iface);
|
2023-02-07 00:38:06 -08:00
|
|
|
+ return This->dsound;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
/* IDirectMusicPerformance8 IUnknown part: */
|
2023-09-11 14:54:37 -07:00
|
|
|
static HRESULT WINAPI performance_QueryInterface(IDirectMusicPerformance8 *iface, REFIID riid, void **ret_iface)
|
|
|
|
{
|
2023-02-07 00:38:06 -08:00
|
|
|
diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c
|
2023-09-29 15:20:32 -07:00
|
|
|
index af7729f34b9..284564749df 100644
|
2023-02-07 00:38:06 -08:00
|
|
|
--- a/dlls/dmime/segment.c
|
|
|
|
+++ b/dlls/dmime/segment.c
|
2023-09-19 15:16:07 -07:00
|
|
|
@@ -54,6 +54,7 @@ struct segment
|
2023-02-07 00:38:06 -08:00
|
|
|
PCMWAVEFORMAT wave_format;
|
|
|
|
void *wave_data;
|
|
|
|
int data_size;
|
|
|
|
+ IDirectSoundBuffer *buffer;
|
2023-09-19 15:16:07 -07:00
|
|
|
};
|
2023-02-07 00:38:06 -08:00
|
|
|
|
2023-09-19 15:16:07 -07:00
|
|
|
static struct segment *segment_create(void);
|
|
|
|
@@ -114,6 +115,8 @@ static ULONG WINAPI segment_Release(IDirectMusicSegment8 *iface)
|
|
|
|
track_entry_destroy(entry);
|
|
|
|
}
|
2023-02-07 00:38:06 -08:00
|
|
|
|
|
|
|
+ if (This->buffer)
|
|
|
|
+ IDirectSoundBuffer_Release(This->buffer);
|
|
|
|
if (This->wave_data)
|
|
|
|
free(This->wave_data);
|
|
|
|
|
2023-09-29 15:20:32 -07:00
|
|
|
@@ -533,8 +536,87 @@ static HRESULT WINAPI segment_Compose(IDirectMusicSegment8 *iface, MUSIC_TIME mt
|
|
|
|
static HRESULT WINAPI segment_Download(IDirectMusicSegment8 *iface, IUnknown *audio_path)
|
2023-02-07 00:38:06 -08:00
|
|
|
{
|
2023-09-19 15:16:07 -07:00
|
|
|
struct segment *This = impl_from_IDirectMusicSegment8(iface);
|
2023-02-07 00:38:06 -08:00
|
|
|
+ IDirectMusicPerformance8 *perf;
|
|
|
|
+ IDirectMusicAudioPath *audio;
|
|
|
|
+ IDirectSound *dsound;
|
|
|
|
+ HRESULT hr;
|
|
|
|
+ DSBUFFERDESC dsbd = {.dwSize = sizeof(dsbd)};
|
|
|
|
+ void *data;
|
|
|
|
+ DWORD size;
|
|
|
|
+ DWORD buffer = 0;
|
|
|
|
+
|
2023-09-29 15:20:32 -07:00
|
|
|
TRACE("(%p, %p)\n", This, audio_path);
|
|
|
|
- return IDirectMusicSegment8_SetParam(iface, &GUID_DownloadToAudioPath, -1, DMUS_SEG_ALLTRACKS, 0, audio_path);
|
2023-02-07 00:38:06 -08:00
|
|
|
+
|
2023-09-29 15:20:32 -07:00
|
|
|
+ if (!audio_path)
|
2023-02-07 00:38:06 -08:00
|
|
|
+ return E_INVALIDARG;
|
|
|
|
+
|
2023-09-29 15:20:32 -07:00
|
|
|
+ hr = IDirectMusicSegment8_SetParam(iface, &GUID_DownloadToAudioPath, -1, DMUS_SEG_ALLTRACKS, 0, audio_path);
|
|
|
|
+ if (FAILED(hr))
|
|
|
|
+ return hr;
|
|
|
|
+
|
2023-02-07 00:38:06 -08:00
|
|
|
+ if (This->buffer)
|
|
|
|
+ {
|
|
|
|
+ TRACE("Using Cached buffer\n");
|
|
|
|
+ return S_OK;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* pAudioPath can either be IDirectMusicAudioPath or IDirectMusicPerformance */
|
2023-09-29 15:20:32 -07:00
|
|
|
+ hr = IUnknown_QueryInterface(audio_path, &IID_IDirectMusicPerformance8, (void**)&perf);
|
2023-02-07 00:38:06 -08:00
|
|
|
+ if (FAILED(hr))
|
|
|
|
+ {
|
|
|
|
+ TRACE("Checking for IDirectMusicAudioPath interface\n");
|
2023-09-29 15:20:32 -07:00
|
|
|
+ hr = IUnknown_QueryInterface(audio_path, &IID_IDirectMusicAudioPath, (void**)&audio);
|
2023-02-07 00:38:06 -08:00
|
|
|
+ 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);
|
|
|
|
+
|
2023-09-29 15:20:32 -07:00
|
|
|
+ return S_OK;
|
2023-02-07 00:38:06 -08:00
|
|
|
}
|
|
|
|
|
2023-09-29 15:20:32 -07:00
|
|
|
static HRESULT WINAPI segment_Unload(IDirectMusicSegment8 *iface, IUnknown *audio_path)
|
2023-02-07 00:38:06 -08:00
|
|
|
--
|
2023-09-29 15:20:32 -07:00
|
|
|
2.42.0
|
2023-02-07 00:38:06 -08:00
|
|
|
|