Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Mon, Nov 29, 2021 at 11:26:45AM +0000, Huw Davies wrote:
The syscall itself is temporary.
Signed-off-by: Huw Davies huw@codeweavers.com
dlls/winecoreaudio.drv/coreaudio.c | 2 ++ dlls/winecoreaudio.drv/coremidi.c | 13 ++++++++++++ dlls/winecoreaudio.drv/midi.c | 32 +++++++++++++----------------- dlls/winecoreaudio.drv/unixlib.h | 3 +++ 4 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index b3aa39bf485..420021a53ea 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -1633,4 +1633,6 @@ unixlib_entry_t __wine_unix_call_funcs[] = midi_release, midi_out_message, midi_in_message,
- midi_in_lock, /* temporary */
}; diff --git a/dlls/winecoreaudio.drv/coremidi.c b/dlls/winecoreaudio.drv/coremidi.c index 0e146ce86f6..8e12ad1a3c5 100644 --- a/dlls/winecoreaudio.drv/coremidi.c +++ b/dlls/winecoreaudio.drv/coremidi.c @@ -72,6 +72,8 @@ #undef HRESULT #undef STDMETHODCALLTYPE
+#include <pthread.h>
#include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" @@ -112,6 +114,17 @@ static struct midi_dest *dests; static struct midi_src *srcs; static CFStringRef midi_in_thread_port_name;
+static pthread_mutex_t midi_in_mutex = PTHREAD_MUTEX_INITIALIZER;
+NTSTATUS midi_in_lock(void *args) +{
- BOOL lock = !!args;
- if (lock) pthread_mutex_lock(&midi_in_mutex);
- else pthread_mutex_unlock(&midi_in_mutex);
- return STATUS_SUCCESS;
+}
static void set_in_notify(struct notify_context *notify, struct midi_src *src, WORD dev_id, WORD msg, DWORD_PTR param_1, DWORD_PTR param_2) { diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c index 559aae2f939..7894b4da906 100644 --- a/dlls/winecoreaudio.drv/midi.c +++ b/dlls/winecoreaudio.drv/midi.c @@ -52,7 +52,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(midi);
static DWORD MIDIIn_NumDevs = 0;
-static CRITICAL_SECTION midiInLock; /* Critical section for MIDI In */
static CFStringRef MIDIInThreadPortName;
static DWORD WINAPI MIDIIn_MessageThread(LPVOID p); @@ -89,9 +89,6 @@ static LONG CoreAudio_MIDIInit(void)
if (MIDIIn_NumDevs > 0) {
InitializeCriticalSection(&midiInLock);
midiInLock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": midiInLock");
}MIDIInThreadPortName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("MIDIInThreadPortName.%u"), getpid()); CloseHandle( CreateThread(NULL, 0, MIDIIn_MessageThread, NULL, 0, NULL));
@@ -105,12 +102,6 @@ static LONG CoreAudio_MIDIRelease(void) UNIX_CALL(midi_release, NULL); sources = NULL;
- if (MIDIIn_NumDevs > 0)
- {
midiInLock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&midiInLock);
- }
- return DRV_SUCCESS;
}
@@ -146,6 +137,11 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_ DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2); }
+static void midi_lock( BOOL lock ) +{
- UNIX_CALL(midi_in_lock, (void *)lock);
+}
static DWORD MIDIIn_AddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) { TRACE("wDevID=%d lpMidiHdr=%p dwSize=%d\n", wDevID, lpMidiHdr, dwSize); @@ -175,7 +171,7 @@ static DWORD MIDIIn_AddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) return MIDIERR_UNPREPARED; }
- EnterCriticalSection(&midiInLock);
- midi_lock( TRUE ); lpMidiHdr->dwFlags &= ~WHDR_DONE; lpMidiHdr->dwFlags |= MHDR_INQUEUE; lpMidiHdr->dwBytesRecorded = 0;
@@ -189,7 +185,7 @@ static DWORD MIDIIn_AddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) ptr = ptr->lpNext); ptr->lpNext = lpMidiHdr; }
- LeaveCriticalSection(&midiInLock);
midi_lock( FALSE );
return MMSYSERR_NOERROR;
} @@ -204,7 +200,7 @@ static DWORD MIDIIn_Reset(WORD wDevID) return MMSYSERR_BADDEVICEID; }
- EnterCriticalSection(&midiInLock);
- midi_lock( TRUE ); while (sources[wDevID].lpQueueHdr) { LPMIDIHDR lpMidiHdr = sources[wDevID].lpQueueHdr; sources[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
@@ -213,7 +209,7 @@ static DWORD MIDIIn_Reset(WORD wDevID) /* FIXME: when called from 16 bit, lpQueueHdr needs to be a segmented ptr */ MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime); }
- LeaveCriticalSection(&midiInLock);
midi_lock( FALSE );
return MMSYSERR_NOERROR;
} @@ -258,7 +254,7 @@ static CFDataRef MIDIIn_MessageHandler(CFMessagePortRef local, SInt32 msgid, CFD src->state |= 2; }
EnterCriticalSection(&midiInLock);
midi_lock( TRUE ); currentTime = GetTickCount() - src->startTime; while (len) {
@@ -289,11 +285,11 @@ static CFDataRef MIDIIn_MessageHandler(CFMessagePortRef local, SInt32 msgid, CFD } }
LeaveCriticalSection(&midiInLock);
midi_lock( FALSE ); return NULL; }
EnterCriticalSection(&midiInLock);
midi_lock( TRUE ); currentTime = GetTickCount() - src->startTime; while (pos < msg->length)
@@ -320,7 +316,7 @@ static CFDataRef MIDIIn_MessageHandler(CFMessagePortRef local, SInt32 msgid, CFD } MIDI_NotifyClient(msg->devID, MIM_DATA, sendData, currentTime); }
LeaveCriticalSection(&midiInLock);
midi_lock( FALSE ); break; default: CFRunLoopStop(CFRunLoopGetCurrent());
diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h index 767309bb763..2f0464ad322 100644 --- a/dlls/winecoreaudio.drv/unixlib.h +++ b/dlls/winecoreaudio.drv/unixlib.h @@ -252,12 +252,15 @@ enum unix_funcs unix_midi_release, unix_midi_out_message, unix_midi_in_message,
- unix_midi_in_lock, /* temporary */
};
NTSTATUS midi_init( void * ) DECLSPEC_HIDDEN; NTSTATUS midi_release( void * ) DECLSPEC_HIDDEN; NTSTATUS midi_out_message( void * ) DECLSPEC_HIDDEN; NTSTATUS midi_in_message( void * ) DECLSPEC_HIDDEN; +NTSTATUS midi_in_lock( void * ) DECLSPEC_HIDDEN;
extern unixlib_handle_t coreaudio_handle;
-- 2.23.0