forked from len0rd/rockbox
Fix file descriptor leak that would cause a hard lockup every 7 files
played. A few other cosmetic changes. please, please no red build =) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9865 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
224b0bf1ff
commit
47efba8bbf
5 changed files with 111 additions and 84 deletions
|
@ -67,7 +67,8 @@ struct MIDIfile * loadFile(char * filename)
|
|||
|
||||
int track=0;
|
||||
|
||||
printf("\nnumTracks=%d div=%d\nBegin reading track data\n", mfload->numTracks, mfload->div);
|
||||
printf("\nFile has %d tracks.", mfload->numTracks);
|
||||
printf("Time division=%d\n", mfload->div);
|
||||
|
||||
|
||||
while(! eof(file) && track < mfload->numTracks)
|
||||
|
@ -79,7 +80,7 @@ struct MIDIfile * loadFile(char * filename)
|
|||
{
|
||||
if(mfload->numTracks != track)
|
||||
{
|
||||
printf("\nError: file claims to have %d tracks.\n I only see %d here.\n", mfload->numTracks, track);
|
||||
printf("\nError: file claims to have %d tracks.\n I only see %d here.\n", mfload->numTracks, track);
|
||||
mfload->numTracks = track;
|
||||
}
|
||||
return mfload;
|
||||
|
@ -88,7 +89,6 @@ struct MIDIfile * loadFile(char * filename)
|
|||
if(id == ID_MTRK)
|
||||
{
|
||||
mfload->tracks[track] = readTrack(file);
|
||||
//exit(0);
|
||||
track++;
|
||||
} else
|
||||
{
|
||||
|
@ -98,16 +98,19 @@ struct MIDIfile * loadFile(char * filename)
|
|||
readChar(file);
|
||||
}
|
||||
}
|
||||
|
||||
rb->close(file);
|
||||
return mfload;
|
||||
|
||||
}
|
||||
|
||||
/* Global again. Not static. What if track 1 ends on a running status event
|
||||
* and then track 2 starts loading */
|
||||
|
||||
int rStatus = 0;
|
||||
/* Returns 0 if done, 1 if keep going */
|
||||
int readEvent(int file, void * dest)
|
||||
{
|
||||
|
||||
static int rStatus = 0;
|
||||
struct Event dummy;
|
||||
struct Event * ev = (struct Event *) dest;
|
||||
|
||||
|
@ -136,7 +139,7 @@ int readEvent(int file, void * dest)
|
|||
else
|
||||
{
|
||||
/*
|
||||
* Don't allocate anything, just see how much it would tale
|
||||
* Don't allocate anything, just see how much it would take
|
||||
* To make memory usage efficient
|
||||
*/
|
||||
unsigned int a=0;
|
||||
|
@ -201,7 +204,7 @@ struct Track * readTrack(int file)
|
|||
{
|
||||
if(trackSize < dataPtr-trk->dataBlock)
|
||||
{
|
||||
printf("\nTrack parser memory out of bounds");
|
||||
printf("\nTrack parser memory out of bounds");
|
||||
exit(1);
|
||||
}
|
||||
dataPtr+=sizeof(struct Event);
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
|
||||
extern struct plugin_api * rb;
|
||||
|
||||
int printf(const char *fmt, ...);
|
||||
|
||||
int chVol[16] IBSS_ATTR; /* Channel volume */
|
||||
int chPanLeft[16] IBSS_ATTR; /* Channel panning */
|
||||
|
@ -156,6 +157,15 @@ void *alloc(int size)
|
|||
|
||||
if (size + 4 > totalSize)
|
||||
{
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
/* We've made our point. */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -229,7 +239,7 @@ int eof(int fd)
|
|||
// Here is a hacked up printf command to get the output from the game.
|
||||
int printf(const char *fmt, ...)
|
||||
{
|
||||
static int p_xtpt;
|
||||
static int p_xtpt = 0;
|
||||
char p_buf[50];
|
||||
bool ok;
|
||||
va_list ap;
|
||||
|
|
|
@ -111,7 +111,7 @@ long pitchTbl[] ICONST_ATTR={
|
|||
72901,72934,72967,72999,73032,73065,73098,73131,73164,73197,73230,73264,
|
||||
73297,73330,73363,73396,73429,73462,73495,73528
|
||||
};
|
||||
|
||||
/*
|
||||
void findDelta(struct SynthObject * so, int ch, int note)
|
||||
{
|
||||
|
||||
|
@ -120,6 +120,22 @@ void findDelta(struct SynthObject * so, int ch, int note)
|
|||
so->delta = (((gustable[note]<<10) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE));
|
||||
so->delta = (so->delta * pitchTbl[chPW[ch]])>> 16;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void findDelta(struct SynthObject * so, int ch, int note)
|
||||
{
|
||||
|
||||
struct GWaveform * wf = patchSet[chPat[ch]]->waveforms[patchSet[chPat[ch]]->noteTable[note]];
|
||||
so->wf=wf; // \|/ was 10
|
||||
|
||||
unsigned long delta= 0 ;
|
||||
|
||||
delta = (((gustable[note]<<FRACTSIZE) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE));
|
||||
delta = (delta * pitchTbl[chPW[ch]])>> 16;
|
||||
|
||||
so->delta = delta;
|
||||
}
|
||||
|
||||
inline void setPW(int ch, int msb, int lsb)
|
||||
{
|
||||
|
|
|
@ -272,7 +272,7 @@ signed short int synthVoice(struct SynthObject * so)
|
|||
so->cp += so->delta;
|
||||
}
|
||||
|
||||
cpShifted = so->cp >> 10; //Was 10
|
||||
cpShifted = so->cp >> FRACTSIZE; //Was 10
|
||||
|
||||
if( (cpShifted > (wf->numSamples) && (so->state != STATE_RAMPDOWN)))
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ signed short int synthVoice(struct SynthObject * so)
|
|||
{
|
||||
if(wf->mode & LOOP_REVERSE)
|
||||
{
|
||||
so->cp = (wf->endLoop)<<10; //Was 10
|
||||
so->cp = (wf->endLoop)<<FRACTSIZE; //Was 10
|
||||
cpShifted = wf->endLoop;
|
||||
s2=getSample((cpShifted), wf);
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ signed short int synthVoice(struct SynthObject * so)
|
|||
so->loopState = STATE_LOOPING;
|
||||
if((wf->mode & (24)) == 0)
|
||||
{
|
||||
so->cp = (wf->startLoop)<<10; //Was 10
|
||||
so->cp = (wf->startLoop)<<FRACTSIZE; //Was 10
|
||||
cpShifted = wf->startLoop;
|
||||
s2=getSample((cpShifted), wf);
|
||||
}
|
||||
|
@ -315,8 +315,8 @@ signed short int synthVoice(struct SynthObject * so)
|
|||
|
||||
/* Better, working, linear interpolation */
|
||||
s1=getSample((cpShifted), wf); //\|/ Was 1023)) >> 10
|
||||
s = s1 + ((signed)((s2 - s1) * (so->cp & 1023))>>10); //Was 10
|
||||
|
||||
// s = s1 + ((signed)((s2 - s1) * (so->cp & (1023)))>>10); //Was 10
|
||||
s = s1 + ((signed)((s2 - s1) * (so->cp & ((1<<FRACTSIZE)-1)))>>FRACTSIZE); //Was 10
|
||||
|
||||
/* ADSR COMMENT WOULD GO FROM HERE.........*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue