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
205c3b0e
Commit
205c3b0e
authored
Jul 15, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate the new callback system.
parent
1bf3ab8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
415 deletions
+7
-415
mini_al.h
mini_al.h
+7
-415
No files found.
mini_al.h
View file @
205c3b0e
...
@@ -17442,202 +17442,6 @@ mal_bool32 mal__is_channel_map_valid(const mal_channel* channelMap, mal_uint32 c
...
@@ -17442,202 +17442,6 @@ mal_bool32 mal__is_channel_map_valid(const mal_channel* channelMap, mal_uint32 c
}
}
mal_result mal_device__start_backend(mal_device* pDevice)
{
mal_assert(pDevice != NULL);
mal_result result = MAL_NO_BACKEND;
#ifdef MAL_HAS_WASAPI
if (pDevice->pContext->backend == mal_backend_wasapi) {
result = pDevice->pContext->onDeviceStart(pDevice);
}
#endif
#ifdef MAL_HAS_DSOUND
if (pDevice->pContext->backend == mal_backend_dsound) {
result = mal_device__start_backend__dsound(pDevice);
}
#endif
#ifdef MAL_HAS_WINMM
if (pDevice->pContext->backend == mal_backend_winmm) {
result = mal_device__start_backend__winmm(pDevice);
}
#endif
#ifdef MAL_HAS_ALSA
if (pDevice->pContext->backend == mal_backend_alsa) {
result = mal_device__start_backend__alsa(pDevice);
}
#endif
#ifdef MAL_HAS_PULSEAUDIO
if (pDevice->pContext->backend == mal_backend_pulseaudio) {
result = mal_device__start_backend__pulse(pDevice);
}
#endif
#ifdef MAL_HAS_OSS
if (pDevice->pContext->backend == mal_backend_oss) {
result = mal_device__start_backend__oss(pDevice);
}
#endif
#ifdef MAL_HAS_OPENAL
if (pDevice->pContext->backend == mal_backend_openal) {
result = mal_device__start_backend__openal(pDevice);
}
#endif
#ifdef MAL_HAS_NULL
if (pDevice->pContext->backend == mal_backend_null) {
result = mal_device__start_backend__null(pDevice);
}
#endif
return result;
}
mal_result mal_device__stop_backend(mal_device* pDevice)
{
mal_assert(pDevice != NULL);
mal_result result = MAL_NO_BACKEND;
#ifdef MAL_HAS_WASAPI
if (pDevice->pContext->backend == mal_backend_wasapi) {
result = pDevice->pContext->onDeviceStop(pDevice);
}
#endif
#ifdef MAL_HAS_DSOUND
if (pDevice->pContext->backend == mal_backend_dsound) {
result = mal_device__stop_backend__dsound(pDevice);
}
#endif
#ifdef MAL_HAS_WINMM
if (pDevice->pContext->backend == mal_backend_winmm) {
result = mal_device__stop_backend__winmm(pDevice);
}
#endif
#ifdef MAL_HAS_ALSA
if (pDevice->pContext->backend == mal_backend_alsa) {
result = mal_device__stop_backend__alsa(pDevice);
}
#endif
#ifdef MAL_HAS_PULSEAUDIO
if (pDevice->pContext->backend == mal_backend_pulseaudio) {
result = mal_device__stop_backend__pulse(pDevice);
}
#endif
#ifdef MAL_HAS_OSS
if (pDevice->pContext->backend == mal_backend_oss) {
result = mal_device__stop_backend__oss(pDevice);
}
#endif
#ifdef MAL_HAS_OPENAL
if (pDevice->pContext->backend == mal_backend_openal) {
result = mal_device__stop_backend__openal(pDevice);
}
#endif
#ifdef MAL_HAS_NULL
if (pDevice->pContext->backend == mal_backend_null) {
result = mal_device__stop_backend__null(pDevice);
}
#endif
return result;
}
mal_result mal_device__break_main_loop(mal_device* pDevice)
{
mal_assert(pDevice != NULL);
mal_result result = MAL_NO_BACKEND;
#ifdef MAL_HAS_WASAPI
if (pDevice->pContext->backend == mal_backend_wasapi) {
result = pDevice->pContext->onDeviceBreakMainLoop(pDevice);
}
#endif
#ifdef MAL_HAS_DSOUND
if (pDevice->pContext->backend == mal_backend_dsound) {
result = mal_device__break_main_loop__dsound(pDevice);
}
#endif
#ifdef MAL_HAS_WINMM
if (pDevice->pContext->backend == mal_backend_winmm) {
result = mal_device__break_main_loop__winmm(pDevice);
}
#endif
#ifdef MAL_HAS_ALSA
if (pDevice->pContext->backend == mal_backend_alsa) {
result = mal_device__break_main_loop__alsa(pDevice);
}
#endif
#ifdef MAL_HAS_PULSEAUDIO
if (pDevice->pContext->backend == mal_backend_pulseaudio) {
result = mal_device__break_main_loop__pulse(pDevice);
}
#endif
#ifdef MAL_HAS_OSS
if (pDevice->pContext->backend == mal_backend_oss) {
result = mal_device__break_main_loop__oss(pDevice);
}
#endif
#ifdef MAL_HAS_OPENAL
if (pDevice->pContext->backend == mal_backend_openal) {
result = mal_device__break_main_loop__openal(pDevice);
}
#endif
#ifdef MAL_HAS_NULL
if (pDevice->pContext->backend == mal_backend_null) {
result = mal_device__break_main_loop__null(pDevice);
}
#endif
return result;
}
mal_result mal_device__main_loop(mal_device* pDevice)
{
mal_assert(pDevice != NULL);
mal_result result = MAL_NO_BACKEND;
#ifdef MAL_HAS_WASAPI
if (pDevice->pContext->backend == mal_backend_wasapi) {
result = pDevice->pContext->onDeviceMainLoop(pDevice);
}
#endif
#ifdef MAL_HAS_DSOUND
if (pDevice->pContext->backend == mal_backend_dsound) {
result = mal_device__main_loop__dsound(pDevice);
}
#endif
#ifdef MAL_HAS_WINMM
if (pDevice->pContext->backend == mal_backend_winmm) {
result = mal_device__main_loop__winmm(pDevice);
}
#endif
#ifdef MAL_HAS_ALSA
if (pDevice->pContext->backend == mal_backend_alsa) {
result = mal_device__main_loop__alsa(pDevice);
}
#endif
#ifdef MAL_HAS_PULSEAUDIO
if (pDevice->pContext->backend == mal_backend_pulseaudio) {
result = mal_device__main_loop__pulse(pDevice);
}
#endif
#ifdef MAL_HAS_OSS
if (pDevice->pContext->backend == mal_backend_oss) {
result = mal_device__main_loop__oss(pDevice);
}
#endif
#ifdef MAL_HAS_OPENAL
if (pDevice->pContext->backend == mal_backend_openal) {
result = mal_device__main_loop__openal(pDevice);
}
#endif
#ifdef MAL_HAS_NULL
if (pDevice->pContext->backend == mal_backend_null) {
result = mal_device__main_loop__null(pDevice);
}
#endif
return result;
}
mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
{
{
mal_device* pDevice = (mal_device*)pData;
mal_device* pDevice = (mal_device*)pData;
...
@@ -17652,7 +17456,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
...
@@ -17652,7 +17456,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
for (;;) {
for (;;) {
// At the start of iteration the device is stopped - we must explicitly mark it as such.
// At the start of iteration the device is stopped - we must explicitly mark it as such.
mal_device__stop_backend
(pDevice);
pDevice->pContext->onDeviceStop
(pDevice);
if (!skipNextStopEvent) {
if (!skipNextStopEvent) {
mal_stop_proc onStop = pDevice->onStop;
mal_stop_proc onStop = pDevice->onStop;
...
@@ -17684,7 +17488,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
...
@@ -17684,7 +17488,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
// either deliver us data (recording) or request more data (playback).
// either deliver us data (recording) or request more data (playback).
mal_assert(mal_device__get_state(pDevice) == MAL_STATE_STARTING);
mal_assert(mal_device__get_state(pDevice) == MAL_STATE_STARTING);
pDevice->workResult =
mal_device__start_backend
(pDevice);
pDevice->workResult =
pDevice->pContext->onDeviceStart
(pDevice);
if (pDevice->workResult != MAL_SUCCESS) {
if (pDevice->workResult != MAL_SUCCESS) {
mal_event_signal(&pDevice->startEvent);
mal_event_signal(&pDevice->startEvent);
continue;
continue;
...
@@ -17696,7 +17500,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
...
@@ -17696,7 +17500,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData)
mal_event_signal(&pDevice->startEvent);
mal_event_signal(&pDevice->startEvent);
// Now we just enter the main loop. The main loop can be broken with mal_device__break_main_loop().
// Now we just enter the main loop. The main loop can be broken with mal_device__break_main_loop().
mal_device__main_l
oop(pDevice);
pDevice->pContext->onDeviceMainL
oop(pDevice);
}
}
// Make sure we aren't continuously waiting on a stop event.
// Make sure we aren't continuously waiting on a stop event.
...
@@ -18024,82 +17828,7 @@ mal_result mal_context_uninit(mal_context* pContext)
...
@@ -18024,82 +17828,7 @@ mal_result mal_context_uninit(mal_context* pContext)
return MAL_INVALID_ARGS;
return MAL_INVALID_ARGS;
}
}
switch (pContext->backend) {
pContext->onUninit(pContext);
#ifdef MAL_HAS_WASAPI
case mal_backend_wasapi:
{
pContext->onUninit(pContext);
} break;
#endif
#ifdef MAL_HAS_DSOUND
case mal_backend_dsound:
{
mal_context_uninit__dsound(pContext);
} break;
#endif
#ifdef MAL_HAS_WINMM
case mal_backend_winmm:
{
mal_context_uninit__winmm(pContext);
} break;
#endif
#ifdef MAL_HAS_ALSA
case mal_backend_alsa:
{
mal_context_uninit__alsa(pContext);
} break;
#endif
#ifdef MAL_HAS_PULSEAUDIO
case mal_backend_pulseaudio:
{
mal_context_uninit__pulse(pContext);
} break;
#endif
#ifdef MAL_HAS_JACK
case mal_backend_jack:
{
pContext->onUninit(pContext);
} break;
#endif
#ifdef MAL_HAS_COREAUDIO
case mal_backend_coreaudio:
{
pContext->onUninit(pContext);
} break;
#endif
#ifdef MAL_HAS_OSS
case mal_backend_oss:
{
mal_context_uninit__oss(pContext);
} break;
#endif
#ifdef MAL_HAS_OPENSL
case mal_backend_opensl:
{
pContext->onUninit(pContext);
} break;
#endif
#ifdef MAL_HAS_OPENAL
case mal_backend_openal:
{
mal_context_uninit__openal(pContext);
} break;
#endif
#ifdef MAL_HAS_SDL
case mal_backend_sdl:
{
pContext->onUninit(pContext);
} break;
#endif
#ifdef MAL_HAS_NULL
case mal_backend_null:
{
mal_context_uninit__null(pContext);
} break;
#endif
default: break;
}
mal_context_uninit_backend_apis(pContext);
mal_context_uninit_backend_apis(pContext);
mal_mutex_uninit(&pContext->deviceEnumLock);
mal_mutex_uninit(&pContext->deviceEnumLock);
...
@@ -18368,85 +18097,7 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
...
@@ -18368,85 +18097,7 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
}
}
mal_result result = MAL_NO_BACKEND;
mal_result result = pContext->onDeviceInit(pContext, type, pDeviceID, &config, pDevice);
switch (pContext->backend)
{
#ifdef MAL_HAS_WASAPI
case mal_backend_wasapi:
{
result = pContext->onDeviceInit(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_DSOUND
case mal_backend_dsound:
{
result = mal_device_init__dsound(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_WINMM
case mal_backend_winmm:
{
result = mal_device_init__winmm(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_ALSA
case mal_backend_alsa:
{
result = mal_device_init__alsa(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_PULSEAUDIO
case mal_backend_pulseaudio:
{
result = mal_device_init__pulse(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_JACK
case mal_backend_jack:
{
result = pContext->onDeviceInit(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_COREAUDIO
case mal_backend_coreaudio:
{
result = pContext->onDeviceInit(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_OSS
case mal_backend_oss:
{
result = mal_device_init__oss(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_OPENSL
case mal_backend_opensl:
{
result = pContext->onDeviceInit(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_OPENAL
case mal_backend_openal:
{
result = mal_device_init__openal(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_SDL
case mal_backend_sdl:
{
result = pContext->onDeviceInit(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
#ifdef MAL_HAS_NULL
case mal_backend_null:
{
result = mal_device_init__null(pContext, type, pDeviceID, &config, pDevice);
} break;
#endif
default: break;
}
if (result != MAL_SUCCESS) {
if (result != MAL_SUCCESS) {
return MAL_NO_BACKEND; // The error message will have been posted with mal_post_error() by the source of the error so don't bother calling it here.
return MAL_NO_BACKEND; // The error message will have been posted with mal_post_error() by the source of the error so don't bother calling it here.
}
}
...
@@ -18594,66 +18245,7 @@ void mal_device_uninit(mal_device* pDevice)
...
@@ -18594,66 +18245,7 @@ void mal_device_uninit(mal_device* pDevice)
mal_thread_wait(&pDevice->thread);
mal_thread_wait(&pDevice->thread);
}
}
#ifdef MAL_HAS_WASAPI
pDevice->pContext->onDeviceUninit(pDevice);
if (pDevice->pContext->backend == mal_backend_wasapi) {
pDevice->pContext->onDeviceUninit(pDevice);
}
#endif
#ifdef MAL_HAS_DSOUND
if (pDevice->pContext->backend == mal_backend_dsound) {
mal_device_uninit__dsound(pDevice);
}
#endif
#ifdef MAL_HAS_WINMM
if (pDevice->pContext->backend == mal_backend_winmm) {
mal_device_uninit__winmm(pDevice);
}
#endif
#ifdef MAL_HAS_ALSA
if (pDevice->pContext->backend == mal_backend_alsa) {
mal_device_uninit__alsa(pDevice);
}
#endif
#ifdef MAL_HAS_PULSEAUDIO
if (pDevice->pContext->backend == mal_backend_pulseaudio) {
mal_device_uninit__pulse(pDevice);
}
#endif
#ifdef MAL_HAS_JACK
if (pDevice->pContext->backend == mal_backend_jack) {
pDevice->pContext->onDeviceUninit(pDevice);
}
#endif
#ifdef MAL_HAS_COREAUDIO
if (pDevice->pContext->backend == mal_backend_coreaudio) {
pDevice->pContext->onDeviceUninit(pDevice);
}
#endif
#ifdef MAL_HAS_OSS
if (pDevice->pContext->backend == mal_backend_oss) {
mal_device_uninit__oss(pDevice);
}
#endif
#ifdef MAL_HAS_OPENSL
if (pDevice->pContext->backend == mal_backend_opensl) {
pDevice->pContext->onDeviceUninit(pDevice);
}
#endif
#ifdef MAL_HAS_OPENAL
if (pDevice->pContext->backend == mal_backend_openal) {
mal_device_uninit__openal(pDevice);
}
#endif
#ifdef MAL_HAS_SDL
if (pDevice->pContext->backend == mal_backend_sdl) {
pDevice->pContext->onDeviceUninit(pDevice);
}
#endif
#ifdef MAL_HAS_NULL
if (pDevice->pContext->backend == mal_backend_null) {
mal_device_uninit__null(pDevice);
}
#endif
mal_event_uninit(&pDevice->stopEvent);
mal_event_uninit(&pDevice->stopEvent);
mal_event_uninit(&pDevice->startEvent);
mal_event_uninit(&pDevice->startEvent);
...
@@ -18772,7 +18364,7 @@ mal_result mal_device_stop(mal_device* pDevice)
...
@@ -18772,7 +18364,7 @@ mal_result mal_device_stop(mal_device* pDevice)
// When we get here the worker thread is likely in a wait state while waiting for the backend device to deliver or request
// When we get here the worker thread is likely in a wait state while waiting for the backend device to deliver or request
// audio data. We need to force these to return as quickly as possible.
// audio data. We need to force these to return as quickly as possible.
mal_device__break_main_l
oop(pDevice);
pDevice->pContext->onDeviceBreakMainL
oop(pDevice);
// We need to wait for the worker thread to become available for work before returning. Note that the worker thread will be
// We need to wait for the worker thread to become available for work before returning. Note that the worker thread will be
// the one who puts the device into the stopped state. Don't call mal_device__set_state() here.
// the one who puts the device into the stopped state. Don't call mal_device__set_state() here.
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