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
dae1bdd6
Commit
dae1bdd6
authored
Mar 05, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update advanced config example.
parent
f4693be9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
23 deletions
+42
-23
examples/advanced_config.c
examples/advanced_config.c
+25
-17
tests/mal_test_0.vcxproj
tests/mal_test_0.vcxproj
+14
-6
tests/mal_test_0.vcxproj.filters
tests/mal_test_0.vcxproj.filters
+3
-0
No files found.
examples/advanced_config.c
View file @
dae1bdd6
...
...
@@ -3,22 +3,23 @@
#include <stdio.h>
void
on_log
(
mal_context
*
pContext
,
mal_device
*
pDevice
,
const
char
*
message
)
void
log_callback
(
mal_context
*
pContext
,
mal_device
*
pDevice
,
mal_uint32
logLevel
,
const
char
*
message
)
{
(
void
)
pContext
;
(
void
)
pDevice
;
printf
(
"mini_al:
%s
\n
"
,
message
);
printf
(
"mini_al:
[%s] %s
\n
"
,
mal_log_level_to_string
(
logLevel
)
,
message
);
}
mal_uint32
on_send_frames_to_device
(
mal_device
*
pDevice
,
mal_uint32
frameCount
,
void
*
pSamples
)
void
data_callback
(
mal_device
*
pDevice
,
void
*
pOutput
,
const
void
*
pInput
,
mal_uint32
frameCount
)
{
(
void
)
pDevice
;
(
void
)
pOutput
;
(
void
)
pInput
;
(
void
)
frameCount
;
(
void
)
pSamples
;
return
0
;
// Just output silence for this example.
return
;
// Just output silence for this example.
}
void
on_device_stop
(
mal_device
*
pDevice
)
void
stop_callback
(
mal_device
*
pDevice
)
{
(
void
)
pDevice
;
printf
(
"Device stopped
\n
"
);
...
...
@@ -32,7 +33,8 @@ int main(int argc, char** argv)
// When initializing a context, you can pass in an optional configuration object that allows you to control
// context-level configuration. The mal_context_config_init() function will initialize a config object with
// common configuration settings, but you can set other members for more detailed control.
mal_context_config
contextConfig
=
mal_context_config_init
(
on_log
);
mal_context_config
contextConfig
=
mal_context_config_init
();
contextConfig
.
logCallback
=
log_callback
;
// The priority of the worker thread can be set with the following. The default priority is
// mal_thread_priority_highest.
...
...
@@ -91,7 +93,7 @@ int main(int argc, char** argv)
mal_backend_pulseaudio
,
mal_backend_alsa
,
mal_backend_jack
,
mal_backend_aaudio
mal_backend_aaudio
,
mal_backend_opensl
,
mal_backend_webaudio
,
mal_backend_null
// Lowest priority.
...
...
@@ -131,23 +133,29 @@ int main(int argc, char** argv)
// Open the device.
//
// Unlike context configs, device configs are required. Similar to context configs, an API exists to help you
// initialize a config object called mal_device_config_init(). There are an additional two helper APIs to make
// it easy for you to initialize playback or capture configs specifically: mal_device_config_init_playback()
// and mal_device_config_init_capture().
mal_device_config
deviceConfig
=
mal_device_config_init
(
mal_format_s16
,
2
,
48000
,
NULL
,
on_send_frames_to_device
,
NULL
);
// initialize a config object called mal_device_config_init().
//
// When using full-duplex you may want to use a different sample format, channel count and channel map. To
// support this, the device configuration splits these into "playback" and "capture" as shown below.
mal_device_config
deviceConfig
=
mal_device_config_init
(
mal_device_type_playback
);
deviceConfig
.
playback
.
format
=
mal_format_s16
;
deviceConfig
.
playback
.
channels
=
2
;
deviceConfig
.
sampleRate
=
48000
;
deviceConfig
.
dataCallback
=
data_callback
;
deviceConfig
.
pUserData
=
NULL
;
// Applications can specify a callback for when a device is stopped.
deviceConfig
.
onStopCallback
=
on_device_stop
;
deviceConfig
.
stopCallback
=
stop_callback
;
// Applications can request exclusive control of the device using the config variable below. Note that not all
// backends support this feature, so this is actually just a hint.
deviceConfig
.
shareMode
=
mal_share_mode_exclusive
;
deviceConfig
.
playback
.
shareMode
=
mal_share_mode_exclusive
;
// mini_al allows applications to control the mapping of channels. The config below swaps the left and right
// channels. Normally in an interleaved audio stream, the left channel comes first, but we can change that
// like the following:
deviceConfig
.
channelMap
[
0
]
=
MAL_CHANNEL_FRONT_RIGHT
;
deviceConfig
.
channelMap
[
1
]
=
MAL_CHANNEL_FRONT_LEFT
;
deviceConfig
.
playback
.
channelMap
[
0
]
=
MAL_CHANNEL_FRONT_RIGHT
;
deviceConfig
.
playback
.
channelMap
[
1
]
=
MAL_CHANNEL_FRONT_LEFT
;
// The ALSA backend has two ways of delivering data to and from a device: memory mapping and read/write. By
// default memory mapping will be used over read/write because it avoids a single point of data movement
...
...
@@ -174,7 +182,7 @@ int main(int argc, char** argv)
#endif
mal_device
playbackDevice
;
if
(
mal_device_init
(
&
context
,
mal_device_type_playback
,
NULL
,
&
deviceConfig
,
&
playbackDevice
)
!=
MAL_SUCCESS
)
{
if
(
mal_device_init
(
&
context
,
&
deviceConfig
,
&
playbackDevice
)
!=
MAL_SUCCESS
)
{
printf
(
"Failed to initialize playback device.
\n
"
);
mal_context_uninit
(
&
context
);
return
-
7
;
...
...
tests/mal_test_0.vcxproj
View file @
dae1bdd6
...
...
@@ -270,6 +270,14 @@
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
true
</ExcludedFromBuild>
</ClCompile>
<ClCompile
Include=
"..\examples\advanced_config.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|ARM'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
false
</ExcludedFromBuild>
</ClCompile>
<ClCompile
Include=
"..\examples\simple_capture.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
true
</ExcludedFromBuild>
...
...
@@ -319,12 +327,12 @@
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
true
</ExcludedFromBuild>
</ClCompile>
<ClCompile
Include=
"mal_duplex.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
fals
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
fals
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
fals
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|ARM'"
>
fals
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
fals
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
fals
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
tru
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
tru
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
tru
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|ARM'"
>
tru
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
tru
e
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
tru
e
</ExcludedFromBuild>
</ClCompile>
<ClCompile
Include=
"mal_no_device_io.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
true
</ExcludedFromBuild>
...
...
tests/mal_test_0.vcxproj.filters
View file @
dae1bdd6
...
...
@@ -60,6 +60,9 @@
<ClCompile
Include=
"..\examples\simple_capture.c"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"..\examples\advanced_config.c"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\mini_al.h"
>
...
...
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