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
a8f3cb85
Commit
a8f3cb85
authored
May 22, 2023
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compilation errors with MA_NO_DEVICE_IO.
parent
563e1c52
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
426 additions
and
447 deletions
+426
-447
examples/custom_backend.c
examples/custom_backend.c
+10
-10
miniaudio.h
miniaudio.h
+400
-400
tests/test_common/ma_test_common.c
tests/test_common/ma_test_common.c
+0
-17
tests/test_generation/ma_test_generation_noise.c
tests/test_generation/ma_test_generation_noise.c
+4
-4
tests/test_generation/ma_test_generation_waveform.c
tests/test_generation/ma_test_generation_waveform.c
+12
-16
No files found.
examples/custom_backend.c
View file @
a8f3cb85
...
...
@@ -521,7 +521,7 @@ static ma_result ma_context_uninit__sdl(ma_context* pContext)
((
MA_PFN_SDL_QuitSubSystem
)
pContextEx
->
sdl
.
SDL_QuitSubSystem
)(
MA_SDL_INIT_AUDIO
);
/* Close the handle to the SDL shared object last. */
ma_dlclose
(
pContext
,
pContextEx
->
sdl
.
hSDL
);
ma_dlclose
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
);
pContextEx
->
sdl
.
hSDL
=
NULL
;
return
MA_SUCCESS
;
...
...
@@ -551,7 +551,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
/* Check if we have SDL2 installed somewhere. If not it's not usable and we need to abort. */
for
(
iName
=
0
;
iName
<
ma_countof
(
pSDLNames
);
iName
+=
1
)
{
pContextEx
->
sdl
.
hSDL
=
ma_dlopen
(
pContext
,
pSDLNames
[
iName
]);
pContextEx
->
sdl
.
hSDL
=
ma_dlopen
(
ma_context_get_log
(
pContext
)
,
pSDLNames
[
iName
]);
if
(
pContextEx
->
sdl
.
hSDL
!=
NULL
)
{
break
;
}
...
...
@@ -562,13 +562,13 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
}
/* Now that we have the handle to the shared object we can go ahead and load some function pointers. */
pContextEx
->
sdl
.
SDL_InitSubSystem
=
ma_dlsym
(
pContext
,
pContextEx
->
sdl
.
hSDL
,
"SDL_InitSubSystem"
);
pContextEx
->
sdl
.
SDL_QuitSubSystem
=
ma_dlsym
(
pContext
,
pContextEx
->
sdl
.
hSDL
,
"SDL_QuitSubSystem"
);
pContextEx
->
sdl
.
SDL_GetNumAudioDevices
=
ma_dlsym
(
pContext
,
pContextEx
->
sdl
.
hSDL
,
"SDL_GetNumAudioDevices"
);
pContextEx
->
sdl
.
SDL_GetAudioDeviceName
=
ma_dlsym
(
pContext
,
pContextEx
->
sdl
.
hSDL
,
"SDL_GetAudioDeviceName"
);
pContextEx
->
sdl
.
SDL_CloseAudioDevice
=
ma_dlsym
(
pContext
,
pContextEx
->
sdl
.
hSDL
,
"SDL_CloseAudioDevice"
);
pContextEx
->
sdl
.
SDL_OpenAudioDevice
=
ma_dlsym
(
pContext
,
pContextEx
->
sdl
.
hSDL
,
"SDL_OpenAudioDevice"
);
pContextEx
->
sdl
.
SDL_PauseAudioDevice
=
ma_dlsym
(
pContext
,
pContextEx
->
sdl
.
hSDL
,
"SDL_PauseAudioDevice"
);
pContextEx
->
sdl
.
SDL_InitSubSystem
=
ma_dlsym
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
,
"SDL_InitSubSystem"
);
pContextEx
->
sdl
.
SDL_QuitSubSystem
=
ma_dlsym
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
,
"SDL_QuitSubSystem"
);
pContextEx
->
sdl
.
SDL_GetNumAudioDevices
=
ma_dlsym
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
,
"SDL_GetNumAudioDevices"
);
pContextEx
->
sdl
.
SDL_GetAudioDeviceName
=
ma_dlsym
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
,
"SDL_GetAudioDeviceName"
);
pContextEx
->
sdl
.
SDL_CloseAudioDevice
=
ma_dlsym
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
,
"SDL_CloseAudioDevice"
);
pContextEx
->
sdl
.
SDL_OpenAudioDevice
=
ma_dlsym
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
,
"SDL_OpenAudioDevice"
);
pContextEx
->
sdl
.
SDL_PauseAudioDevice
=
ma_dlsym
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
,
"SDL_PauseAudioDevice"
);
#else
pContextEx
->
sdl
.
SDL_InitSubSystem
=
(
ma_proc
)
SDL_InitSubSystem
;
pContextEx
->
sdl
.
SDL_QuitSubSystem
=
(
ma_proc
)
SDL_QuitSubSystem
;
...
...
@@ -581,7 +581,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
resultSDL
=
((
MA_PFN_SDL_InitSubSystem
)
pContextEx
->
sdl
.
SDL_InitSubSystem
)(
MA_SDL_INIT_AUDIO
);
if
(
resultSDL
!=
0
)
{
ma_dlclose
(
pContext
,
pContextEx
->
sdl
.
hSDL
);
ma_dlclose
(
ma_context_get_log
(
pContext
)
,
pContextEx
->
sdl
.
hSDL
);
return
MA_ERROR
;
}
...
...
miniaudio.h
View file @
a8f3cb85
This diff is collapsed.
Click to expand it.
tests/test_common/ma_test_common.c
View file @
a8f3cb85
...
...
@@ -37,20 +37,3 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
return
MA_SUCCESS
;
}
drwav_data_format
drwav_data_format_from_minaudio_format
(
ma_format
format
,
ma_uint32
channels
,
ma_uint32
sampleRate
)
{
drwav_data_format
wavFormat
;
wavFormat
.
container
=
drwav_container_riff
;
wavFormat
.
channels
=
channels
;
wavFormat
.
sampleRate
=
sampleRate
;
wavFormat
.
bitsPerSample
=
ma_get_bytes_per_sample
(
format
)
*
8
;
if
(
format
==
ma_format_f32
)
{
wavFormat
.
format
=
DR_WAVE_FORMAT_IEEE_FLOAT
;
}
else
{
wavFormat
.
format
=
DR_WAVE_FORMAT_PCM
;
}
return
wavFormat
;
}
tests/test_generation/ma_test_generation_noise.c
View file @
a8f3cb85
...
...
@@ -11,12 +11,12 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
printf
(
" %s
\n
"
,
pFileName
);
noiseConfig
=
ma_noise_config_init
(
format
,
1
,
type
,
0
,
0
.
1
);
result
=
ma_noise_init
(
&
noiseConfig
,
&
noise
);
result
=
ma_noise_init
(
&
noiseConfig
,
NULL
,
&
noise
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
encoderConfig
=
ma_encoder_config_init
(
ma_
resource
_format_wav
,
format
,
noiseConfig
.
channels
,
48000
);
encoderConfig
=
ma_encoder_config_init
(
ma_
encoding
_format_wav
,
format
,
noiseConfig
.
channels
,
48000
);
result
=
ma_encoder_init_file
(
pFileName
,
&
encoderConfig
,
&
encoder
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
...
...
@@ -25,8 +25,8 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
/* We'll do a few seconds of data. */
for
(
iFrame
=
0
;
iFrame
<
encoder
.
config
.
sampleRate
*
10
;
iFrame
+=
1
)
{
ma_uint8
temp
[
1024
];
ma_noise_read_pcm_frames
(
&
noise
,
temp
,
1
);
ma_encoder_write_pcm_frames
(
&
encoder
,
temp
,
1
);
ma_noise_read_pcm_frames
(
&
noise
,
temp
,
1
,
NULL
);
ma_encoder_write_pcm_frames
(
&
encoder
,
temp
,
1
,
NULL
);
}
ma_encoder_uninit
(
&
encoder
);
...
...
tests/test_generation/ma_test_generation_waveform.c
View file @
a8f3cb85
static
drwav_data_format
drwav_data_format_from_waveform_config
(
const
ma_waveform_config
*
pWaveformConfig
)
{
MA_ASSERT
(
pWaveformConfig
!=
NULL
);
return
drwav_data_format_from_minaudio_format
(
pWaveformConfig
->
format
,
pWaveformConfig
->
channels
,
pWaveformConfig
->
sampleRate
);
}
ma_result
test_waveform__by_format_and_type
(
ma_format
format
,
ma_waveform_type
type
,
double
amplitude
,
const
char
*
pFileName
)
{
ma_result
result
;
ma_waveform_config
waveformConfig
;
ma_waveform
waveform
;
drwav_data_format
wavFormat
;
drwav
wav
;
ma_encoder_config
encoderConfig
;
ma_encoder
encoder
;
ma_uint32
iFrame
;
printf
(
" %s
\n
"
,
pFileName
);
...
...
@@ -23,19 +16,22 @@ ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type t
return
result
;
}
wavFormat
=
drwav_data_format_from_waveform_config
(
&
waveformConfig
);
if
(
!
drwav_init_file_write
(
&
wav
,
pFileName
,
&
wavFormat
,
NULL
))
{
return
MA_ERROR
;
/* Could not open file for writing. */
encoderConfig
=
ma_encoder_config_init
(
ma_encoding_format_wav
,
waveformConfig
.
format
,
waveformConfig
.
channels
,
waveformConfig
.
sampleRate
);
result
=
ma_encoder_init_file
(
pFileName
,
&
encoderConfig
,
&
encoder
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
/* Failed to initialize encoder. */
}
/* We'll do a few seconds of data. */
for
(
iFrame
=
0
;
iFrame
<
wav
Format
.
sampleRate
*
10
;
iFrame
+=
1
)
{
for
(
iFrame
=
0
;
iFrame
<
wav
eformConfig
.
sampleRate
*
10
;
iFrame
+=
1
)
{
float
temp
[
MA_MAX_CHANNELS
];
ma_waveform_read_pcm_frames
(
&
waveform
,
temp
,
1
);
drwav_write_pcm_frames
(
&
wav
,
1
,
temp
);
ma_waveform_read_pcm_frames
(
&
waveform
,
temp
,
1
,
NULL
);
ma_encoder_write_pcm_frames
(
&
encoder
,
temp
,
1
,
NULL
);
}
drwav_uninit
(
&
wav
);
ma_encoder_uninit
(
&
encoder
);
ma_waveform_uninit
(
&
waveform
);
return
MA_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