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
8c2f457d
Commit
8c2f457d
authored
Apr 04, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce the weight of ma_sound by allocating some data on the heap.
parent
65987d80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
research/miniaudio_engine.h
research/miniaudio_engine.h
+17
-10
No files found.
research/miniaudio_engine.h
View file @
8c2f457d
...
...
@@ -1691,7 +1691,7 @@ struct ma_sound
sound via the resource manager, which I *think* will be the most common scenario.
*/
#ifndef MA_NO_RESOURCE_MANAGER
ma_resource_manager_data_source
r
esourceManagerDataSource
;
ma_resource_manager_data_source
*
pR
esourceManagerDataSource
;
#endif
};
...
...
@@ -11145,10 +11145,15 @@ MA_API ma_result ma_sound_init_from_file_internal(ma_engine* pEngine, const ma_s
*/
flags
=
pConfig
->
flags
|
MA_DATA_SOURCE_FLAG_WAIT_INIT
;
pSound
->
pResourceManagerDataSource
=
(
ma_resource_manager_data_source
*
)
ma_malloc
(
sizeof
(
*
pSound
->
pResourceManagerDataSource
),
&
pEngine
->
allocationCallbacks
);
if
(
pSound
->
pResourceManagerDataSource
==
NULL
)
{
return
MA_OUT_OF_MEMORY
;
}
if
(
pConfig
->
pFilePath
!=
NULL
)
{
result
=
ma_resource_manager_data_source_init
(
pEngine
->
pResourceManager
,
pConfig
->
pFilePath
,
flags
,
NULL
,
&
pSound
->
r
esourceManagerDataSource
);
result
=
ma_resource_manager_data_source_init
(
pEngine
->
pResourceManager
,
pConfig
->
pFilePath
,
flags
,
NULL
,
pSound
->
pR
esourceManagerDataSource
);
}
else
{
result
=
ma_resource_manager_data_source_init_w
(
pEngine
->
pResourceManager
,
pConfig
->
pFilePathW
,
flags
,
NULL
,
&
pSound
->
r
esourceManagerDataSource
);
result
=
ma_resource_manager_data_source_init_w
(
pEngine
->
pResourceManager
,
pConfig
->
pFilePathW
,
flags
,
NULL
,
pSound
->
pR
esourceManagerDataSource
);
}
if
(
result
!=
MA_SUCCESS
)
{
...
...
@@ -11161,11 +11166,12 @@ MA_API ma_result ma_sound_init_from_file_internal(ma_engine* pEngine, const ma_s
config
=
*
pConfig
;
config
.
pFilePath
=
NULL
;
config
.
pFilePathW
=
NULL
;
config
.
pDataSource
=
&
pSound
->
r
esourceManagerDataSource
;
config
.
pDataSource
=
pSound
->
pR
esourceManagerDataSource
;
result
=
ma_sound_init_from_data_source_internal
(
pEngine
,
&
config
,
pSound
);
if
(
result
!=
MA_SUCCESS
)
{
ma_resource_manager_data_source_uninit
(
&
pSound
->
resourceManagerDataSource
);
ma_resource_manager_data_source_uninit
(
pSound
->
pResourceManagerDataSource
);
ma_free
(
pSound
->
pResourceManagerDataSource
,
&
pEngine
->
allocationCallbacks
);
MA_ZERO_OBJECT
(
pSound
);
return
result
;
}
...
...
@@ -11246,7 +11252,8 @@ MA_API void ma_sound_uninit(ma_sound* pSound)
/* Once the sound is detached from the group we can guarantee that it won't be referenced by the mixer thread which means it's safe for us to destroy the data source. */
#ifndef MA_NO_RESOURCE_MANAGER
if
(
pSound
->
ownsDataSource
)
{
ma_resource_manager_data_source_uninit
(
&
pSound
->
resourceManagerDataSource
);
ma_resource_manager_data_source_uninit
(
pSound
->
pResourceManagerDataSource
);
ma_free
(
pSound
->
pResourceManagerDataSource
,
&
pSound
->
engineNode
.
pEngine
->
allocationCallbacks
);
pSound
->
pDataSource
=
NULL
;
}
#else
...
...
@@ -11710,8 +11717,8 @@ MA_API ma_result ma_sound_set_looping(ma_sound* pSound, ma_bool8 isLooping)
generically.
*/
#ifndef MA_NO_RESOURCE_MANAGER
if
(
pSound
->
pDataSource
==
&
pSound
->
r
esourceManagerDataSource
)
{
ma_resource_manager_data_source_set_looping
(
&
pSound
->
r
esourceManagerDataSource
,
isLooping
);
if
(
pSound
->
pDataSource
==
pSound
->
pR
esourceManagerDataSource
)
{
ma_resource_manager_data_source_set_looping
(
pSound
->
pR
esourceManagerDataSource
,
isLooping
);
}
#endif
...
...
@@ -11762,8 +11769,8 @@ MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameInd
thread safe as well so in that case we'll need to get the mixing thread to seek for us to ensure we don't try seeking at the same time as reading.
*/
#ifndef MA_NO_RESOURCE_MANAGER
if
(
pSound
->
pDataSource
==
&
pSound
->
r
esourceManagerDataSource
)
{
ma_result
result
=
ma_resource_manager_data_source_seek_to_pcm_frame
(
&
pSound
->
r
esourceManagerDataSource
,
frameIndex
);
if
(
pSound
->
pDataSource
==
pSound
->
pR
esourceManagerDataSource
)
{
ma_result
result
=
ma_resource_manager_data_source_seek_to_pcm_frame
(
pSound
->
pR
esourceManagerDataSource
,
frameIndex
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
...
...
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