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
631ab4d6
Commit
631ab4d6
authored
Feb 20, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update example for the decoder API.
parent
7ce6a5fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
examples/multi_playback.c
examples/multi_playback.c
+65
-0
No files found.
examples/multi_playback.c
View file @
631ab4d6
...
@@ -58,6 +58,70 @@
...
@@ -58,6 +58,70 @@
#define MAL_IMPLEMENTATION
#define MAL_IMPLEMENTATION
#include "../mini_al.h"
#include "../mini_al.h"
mal_uint32
on_send_frames_to_device
(
mal_device
*
pDevice
,
mal_uint32
frameCount
,
void
*
pFramesOut
)
{
mal_decoder
*
pDecoder
=
(
mal_decoder
*
)
pDevice
->
pUserData
;
if
(
pDecoder
==
NULL
)
{
return
0
;
}
return
(
mal_uint32
)
mal_decoder_read
(
pDecoder
,
frameCount
,
pFramesOut
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
2
)
{
printf
(
"No input file."
);
return
-
1
;
}
//mal_decoder_config decoderConfig = mal_decoder_config_init(mal_format_f32, 2, 48000);
mal_decoder
decoder
;
mal_result
result
=
mal_decoder_init_file
(
argv
[
1
],
/*&decoderConfig*/
NULL
,
&
decoder
);
if
(
result
!=
MAL_SUCCESS
)
{
return
-
2
;
}
mal_context
context
;
if
(
mal_context_init
(
NULL
,
0
,
NULL
,
&
context
)
!=
MAL_SUCCESS
)
{
printf
(
"Failed to initialize context.
\n
"
);
mal_decoder_uninit
(
&
decoder
);
return
-
3
;
}
mal_device_config
deviceConfig
=
mal_device_config_init_playback
(
decoder
.
outputFormat
,
decoder
.
outputChannels
,
decoder
.
outputSampleRate
,
on_send_frames_to_device
);
mal_copy_memory
(
&
deviceConfig
.
channelMap
,
decoder
.
outputChannelMap
,
sizeof
(
decoder
.
outputChannelMap
));
mal_device
device
;
if
(
mal_device_init
(
&
context
,
mal_device_type_playback
,
NULL
,
&
deviceConfig
,
&
decoder
,
&
device
)
!=
MAL_SUCCESS
)
{
printf
(
"Failed to initialize device.
\n
"
);
mal_context_uninit
(
&
context
);
mal_decoder_uninit
(
&
decoder
);
return
-
4
;
}
if
(
mal_device_start
(
&
device
)
!=
MAL_SUCCESS
)
{
printf
(
"Failed to start playback device.
\n
"
);
mal_device_uninit
(
&
device
);
mal_context_uninit
(
&
context
);
mal_decoder_uninit
(
&
decoder
);
return
-
5
;
}
printf
(
"Press Enter to quit..."
);
getchar
();
mal_device_uninit
(
&
device
);
mal_context_uninit
(
&
context
);
mal_decoder_uninit
(
&
decoder
);
return
0
;
}
#if 0
#include <stdio.h>
#include <stdio.h>
mal_uint32 on_send_flac_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples)
mal_uint32 on_send_flac_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples)
...
@@ -211,3 +275,4 @@ end:;
...
@@ -211,3 +275,4 @@ end:;
return exitcode;
return exitcode;
}
}
#endif
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