@@ -72,10 +72,13 @@ struct performance
72
72
struct message
73
73
{
74
74
struct list entry ;
75
- DMUS_PMSG pMsg ;
75
+ DMUS_PMSG msg ;
76
76
};
77
77
78
- #define DMUS_PMSGToItem (pMSG ) ((struct message *)(((unsigned char *)pMSG) - offsetof(struct message, pMsg)))
78
+ static inline struct message * message_from_DMUS_PMSG (DMUS_PMSG * msg )
79
+ {
80
+ return msg ? CONTAINING_RECORD (msg , struct message , msg ) : NULL ;
81
+ }
79
82
80
83
#define PROCESSMSG_START (WM_APP + 0)
81
84
#define PROCESSMSG_EXIT (WM_APP + 1)
@@ -85,17 +88,17 @@ struct message
85
88
86
89
static struct message * ProceedMsg (struct performance * This , struct message * cur )
87
90
{
88
- if (cur -> pMsg .dwType == DMUS_PMSGT_NOTIFICATION ) {
91
+ if (cur -> msg .dwType == DMUS_PMSGT_NOTIFICATION ) {
89
92
SetEvent (This -> hNotification );
90
93
}
91
94
list_remove (& cur -> entry );
92
95
list_init (& cur -> entry );
93
- switch (cur -> pMsg .dwType ) {
96
+ switch (cur -> msg .dwType ) {
94
97
case DMUS_PMSGT_WAVE :
95
98
case DMUS_PMSGT_TEMPO :
96
99
case DMUS_PMSGT_STOP :
97
100
default :
98
- FIXME ("Unhandled PMsg Type: %#lx\n" , cur -> pMsg .dwType );
101
+ FIXME ("Unhandled PMsg Type: %#lx\n" , cur -> msg .dwType );
99
102
break ;
100
103
}
101
104
return cur ;
@@ -130,8 +133,8 @@ static DWORD WINAPI ProcessMsgThread(LPVOID lpParam) {
130
133
131
134
LIST_FOR_EACH_ENTRY_SAFE (message , next , & This -> queued_messages , struct message , entry )
132
135
{
133
- timeOut = (message -> pMsg .rtTime - rtCurTime ) + This -> rtLatencyTime ;
134
- if (message -> pMsg .rtTime >= rtCurTime + dwDec ) break ;
136
+ timeOut = (message -> msg .rtTime - rtCurTime ) + This -> rtLatencyTime ;
137
+ if (message -> msg .rtTime >= rtCurTime + dwDec ) break ;
135
138
cur = ProceedMsg (This , message );
136
139
free (cur );
137
140
}
@@ -393,15 +396,13 @@ static HRESULT WINAPI performance_SendPMsg(IDirectMusicPerformance8 *iface, DMUS
393
396
394
397
FIXME ("(%p, %p): semi-stub\n" , This , msg );
395
398
396
- if (!msg ) return E_POINTER ;
399
+ if (!( message = message_from_DMUS_PMSG ( msg )) ) return E_POINTER ;
397
400
if (!This -> dmusic ) return DMUS_E_NO_MASTER_CLOCK ;
398
401
if (!(msg -> dwFlags & (DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_REFTIME ))) return E_INVALIDARG ;
399
402
400
403
if (msg -> dwFlags & DMUS_PMSGF_TOOL_IMMEDIATE ) queue = & This -> immediate_messages ;
401
404
else queue = & This -> queued_messages ;
402
405
403
- message = DMUS_PMSGToItem (msg );
404
-
405
406
EnterCriticalSection (& This -> safe );
406
407
407
408
if (!list_empty (& message -> entry ))
@@ -424,7 +425,7 @@ static HRESULT WINAPI performance_SendPMsg(IDirectMusicPerformance8 *iface, DMUS
424
425
}
425
426
426
427
LIST_FOR_EACH_ENTRY (next , queue , struct message , entry )
427
- if (next -> pMsg .rtTime >= message -> pMsg .rtTime ) break ;
428
+ if (next -> msg .rtTime >= message -> msg .rtTime ) break ;
428
429
list_add_before (& next -> entry , & message -> entry );
429
430
430
431
hr = S_OK ;
@@ -511,9 +512,9 @@ static HRESULT WINAPI performance_AllocPMsg(IDirectMusicPerformance8 *iface, ULO
511
512
if (size < sizeof (DMUS_PMSG )) return E_INVALIDARG ;
512
513
513
514
if (!(message = calloc (1 , size - sizeof (DMUS_PMSG ) + sizeof (struct message )))) return E_OUTOFMEMORY ;
514
- message -> pMsg .dwSize = size ;
515
+ message -> msg .dwSize = size ;
515
516
list_init (& message -> entry );
516
- * msg = & message -> pMsg ;
517
+ * msg = & message -> msg ;
517
518
518
519
return S_OK ;
519
520
}
@@ -526,8 +527,7 @@ static HRESULT WINAPI performance_FreePMsg(IDirectMusicPerformance8 *iface, DMUS
526
527
527
528
TRACE ("(%p, %p)\n" , This , msg );
528
529
529
- if (!msg ) return E_POINTER ;
530
- message = DMUS_PMSGToItem (msg );
530
+ if (!(message = message_from_DMUS_PMSG (msg ))) return E_POINTER ;
531
531
532
532
EnterCriticalSection (& This -> safe );
533
533
hr = !list_empty (& message -> entry ) ? DMUS_E_CANNOT_FREE : S_OK ;
0 commit comments