Thmp3/Devblog

From ProjectWiki
Revision as of 17:34, 17 June 2009 by Wikisysop (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 the state machine design patterns.

Personal tools
irssi scripts
eggdrop scripts