We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4138 - Issue reusing a Mix_Music more than once
Summary: Issue reusing a Mix_Music more than once
Status: NEW
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-16 06:57 UTC by Michele Caini
Modified: 2018-04-16 06:57 UTC (History)
0 users

See Also:


Attachments
minimal example to reproduce the issue (1.19 KB, text/plain)
2018-04-16 06:57 UTC, Michele Caini
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michele Caini 2018-04-16 06:57:19 UTC
Created attachment 3223 [details]
minimal example to reproduce the issue

Consider the following:

    Mix_Music *m1 = Mix_LoadMUS("foo.mp3");
    Mix_Music *m2 = Mix_LoadMUS("foo.mp2");

    Mix_PlayMusic(m1, -1);
    // do things for N seconds
    Mix_PlayMusic(m2, -1);
    // do things for M seconds
    Mix_PlayMusic(m1, -1);

Note that I don't free neither m1 nor m2 in any case.

Here the problem: when I play m1 the second time, a few ms of the music from the point where it was when I stopped it the first time are played. Then it resets to the start and plays the whole music from there as expected.
It looks like a Mix_Music has a buffer it starts playing before doing any other thing.

Here is a Q/A on SO, actually only a Q so far - https://stackoverflow.com/questions/49836263/issue-reusing-a-mix-music-more-than-once
From the question above, you can get this link where you can find a short snippet to reproduce the issue (many thanks to the author) - https://gist.github.com/araml/7191ba537e497cc1ccd7e0199c65bdc6
I'm creating also an attachment with exactly the same code.

It happens with all the mp3 files I tried so far, so I don't think it depends on the file itself.
If you want a file that I used to reproduce the issue, here it is - https://ozzed.net/music/8-bit-empire.shtml#tune01