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
c715ead0
Commit
c715ead0
authored
Jan 31, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor simplification to the custom backend example.
parent
ddb8f845
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
15 deletions
+4
-15
examples/custom_backend.c
examples/custom_backend.c
+4
-15
No files found.
examples/custom_backend.c
View file @
c715ead0
...
...
@@ -366,22 +366,11 @@ static ma_result ma_device_init_internal__sdl(ma_device_ex* pDeviceEx, const ma_
Note that options 2 and 3 require knowledge of the sample rate in order to convert it to a frame count. You should try to keep the
calculation of the period size as accurate as possible, but sometimes it's just not practical so just use whatever you can.
A helper function called ma_calculate_buffer_size_in_frames_from_descriptor() is available to do all of this for you which is what
we'll be using here.
*/
if
(
pDescriptor
->
periodSizeInFrames
==
0
)
{
if
(
pDescriptor
->
periodSizeInMilliseconds
==
0
)
{
/* The default period size has been requested. I don't think SDL has an API to retrieve this, so just using defaults defined by miniaudio. */
if
(
pConfig
->
performanceProfile
==
ma_performance_profile_low_latency
)
{
pDescriptor
->
periodSizeInFrames
=
ma_calculate_buffer_size_in_frames_from_milliseconds
(
MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY
,
pDescriptor
->
sampleRate
);
}
else
{
pDescriptor
->
periodSizeInFrames
=
ma_calculate_buffer_size_in_frames_from_milliseconds
(
MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE
,
pDescriptor
->
sampleRate
);
}
}
else
{
/* An explicit period size in milliseconds was specified. */
pDescriptor
->
periodSizeInFrames
=
ma_calculate_buffer_size_in_frames_from_milliseconds
(
pDescriptor
->
periodSizeInMilliseconds
,
pDescriptor
->
sampleRate
);
}
}
else
{
/* Nothing to do here. An explicit period size in frames was specified. */
}
pDescriptor
->
periodSizeInFrames
=
ma_calculate_buffer_size_in_frames_from_descriptor
(
pDescriptor
,
pDescriptor
->
sampleRate
,
pConfig
->
performanceProfile
);
/* SDL wants the buffer size to be a power of 2 for some reason. */
if
(
pDescriptor
->
periodSizeInFrames
>
32768
)
{
...
...
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