Commit 0c4e1e43 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmime: Cleanup IDirectMusicPerformance_SendPMsg.

parent 4adeeb72
......@@ -399,55 +399,62 @@ static HRESULT WINAPI performance_GetBumperLength(IDirectMusicPerformance8 *ifac
return S_OK;
}
static HRESULT WINAPI performance_SendPMsg(IDirectMusicPerformance8 *iface, DMUS_PMSG *pPMSG)
static HRESULT WINAPI performance_SendPMsg(IDirectMusicPerformance8 *iface, DMUS_PMSG *msg)
{
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
DMUS_PMSGItem* pItem = NULL;
DMUS_PMSGItem* it = NULL;
DMUS_PMSGItem* prev_it = NULL;
DMUS_PMSGItem** queue = NULL;
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
DMUS_PMSGItem *message;
DMUS_PMSGItem *it = NULL;
DMUS_PMSGItem *prev_it = NULL;
DMUS_PMSGItem **queue;
HRESULT hr;
FIXME("(%p, %p): stub\n", This, pPMSG);
if (NULL == pPMSG) {
return E_POINTER;
}
pItem = DMUS_PMSGToItem(pPMSG);
if (pItem->bInUse) {
return DMUS_E_ALREADY_SENT;
}
/* TODO: Valid Flags */
/* TODO: DMUS_PMSGF_MUSICTIME */
pItem->rtItemTime = pPMSG->rtTime;
if (pPMSG->dwFlags & DMUS_PMSGF_TOOL_IMMEDIATE) {
queue = &This->imm_head;
} else {
queue = &This->head;
}
FIXME("(%p, %p): semi-stub\n", This, msg);
EnterCriticalSection(&This->safe);
for (it = *queue; NULL != it && it->rtItemTime < pItem->rtItemTime; it = it->next) {
prev_it = it;
}
if (NULL == prev_it) {
pItem->prev = NULL;
if (NULL != *queue) pItem->next = (*queue)->next;
/*assert( NULL == pItem->next->prev );*/
if (NULL != pItem->next) pItem->next->prev = pItem;
*queue = pItem;
} else {
pItem->prev = prev_it;
pItem->next = prev_it->next;
prev_it->next = pItem;
if (NULL != pItem->next) pItem->next->prev = pItem;
}
LeaveCriticalSection(&This->safe);
/** now in use, prevent from stupid Frees */
pItem->bInUse = TRUE;
return S_OK;
if (!msg) return E_POINTER;
if (!This->dmusic) return DMUS_E_NO_MASTER_CLOCK;
if (!(msg->dwFlags & (DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_REFTIME))) return E_INVALIDARG;
if (msg->dwFlags & DMUS_PMSGF_TOOL_IMMEDIATE) queue = &This->imm_head;
else queue = &This->head;
message = DMUS_PMSGToItem(msg);
EnterCriticalSection(&This->safe);
if (message->bInUse)
hr = DMUS_E_ALREADY_SENT;
else
{
/* TODO: Valid Flags */
/* TODO: DMUS_PMSGF_MUSICTIME */
message->rtItemTime = msg->rtTime;
for (it = *queue; NULL != it && it->rtItemTime < message->rtItemTime; it = it->next)
prev_it = it;
if (!prev_it)
{
message->prev = NULL;
if (*queue) message->next = (*queue)->next;
/*assert( NULL == message->next->prev );*/
if (message->next) message->next->prev = message;
*queue = message;
}
else
{
message->prev = prev_it;
message->next = prev_it->next;
prev_it->next = message;
if (message->next) message->next->prev = message;
}
message->bInUse = TRUE;
hr = S_OK;
}
LeaveCriticalSection(&This->safe);
return hr;
}
static HRESULT WINAPI performance_MusicToReferenceTime(IDirectMusicPerformance8 *iface,
......
......@@ -1767,12 +1767,12 @@ static void test_performance_pmsg(void)
hr = IDirectMusicPerformance_SendPMsg(performance, NULL);
ok(hr == E_POINTER, "got %#lx\n", hr);
hr = IDirectMusicPerformance_SendPMsg(performance, msg);
todo_wine ok(hr == DMUS_E_NO_MASTER_CLOCK, "got %#lx\n", hr);
ok(hr == DMUS_E_NO_MASTER_CLOCK, "got %#lx\n", hr);
hr = IDirectMusicPerformance_FreePMsg(performance, NULL);
ok(hr == E_POINTER, "got %#lx\n", hr);
hr = IDirectMusicPerformance_FreePMsg(performance, msg);
todo_wine ok(hr == S_OK, "got %#lx\n", hr);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicPerformance_Init(performance, NULL, 0, 0);
......@@ -1802,7 +1802,7 @@ static void test_performance_pmsg(void)
ok(!msg->dwGroupID, "got %ld\n", msg->dwGroupID);
ok(!msg->punkUser, "got %p\n", msg->punkUser);
hr = IDirectMusicPerformance_SendPMsg(performance, msg);
todo_wine ok(hr == E_INVALIDARG, "got %#lx\n", hr);
ok(hr == E_INVALIDARG, "got %#lx\n", hr);
hr = IDirectMusicPerformance8_ClonePMsg((IDirectMusicPerformance8 *)performance, msg, NULL);
todo_wine ok(hr == E_POINTER, "got %#lx\n", hr);
......@@ -1816,7 +1816,7 @@ static void test_performance_pmsg(void)
msg->mtTime = 500;
msg->dwFlags = DMUS_PMSGF_MUSICTIME;
hr = IDirectMusicPerformance_SendPMsg(performance, msg);
todo_wine ok(hr == S_OK, "got %#lx\n", hr);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicPerformance_SendPMsg(performance, msg);
ok(hr == DMUS_E_ALREADY_SENT, "got %#lx\n", hr);
hr = IDirectMusicPerformance_FreePMsg(performance, msg);
......
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