Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
66e7518e
Commit
66e7518e
authored
Jun 08, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the ma_event structure.
parent
ad708403
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
38 deletions
+28
-38
miniaudio.h
miniaudio.h
+28
-38
No files found.
miniaudio.h
View file @
66e7518e
...
...
@@ -3029,27 +3029,17 @@ typedef ma_handle ma_mutex;
typedef pthread_mutex_t ma_mutex;
#endif
#if defined(MA_WIN32)
typedef ma_handle ma_event;
#endif
#if defined(MA_POSIX)
typedef struct
{
union
{
#ifdef MA_WIN32
struct
{
/*HANDLE*/ ma_handle hEvent;
} win32;
#endif
#ifdef MA_POSIX
struct
{
pthread_mutex_t mutex;
pthread_cond_t condition;
ma_uint32 value;
} posix;
#endif
int _unused;
};
pthread_mutex_t lock;
pthread_cond_t cond;
ma_uint32 value;
} ma_event;
#endif
typedef struct
{
...
...
@@ -7766,8 +7756,8 @@ static void ma_mutex_unlock__win32(ma_mutex* pMutex)
static ma_result ma_event_init__win32(ma_event* pEvent)
{
pEvent->win32.h
Event = CreateEventW(NULL, FALSE, FALSE, NULL);
if (
pEvent->win32.h
Event == NULL) {
*p
Event = CreateEventW(NULL, FALSE, FALSE, NULL);
if (
*p
Event == NULL) {
return ma_result_from_GetLastError(GetLastError());
}
...
...
@@ -7776,17 +7766,17 @@ static ma_result ma_event_init__win32(ma_event* pEvent)
static void ma_event_uninit__win32(ma_event* pEvent)
{
CloseHandle(
pEvent->win32.h
Event);
CloseHandle(
(HANDLE)*p
Event);
}
static ma_bool32 ma_event_wait__win32(ma_event* pEvent)
{
return WaitForSingleObject(
pEvent->win32.h
Event, INFINITE) == WAIT_OBJECT_0;
return WaitForSingleObject(
(HANDLE)*p
Event, INFINITE) == WAIT_OBJECT_0;
}
static ma_bool32 ma_event_signal__win32(ma_event* pEvent)
{
return SetEvent(
pEvent->win32.h
Event);
return SetEvent(
(HANDLE)*p
Event);
}
...
...
@@ -7946,49 +7936,49 @@ static ma_result ma_event_init__posix(ma_event* pEvent)
{
int result;
result = pthread_mutex_init(&pEvent->
posix.mutex
, NULL);
result = pthread_mutex_init(&pEvent->
lock
, NULL);
if (result != 0) {
return ma_result_from_errno(result);
}
result = pthread_cond_init(&pEvent->
posix.condition
, NULL);
result = pthread_cond_init(&pEvent->
cond
, NULL);
if (result != 0) {
pthread_mutex_destroy(&pEvent->
posix.mutex
);
pthread_mutex_destroy(&pEvent->
lock
);
return ma_result_from_errno(result);
}
pEvent->
posix.
value = 0;
pEvent->value = 0;
return MA_SUCCESS;
}
static void ma_event_uninit__posix(ma_event* pEvent)
{
pthread_cond_destroy(&pEvent->
posix.condition
);
pthread_mutex_destroy(&pEvent->
posix.mutex
);
pthread_cond_destroy(&pEvent->
cond
);
pthread_mutex_destroy(&pEvent->
lock
);
}
static ma_bool32 ma_event_wait__posix(ma_event* pEvent)
{
pthread_mutex_lock(&pEvent->
posix.mutex
);
pthread_mutex_lock(&pEvent->
lock
);
{
while (pEvent->
posix.
value == 0) {
pthread_cond_wait(&pEvent->
posix.condition, &pEvent->posix.mutex
);
while (pEvent->value == 0) {
pthread_cond_wait(&pEvent->
cond, &pEvent->lock
);
}
pEvent->
posix.
value = 0; /* Auto-reset. */
pEvent->value = 0; /* Auto-reset. */
}
pthread_mutex_unlock(&pEvent->
posix.mutex
);
pthread_mutex_unlock(&pEvent->
lock
);
return MA_TRUE;
}
static ma_bool32 ma_event_signal__posix(ma_event* pEvent)
{
pthread_mutex_lock(&pEvent->
posix.mutex
);
pthread_mutex_lock(&pEvent->
lock
);
{
pEvent->
posix.
value = 1;
pthread_cond_signal(&pEvent->
posix.condition
);
pEvent->value = 1;
pthread_cond_signal(&pEvent->
cond
);
}
pthread_mutex_unlock(&pEvent->
posix.mutex
);
pthread_mutex_unlock(&pEvent->
lock
);
return MA_TRUE;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment