Commit 45d1c00e authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmime: Introduce a new segment_state_create constructor.

parent 9cb01426
......@@ -70,6 +70,9 @@ extern void set_audiopath_perf_pointer(IDirectMusicAudioPath*,IDirectMusicPerfor
extern void set_audiopath_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffer*);
extern void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffer*);
extern HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time,
IDirectMusicSegmentState **ret_iface);
/*****************************************************************************
* Auxiliary definitions
*/
......
......@@ -1063,17 +1063,35 @@ static HRESULT WINAPI performance_InitAudio(IDirectMusicPerformance8 *iface, IDi
return S_OK;
}
static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface, IUnknown *pSource,
WCHAR *pwzSegmentName, IUnknown *pTransition, DWORD dwFlags, __int64 i64StartTime,
IDirectMusicSegmentState **ppSegmentState, IUnknown *pFrom, IUnknown *pAudioPath)
static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface, IUnknown *source,
WCHAR *segment_name, IUnknown *transition, DWORD segment_flags, INT64 start_time,
IDirectMusicSegmentState **segment_state, IUnknown *from, IUnknown *audio_path)
{
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
IDirectMusicSegmentState *state;
IDirectMusicSegment *segment;
HRESULT hr;
FIXME("(%p, %p, %p, %p, %ld, 0x%s, %p, %p, %p): stub\n", This, pSource, pwzSegmentName,
pTransition, dwFlags, wine_dbgstr_longlong(i64StartTime), ppSegmentState, pFrom, pAudioPath);
if (ppSegmentState)
return create_dmsegmentstate(&IID_IDirectMusicSegmentState,(void**)ppSegmentState);
return S_OK;
FIXME("(%p, %p, %s, %p, %#lx, %I64d, %p, %p, %p): stub\n", This, source, debugstr_w(segment_name),
transition, segment_flags, start_time, segment_state, from, audio_path);
if (FAILED(hr = IUnknown_QueryInterface(source, &IID_IDirectMusicSegment, (void **)&segment)))
return hr;
if (FAILED(hr = segment_state_create((IDirectMusicSegment *)segment, start_time, &state)))
{
IDirectMusicSegment_Release(segment);
return hr;
}
if (segment_state)
{
*segment_state = state;
IDirectMusicSegmentState_AddRef(state);
}
IDirectMusicSegmentState_Release(state);
IDirectMusicSegment_Release(segment);
return hr;
}
static HRESULT WINAPI performance_StopEx(IDirectMusicPerformance8 *iface, IUnknown *pObjectToStop,
......
......@@ -25,6 +25,10 @@ struct segment_state
{
IDirectMusicSegmentState8 IDirectMusicSegmentState8_iface;
LONG ref;
IDirectMusicSegment *segment;
MUSIC_TIME start_point;
MUSIC_TIME start_time;
};
static inline struct segment_state *impl_from_IDirectMusicSegmentState8(IDirectMusicSegmentState8 *iface)
......@@ -73,7 +77,11 @@ static ULONG WINAPI segment_state_Release(IDirectMusicSegmentState8 *iface)
TRACE("(%p): %ld\n", This, ref);
if (!ref) free(This);
if (!ref)
{
if (This->segment) IDirectMusicSegment_Release(This->segment);
free(This);
}
return ref;
}
......@@ -89,17 +97,21 @@ static HRESULT WINAPI segment_state_GetSegment(IDirectMusicSegmentState8 *iface,
{
struct segment_state *This = impl_from_IDirectMusicSegmentState8(iface);
FIXME("(%p, %p): semi-stub\n", This, segment);
TRACE("(%p, %p)\n", This, segment);
*segment = NULL;
return DMUS_E_NOT_FOUND;
if (!(*segment = This->segment)) return DMUS_E_NOT_FOUND;
IDirectMusicSegment_AddRef(This->segment);
return S_OK;
}
static HRESULT WINAPI segment_state_GetStartTime(IDirectMusicSegmentState8 *iface, MUSIC_TIME *start_time)
{
struct segment_state *This = impl_from_IDirectMusicSegmentState8(iface);
FIXME("(%p, %p): semi-stub\n", This, start_time);
*start_time = -1;
TRACE("(%p, %p)\n", This, start_time);
*start_time = This->start_time;
return S_OK;
}
......@@ -111,13 +123,13 @@ static HRESULT WINAPI segment_state_GetSeek(IDirectMusicSegmentState8 *iface, MU
return S_OK;
}
static HRESULT WINAPI segment_state_GetStartPoint(IDirectMusicSegmentState8 *iface, MUSIC_TIME *start_time)
static HRESULT WINAPI segment_state_GetStartPoint(IDirectMusicSegmentState8 *iface, MUSIC_TIME *start_point)
{
struct segment_state *This = impl_from_IDirectMusicSegmentState8(iface);
FIXME("(%p, %p): semi-stub\n", This, start_time);
TRACE("(%p, %p)\n", This, start_point);
*start_time = 0;
*start_point = This->start_point;
return S_OK;
}
......@@ -161,8 +173,33 @@ HRESULT create_dmsegmentstate(REFIID riid, void **ret_iface)
if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDirectMusicSegmentState8_iface.lpVtbl = &segment_state_vtbl;
obj->ref = 1;
obj->start_time = -1;
TRACE("Created IDirectMusicSegmentState %p\n", obj);
hr = IDirectMusicSegmentState8_QueryInterface(&obj->IDirectMusicSegmentState8_iface, riid, ret_iface);
IDirectMusicSegmentState8_Release(&obj->IDirectMusicSegmentState8_iface);
return hr;
}
HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time,
IDirectMusicSegmentState **ret_iface)
{
IDirectMusicSegmentState *iface;
struct segment_state *This;
HRESULT hr;
TRACE("(%p, %lu, %p)\n", segment, start_time, ret_iface);
if (FAILED(hr = create_dmsegmentstate(&IID_IDirectMusicSegmentState, (void **)&iface))) return hr;
This = impl_from_IDirectMusicSegmentState8((IDirectMusicSegmentState8 *)iface);
This->segment = segment;
IDirectMusicSegment_AddRef(This->segment);
This->start_time = start_time;
hr = IDirectMusicSegment_GetStartPoint(segment, &This->start_point);
if (SUCCEEDED(hr)) *ret_iface = iface;
else IDirectMusicSegmentState_Release(iface);
return hr;
}
......@@ -4043,14 +4043,14 @@ static void test_segment_state(void)
tmp_segment = (void *)0xdeadbeef;
hr = IDirectMusicSegmentState_GetSegment(state, &tmp_segment);
todo_wine ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(tmp_segment == segment, "got %p\n", tmp_segment);
if (tmp_segment) IDirectMusicSegment_Release(tmp_segment);
ok(hr == S_OK, "got %#lx\n", hr);
ok(tmp_segment == segment, "got %p\n", tmp_segment);
IDirectMusicSegment_Release(tmp_segment);
time = 0xdeadbeef;
hr = IDirectMusicSegmentState_GetStartPoint(state, &time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(time == 50, "got %lu\n", time);
ok(time == 50, "got %lu\n", time);
time = 0xdeadbeef;
hr = IDirectMusicSegmentState_GetRepeats(state, &value);
ok(hr == S_OK, "got %#lx\n", hr);
......@@ -4058,7 +4058,7 @@ static void test_segment_state(void)
time = 0xdeadbeef;
hr = IDirectMusicSegmentState_GetStartTime(state, &time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(time == 20, "got %#lx\n", time);
ok(time == 20, "got %#lx\n", time);
time = 0xdeadbeef;
/* The seek value is also dependent on whether the tracks are playing.
......@@ -4080,7 +4080,7 @@ static void test_segment_state(void)
time = 0xdeadbeef;
hr = IDirectMusicSegmentState_GetStartPoint(state, &time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(time == 50, "got %#lx\n", time);
ok(time == 50, "got %#lx\n", time);
time = 0xdeadbeef;
hr = IDirectMusicSegmentState_GetRepeats(state, &value);
ok(hr == S_OK, "got %#lx\n", hr);
......@@ -4088,7 +4088,7 @@ static void test_segment_state(void)
time = 0xdeadbeef;
hr = IDirectMusicSegmentState_GetStartTime(state, &time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(time == 20, "got %#lx\n", time);
ok(time == 20, "got %#lx\n", time);
time = 0xdeadbeef;
hr = IDirectMusicSegmentState_GetSeek(state, &time);
ok(hr == S_OK, "got %#lx\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment