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