Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. #include "sndcounter.h"
  2.  
  3. #ifdef SND_EXTERNAL_BUFFER
  4.  
  5. //#define SND_TEST_FAILURES // disable after careful debug
  6. //#define SND_TEST_SHOWSTAT
  7.  
  8. void SNDCOUNTER::begin()
  9. {
  10.    n_samples = SND_EXTERNAL_BUFFER_SIZE;
  11.    #ifdef SND_TEST_SHOWSTAT
  12.    printf("CNT:");
  13.    #endif // SND_TEST_SHOWSTAT
  14. }
  15.  
  16. void SNDCOUNTER::count(SNDRENDER &render)
  17. {
  18.    unsigned rendsamples = (render.dstpos - bufstart) & (SND_EXTERNAL_BUFFER_SIZE-1);
  19. //   assert(rendsamples != 0);
  20.    if (rendsamples < n_samples)
  21.        n_samples = rendsamples;
  22.    #ifdef SND_TEST_FAILURES
  23.    unsigned lastframe_samples = (render.dstpos - render.dst_start) & (SND_EXTERNAL_BUFFER_SIZE-1);
  24.    if (lastframe_samples > rendsamples)
  25.       errexit("SNDRENDER object is out of sync with other sound objects");
  26.    #endif // SND_TEST_FAILURES
  27.    #ifdef SND_TEST_SHOWSTAT
  28.    printf(" %I64d", render.passed_snd_ticks);
  29.    #endif // SND_TEST_SHOWSTAT
  30. }
  31.  
  32. void SNDCOUNTER::end(bufptr_t &start_offset, unsigned &n_samples)
  33. {
  34.    start_offset = bufstart;
  35.    n_samples = SNDCOUNTER::n_samples;
  36.    bufstart = (bufstart + n_samples) & (SND_EXTERNAL_BUFFER_SIZE-1);
  37.    #ifdef SND_TEST_SHOWSTAT
  38.    printf("\n");
  39.    #endif // SND_TEST_SHOWSTAT
  40. }
  41.  
  42. void SNDCOUNTER::reset()
  43. {
  44.    bufstart = 0;
  45. }
  46.  
  47. #endif // SND_EXTERNAL_BUFFER
  48.