Skip to content

Commit

Permalink
PlatformPlayer: Treat more setLoopCount cases correctly
Browse files Browse the repository at this point in the history
Previously, my setLoopCount() on both midi and wav player only
accounted for Gameloft games setting the loop count 1 level above
where they should, while ignoring cases where apps could set loop
count as 0 outright, or -1 (loop continuously). This commit amends
that.
  • Loading branch information
AShiningRay committed Sep 19, 2024
1 parent 0a79a62 commit ef7d3f6
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/org/recompile/mobile/PlatformPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,15 @@ public void deallocate()

public void setLoopCount(int count)
{
if(count < 1) {count = 1;} /* Treat cases where an app might set loops as 0 */
midi.setLoopCount(count-1);
/*
* Treat cases where an app has already set
* loops as 0, or wants this stream to loop continuously.
* Here, count = 1 means it should loop one time, whereas in j2me
* it appears that count = 1 means no loop at all, at least based
* on Gameloft games that set effects and some music with count = 1
*/
if(count == Clip.LOOP_CONTINUOUSLY || count == 0) { midi.setLoopCount(count); }
else { midi.setLoopCount(count-1); }
}
public long setMediaTime(long now)
{
Expand Down Expand Up @@ -442,8 +449,15 @@ public void stop()

public void setLoopCount(int count)
{
if(count < 1) {count = 1;} /* Treat cases where an app might set loops as 0 */
wavClip.loop(count-1);
/*
* Treat cases where an app has already set
* loops as 0, or wants this stream to loop continuously.
* Here, count = 1 means it should loop one time, whereas in j2me
* it appears that count = 1 means no loop at all, at least based
* on Gameloft games that set effects and some music with count = 1
*/
if(count == Clip.LOOP_CONTINUOUSLY || count == 0) { wavClip.loop(count); }
else { wavClip.loop(count-1); }
}

public long setMediaTime(long now)
Expand Down

0 comments on commit ef7d3f6

Please sign in to comment.