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
19c52c98
Commit
19c52c98
authored
Aug 25, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resource Manager: Fix a data buffer bug.
parent
07ae0be2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
research/ma_engine.c
research/ma_engine.c
+9
-7
research/ma_engine.h
research/ma_engine.h
+5
-0
No files found.
research/ma_engine.c
View file @
19c52c98
...
...
@@ -21,8 +21,8 @@ void on_sound_loaded(ma_async_notification* pNotification)
This will be fired when the sound has finished loading. We should be able to retrieve the length of the sound at this point. Here we'll just set
the fade out time.
*/
ma_sound_get_length_in_pcm_frames
(
pLoadedNotification
->
pSound
,
&
lengthInPCMFrames
);
ma_sound_set_fade_point_in_frames
(
pLoadedNotification
->
pSound
,
1
,
1
,
0
,
lengthInPCMFrames
-
192000
,
lengthInPCMFrames
);
//
ma_sound_get_length_in_pcm_frames(pLoadedNotification->pSound, &lengthInPCMFrames);
//
ma_sound_set_fade_point_in_frames(pLoadedNotification->pSound, 1, 1, 0, lengthInPCMFrames - 192000, lengthInPCMFrames);
}
int
main
(
int
argc
,
char
**
argv
)
...
...
@@ -50,14 +50,14 @@ int main(int argc, char** argv)
loadNotification
.
cb
.
onSignal
=
on_sound_loaded
;
loadNotification
.
pSound
=
&
sound
;
result
=
ma_sound_init_from_file
(
&
engine
,
argv
[
1
],
MA_DATA_SOURCE_FLAG_DECODE
/*| MA_DATA_SOURCE_FLAG_ASYNC
| MA_DATA_SOURCE_FLAG_STREAM*/
,
&
loadNotification
,
NULL
,
&
sound
);
result
=
ma_sound_init_from_file
(
&
engine
,
argv
[
1
],
MA_DATA_SOURCE_FLAG_DECODE
|
MA_DATA_SOURCE_FLAG_ASYNC
/*
| MA_DATA_SOURCE_FLAG_STREAM*/
,
&
loadNotification
,
NULL
,
&
sound
);
if
(
result
!=
MA_SUCCESS
)
{
printf
(
"Failed to load sound: %s
\n
"
,
argv
[
1
]);
ma_engine_uninit
(
&
engine
);
return
-
1
;
}
result
=
ma_sound_init_from_file
(
&
engine
,
argv
[
1
],
MA_DATA_SOURCE_FLAG_DECODE
/*| MA_DATA_SOURCE_FLAG_ASYNC
| MA_DATA_SOURCE_FLAG_STREAM*/
,
&
loadNotification
,
NULL
,
&
sound2
);
result
=
ma_sound_init_from_file
(
&
engine
,
argv
[
1
],
MA_DATA_SOURCE_FLAG_DECODE
|
MA_DATA_SOURCE_FLAG_ASYNC
/*
| MA_DATA_SOURCE_FLAG_STREAM*/
,
&
loadNotification
,
NULL
,
&
sound2
);
if
(
result
!=
MA_SUCCESS
)
{
printf
(
"Failed to load sound: %s
\n
"
,
argv
[
1
]);
ma_engine_uninit
(
&
engine
);
...
...
@@ -76,13 +76,15 @@ int main(int argc, char** argv)
ma_sound_set_looping
(
&
sound
,
MA_TRUE
);
//ma_sound_seek_to_pcm_frame(&sound, 6000000);
//ma_sound_set_start_delay(&sound, 1110);
ma_sound_set_fade_point_in_milliseconds
(
&
sound
,
0
,
0
,
1
,
0
,
2000
);
ma_sound_set_fade_point_auto_reset
(
&
sound
,
0
,
MA_FALSE
);
/* Enable fading around loop transitions. */
ma_sound_set_fade_point_auto_reset
(
&
sound
,
1
,
MA_FALSE
);
ma_sound_set_volume
(
&
sound
,
0
.
5
f
);
//ma_sound_set_fade_point_in_milliseconds(&sound, 0, 0, 1, 0, 2000);
//ma_sound_set_fade_point_auto_reset(&sound, 0, MA_FALSE); /* Enable fading around loop transitions. */
//ma_sound_set_fade_point_auto_reset(&sound, 1, MA_FALSE);
ma_sound_set_stop_delay
(
&
sound
,
1000
);
ma_sound_start
(
&
sound
);
ma_sleep
(
1000
);
ma_sound_set_volume
(
&
sound2
,
0
.
5
f
);
ma_sound_start
(
&
sound2
);
//ma_sleep(2000);
...
...
research/ma_engine.h
View file @
19c52c98
...
...
@@ -2197,6 +2197,11 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager
return
result
;
/* Should never happen. Failed to increment the reference count. */
}
/* The existing node may be in the middle of loading. We need to wait for the node to finish loading before going any further. */
while
(
pDataBuffer
->
pNode
->
result
==
MA_BUSY
)
{
ma_yield
();
}
result
=
ma_resource_manager_data_buffer_init_connector
(
pDataBuffer
);
if
(
result
!=
MA_SUCCESS
)
{
ma_resource_manager_data_buffer_node_free
(
pDataBuffer
->
pResourceManager
,
pDataBuffer
->
pNode
);
...
...
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