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
b48cb209
Commit
b48cb209
authored
Jun 13, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an infinite loop when reading 0 frames from a data data buffer.
parent
a26d41ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
research/miniaudio_engine.h
research/miniaudio_engine.h
+20
-6
No files found.
research/miniaudio_engine.h
View file @
b48cb209
...
...
@@ -7422,7 +7422,7 @@ MA_API ma_result ma_resource_manager_data_buffer_uninit(ma_resource_manager_data
MA_API
ma_result
ma_resource_manager_data_buffer_read_pcm_frames
(
ma_resource_manager_data_buffer
*
pDataBuffer
,
void
*
pFramesOut
,
ma_uint64
frameCount
,
ma_uint64
*
pFramesRead
)
{
ma_result
result
=
MA_SUCCESS
;
ma_uint64
framesRead
;
ma_uint64
framesRead
=
0
;
ma_bool32
isLooping
;
ma_bool32
isDecodedBufferBusy
=
MA_FALSE
;
...
...
@@ -7451,6 +7451,11 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man
}
}
result
=
ma_resource_manager_data_buffer_get_looping
(
pDataBuffer
,
&
isLooping
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
/*
For decoded buffers (not paged) we need to check beforehand how many frames we have available. We cannot
exceed this amount. We'll read as much as we can, and then return MA_BUSY.
...
...
@@ -7464,19 +7469,28 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man
/* Don't try reading more than the available frame count. */
if
(
frameCount
>
availableFrames
)
{
frameCount
=
availableFrames
;
/*
If there's no frames available we want to set the status to MA_AT_END. The logic below
will check if the node is busy, and if so, change it to MA_BUSY. The reason we do this
is because we don't want to call `ma_data_source_read_pcm_frames()` if the frame count
is 0 because that'll result in a situation where it's possible MA_AT_END won't get
returned.
*/
if
(
frameCount
==
0
)
{
result
=
MA_AT_END
;
}
}
else
{
isDecodedBufferBusy
=
MA_FALSE
;
/* We have enough frames available in the buffer to avoid a MA_BUSY status. */
}
}
}
result
=
ma_resource_manager_data_buffer_get_looping
(
pDataBuffer
,
&
isLooping
);
if
(
result
!=
MA_SUCCESS
)
{
re
turn
result
;
/* Don't attempt to read anything if we've got no frames available. */
if
(
frameCount
>
0
)
{
re
sult
=
ma_data_source_read_pcm_frames
(
ma_resource_manager_data_buffer_get_connector
(
pDataBuffer
),
pFramesOut
,
frameCount
,
&
framesRead
,
isLooping
)
;
}
result
=
ma_data_source_read_pcm_frames
(
ma_resource_manager_data_buffer_get_connector
(
pDataBuffer
),
pFramesOut
,
frameCount
,
&
framesRead
,
isLooping
);
/*
If we returned MA_AT_END, but the node is still loading, we don't want to return that code or else the caller will interpret the sound
as at the end and terminate decoding.
...
...
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