REVISION
Definition in file DECODER_getData.c.
#include "../SYSTEM/sys_hardware.h"
#include "../SYSTEM/sys_main.h"
#include "../MESSAGE/message.h"
#include "../codec/codec.h"
#include "../coder/coder.h"
#include "../UI/playQ.h"
#include "decoder.h"
Include dependency graph for DECODER_getData.c:

Go to the source code of this file.
Data Structures | |
| struct | st_CACHE |
| Cache control structure definition. More... | |
Typedefs | |
| typedef st_CACHE | st_CACHE |
| Cache control structure definition. | |
Enumerations | |
| enum | IN_CACHE_STATE { INCACHE_ALREADY, INCACHE_CHECK, INCACHE_WAIT } |
| Cache check state definitions. More... | |
Functions | |
| unsigned short | DECODER_getData (int *pD, unsigned long offset, unsigned short reqLen) |
| Function feeds data into docoder bit stream/buffer. | |
| void | DECODER_cache (void) |
| Function serves as the decoder cache task handle. | |
| BOOL | DECODER_cacheInit (void) |
| Function initialized the decoder cache. | |
| void | DECODER_cacheDepthReset (unsigned short mode) |
| Function resets cache depth controls. | |
|
|
Cache check state definitions.
Definition at line 76 of file DECODER_getData.c. 00077 {
00078 INCACHE_ALREADY,
00079 INCACHE_CHECK,
00080 INCACHE_WAIT
00081 } IN_CACHE_STATE;
|
|
|
Function serves as the decoder cache task handle. This task feeds the cache. Definition at line 156 of file DECODER_getData.c. References st_CACHE::actvFileSize, st_CACHE::actvStartClus, Audio, st_AUDIO::cachefile, DECODER_cacheDepthReset(), st_CACHE::done, st_CACHE::endSec, FAT_fread(), FAT_fseek(), st_AUDIO::file, st_CODER::flag, NAND_writeSec(), st_CACHE::next, st_CACHE::prev, SCURRENTAUDIOFILE, st_CACHE::secNum, st_CACHE::secOffset, SEEK_HEAD, File::size, SNEXTAUDIOFILE, File::startClus, and st_CACHE::startSec. 00157 {
00158 unsigned short len;
00159 st_CACHE * c;
00160 unsigned short buf[256];
00161
00162 if( F_CODER_CACHESETIDLE & Coder.flag )
00163 {
00164 SEM_post(SEM_cacheIdle);
00165 return;
00166 }
00167
00168 // On entry, check the lower threshold.
00169 if( (!(F_CODER_CACHESHUTDOWN & Coder.flag)) &&
00170 (cacheDepth > cacheLowerThreshold) )
00171 {
00172 CACHE_RETURN();
00173 }
00174
00175 while(1)
00176 {
00177 if( F_CODER_CACHESHUTDOWN & Coder.flag )
00178 {
00179 _cacheShutdown(buf);
00180 SEM_post(SEM_cacheIdle);
00181 CACHE_RETURN();
00182 }
00183 if( F_CODER_CACHESETIDLE & Coder.flag )
00184 {
00185 SEM_post(SEM_cacheIdle);
00186 }
00187
00188 // Every time cache gets posted, check will be done
00189 // in the following order,
00190 // 1) Is current audio file in cache queue and has it been fully cached?
00191 // 2) Is it necessary to update cache to read in more new data?
00192
00193 // File in cache and fully cached, check to read in more.
00194 if( (rdCache->actvStartClus == Audio.file.startClus)&&
00195 (rdCache->actvFileSize == Audio.file.size)&&
00196 (rdCache->done == TRUE) )
00197 {
00198 if(wrCache->done == TRUE)
00199 {
00200 // Try next file.
00201 mMSG_send(uiParentMsgQ, SYS_MSG_ID, SNEXTAUDIOFILE, 1, SYS_FOREVER);
00202
00203 // Get a copy of cachefile handle.
00204 //TSK_disable();
00205 cachefile = Audio.cachefile;
00206 //TSK_enable();
00207 c = _cachePosition(&cachefile);
00208
00209 //if( (c->done == TRUE)&&(c == cacheHead) )
00210 //{
00211 // Already cached all tracks.
00212 //msgOUT.id = SYS_MSG_ID;
00213 //msgOUT.d1 = SCURRENTAUDIOFILE;
00214 //mMSG_send(uiParentMsgQ, &msgOUT, SYS_FOREVER);
00215 //CACHE_RETURN();
00216 //}
00217 //else
00218
00219 if( (c->actvStartClus == cachefile.startClus)&&
00220 (c->actvFileSize == cachefile.size)&&
00221 (c->done == TRUE) )
00222 {
00223 cacheDepth += c->secNum;
00224
00225 if(c->actvStartClus != wrCache->actvStartClus)
00226 {
00227 wrCacheSec += c->secNum;
00228 if(wrCacheSec > SYS_cacheEndSec()) wrCacheSec -= SYS_cacheSecNum();
00229 }
00230 CACHE_RETURN();
00231 //continue;
00232 }
00233 else
00234 {
00235 FAT_fseek(&cachefile, 0, SEEK_HEAD);
00236 //TSK_disable();
00237 cacheTail = c->next;
00238 cacheTail->actvStartClus = 0;
00239 cacheTail->done = FALSE;
00240
00241 if(cacheTail == cacheHead)
00242 cacheHead = cacheHead->next;
00243
00244 wrCache = c;
00245 wrCacheSec =
00246 wrCache->startSec =
00247 wrCache->endSec = c->prev->endSec;
00248 wrCache->secNum = 0;
00249 wrCache->secOffset= 0;
00250
00251 wrCache->actvStartClus = cachefile.startClus;
00252 wrCache->actvFileSize = cachefile.size;
00253 wrCache->done = FALSE;
00254 //TSK_enable();
00255 }
00256 }
00257 }
00258 else
00259 {
00260 if( (wrCache->actvStartClus != Audio.file.startClus)||
00261 (wrCache->actvFileSize != Audio.file.size)||
00262 (wrCache != rdCache))
00263 {
00264 ULONG secOffset = 0;
00265
00266 mMSG_send(uiParentMsgQ, SYS_MSG_ID, SCURRENTAUDIOFILE, DONTCARE, SYS_FOREVER);
00267
00268 //TSK_disable();
00269 cachefile = Audio.file;
00270
00271 //TSK_enable();
00272 if(prevOffset > 0x40000)
00273 {
00274 secOffset = prevOffset/256;
00275 FAT_fseek(&cachefile, secOffset*256, SEEK_HEAD);
00276 }
00277 else FAT_fseek(&cachefile, 0, SEEK_HEAD);
00278
00279 //TSK_disable();
00280 if(wrCache->done == TRUE)
00281 {
00282 wrCacheSec = wrCache->endSec;
00283 wrCache = wrCache->next;
00284 wrCache->startSec = wrCacheSec;
00285 }
00286 else wrCacheSec = wrCache->startSec;
00287
00288 cacheTail = wrCache->next;
00289 cacheTail->actvStartClus = 0;
00290 cacheTail->done = FALSE;
00291 if(cacheTail == cacheHead)
00292 cacheHead = cacheHead->next;
00293
00294 wrCache->actvStartClus = cachefile.startClus;
00295 wrCache->actvFileSize = cachefile.size;
00296
00297 wrCache->endSec = wrCacheSec ;
00298 wrCache->secNum = 0;
00299 wrCache->done = FALSE;
00300 wrCache->secOffset= secOffset;
00301
00302 rdCache = wrCache;
00303 cacheDepth = 0;
00304 //TSK_enable();
00305 }
00306 }
00307
00308 // Check cache depth.
00309 if(cacheDepth > cacheUpperThreshold)
00310 {
00311 DECODER_cacheDepthReset(2);
00312 mMSG_send(uiParentMsgQ, SYS_MSG_ID, SNEXTAUDIOFILE, 0, SYS_FOREVER);
00313 CACHE_RETURN();
00314 }
00315
00316 if(SYS_nextCacheSec(wrCache->endSec) == cacheHead->startSec)
00317 {
00318 //TSK_disable();
00319 if( (cacheHead != wrCache) )
00320 {
00321 if(cacheHead != rdCache) cacheHead = cacheHead->next;
00322 else CACHE_RETURN();
00323 }
00324 else
00325 {
00326 // Cache is full.
00327 cacheHead->secOffset++;
00328 cacheHead->secNum--;
00329 cacheHead->startSec = SYS_nextCacheSec(cacheHead->startSec);
00330 }
00331 //TSK_enable();
00332 }
00333
00334 len = FAT_fread(&cachefile, buf, 256);
00335 NAND_writeSec(wrCacheSec, buf, FALSE);
00336 cacheDepth++;
00337 wrCacheSec = SYS_nextCacheSec(wrCacheSec);
00338 wrCache->endSec = wrCacheSec;
00339 wrCache->secNum++;
00340 if(len<256) wrCache->done = TRUE;
00341
00342 SYS_swWdtReset();
00343 }
00344 }
|
Here is the call graph for this function:

