equal
deleted
inserted
replaced
7 condFrontend, condEngine: PSDL_cond; |
7 condFrontend, condEngine: PSDL_cond; |
8 |
8 |
9 procedure initIPC; |
9 procedure initIPC; |
10 procedure freeIPC; |
10 procedure freeIPC; |
11 |
11 |
12 procedure ipcToEngine(p: PChar; len: byte); cdecl; export; |
12 procedure ipcToEngine(s: shortstring); |
13 //function ipcReadFromEngine: shortstring; |
13 //function ipcReadFromEngine: shortstring; |
14 //function ipcCheckFromEngine: boolean; |
14 //function ipcCheckFromEngine: boolean; |
15 |
15 |
16 procedure ipcToFrontend(s: shortstring); |
16 procedure ipcToFrontend(s: shortstring); |
17 procedure ipcToFrontendRaw(p: pointer; len: Longword); |
17 procedure ipcToFrontendRaw(p: pointer; len: Longword); |
18 function ipcReadFromFrontend: shortstring; |
18 function ipcReadFromFrontend: shortstring; |
19 function ipcCheckFromFrontend: boolean; |
19 function ipcCheckFromFrontend: boolean; |
20 |
20 |
21 procedure registerPreviewCallback(p: pointer; f: TIPCCallback); cdecl; export; |
21 procedure registerIPCCallback(p: pointer; f: TIPCCallback); |
22 |
22 |
23 implementation |
23 implementation |
24 |
24 |
25 var callbackPointer: pointer; |
25 var callbackPointer: pointer; |
26 callbackFunction: TIPCCallback; |
26 callbackFunction: TIPCCallback; |
67 SDL_LockMutex(mut); |
67 SDL_LockMutex(mut); |
68 ipcCheck:= (msg.str[0] > #0) or (msg.buf <> nil); |
68 ipcCheck:= (msg.str[0] > #0) or (msg.buf <> nil); |
69 SDL_UnlockMutex(mut) |
69 SDL_UnlockMutex(mut) |
70 end; |
70 end; |
71 |
71 |
72 procedure ipcToEngine(p: PChar; len: byte); cdecl; export; |
72 procedure ipcToEngine(s: shortstring); |
73 var msg: TIPCMessage; |
73 var msg: TIPCMessage; |
74 begin |
74 begin |
75 writeln(stderr, len); |
75 msg.str:= s; |
76 Move(p^, msg.str[1], len); |
|
77 msg.str[0]:= char(len); |
|
78 msg.buf:= nil; |
76 msg.buf:= nil; |
79 ipcSend(msg, msgEngine, mutEngine, condEngine) |
77 ipcSend(msg, msgEngine, mutEngine, condEngine) |
80 end; |
78 end; |
81 |
79 |
82 procedure ipcToFrontend(s: shortstring); |
80 procedure ipcToFrontend(s: shortstring); |
131 FreeMem(msg.buf, msg.len) |
129 FreeMem(msg.buf, msg.len) |
132 end |
130 end |
133 until false |
131 until false |
134 end; |
132 end; |
135 |
133 |
136 procedure registerPreviewCallback(p: pointer; f: TIPCCallback); cdecl; export; |
134 procedure registerIPCCallback(p: pointer; f: TIPCCallback); |
137 begin |
135 begin |
138 callbackPointer:= p; |
136 callbackPointer:= p; |
139 callbackFunction:= f; |
137 callbackFunction:= f; |
140 callbackListenerThread:= SDL_CreateThread(@listener{$IFDEF SDL2}, 'ipcListener'{$ENDIF}, nil); |
138 callbackListenerThread:= SDL_CreateThread(@listener{$IFDEF SDL2}, 'ipcListener'{$ENDIF}, nil); |
141 end; |
139 end; |