Thmp3/Devblog

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
(2009.06.17)
m (2009.06.17)
Line 48: Line 48:
 
Most of the old control code was replaced with state machine [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design patterns]. Making it more stable, and easier to read among other things. More stable because now ARM9 waits for the other CPU to acknowledge completion of a command before changing its own state, much better than sending commands and hoping it worked.. :P
 
Most of the old control code was replaced with state machine [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design patterns]. Making it more stable, and easier to read among other things. More stable because now ARM9 waits for the other CPU to acknowledge completion of a command before changing its own state, much better than sending commands and hoping it worked.. :P
  
Another useful thing here with state machines on a single process system, the SM's code can be called over and over in a loop and it wont change state untill the proper conditions have been met.
+
Another useful thing here with state machines on a single process system, the SM's code can be called over and over in a loop and it wont change state untill the proper conditions have been met. >:D

Revision as of 17:44, 17 June 2009

Whats this?

Blog regarding functionality of the mp3 player. This was start almost a year after original release since there were major changes.

background

The thmp3 lib uses Helix mp3 decoder, which is a free open source mp3 decoder lib with special optimizations for the ARM series of CPUs. The decoding is done in the ARM7 cpu while the ARM9 fetches data from files and commands the ARM7.

2009.06.17

Was decided to use a state machine on both sides (the arm7 actually has two state machines for decoding and playback of pcm). Among other things state machines allow different states' (sometimes also called stages or steps), each stage has actions to perform and/or conditions to check for. If the proper conditions are met the machine will move to another stage, perform other actions, wait for other conditions.

For instance, the mp3 player has states such as READY, PLAYING, and PAUSED. it actually has a few more, but for illustration, these will do.

In this example can see operation of simple state machine, as the machine receives commands, depending on the current state it will perform different actions and

switch(state) {
   case STOPPED:
      if(cmd==PLAY) {
       startPlaying();
       state=PLAYING;
     break;
   case PLAYING:
      select(cmd) {
       case STOP:
        state=STOPING;
        break;
       case PAUSE:
        pausePlaying();
        state=PAUSED;
        break;
      };
     break;
   case STOPING:
        stopPlaying();
        state=STOPPED;
     break;
   case PAUSED:
     select(cmd) {
      case PLAY:
        startPlaying();
        state=PLAYING;
      case STOP:
        state=STOPING;
        break;
     }; 
     break;
 }

Most of the old control code was replaced with state machine design patterns. Making it more stable, and easier to read among other things. More stable because now ARM9 waits for the other CPU to acknowledge completion of a command before changing its own state, much better than sending commands and hoping it worked.. :P

Another useful thing here with state machines on a single process system, the SM's code can be called over and over in a loop and it wont change state untill the proper conditions have been met. >:D

Personal tools
irssi scripts
eggdrop scripts