-
-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new API method for seeking audio streams using seconds; bugfix where one method returns success when NULL is parsed; typo corrected in a comment #928
base: dev
Are you sure you want to change the base?
Conversation
About this Segmentation Fault, I used Valgrind to see where it happened, and this is its output:
I used GDB as well to see the values and how they propagated. What I've noticed is that when Posting this here for now, just in case |
Thanks. I can see the null dereference bug but haven't had a chance to fix that just yet. I'll address that separately to this PR. As for the PR itself, I support the idea behind this in principle, but a few minor things:
Other than that I can't see any issues from my quick scan just now. Thanks. |
I corrected those things you have mentioned. Additionally, I've found an uninitialized variable bug present in my initial code (oops), and fixed it quickly. About the 5th point: I couldn't find I tested with the same mini program ( |
I finally got around to fixing up that crash in Yes I did indeed mean |
Since there is one API method called
ma_sound_seek_to_pcm_frame()
available to end-users, it would be nice to have similar API methods that use seconds instead of PCM frames (as there are other alternative methods having their PCM equivalents).Three new methods are introduced:
ma_result ma_sound_seek_to_second(ma_sound*, float)
(matchesma_sound_seek_to_pcm_frame(ma_sound*, ma_uint64)
),ma_result ma_data_source_seek_to_second(ma_data_source*, float)
(matchesma_data_source_seek_to_pcm_frame(ma_data_source*, ma_uint64
), andma_result ma_data_source_seek_seconds(ma_data_source*, float, float*)
(matchesma_data_source_seek_pcm_frames(ma_data_source*, ma_uint64, ma_uint64*)
)While reading definitions of those inspired functions, I noticed that there is (I suppose) a bug in
ma_result ma_data_source_seek_to_pcm_frame(ma_data_source *pDataSource, ma_uint64 frameIndex)
where this function returnsMA_SUCCESS
whenpDataSource
isNULL
, while other similar functions returnMA_INVALID_ARGS
. It should not return successful operation on uninitialized data sourcepDataSource
. That was a one line change. Another thing I've noticed was a typo in a comment inside the same function definition, so I quickly corrected that in the same commit where this bugfix is done.To test new changes, I wrote a mini program (
main.c
):And compiled with
gcc main.c -o main -lm -ldl -pthread -g
Two new methods
ma_sound_seek_to_second()
andma_data_source_seek_to_second()
work as expected, andma_data_source_seek_to_pcm_frame()
returns error properly......but the last new method
ma_data_source_seek_seconds()
leads to segmentation fault. Though it was something in my implementation, so I tried out quickly with its pairma_data_source_seek_pcm_frames()
, and it also segfaults. Those two functions lead to segmentation fault because... TLDR:NULL
value is passed to second argumentvoid *pFramesOut
ofma_data_source_read_pcm_frames()
function, where further aNULL
value was dereferenced.On the eye,
ma_data_source_seek_seconds()
seems fine. For this segfault problem, I can create an issue or make separate PR, but I'll discuss with you first on what's appropriate action.