Ken Thomases : winecoreaudio: Use unique name for message port.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jun 1 06:49:04 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: fb5a073e462308eeb6a0ba19be91d6fe30a59f22
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=fb5a073e462308eeb6a0ba19be91d6fe30a59f22
Author: Ken Thomases <ken at codeweavers.com>
Date: Wed May 24 05:43:14 2006 -0500
winecoreaudio: Use unique name for message port.
Use a unique port name for the message port to the message thread.
Port names are system-global, so using a non-unique constant name
prevents the CoreAudio driver from being used in multiple processes
simultaneously.
---
dlls/winmm/winecoreaudio/audio.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/winmm/winecoreaudio/audio.c b/dlls/winmm/winecoreaudio/audio.c
index bc7a47d..df6bdc8 100644
--- a/dlls/winmm/winecoreaudio/audio.c
+++ b/dlls/winmm/winecoreaudio/audio.c
@@ -171,6 +171,8 @@ typedef struct {
static WINE_WAVEOUT WOutDev [MAX_WAVEOUTDRV];
+static CFStringRef MessageThreadPortName;
+
static LPWAVEHDR wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo);
static DWORD wodHelper_NotifyCompletions(WINE_WAVEOUT* wwo, BOOL force);
@@ -279,7 +281,7 @@ static DWORD WINAPI messageThread(LPVOID
CFRunLoopSourceRef source;
Boolean info;
- local = CFMessagePortCreateLocal(kCFAllocatorDefault, CFSTR("WaveMessagePort"),
+ local = CFMessagePortCreateLocal(kCFAllocatorDefault, MessageThreadPortName,
&wodMessageHandler, NULL, &info);
source = CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, local, (CFIndex)0);
@@ -290,6 +292,8 @@ static DWORD WINAPI messageThread(LPVOID
CFRunLoopSourceInvalidate(source);
CFRelease(source);
CFRelease(local);
+ CFRelease(MessageThreadPortName);
+ MessageThreadPortName = NULL;
return 0;
}
@@ -301,7 +305,7 @@ static DWORD wodSendDriverCallbackMessag
SInt32 ret;
CFMessagePortRef messagePort;
- messagePort = CFMessagePortCreateRemote(kCFAllocatorDefault, CFSTR("WaveMessagePort"));
+ messagePort = CFMessagePortCreateRemote(kCFAllocatorDefault, MessageThreadPortName);
buffer = CFAllocatorAllocate(NULL, sizeof(UInt32) * 4, 0);
if (!buffer)
@@ -525,6 +529,15 @@ LONG CoreAudio_WaveInit(void)
pthread_mutexattr_destroy(&mutexattr);
/* create mach messages handler */
+ srandomdev();
+ MessageThreadPortName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
+ CFSTR("WaveMessagePort.%d.%lu"), getpid(), (unsigned long)random());
+ if (!MessageThreadPortName)
+ {
+ ERR("Can't create message thread port name\n");
+ return 1;
+ }
+
hThread = CreateThread(NULL, 0, messageThread, NULL, 0, NULL);
if ( !hThread )
{
@@ -543,7 +556,7 @@ void CoreAudio_WaveRelease(void)
TRACE("()\n");
- messagePort = CFMessagePortCreateRemote(kCFAllocatorDefault, CFSTR("WaveMessagePort"));
+ messagePort = CFMessagePortCreateRemote(kCFAllocatorDefault, MessageThreadPortName);
CFMessagePortSendRequest(messagePort, kStopLoopMessage, NULL, 0.0, 0.0, NULL, NULL);
CFRelease(messagePort);
More information about the wine-cvs
mailing list