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
2c01858f
Commit
2c01858f
authored
Mar 18, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SDL: Implement the new device enumeration APIs.
parent
59f01c5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
mini_al.h
mini_al.h
+118
-0
No files found.
mini_al.h
View file @
2c01858f
...
@@ -13601,6 +13601,120 @@ mal_format mal_format_from_sdl(MAL_SDL_AudioFormat format)
...
@@ -13601,6 +13601,120 @@ mal_format mal_format_from_sdl(MAL_SDL_AudioFormat format)
}
}
}
}
mal_bool32
mal_context_is_device_id_equal__sdl
(
mal_context
*
pContext
,
const
mal_device_id
*
pID0
,
const
mal_device_id
*
pID1
)
{
mal_assert
(
pContext
!=
NULL
);
mal_assert
(
pID0
!=
NULL
);
mal_assert
(
pID1
!=
NULL
);
(
void
)
pContext
;
return
pID0
->
sdl
==
pID1
->
sdl
;
}
mal_result
mal_context_enumerate_devices__sdl
(
mal_context
*
pContext
,
mal_enum_devices_callback_proc
callback
,
void
*
pUserData
)
{
mal_assert
(
pContext
!=
NULL
);
mal_assert
(
callback
!=
NULL
);
#ifndef MAL_USE_SDL_1
if
(
!
pContext
->
sdl
.
usingSDL1
)
{
mal_bool32
isTerminated
=
MAL_FALSE
;
// Playback
if
(
!
isTerminated
)
{
int
deviceCount
=
((
MAL_PFN_SDL_GetNumAudioDevices
)
pContext
->
sdl
.
SDL_GetNumAudioDevices
)(
0
);
for
(
int
i
=
0
;
i
<
deviceCount
;
++
i
)
{
mal_device_info
deviceInfo
;
mal_zero_object
(
&
deviceInfo
);
deviceInfo
.
id
.
sdl
=
i
;
mal_strncpy_s
(
deviceInfo
.
name
,
sizeof
(
deviceInfo
.
name
),
((
MAL_PFN_SDL_GetAudioDeviceName
)
pContext
->
sdl
.
SDL_GetAudioDeviceName
)(
i
,
0
),
(
size_t
)
-
1
);
mal_bool32
cbResult
=
callback
(
pContext
,
mal_device_type_playback
,
&
deviceInfo
,
pUserData
);
if
(
cbResult
==
MAL_FALSE
)
{
isTerminated
=
MAL_TRUE
;
break
;
}
}
}
// Capture
if
(
!
isTerminated
)
{
int
deviceCount
=
((
MAL_PFN_SDL_GetNumAudioDevices
)
pContext
->
sdl
.
SDL_GetNumAudioDevices
)(
1
);
for
(
int
i
=
0
;
i
<
deviceCount
;
++
i
)
{
mal_device_info
deviceInfo
;
mal_zero_object
(
&
deviceInfo
);
deviceInfo
.
id
.
sdl
=
i
;
mal_strncpy_s
(
deviceInfo
.
name
,
sizeof
(
deviceInfo
.
name
),
((
MAL_PFN_SDL_GetAudioDeviceName
)
pContext
->
sdl
.
SDL_GetAudioDeviceName
)(
i
,
1
),
(
size_t
)
-
1
);
mal_bool32
cbResult
=
callback
(
pContext
,
mal_device_type_capture
,
&
deviceInfo
,
pUserData
);
if
(
cbResult
==
MAL_FALSE
)
{
isTerminated
=
MAL_TRUE
;
break
;
}
}
}
}
else
#endif
{
// SDL1 only uses default devices.
mal_bool32
cbResult
=
MAL_TRUE
;
// Playback.
if
(
cbResult
)
{
mal_device_info
deviceInfo
;
mal_zero_object
(
&
deviceInfo
);
mal_strncpy_s
(
deviceInfo
.
name
,
sizeof
(
deviceInfo
.
name
),
MAL_DEFAULT_PLAYBACK_DEVICE_NAME
,
(
size_t
)
-
1
);
cbResult
=
callback
(
pContext
,
mal_device_type_playback
,
&
deviceInfo
,
pUserData
);
}
// Capture.
if
(
cbResult
)
{
mal_device_info
deviceInfo
;
mal_zero_object
(
&
deviceInfo
);
mal_strncpy_s
(
deviceInfo
.
name
,
sizeof
(
deviceInfo
.
name
),
MAL_DEFAULT_CAPTURE_DEVICE_NAME
,
(
size_t
)
-
1
);
cbResult
=
callback
(
pContext
,
mal_device_type_capture
,
&
deviceInfo
,
pUserData
);
}
}
return
MAL_SUCCESS
;
}
mal_result
mal_context_get_device_info__sdl
(
mal_context
*
pContext
,
mal_device_type
deviceType
,
const
mal_device_id
*
pDeviceID
,
mal_share_mode
shareMode
,
mal_device_info
*
pDeviceInfo
)
{
mal_assert
(
pContext
!=
NULL
);
(
void
)
shareMode
;
#ifndef MAL_USE_SDL_1
if
(
!
pContext
->
sdl
.
usingSDL1
)
{
if
(
pDeviceID
==
NULL
)
{
if
(
deviceType
==
mal_device_type_playback
)
{
pDeviceInfo
->
id
.
sdl
=
0
;
mal_strncpy_s
(
pDeviceInfo
->
name
,
sizeof
(
pDeviceInfo
->
name
),
MAL_DEFAULT_PLAYBACK_DEVICE_NAME
,
(
size_t
)
-
1
);
}
else
{
pDeviceInfo
->
id
.
sdl
=
0
;
mal_strncpy_s
(
pDeviceInfo
->
name
,
sizeof
(
pDeviceInfo
->
name
),
MAL_DEFAULT_CAPTURE_DEVICE_NAME
,
(
size_t
)
-
1
);
}
}
else
{
pDeviceInfo
->
id
.
sdl
=
pDeviceID
->
sdl
;
mal_strncpy_s
(
pDeviceInfo
->
name
,
sizeof
(
pDeviceInfo
->
name
),
((
MAL_PFN_SDL_GetAudioDeviceName
)
pContext
->
sdl
.
SDL_GetAudioDeviceName
)(
pDeviceID
->
sdl
,
(
deviceType
==
mal_device_type_playback
)
?
0
:
1
),
(
size_t
)
-
1
);
}
}
else
#endif
{
// SDL1 uses default devices.
if
(
deviceType
==
mal_device_type_playback
)
{
pDeviceInfo
->
id
.
sdl
=
0
;
mal_strncpy_s
(
pDeviceInfo
->
name
,
sizeof
(
pDeviceInfo
->
name
),
MAL_DEFAULT_PLAYBACK_DEVICE_NAME
,
(
size_t
)
-
1
);
}
else
{
pDeviceInfo
->
id
.
sdl
=
0
;
mal_strncpy_s
(
pDeviceInfo
->
name
,
sizeof
(
pDeviceInfo
->
name
),
MAL_DEFAULT_CAPTURE_DEVICE_NAME
,
(
size_t
)
-
1
);
}
}
return
MAL_SUCCESS
;
}
mal_result
mal_context_init__sdl
(
mal_context
*
pContext
)
mal_result
mal_context_init__sdl
(
mal_context
*
pContext
)
{
{
...
@@ -13675,6 +13789,10 @@ mal_result mal_context_init__sdl(mal_context* pContext)
...
@@ -13675,6 +13789,10 @@ mal_result mal_context_init__sdl(mal_context* pContext)
return
MAL_ERROR
;
return
MAL_ERROR
;
}
}
pContext
->
onDeviceIDEqual
=
mal_context_is_device_id_equal__sdl
;
pContext
->
onEnumDevices
=
mal_context_enumerate_devices__sdl
;
pContext
->
onGetDeviceInfo
=
mal_context_get_device_info__sdl
;
return
MAL_SUCCESS
;
return
MAL_SUCCESS
;
}
}
...
...
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