Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

648 lines
16 KiB

  1. //
  2. // MODULE : STAUDIO.C
  3. // PURPOSE : Audio Routines
  4. // AUTHOR : JBS Yadawa
  5. // CREATED : 7/20/96
  6. //
  7. //
  8. // Copyright (C) 1996 SGS-THOMSON Microelectronics
  9. //
  10. //
  11. // REVISION HISTORY :
  12. //
  13. // DATE :
  14. //
  15. // COMMENTS :
  16. //
  17. #include "common.h"
  18. #include "stdefs.h"
  19. #include "staudio.h"
  20. #include "debug.h"
  21. #include "error.h"
  22. #include "board.h"
  23. #include "sti3520A.h"
  24. #include <dos.h> ///////////
  25. static PAUDIO pAudio;
  26. #define SLOW_MODE 0
  27. #define PLAY_MODE 1
  28. #define FAST_MODE 2
  29. #define IT_A 0 // interrupt detected
  30. void AudioOpen(PAUDIO pAud)
  31. {
  32. pAudio = pAud;
  33. pAudio->AudioState = AUDIO_POWER_UP;
  34. pAudio->IntAudio = NO_IT_A;
  35. pAudio->MaskItAudio = 0;
  36. pAudio->ErrorMsg = NO_ERROR;
  37. pAudio->FirstPTS = FALSE; // First PTS not reached yet
  38. pAudio->mute = FALSE;
  39. pAudio->Stepped = FALSE;
  40. pAudio->FrameCount = 0;
  41. }
  42. void AudioClose(void)
  43. {
  44. }
  45. void AudioInitDecoder(WORD StreamType)
  46. {
  47. /*
  48. #if 0
  49. pAudio->StrType = StreamType;
  50. switch(pAudio->AudioState) {
  51. case AUDIO_POWER_UP:
  52. BoardWriteAudio(RESET, 1); // reset the decoder
  53. //ALTERAClearPendingAudioIT(); // Clear pending audio interrupt generated by soft reset
  54. BoardWriteAudio(INTR_EN, 0); // disable all interupts
  55. BoardWriteAudio(INTR_EN + LSB, 0);
  56. BoardWriteAudio(PLAY, 0); // disable play output
  57. BoardWriteAudio(MUTE, 0); // do not mute output. LRclk and Sclk Stopped here
  58. BoardWriteAudio(INVERT_SCLK, 0); // standard
  59. BoardWriteAudio(INVERT_LRCLK, 1);// standard
  60. #ifndef VALID3520
  61. //**************************************************************
  62. // Philips TDA1311 is a 16 bit DAC (oversampling 1x, 2x, 4x, 8x)
  63. // -> LRCLK = SCLK / 32
  64. // -> SCLK = PCMCLK / 8 (8 times oversampling => PCM_DIV = 3)
  65. // => PCMCLK = 256 * Sampling Frequency
  66. //**************************************************************
  67. BoardWriteAudio(PCM_DIV, 3);
  68. BoardWriteAudio(PCM_ORD, 0); // MSB first
  69. BoardWriteAudio(PCM_18, 0); // 16 bits of PCM data
  70. BoardWriteAudio(FORMAT, 0); // I2S output format
  71. BoardWriteAudio(DIF, 0); // Optionnal in 16 bit output
  72. #else
  73. //**************************************************************
  74. // Crystal CS4330 is an 18 bit DAC (oversampling 1x, 4x, 6x, 8x)
  75. // -> LRCLK = SCLK / 64
  76. // -> SCLK = PCMCLK / 4 (4 times oversampling => PCM_DIV = 1)
  77. // => PCMCLK = 256 * Sampling Frequency
  78. //**************************************************************
  79. BoardWriteAudio(PCM_DIV, 1);
  80. BoardWriteAudio(PCM_ORD, 0);
  81. BoardWriteAudio(PCM_18, 1); // 18 bits of PCM data
  82. BoardWriteAudio(FORMAT, 0); // I2S output format
  83. BoardWriteAudio(DIF, 0); // Optionnal in 16 bit
  84. #endif
  85. BoardWriteAudio(STR_SEL, 0); // Default Stream Type is audio elem stream
  86. BoardWriteAudio(CRC_ECM, 1); // mute on CRC error correction
  87. BoardWriteAudio(SYNC_ECM, 1); // mute if Sync lost
  88. BoardWriteAudio(SYNCHRO_CONFIRM, 1); // synchro confirmation mode
  89. BoardWriteAudio(SYNC_REG, 0x3F); // layer, bitrate, fs fields not used
  90. BoardWriteAudio(PACKET_SYNC_CHOICE, 0);// multiplexed stream
  91. BoardWriteAudio(LATENCY, 0x0); // Low Lattency decoding
  92. BoardWriteAudio(SYNC_LCK, 0x2); // locked after 2 good Sync
  93. BoardWriteAudio(SIN_EN, 0x01); // Serial data input to enable bit buffer access
  94. BoardWriteAudio(AUDIO_ID_EN, 0x0);// ignore audio stream ID
  95. BoardWriteAudio(AUDIO_ID, 0x0); // audio stream ID ignored
  96. BoardWriteAudio(FREE_FORM_H, 0x0);// not free format
  97. BoardWriteAudio(FREE_FORM_L, 0x0);
  98. BoardWriteAudio(DUAL_REG, 0); // Select Stereo Mode
  99. AudioSetSTCParameters(44100UL);
  100. BoardAudioSetSamplingFrequency(44100UL);
  101. pAudio->FrameCount = 0; // Reset Frame Count.
  102. pAudio->AudioState = AUDIO_INIT;
  103. break;
  104. default:
  105. break;
  106. }
  107. #else
  108. BoardWriteAudio(0xF0, 1); // reset the decoder
  109. BoardWriteAudio(0xC6, 0);
  110. BoardWriteAudio(0xEF, 1);
  111. BoardWriteAudio(PCM_DIV, 2);
  112. BoardWriteAudio(0x9f, 0);
  113. BoardWriteAudio(0x99, 0);
  114. BoardWriteAudio(0xB6, 3);
  115. BoardWriteAudio(0x9e, 0);
  116. BoardWriteAudio(0xa0, 0);
  117. BoardWriteAudio(0x91, 0);
  118. BoardWriteAudio(0xb8, 0);
  119. BoardWriteAudio(0x96, 1);
  120. BoardWriteAudio(0xd3, 0);
  121. BoardWriteAudio(0xac, 0);
  122. BoardWriteAudio(0xc4, 0);
  123. BoardWriteAudio(0xc2, 1);
  124. BoardWriteAudio(0xAE, 1);
  125. #endif
  126. */
  127. }
  128. WORD AudioTestReg(void)
  129. {
  130. #if 0
  131. WORD ReadValue;
  132. BoardWriteAudio(ATTEN_L, 0x55);
  133. BoardWriteAudio(ATTEN_R, 0xAA);
  134. ReadValue = BoardReadAudio(ATTEN_L);
  135. if ((ReadValue & 0x3F) != 0x15)
  136. goto Error;
  137. ReadValue = BoardReadAudio(ATTEN_R);
  138. if ((ReadValue & 0x3F) != 0x2A)
  139. goto Error;
  140. return NO_ERROR;
  141. Error :
  142. SetErrorCode(ERR_AUDIO_REG_TEST_FAILED);
  143. return BAD_REG_A;
  144. #else
  145. return NO_ERROR;
  146. #endif
  147. }
  148. WORD AudioTest(void)
  149. {
  150. #if 0
  151. WORD TestResult;
  152. TestResult = AudioTestReg();
  153. if (TestResult != NO_ERROR)
  154. return TestResult;
  155. else {
  156. #ifdef DOSAPP
  157. if (AudioTestInt(pAudio) == NO_IT_A)
  158. return NO_IT_A;
  159. else
  160. #endif
  161. return NO_ERROR;
  162. }
  163. #else
  164. return NO_ERROR;
  165. #endif
  166. }
  167. WORD AudioTestInt(void)
  168. {
  169. WORD err = NO_ERROR;
  170. #if 0
  171. U8 Threshold;
  172. WORD a = 0;
  173. pAudio->MaskItAudio = FIFT;
  174. Threshold = BoardReadAudio(FIFO_IN_TRESHOLD);
  175. //---- Configure audio
  176. BoardWriteAudio(PLAY, 0x00);
  177. BoardWriteAudio(FIFO_IN_TRESHOLD, 0x01);
  178. //---- Enable FIFO full interrupt
  179. BoardWriteAudio(INTR_EN, 0x00);
  180. BoardWriteAudio(INTR_EN + LSB, 0x10);
  181. //---- Write a byte to force an interrupt
  182. BoardWriteAudio(DATA_IN, 0x00);
  183. // wait for occurrence of first audio interrupt
  184. while (pAudio->IntAudio == NO_IT_A) {
  185. Delay(1000);
  186. a++; /* incremented every 1 ms */
  187. if (a >= 1000) {
  188. DPF((Trace, "AudioTestInt failed !!"));
  189. SetErrorCode(ERR_NO_AUDIO_INTR);
  190. err = NO_IT_A; /* No interrupt */
  191. break;
  192. }
  193. }
  194. // Restore Interrupt mask
  195. pAudio->MaskItAudio = 0;
  196. AudioMaskInt();
  197. BoardWriteAudio(FIFO_IN_TRESHOLD, Threshold);
  198. BoardReadAudio(INTR); /* to clear audio interrupts flags */
  199. #endif
  200. return err;
  201. }
  202. // Set the decoding mode and parameters
  203. void AudioSetMode(WORD Mode, WORD param)
  204. {
  205. #if 0
  206. pAudio->DecodeMode = Mode;
  207. switch (pAudio->DecodeMode) {
  208. case PLAY_MODE:
  209. BoardWriteAudio(MUTE, 0);
  210. pAudio->fastForward = 0;
  211. pAudio->decSlowDown = 0;
  212. break;
  213. case FAST_MODE:
  214. pAudio->fastForward = 1;
  215. pAudio->decSlowDown = 0;
  216. break;
  217. case SLOW_MODE:
  218. pAudio->fastForward = 0;
  219. pAudio->decSlowDown = param;
  220. break;
  221. }
  222. #endif
  223. }
  224. // Decode
  225. void AudioDecode(void)
  226. {
  227. #if 0
  228. switch (pAudio->AudioState) {
  229. case AUDIO_POWER_UP:
  230. break;
  231. case AUDIO_INIT:
  232. // Change in synchro + buffer over BALF +PTS
  233. pAudio->MaskItAudio = SYNC|BOF|PCMU|CRC| PTS;
  234. BoardWriteAudio(INTR_EN, (BYTE)(pAudio->MaskItAudio & 0xFF));
  235. BoardWriteAudio(INTR_EN + LSB, (BYTE)(pAudio->MaskItAudio >> 8 ));
  236. //yg BoardWriteAudio(MUTE, 1); // This Starts SClk and LRClk outputs
  237. BoardWriteAudio(PLAY, 1); // Start decoding Output is Mute
  238. pAudio->AudioState = AUDIO_STC_INIT;
  239. break;
  240. case AUDIO_STC_INIT:
  241. pAudio->AudioState = AUDIO_DECODE;
  242. BoardWriteAudio(PLAY, 1); // Restart decoding (decoding had been stopped when first audio PTS detected)
  243. BoardWriteAudio(MUTE, 0); // Stop Muting output
  244. break;
  245. case AUDIO_DECODE:
  246. break;
  247. case AUDIO_PAUSE:
  248. case AUDIO_STEP:
  249. BoardWriteAudio(PLAY, 1);
  250. BoardWriteAudio(MUTE, 0);
  251. pAudio->AudioState = AUDIO_DECODE;
  252. break;
  253. }
  254. #endif
  255. }
  256. void AudioStep(void)
  257. {
  258. #if 0
  259. BoardWriteAudio(MUTE, 0);
  260. BoardWriteAudio(PLAY, 1);
  261. pAudio->AudioState = AUDIO_STEP;
  262. pAudio->Stepped = FALSE;
  263. #endif
  264. }
  265. void AudioStop(void)
  266. {
  267. #if 0
  268. switch(pAudio->AudioState) {
  269. case AUDIO_POWER_UP:
  270. break;
  271. case AUDIO_INIT:
  272. break;
  273. case AUDIO_STC_INIT:
  274. case AUDIO_DECODE:
  275. pAudio->AudioState = AUDIO_POWER_UP;
  276. AudioInitDecoder(pAudio, pAudio->StrType);
  277. break;
  278. }
  279. #endif
  280. }
  281. void AudioPause(void)
  282. {
  283. #if 0
  284. switch(pAudio->AudioState) {
  285. case AUDIO_POWER_UP: /* After reset */
  286. case AUDIO_INIT: /* Initialisation + test of the decoders */
  287. case AUDIO_STC_INIT: /* STC of audio decoder initialized */
  288. case AUDIO_DECODE: /* Normal decode */
  289. BoardWriteAudio(MUTE, 1);
  290. BoardWriteAudio(PLAY, 0);
  291. pAudio->AudioState = AUDIO_PAUSE;
  292. break;
  293. }
  294. #endif
  295. }
  296. WORD AudioGetState(void)
  297. {
  298. return ( pAudio->AudioState);
  299. }
  300. void AudioSetSTCParameters(DWORD SampFreq)
  301. {
  302. #if 0
  303. // Note :
  304. // STCCLK = PCMCLK (fixed inside STi3520A)
  305. // (PCMCLK * inc) / div = 90kHz
  306. switch(SampFreq){
  307. case 32000UL:
  308. // PCMCLK = 256 * 32 = 8192 kHz, inc = 45, div = 4096 -> 90kHz
  309. BoardWriteAudio(STC_INC, 45);
  310. BoardWriteAudio(STC_DIVH, 0x10);
  311. BoardWriteAudio(STC_DIVL, 0x00);
  312. break;
  313. case 44100UL:
  314. // PCMCLK = 256 * 44.1 = 11289.6 kHz, inc = 25, div = 3136 -> 90kHz
  315. BoardWriteAudio(STC_INC, 25);
  316. BoardWriteAudio(STC_DIVH, 0x0C);
  317. BoardWriteAudio(STC_DIVL, 0x40);
  318. break;
  319. case 48000UL:
  320. // PCMCLK = 256 * 48 = 12288 kHz, inc = 15, div = 2048 -> 90kHz
  321. BoardWriteAudio(STC_INC, 15);
  322. BoardWriteAudio(STC_DIVH, 0x08);
  323. BoardWriteAudio(STC_DIVL, 0x00);
  324. break;
  325. default :
  326. break;
  327. }
  328. BoardWriteAudio(STC_CTL, 0x40); // Load STC_VID on rising edge of VSYNC
  329. #endif
  330. }
  331. DWORD AudioGetSTC(void)
  332. {
  333. #if 0
  334. DWORD stc;
  335. WORD j;
  336. BoardWriteAudio(STC_CTL, 0x44); // load current STC value to STC
  337. for ( j = 0; j < 0xF; j++)
  338. ;
  339. stc = ( BoardReadAudio(STC_3 ) & 0xFFL ) << 24;
  340. stc = stc | ( ( BoardReadAudio(STC_2 ) & 0xFFL ) << 16);
  341. stc = stc | ( ( BoardReadAudio(STC_1 ) & 0xFFL ) << 8);
  342. stc = stc | ( BoardReadAudio(STC_0 ) & 0xFFL);
  343. return ( stc);
  344. #else
  345. return 0;
  346. #endif
  347. }
  348. DWORD AudioGetVideoSTC(void)
  349. {
  350. #if 0
  351. DWORD stc;
  352. WORD j;
  353. BoardWriteAudio(STC_CTL, 0x48); // load STC_VID to STC, Mode 0 mapping
  354. // BoardWriteAudio(STC_CTL, 0x44); accu
  355. // BoardWriteAudio(STC_CTL, 0x50);
  356. for ( j = 0; j < 0xF; j++)
  357. ;
  358. /*
  359. stc = ( BoardReadAudio(STC_3 ) & 0xFFL ) << 24;
  360. stc = stc | ((BoardReadAudio(STC_2) & 0xFFL ) << 16);
  361. stc = stc | ((BoardReadAudio(STC_1) & 0xFFL ) << 8);
  362. stc = stc | ((BoardReadAudio(STC_0) & 0xFFL ));
  363. */
  364. stc = ( BoardReadAudio(STC_0) & 0xFFL ) << 0;
  365. stc = stc | ((BoardReadAudio(STC_1) & 0xFFL ) << 8);
  366. stc = stc | ((BoardReadAudio(STC_2) & 0xFFL ) << 16);
  367. stc = stc | ((BoardReadAudio(STC_3) & 0xFFL ) << 24);
  368. return stc;
  369. #else
  370. return 0;
  371. #endif
  372. }
  373. void AudioInitSTC(DWORD stc)
  374. {
  375. #if 0
  376. BoardWriteAudio(STC_0, (U8)(stc & 0xFFL));
  377. stc >>= 8;
  378. BoardWriteAudio(STC_1, (U8)(stc & 0xFFL));
  379. stc >>= 8;
  380. BoardWriteAudio(STC_2, (U8)(stc & 0xFFL));
  381. stc >>= 8;
  382. BoardWriteAudio(STC_3, (U8)(stc & 0xFFL));
  383. BoardWriteAudio(STC_CTL, 0x41); // load STC to accumulator,
  384. #endif
  385. }
  386. DWORD AudioGetPTS(void)
  387. {
  388. return pAudio->PtsAudio;
  389. }
  390. WORD AudioGetErrorMsg(void)
  391. {
  392. return pAudio->ErrorMsg;
  393. }
  394. void AudioSetRightVolume(WORD volume)
  395. {
  396. #if 0
  397. BoardWriteAudio(ATTEN_R, (BYTE)volume);
  398. #endif
  399. }
  400. void AudioSetLeftVolume(WORD volume)
  401. {
  402. #if 0
  403. BoardWriteAudio(ATTEN_L, (BYTE)volume);
  404. #endif
  405. }
  406. void AudioMute(void)
  407. {
  408. #if 0
  409. if (pAudio->mute) {
  410. BoardWriteAudio(MUTE, 0);
  411. pAudio->mute = FALSE;
  412. }
  413. else {
  414. BoardWriteAudio(MUTE, 1);
  415. pAudio->mute = TRUE;
  416. }
  417. #endif
  418. }
  419. BOOL AudioIsFirstPTS(void)
  420. {
  421. return pAudio->FirstPTS;
  422. }
  423. void AudioSetStreamType(WORD StrType)
  424. {
  425. #if 0
  426. BoardWriteAudio(STR_SEL, (BYTE)StrType);
  427. #endif
  428. }
  429. void AudioInitPesParser (WORD StreamType)
  430. {
  431. #if 0
  432. switch(StreamType)
  433. {
  434. case SYSTEM_STREAM:
  435. case VIDEO_PACKET:
  436. case AUDIO_PACKET:
  437. case VIDEO_PES:
  438. case AUDIO_PES:
  439. BoardWriteAudio( STR_SEL, 1);
  440. break;
  441. case DUAL_PES:
  442. BoardWriteAudio( STR_SEL, 4);
  443. break;
  444. case DUAL_ES:
  445. BoardWriteAudio( STR_SEL, 0);
  446. break;
  447. case VIDEO_STREAM:
  448. case AUDIO_STREAM:
  449. BoardWriteAudio( STR_SEL, 0);
  450. break;
  451. }
  452. #endif
  453. }
  454. void AudioMaskInt(void)
  455. {
  456. #if 0
  457. BoardWriteAudio(INTR_EN, 0);
  458. BoardWriteAudio(INTR_EN + LSB, 0);
  459. #endif
  460. }
  461. void AudioRestoreInt(void)
  462. {
  463. #if 0
  464. //HostDisplay(DISPLAY_FASTEST, "!%x!", pAudio->MaskItAudio);
  465. BoardWriteAudio(INTR_EN, (BYTE)(pAudio->MaskItAudio & 0xFF));
  466. BoardWriteAudio(INTR_EN + LSB, (BYTE)(pAudio->MaskItAudio >> 8));
  467. #endif
  468. }
  469. BOOL AudioAudioInt(void)
  470. {
  471. #if 0
  472. WORD int_stat_reg, i;
  473. BOOLEAN bAudioIntr = FALSE;
  474. // Read the interrupt status register
  475. int_stat_reg = BoardReadAudio(INTR);
  476. i = BoardReadAudio(INTR + LSB);
  477. i = i << 8;
  478. int_stat_reg = ( int_stat_reg & 0xFF ) | i;
  479. int_stat_reg = int_stat_reg & pAudio->MaskItAudio; /* Mask the IT not used */
  480. if(int_stat_reg)
  481. bAudioIntr = TRUE;
  482. /******************************************************/
  483. /** FIFO FULL used to test audio interrupt generation**/
  484. /******************************************************/
  485. if (int_stat_reg & FIFT) {
  486. pAudio->IntAudio = IT_A;
  487. }
  488. /******************************************************/
  489. /** CHANGE SYNCHRO **/
  490. /******************************************************/
  491. if (int_stat_reg & SYNC) {
  492. i = BoardReadAudio(SYNC_ST); // Synchronization status
  493. if ((i & 0x3) == 3) { // Locked
  494. // Disable Change in synchro
  495. pAudio->MaskItAudio = pAudio->MaskItAudio & NSYNC;
  496. // Next Interrupt should be change in sampling freq
  497. pAudio->MaskItAudio = pAudio->MaskItAudio | SAMP;
  498. }
  499. }
  500. /******************************************************/
  501. /** CHANGE IN SAMPLING FREQUENCY **/
  502. /******************************************************/
  503. if (int_stat_reg & SAMP) {
  504. i = BoardReadAudio(PCM_FS ) & 0x3; // Get Sampling frequency
  505. switch(i) {
  506. case 0 :
  507. BoardAudioSetSamplingFrequency(44100UL);
  508. AudioSetSTCParameters(44100UL);
  509. break;
  510. case 1 :
  511. BoardAudioSetSamplingFrequency(48000UL);
  512. AudioSetSTCParameters(48000UL);
  513. break;
  514. case 2 :
  515. BoardAudioSetSamplingFrequency(32000UL);
  516. AudioSetSTCParameters(32000UL);
  517. break;
  518. default :
  519. break;
  520. }
  521. // Disable change in sampling frequency
  522. pAudio->MaskItAudio = pAudio->MaskItAudio & NSAMP;
  523. }
  524. /******************************************************/
  525. /** CRC error **/
  526. /******************************************************/
  527. if (int_stat_reg & CRC) {
  528. }
  529. /******************************************************/
  530. /** PCM Underflow **/
  531. /******************************************************/
  532. if (int_stat_reg & PCMU) {
  533. }
  534. /******************************************************/
  535. /** Begining of Frame **/
  536. /******************************************************/
  537. if (int_stat_reg & BOF) {
  538. DWORD STC = AudioGetVideoSTC();
  539. static DWORD STCOld;
  540. // HostDisplay(DISPLAY_FASTEST, "STCBOF = %8lu D = %5ld\r\n", STC, STC - STCOld);
  541. // STCOld = STC;
  542. // Check if stepping
  543. if ((pAudio->AudioState == AUDIO_STEP) && (pAudio->Stepped == FALSE)) {
  544. BoardWriteAudio(MUTE, 1);
  545. BoardWriteAudio(PLAY, 0);
  546. pAudio->Stepped = TRUE;
  547. }
  548. // If Slow motion or Fast forward, Mute Audio
  549. if ( pAudio->DecodeMode != PLAY_MODE ) {
  550. BoardWriteAudio(MUTE, 1);
  551. pAudio->mute = TRUE;
  552. if ((pAudio->FrameCount % 4) && (pAudio->fastForward))
  553. BoardWriteAudio(SKIP, 1);
  554. else if ((pAudio->DecodeMode == SLOW_MODE ) &&
  555. ((pAudio->FrameCount % (pAudio->decSlowDown + 1)) != 0))
  556. BoardWriteAudio(REPEAT, 1);
  557. }
  558. pAudio->FrameCount++; // Increment Frame Count
  559. }
  560. /******************************************************/
  561. /** PTS detected **/
  562. /******************************************************/
  563. if ( int_stat_reg & PTS ) {
  564. DWORD pts;
  565. //DBG1('p');
  566. /*
  567. BoardReadAudio(PTS_4); // To clear pts interrupt
  568. pts = (BoardReadAudio(PTS_3) & 0xFFL) << 24;
  569. pts = pts | ((BoardReadAudio(PTS_2 ) & 0xFFL) << 16);
  570. pts = pts | ((BoardReadAudio(PTS_1 ) & 0xFFL) << 8);
  571. pts = pts | ( BoardReadAudio(PTS_0 ) & 0xFFL);
  572. */
  573. pts = (BoardReadAudio(PTS_0) & 0xFFL) << 0;
  574. pts = pts | ((BoardReadAudio(PTS_1) & 0xFFL) << 8);
  575. pts = pts | ((BoardReadAudio(PTS_2) & 0xFFL) << 16);
  576. pts = pts | ((BoardReadAudio(PTS_3) & 0xFFL) << 24);
  577. BoardReadAudio(PTS_4); // To clear pts interrupt
  578. pAudio->PtsAudio = pts;
  579. if (pAudio->AudioState == AUDIO_STC_INIT) {
  580. pAudio->FirstPTS = TRUE;
  581. //yg BoardWriteAudio(PLAY, 0);
  582. }
  583. if (pAudio->AudioState == AUDIO_DECODE) {
  584. // HostDirectPutChar('P', BLACK, LIGHTBLUE);
  585. AudioInitSTC ( pts);
  586. // DWORD STC = AudioGetVideoSTC();
  587. // HostDisplay(DISPLAY_FASTEST, "STC = %8lu PTSA = %8lu D = %8ld\r\n", STC, pts, STC - pts);
  588. }
  589. }
  590. return bAudioIntr;
  591. #else
  592. return FALSE;
  593. #endif
  594. }
  595.