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
165c92ec
Commit
165c92ec
authored
Mar 08, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make mal_device_init_ex() more robust.
parent
293d7424
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
26 deletions
+39
-26
mini_al.h
mini_al.h
+39
-26
No files found.
mini_al.h
View file @
165c92ec
...
@@ -1283,7 +1283,7 @@ struct mal_device
...
@@ -1283,7 +1283,7 @@ struct mal_device
//
//
// Effeciency: LOW
// Effeciency: LOW
// This will dynamically load backends DLLs/SOs (such as dsound.dll).
// This will dynamically load backends DLLs/SOs (such as dsound.dll).
mal_result
mal_context_init
(
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pConfig
,
mal_context
*
pContext
);
mal_result
mal_context_init
(
const
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pConfig
,
mal_context
*
pContext
);
// Uninitializes a context.
// Uninitializes a context.
//
//
...
@@ -1364,7 +1364,7 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
...
@@ -1364,7 +1364,7 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
// of the internal self-managed context.
// of the internal self-managed context.
//
//
// See mal_device_init().
// See mal_device_init().
mal_result
mal_device_init_ex
(
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pContextConfig
,
mal_device_type
type
,
mal_device_id
*
pDeviceID
,
const
mal_device_config
*
pConfig
,
void
*
pUserData
,
mal_device
*
pDevice
);
mal_result
mal_device_init_ex
(
const
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pContextConfig
,
mal_device_type
type
,
mal_device_id
*
pDeviceID
,
const
mal_device_config
*
pConfig
,
void
*
pUserData
,
mal_device
*
pDevice
);
// Uninitializes a device.
// Uninitializes a device.
//
//
...
@@ -11927,7 +11927,21 @@ mal_result mal_context_uninit_backend_apis(mal_context* pContext)
...
@@ -11927,7 +11927,21 @@ mal_result mal_context_uninit_backend_apis(mal_context* pContext)
return
result
;
return
result
;
}
}
mal_result
mal_context_init
(
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pConfig
,
mal_context
*
pContext
)
static
const
mal_backend
g_malDefaultBackends
[]
=
{
mal_backend_wasapi
,
mal_backend_dsound
,
mal_backend_winmm
,
mal_backend_alsa
,
mal_backend_pulseaudio
,
mal_backend_jack
,
mal_backend_oss
,
mal_backend_opensl
,
mal_backend_openal
,
mal_backend_sdl
,
mal_backend_null
};
mal_result
mal_context_init
(
const
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pConfig
,
mal_context
*
pContext
)
{
{
if
(
pContext
==
NULL
)
return
MAL_INVALID_ARGS
;
if
(
pContext
==
NULL
)
return
MAL_INVALID_ARGS
;
mal_zero_object
(
pContext
);
mal_zero_object
(
pContext
);
...
@@ -11945,23 +11959,9 @@ mal_result mal_context_init(mal_backend backends[], mal_uint32 backendCount, con
...
@@ -11945,23 +11959,9 @@ mal_result mal_context_init(mal_backend backends[], mal_uint32 backendCount, con
return
result
;
return
result
;
}
}
static
mal_backend
defaultBackends
[]
=
{
mal_backend_wasapi
,
mal_backend_dsound
,
mal_backend_winmm
,
mal_backend_alsa
,
mal_backend_pulseaudio
,
mal_backend_jack
,
mal_backend_oss
,
mal_backend_opensl
,
mal_backend_openal
,
mal_backend_sdl
,
mal_backend_null
};
if
(
backends
==
NULL
)
{
if
(
backends
==
NULL
)
{
backends
=
d
efaultBackends
;
backends
=
g_malD
efaultBackends
;
backendCount
=
mal_countof
(
d
efaultBackends
);
backendCount
=
mal_countof
(
g_malD
efaultBackends
);
}
}
mal_assert
(
backends
!=
NULL
);
mal_assert
(
backends
!=
NULL
);
...
@@ -12466,22 +12466,33 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
...
@@ -12466,22 +12466,33 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
return
MAL_SUCCESS
;
return
MAL_SUCCESS
;
}
}
mal_result
mal_device_init_ex
(
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pContextConfig
,
mal_device_type
type
,
mal_device_id
*
pDeviceID
,
const
mal_device_config
*
pConfig
,
void
*
pUserData
,
mal_device
*
pDevice
)
mal_result
mal_device_init_ex
(
const
mal_backend
backends
[],
mal_uint32
backendCount
,
const
mal_context_config
*
pContextConfig
,
mal_device_type
type
,
mal_device_id
*
pDeviceID
,
const
mal_device_config
*
pConfig
,
void
*
pUserData
,
mal_device
*
pDevice
)
{
{
mal_context
*
pContext
=
(
mal_context
*
)
mal_malloc
(
sizeof
(
*
pContext
));
mal_context
*
pContext
=
(
mal_context
*
)
mal_malloc
(
sizeof
(
*
pContext
));
if
(
pContext
==
NULL
)
{
if
(
pContext
==
NULL
)
{
return
MAL_OUT_OF_MEMORY
;
return
MAL_OUT_OF_MEMORY
;
}
}
mal_result
result
=
mal_context_init
(
backends
,
backendCount
,
pContextConfig
,
pContext
);
if
(
backends
==
NULL
)
{
if
(
result
!=
MAL_SUCCESS
)
{
backends
=
g_malDefaultBackends
;
mal_free
(
pContext
);
backendCount
=
mal_countof
(
g_malDefaultBackends
);
return
result
;
}
mal_result
result
=
MAL_NO_BACKEND
;
for
(
mal_uint32
iBackend
=
0
;
iBackend
<
backendCount
;
++
iBackend
)
{
result
=
mal_context_init
(
&
backends
[
iBackend
],
1
,
pContextConfig
,
pContext
);
if
(
result
==
MAL_SUCCESS
)
{
result
=
mal_device_init
(
pContext
,
type
,
pDeviceID
,
pConfig
,
pUserData
,
pDevice
);
if
(
result
==
MAL_SUCCESS
)
{
break
;
// Success.
}
else
{
mal_context_uninit
(
pContext
);
// Failure.
}
}
}
}
result
=
mal_device_init
(
pContext
,
type
,
pDeviceID
,
pConfig
,
pUserData
,
pDevice
);
if
(
result
!=
MAL_SUCCESS
)
{
if
(
result
!=
MAL_SUCCESS
)
{
mal_context_uninit
(
pContext
);
mal_free
(
pContext
);
mal_free
(
pContext
);
return
result
;
return
result
;
}
}
...
@@ -15596,6 +15607,8 @@ void mal_pcm_f32_to_s32(int* pOut, const float* pIn, unsigned int count)
...
@@ -15596,6 +15607,8 @@ void mal_pcm_f32_to_s32(int* pOut, const float* pIn, unsigned int count)
// - Add support for JACK.
// - Add support for JACK.
// - Remove dependency on asound.h for the ALSA backend. This means the ALSA development packages are no
// - Remove dependency on asound.h for the ALSA backend. This means the ALSA development packages are no
// longer required to build mini_al.
// longer required to build mini_al.
// - Make mal_device_init_ex() more robust.
// - Make some APIs more const-correct.
// - Fix errors with OpenAL detection.
// - Fix errors with OpenAL detection.
// - Fix some memory leaks.
// - Fix some memory leaks.
// - Miscellaneous bug fixes.
// - Miscellaneous bug fixes.
...
...
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