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
f0a8ea3a
Commit
f0a8ea3a
authored
Jun 02, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gh-301' into dev
parents
3c4b0d2e
c6b44df8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
7 deletions
+59
-7
miniaudio.h
miniaudio.h
+58
-6
research/miniaudio_engine.h
research/miniaudio_engine.h
+1
-1
No files found.
miniaudio.h
View file @
f0a8ea3a
...
...
@@ -10672,18 +10672,70 @@ static ma_result ma_semaphore_release__posix(ma_semaphore* pSemaphore)
}
#endif
static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
typedef struct
{
ma_thread_entry_proc entryProc;
void* pData;
ma_allocation_callbacks allocationCallbacks;
} ma_thread_proxy_data;
static ma_thread_result MA_THREADCALL ma_thread_entry_proxy(void* pData)
{
ma_thread_proxy_data* pProxyData = (ma_thread_proxy_data*)pData;
ma_thread_entry_proc entryProc;
void* pEntryProcData;
ma_thread_result result;
#if defined(MA_ON_THREAD_ENTRY)
MA_ON_THREAD_ENTRY
#endif
entryProc = pProxyData->entryProc;
pEntryProcData = pProxyData->pData;
/* Free the proxy data before getting into the real thread entry proc. */
ma_free(pProxyData, &pProxyData->allocationCallbacks);
result = entryProc(pEntryProcData);
#if defined(MA_ON_THREAD_EXIT)
MA_ON_THREAD_EXIT
#endif
return result;
}
static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData, const ma_allocation_callbacks* pAllocationCallbacks)
{
ma_result result;
ma_thread_proxy_data* pProxyData;
if (pThread == NULL || entryProc == NULL) {
return MA_FALSE;
}
pProxyData = (ma_thread_proxy_data*)ma_malloc(sizeof(*pProxyData), pAllocationCallbacks); /* Will be freed by the proxy entry proc. */
if (pProxyData == NULL) {
return MA_OUT_OF_MEMORY;
}
pProxyData->entryProc = entryProc;
pProxyData->pData = pData;
ma_allocation_callbacks_init_copy(&pProxyData->allocationCallbacks, pAllocationCallbacks);
#ifdef MA_WIN32
re
turn ma_thread_create__win32(pThread, priority, stackSize, entryProc, p
Data);
re
sult = ma_thread_create__win32(pThread, priority, stackSize, ma_thread_entry_proxy, pProxy
Data);
#endif
#ifdef MA_POSIX
re
turn ma_thread_create__posix(pThread, priority, stackSize, entryProc, p
Data);
re
sult = ma_thread_create__posix(pThread, priority, stackSize, ma_thread_entry_proxy, pProxy
Data);
#endif
if (result != MA_SUCCESS) {
ma_free(pProxyData, pAllocationCallbacks);
return result;
}
return MA_SUCCESS;
}
static void ma_thread_wait(ma_thread* pThread)
...
...
@@ -12553,7 +12605,7 @@ static ma_result ma_device_init__null(ma_device* pDevice, const ma_device_config
return result;
}
result = ma_thread_create(&pDevice->null_device.deviceThread, pDevice->pContext->threadPriority, 0, ma_device_thread__null, pDevice);
result = ma_thread_create(&pDevice->null_device.deviceThread, pDevice->pContext->threadPriority, 0, ma_device_thread__null, pDevice
, &pDevice->pContext->allocationCallbacks
);
if (result != MA_SUCCESS) {
return result;
}
...
...
@@ -16382,7 +16434,7 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_
return result;
}
result = ma_thread_create(&pContext->wasapi.commandThread, ma_thread_priority_normal, 0, ma_context_command_thread__wasapi, pContext);
result = ma_thread_create(&pContext->wasapi.commandThread, ma_thread_priority_normal, 0, ma_context_command_thread__wasapi, pContext
, &pContext->allocationCallbacks
);
if (result != MA_SUCCESS) {
ma_semaphore_uninit(&pContext->wasapi.commandSem);
ma_mutex_uninit(&pContext->wasapi.commandLock);
...
...
@@ -33403,7 +33455,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
/* Some backends don't require the worker thread. */
if (!ma_context_is_backend_asynchronous(pContext)) {
/* The worker thread. */
result = ma_thread_create(&pDevice->thread, pContext->threadPriority, pContext->threadStackSize, ma_worker_thread, pDevice);
result = ma_thread_create(&pDevice->thread, pContext->threadPriority, pContext->threadStackSize, ma_worker_thread, pDevice
, &pContext->allocationCallbacks
);
if (result != MA_SUCCESS) {
ma_device_uninit(pDevice);
return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread.", result);
research/miniaudio_engine.h
View file @
f0a8ea3a
...
...
@@ -6410,7 +6410,7 @@ MA_API ma_result ma_resource_manager_init(const ma_resource_manager_config* pCon
/* Create the job threads last to ensure the threads has access to valid data. */
for
(
iJobThread
=
0
;
iJobThread
<
pResourceManager
->
config
.
jobThreadCount
;
iJobThread
+=
1
)
{
result
=
ma_thread_create
(
&
pResourceManager
->
jobThreads
[
iJobThread
],
ma_thread_priority_normal
,
0
,
ma_resource_manager_job_thread
,
pResourceManager
);
result
=
ma_thread_create
(
&
pResourceManager
->
jobThreads
[
iJobThread
],
ma_thread_priority_normal
,
0
,
ma_resource_manager_job_thread
,
&
pResourceManager
->
config
.
allocationCallbacks
);
if
(
result
!=
MA_SUCCESS
)
{
ma_mutex_uninit
(
&
pResourceManager
->
dataBufferBSTLock
);
ma_job_queue_uninit
(
&
pResourceManager
->
jobQueue
);
...
...
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