|
|
Function resets cache depth controls. This function also resets cache check state to verify if file exists in cache.
Definition at line 406 of file DECODER_getData.c. Referenced by DECODER_cache(), DECODER_cacheInit(), and UI_PSF_play(). 00407 {
00408 TSK_disable();
00409 inCacheState = INCACHE_CHECK;
00410 if(0 == mode)
00411 {
00412 cacheUpperThreshold = 0x1000;
00413 cacheLowerThreshold = 0x800;
00414 }
00415 else
00416 {
00417 if(1 == mode) // Double upper threshold.
00418 {
00419 cacheUpperThreshold <<= 1;
00420 }
00421 else // Increment upper threshold.
00422 {
00423 cacheUpperThreshold += 0x1000;
00424 }
00425
00426 if(cacheUpperThreshold >= SYS_cacheSecNum() )
00427 {
00428 // Aligned to NAND page boundary.
00429 cacheUpperThreshold = SYS_cacheSecNum() - 62;
00430 }
00431 }
00432 TSK_enable();
00433 }
|
|
||||||||||||||||
|
Function feeds data into docoder bit stream/buffer. A NAND cache is managed here if HDD is present.
Definition at line 132 of file DECODER_getData.c. References Audio, FAT_fread(), FAT_fseek(), st_AUDIO::file, File::ptr, and SEEK_MID. Referenced by DECODER__mp3media(), DECODER__oggRead(), DECODER__wavmedia(), and DECODER__wmamedia(). 00133 {
00134 unsigned short len;
00135 File * fp = &Audio.file;
00136 if(FALSE == _isCacheHit(fp, offset, &reqLen))
00137 {
00138 if(offset != fp->ptr) FAT_fseek(fp, (long)(offset-fp->ptr), SEEK_MID);
00139 len = FAT_fread(fp, (unsigned short*)pD, reqLen);
00140 }
00141 else
00142 {
00143 len = _cacheRead(offset, (unsigned short*)pD, reqLen);
00144 }
00145
00146 if(len == 0) DECODER_stop();
00147
00148 return len;
00149 }
|
Here is the call graph for this function:

1.3.9.1