From: Yuxuan Shui yshui@codeweavers.com
--- dlls/dmband/bandtrack.c | 41 ++++++++++++++++++++++++++++++++++---- dlls/dmband/tests/dmband.c | 19 ++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/dlls/dmband/bandtrack.c b/dlls/dmband/bandtrack.c index 4756ed194ef..4fe52ecbd01 100644 --- a/dlls/dmband/bandtrack.c +++ b/dlls/dmband/bandtrack.c @@ -198,19 +198,38 @@ static HRESULT WINAPI band_track_Play(IDirectMusicTrack8 *iface, void *state_dat }
static HRESULT WINAPI band_track_GetParam(IDirectMusicTrack8 *iface, REFGUID type, MUSIC_TIME time, - MUSIC_TIME *next, void *param) + MUSIC_TIME *out_next, void *param) { struct band_track *This = impl_from_IDirectMusicTrack8(iface); + struct band_entry *band; + DMUS_BAND_PARAM *bandparam; + MUSIC_TIME prev = -1, next = time;
- TRACE("(%p, %s, %ld, %p, %p)\n", This, debugstr_dmguid(type), time, next, param); + TRACE("(%p, %s, %ld, %p, %p)\n", This, debugstr_dmguid(type), time, out_next, param);
if (!type) return E_POINTER; if (!IsEqualGUID(type, &GUID_BandParam)) return DMUS_E_GET_UNSUPPORTED;
- FIXME("GUID_BandParam not handled yet\n"); + bandparam = param;
+ LIST_FOR_EACH_ENTRY(band, &This->bands, struct band_entry, entry) + { + if (band->head.lBandTimeLogical <= time && band->head.lBandTimeLogical >= prev) + { + bandparam->pBand = band->band; + bandparam->mtTimePhysical = band->head.lBandTimePhysical; + prev = band->head.lBandTimeLogical; + } + else if (band->head.lBandTimeLogical > time && band->head.lBandTimeLogical < next) + next = band->head.lBandTimeLogical; + } + + if (prev == -1) + return DMUS_E_NOT_FOUND; + + if (out_next) *out_next = next - time; return S_OK; }
@@ -227,7 +246,21 @@ static HRESULT WINAPI band_track_SetParam(IDirectMusicTrack8 *iface, REFGUID typ return DMUS_E_TYPE_UNSUPPORTED;
if (IsEqualGUID(type, &GUID_BandParam)) - FIXME("GUID_BandParam not handled yet\n"); + { + struct band_entry *entry = calloc(1, sizeof(*entry)); + DMUS_BAND_PARAM *band_param = param; + if (!band_param) + return E_POINTER; + if (!band_param->pBand) + return E_INVALIDARG; + if (!entry) + return E_OUTOFMEMORY; + entry->band = band_param->pBand; + entry->head.lBandTimeLogical = time; + entry->head.lBandTimePhysical = band_param->mtTimePhysical; + IDirectMusicBand_AddRef(entry->band); + list_add_tail(&This->bands, &entry->entry); + } else if (IsEqualGUID(type, &GUID_Clear_All_Bands)) FIXME("GUID_Clear_All_Bands not handled yet\n"); else if (IsEqualGUID(type, &GUID_ConnectToDLSCollection)) diff --git a/dlls/dmband/tests/dmband.c b/dlls/dmband/tests/dmband.c index d88606976e4..caa8823d2ba 100644 --- a/dlls/dmband/tests/dmband.c +++ b/dlls/dmband/tests/dmband.c @@ -176,9 +176,12 @@ static void test_dmband(void)
static void test_bandtrack(void) { + DMUS_BAND_PARAM bandparam; IDirectMusicTrack8 *dmt8; + IDirectMusicBand *dmb; IPersistStream *ps; CLSID class; + MUSIC_TIME mt; ULARGE_INTEGER size; char buf[64] = { 0 }; HRESULT hr; @@ -266,6 +269,22 @@ static void test_bandtrack(void) } }
+ hr = CoCreateInstance(&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicBand, (void**)&dmb); + ok(hr == S_OK, "DirectMusicBand create failed: %#lx, expected S_OK\n", hr); + + bandparam.mtTimePhysical = 0; + bandparam.pBand = dmb; + hr = IDirectMusicTrack8_SetParam(dmt8, &GUID_BandParam, 0, &bandparam); + ok(hr == S_OK, "SetParam failed: %#lx, expected S_OK\n", hr); + + hr = IDirectMusicTrack8_GetParam(dmt8, &GUID_BandParam, 0, &mt, &bandparam); + ok(hr == S_OK, "GetParam failed: %#lx, expected S_OK\n", hr); + ok(mt == 0, "Got time %lu, expected 0\n", mt); + ok(bandparam.mtTimePhysical == 0, "Got physical time %lu, expected 0\n", bandparam.mtTimePhysical); + ok(bandparam.pBand == dmb, "Got band %p, expected %p\n", bandparam.pBand, dmb); + IDirectMusicBand_Release(dmb); + hr = IDirectMusicTrack8_AddNotificationType(dmt8, NULL); ok(hr == E_NOTIMPL, "IDirectMusicTrack8_AddNotificationType failed: %#lx\n", hr); hr = IDirectMusicTrack8_RemoveNotificationType(dmt8, NULL);