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
a27a97f8
Commit
a27a97f8
authored
Mar 18, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some thread safety to the ALSA backend.
parent
5f0f7eb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
mini_al.h
mini_al.h
+13
-25
No files found.
mini_al.h
View file @
a27a97f8
...
...
@@ -905,6 +905,8 @@ struct mal_context
mal_proc snd_pcm_info_sizeof;
mal_proc snd_pcm_info_get_name;
mal_proc snd_config_update_free_global;
mal_mutex internalDeviceEnumLock;
} alsa;
#endif
#ifdef MAL_SUPPORT_PULSEAUDIO
...
...
@@ -7721,8 +7723,11 @@ mal_result mal_context_enumerate_devices__alsa(mal_context* pContext, mal_enum_d
mal_assert(pContext != NULL);
mal_assert(callback != NULL);
mal_mutex_lock(&pContext->alsa.internalDeviceEnumLock);
char** ppDeviceHints;
if (((mal_snd_device_name_hint_proc)pContext->alsa.snd_device_name_hint)(-1, "pcm", (void***)&ppDeviceHints) < 0) {
mal_mutex_unlock(&pContext->alsa.internalDeviceEnumLock);
return MAL_NO_BACKEND;
}
...
...
@@ -7868,6 +7873,8 @@ mal_result mal_context_enumerate_devices__alsa(mal_context* pContext, mal_enum_d
mal_free(pUniqueIDs);
((mal_snd_device_name_free_hint_proc)pContext->alsa.snd_device_name_free_hint)((void**)ppDeviceHints);
mal_mutex_unlock(&pContext->alsa.internalDeviceEnumLock);
return MAL_SUCCESS;
}
...
...
@@ -8079,6 +8086,10 @@ mal_result mal_context_init__alsa(mal_context* pContext)
pContext->alsa.snd_config_update_free_global = (mal_proc)_snd_config_update_free_global;
#endif
if (mal_mutex_init(pContext, &pContext->alsa.internalDeviceEnumLock) != MAL_SUCCESS) {
mal_context_post_error(pContext, NULL, "[ALSA] WARNING: Failed to initialize mutex for internal device enumeration.", MAL_ERROR);
}
pContext->onDeviceIDEqual = mal_context_is_device_id_equal__alsa;
pContext->onEnumDevices = mal_context_enumerate_devices__alsa;
pContext->onGetDeviceInfo = mal_context_get_device_info__alsa;
...
...
@@ -8098,6 +8109,8 @@ mal_result mal_context_uninit__alsa(mal_context* pContext)
mal_dlclose(pContext->alsa.asoundSO);
#endif
mal_mutex_uninit(&pContext->alsa.internalDeviceEnumLock);
return MAL_SUCCESS;
}
...
...
@@ -14763,31 +14776,6 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl
}
typedef
struct
{
mal_device_type
type
;
const
mal_device_id
*
pDeviceID
;
mal_device_info
*
pDeviceInfo
;
}
mal_context_get_device_info__enum_callback_data
;
static
mal_bool32
mal_context_get_device_info__enum_callback
(
mal_context
*
pContext
,
mal_device_type
type
,
const
mal_device_info
*
pInfoIn
,
void
*
pUserData
)
{
mal_context_get_device_info__enum_callback_data
*
pData
=
(
mal_context_get_device_info__enum_callback_data
*
)
pUserData
;
mal_assert
(
pData
!=
NULL
);
if
(
type
==
pData
->
type
&&
mal_context__device_id_equal
(
pContext
,
&
pInfoIn
->
id
,
pData
->
pDeviceID
))
{
// Found it. Copy the info and stop iteration.
if
(
pData
->
pDeviceInfo
!=
NULL
)
{
*
pData
->
pDeviceInfo
=
*
pInfoIn
;
}
return
MAL_FALSE
;
// Stop iteration.
}
else
{
// Didn't find it. Continue.
return
MAL_TRUE
;
}
}
mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type type, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo)
{
if (pDeviceInfo == NULL) return MAL_INVALID_ARGS;
...
...
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