Slick Forums

Discuss the Slick 2D Library
It is currently Sat Feb 23, 2019 1:18 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Aug 15, 2011 5:46 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Right now the SoundStore findFreeSource() method skips the first source (because it's music), but also skips the last source:

Code:
private int findFreeSource() {
      for (int i=1;i<sourceCount-1;i++) {
         int state = AL10.alGetSourcei(sources.get(i), AL10.AL_SOURCE_STATE);
         
         if ((state != AL10.AL_PLAYING) && (state != AL10.AL_PAUSED)) {
            return i;
         }
      }
      
      return -1;
   }


(notice sourceCount-1)

So no matter how many sounds are playing, the last source is never used.


Last edited by davedes on Sun Oct 16, 2011 5:43 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2011 5:00 pm 
Offline
User avatar

Joined: Mon Jun 20, 2011 4:28 pm
Posts: 71
eeh, no ?

sourceCount is, how many element there are
0 is skipped, there for it starts at 1

[COUNT-1] is the last element (of ANY array), because computers begin counting at 0 not 1

I surely don't tell you anything new ? =P


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2011 5:16 pm 
Offline
User avatar

Joined: Mon Jun 20, 2011 4:28 pm
Posts: 71
I stand corrected. Here it's LESS THEN < COUNT-1, you're actually right.
I think.


Top
 Profile  
 
PostPosted: Sun Mar 04, 2012 10:22 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Fixed in dev branch.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group