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
f194a8bb
Commit
f194a8bb
authored
Jan 22, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug in the resource_manager_advanced example.
parent
8f494c41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
10 deletions
+21
-10
research/_examples/resource_manager_advanced.c
research/_examples/resource_manager_advanced.c
+21
-10
No files found.
research/_examples/resource_manager_advanced.c
View file @
f194a8bb
...
...
@@ -291,24 +291,35 @@ int main(int argc, char** argv)
/* Teardown. */
/* Uninitialize the device first to ensure the data callback is stopped and doesn't try to access any data. */
/*
Uninitialize the device first to ensure the data callback is stopped and doesn't try to access
any data.
*/
ma_device_uninit
(
&
device
);
/*
Before uninitializing the resource manager we need to make sure a quit event has been posted to ensure we can get
out of our custom thread. The call to ma_resource_manager_uninit() will also do this, but we need to call it
explicitly so that our thread can exit naturally. You only need to post a quit job if you're using that as the exit
indicator. You can instead use whatever variable you want to terminate your job thread, but since this example is
using a quit job we need to post one
.
Our data sources need to be explicitly uninitialized. ma_resource_manager_uninit() will not do
it for us. This needs to be done before posting the quit event and uninitializing the resource
manager or else we'll get stuck in a deadlock because ma_resource_manager_data_source_uninit()
will be waiting for the job thread(s) to finish work, which will never happen because they were
just terminated
.
*/
ma_resource_manager_post_job_quit
(
&
resourceManager
);
ma_thread_wait
(
&
jobThread
);
/* Wait for the custom job thread to finish so it doesn't try to access any data. */
/* Our data sources need to be explicitly uninitialized. ma_resource_manager_uninit() will not do it for us. */
for
(
iFile
=
0
;
(
size_t
)
iFile
<
g_dataSourceCount
;
iFile
+=
1
)
{
ma_resource_manager_data_source_uninit
(
&
g_dataSources
[
iFile
]);
}
/*
Before uninitializing the resource manager we need to make sure a quit event has been posted to
ensure we can get out of our custom thread. The call to ma_resource_manager_uninit() will also
do this, but we need to call it explicitly so that our self-managed thread can exit naturally.
You only need to post a quit job if you're using that as the exit indicator. You can instead
use whatever variable you want to terminate your job thread, but since this example is using a
quit job we need to post one. Note that you don't need to do this if you're not managing your
own threads - ma_resource_manager_uninit() alone will suffice in that case.
*/
ma_resource_manager_post_job_quit
(
&
resourceManager
);
ma_thread_wait
(
&
jobThread
);
/* Wait for the custom job thread to finish so it doesn't try to access any data. */
/* Uninitialize the resource manager after each data source. */
ma_resource_manager_uninit
(
&
resourceManager
);
...
...
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