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
6effc986
Commit
6effc986
authored
Jul 17, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move async notifications into the main library.
parent
2bd5ddd6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
140 deletions
+176
-140
miniaudio.h
miniaudio.h
+176
-0
research/miniaudio_engine.h
research/miniaudio_engine.h
+0
-140
No files found.
miniaudio.h
View file @
6effc986
...
@@ -5845,6 +5845,53 @@ MA_API ma_result ma_fence_wait(ma_fence* pFence); /* Wait for counter to r
...
@@ -5845,6 +5845,53 @@ MA_API ma_result ma_fence_wait(ma_fence* pFence); /* Wait for counter to r
/*
Notification callback for asynchronous operations.
*/
typedef void ma_async_notification;
typedef struct
{
void (* onSignal)(ma_async_notification* pNotification);
} ma_async_notification_callbacks;
MA_API ma_result ma_async_notification_signal(ma_async_notification* pNotification);
/*
Simple polling notification.
This just sets a variable when the notification has been signalled which is then polled with ma_async_notification_poll_is_signalled()
*/
typedef struct
{
ma_async_notification_callbacks cb;
ma_bool32 signalled;
} ma_async_notification_poll;
MA_API ma_result ma_async_notification_poll_init(ma_async_notification_poll* pNotificationPoll);
MA_API ma_bool32 ma_async_notification_poll_is_signalled(const ma_async_notification_poll* pNotificationPoll);
/*
Event Notification
This uses an ma_event. If threading is disabled (MA_NO_THREADING), initialization will fail.
*/
typedef struct
{
ma_async_notification_callbacks cb;
#ifndef MA_NO_THREADING
ma_event e;
#endif
} ma_async_notification_event;
MA_API ma_result ma_async_notification_event_init(ma_async_notification_event* pNotificationEvent);
MA_API ma_result ma_async_notification_event_uninit(ma_async_notification_event* pNotificationEvent);
MA_API ma_result ma_async_notification_event_wait(ma_async_notification_event* pNotificationEvent);
MA_API ma_result ma_async_notification_event_signal(ma_async_notification_event* pNotificationEvent);
/************************************************************************************************************************************************************
/************************************************************************************************************************************************************
...
@@ -11655,6 +11702,135 @@ MA_API ma_result ma_fence_wait(ma_fence* pFence)
...
@@ -11655,6 +11702,135 @@ MA_API ma_result ma_fence_wait(ma_fence* pFence)
}
}
MA_API ma_result ma_async_notification_signal(ma_async_notification* pNotification)
{
ma_async_notification_callbacks* pNotificationCallbacks = (ma_async_notification_callbacks*)pNotification;
if (pNotification == NULL) {
return MA_INVALID_ARGS;
}
if (pNotificationCallbacks->onSignal == NULL) {
return MA_NOT_IMPLEMENTED;
}
pNotificationCallbacks->onSignal(pNotification);
return MA_INVALID_ARGS;
}
static void ma_async_notification_poll__on_signal(ma_async_notification* pNotification)
{
((ma_async_notification_poll*)pNotification)->signalled = MA_TRUE;
}
MA_API ma_result ma_async_notification_poll_init(ma_async_notification_poll* pNotificationPoll)
{
if (pNotificationPoll == NULL) {
return MA_INVALID_ARGS;
}
pNotificationPoll->cb.onSignal = ma_async_notification_poll__on_signal;
pNotificationPoll->signalled = MA_FALSE;
return MA_SUCCESS;
}
MA_API ma_bool32 ma_async_notification_poll_is_signalled(const ma_async_notification_poll* pNotificationPoll)
{
if (pNotificationPoll == NULL) {
return MA_FALSE;
}
return pNotificationPoll->signalled;
}
static void ma_async_notification_event__on_signal(ma_async_notification* pNotification)
{
ma_async_notification_event_signal((ma_async_notification_event*)pNotification);
}
MA_API ma_result ma_async_notification_event_init(ma_async_notification_event* pNotificationEvent)
{
if (pNotificationEvent == NULL) {
return MA_INVALID_ARGS;
}
pNotificationEvent->cb.onSignal = ma_async_notification_event__on_signal;
#ifndef MA_NO_THREADING
{
ma_result result;
result = ma_event_init(&pNotificationEvent->e);
if (result != MA_SUCCESS) {
return result;
}
return MA_SUCCESS;
}
#else
{
return MA_NOT_IMPLEMENTED; /* Threading is disabled. */
}
#endif
}
MA_API ma_result ma_async_notification_event_uninit(ma_async_notification_event* pNotificationEvent)
{
if (pNotificationEvent == NULL) {
return MA_INVALID_ARGS;
}
#ifndef MA_NO_THREADING
{
ma_event_uninit(&pNotificationEvent->e);
return MA_SUCCESS;
}
#else
{
return MA_NOT_IMPLEMENTED; /* Threading is disabled. */
}
#endif
}
MA_API ma_result ma_async_notification_event_wait(ma_async_notification_event* pNotificationEvent)
{
if (pNotificationEvent == NULL) {
return MA_INVALID_ARGS;
}
#ifndef MA_NO_THREADING
{
return ma_event_wait(&pNotificationEvent->e);
}
#else
{
return MA_NOT_IMPLEMENTED; /* Threading is disabled. */
}
#endif
}
MA_API ma_result ma_async_notification_event_signal(ma_async_notification_event* pNotificationEvent)
{
if (pNotificationEvent == NULL) {
return MA_INVALID_ARGS;
}
#ifndef MA_NO_THREADING
{
return ma_event_signal(&pNotificationEvent->e);
}
#else
{
return MA_NOT_IMPLEMENTED; /* Threading is disabled. */
}
#endif
}
/************************************************************************************************************************************************************
/************************************************************************************************************************************************************
*************************************************************************************************************************************************************
*************************************************************************************************************************************************************
research/miniaudio_engine.h
View file @
6effc986
...
@@ -1102,49 +1102,6 @@ typedef struct ma_resource_manager_data_source ma_resource_manager_data_sou
...
@@ -1102,49 +1102,6 @@ typedef struct ma_resource_manager_data_source ma_resource_manager_data_sou
/*
Notification callback for asynchronous operations.
*/
typedef
void
ma_async_notification
;
typedef
struct
{
void
(
*
onSignal
)(
ma_async_notification
*
pNotification
);
}
ma_async_notification_callbacks
;
MA_API
ma_result
ma_async_notification_signal
(
ma_async_notification
*
pNotification
);
/*
Simple polling notification.
This just sets a variable when the notification has been signalled which is then polled with ma_async_notification_poll_is_signalled()
*/
typedef
struct
{
ma_async_notification_callbacks
cb
;
ma_bool32
signalled
;
}
ma_async_notification_poll
;
MA_API
ma_result
ma_async_notification_poll_init
(
ma_async_notification_poll
*
pNotificationPoll
);
MA_API
ma_bool32
ma_async_notification_poll_is_signalled
(
const
ma_async_notification_poll
*
pNotificationPoll
);
/*
Event Notification
*/
typedef
struct
{
ma_async_notification_callbacks
cb
;
ma_event
e
;
}
ma_async_notification_event
;
MA_API
ma_result
ma_async_notification_event_init
(
ma_async_notification_event
*
pNotificationEvent
);
MA_API
ma_result
ma_async_notification_event_uninit
(
ma_async_notification_event
*
pNotificationEvent
);
MA_API
ma_result
ma_async_notification_event_wait
(
ma_async_notification_event
*
pNotificationEvent
);
MA_API
ma_result
ma_async_notification_event_signal
(
ma_async_notification_event
*
pNotificationEvent
);
/*
/*
Pipeline notifications used by the resource manager. Made up of both an async notification and a fence, both of which are optionally.
Pipeline notifications used by the resource manager. Made up of both an async notification and a fence, both of which are optionally.
*/
*/
...
@@ -4561,103 +4518,6 @@ MA_API void ma_splitter_node_uninit(ma_splitter_node* pSplitterNode, const ma_al
...
@@ -4561,103 +4518,6 @@ MA_API void ma_splitter_node_uninit(ma_splitter_node* pSplitterNode, const ma_al
#define MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS 1000
#define MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS 1000
#endif
#endif
MA_API
ma_result
ma_async_notification_signal
(
ma_async_notification
*
pNotification
)
{
ma_async_notification_callbacks
*
pNotificationCallbacks
=
(
ma_async_notification_callbacks
*
)
pNotification
;
if
(
pNotification
==
NULL
)
{
return
MA_INVALID_ARGS
;
}
if
(
pNotificationCallbacks
->
onSignal
==
NULL
)
{
return
MA_NOT_IMPLEMENTED
;
}
pNotificationCallbacks
->
onSignal
(
pNotification
);
return
MA_INVALID_ARGS
;
}
static
void
ma_async_notification_poll__on_signal
(
ma_async_notification
*
pNotification
)
{
((
ma_async_notification_poll
*
)
pNotification
)
->
signalled
=
MA_TRUE
;
}
MA_API
ma_result
ma_async_notification_poll_init
(
ma_async_notification_poll
*
pNotificationPoll
)
{
if
(
pNotificationPoll
==
NULL
)
{
return
MA_INVALID_ARGS
;
}
pNotificationPoll
->
cb
.
onSignal
=
ma_async_notification_poll__on_signal
;
pNotificationPoll
->
signalled
=
MA_FALSE
;
return
MA_SUCCESS
;
}
MA_API
ma_bool32
ma_async_notification_poll_is_signalled
(
const
ma_async_notification_poll
*
pNotificationPoll
)
{
if
(
pNotificationPoll
==
NULL
)
{
return
MA_FALSE
;
}
return
pNotificationPoll
->
signalled
;
}
static
void
ma_async_notification_event__on_signal
(
ma_async_notification
*
pNotification
)
{
ma_async_notification_event_signal
((
ma_async_notification_event
*
)
pNotification
);
}
MA_API
ma_result
ma_async_notification_event_init
(
ma_async_notification_event
*
pNotificationEvent
)
{
ma_result
result
;
if
(
pNotificationEvent
==
NULL
)
{
return
MA_INVALID_ARGS
;
}
pNotificationEvent
->
cb
.
onSignal
=
ma_async_notification_event__on_signal
;
result
=
ma_event_init
(
&
pNotificationEvent
->
e
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
return
MA_SUCCESS
;
}
MA_API
ma_result
ma_async_notification_event_uninit
(
ma_async_notification_event
*
pNotificationEvent
)
{
if
(
pNotificationEvent
==
NULL
)
{
return
MA_INVALID_ARGS
;
}
ma_event_uninit
(
&
pNotificationEvent
->
e
);
return
MA_SUCCESS
;
}
MA_API
ma_result
ma_async_notification_event_wait
(
ma_async_notification_event
*
pNotificationEvent
)
{
if
(
pNotificationEvent
==
NULL
)
{
return
MA_INVALID_ARGS
;
}
return
ma_event_wait
(
&
pNotificationEvent
->
e
);
}
MA_API
ma_result
ma_async_notification_event_signal
(
ma_async_notification_event
*
pNotificationEvent
)
{
if
(
pNotificationEvent
==
NULL
)
{
return
MA_INVALID_ARGS
;
}
return
ma_event_signal
(
&
pNotificationEvent
->
e
);
}
MA_API
ma_resource_manager_pipeline_notifications
ma_resource_manager_pipeline_notifications_init
(
void
)
MA_API
ma_resource_manager_pipeline_notifications
ma_resource_manager_pipeline_notifications_init
(
void
)
{
{
ma_resource_manager_pipeline_notifications
notifications
;
ma_resource_manager_pipeline_notifications
notifications
;
...
...
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