예제 #1
0
int main( int argc, char const *const argv[] )
{
   curlCache_t &cache = getCurlCache();

   curlFile_t f1( cache.get( "http://linuxbox/effects/push.mp3" ) );
   curlFile_t f2( cache.get( "http://linuxbox/effects/release.mp3" ) );

   if( f1.isOpen() && f2.isOpen() )
   {
      pthread_t tHandle ;
      
      int const create = pthread_create( &tHandle, 0, audioOutputThread, 0 );
      if( 0 == create )
      {
         struct sched_param tsParam ;
         tsParam.__sched_priority = 1 ;
         pthread_setschedparam( tHandle, SCHED_FIFO, &tsParam );
         threadHandle_ = (void *)tHandle ;

         madDecoder_t decode1( f1.getData(), f1.getSize() );
         if( decode1.worked() )
         {
            madDecoder_t decode2( f2.getData(), f2.getSize() );
            if( decode2.worked() )
            {
               item_t item1 ;
               item1.sampleRate_  = decode1.headers().playbackRate();
               item1.numChannels_ = decode1.headers().numChannels();
               item1.data_        = decode1.getSamples();
               item1.length_      = decode1.numSamples();
               item_t item2 ;
               item2.sampleRate_ = decode2.headers().playbackRate();
               item2.numChannels_ = decode2.headers().numChannels();
               item2.data_        = decode2.getSamples();
               item2.length_      = decode2.numSamples();

               int uS = ( 2 == argc ) ? atoi( argv[1] ) : 20000 ;

               while( 1 )
               {
                  printf( "playback\n" );
                  queue_.push( item1 );
                  usleep( uS );
                  queue_.push( item2 );
                  sleep( 5 );
               }
            }
            else
               fprintf( stderr, "Error decoding file2\n" );
         }
         else
            fprintf( stderr, "Error decoding file1\n" );
      }
      else
         fprintf( stderr, "Error %m creating curl-reader thread\n" );
   }
   else
      fprintf( stderr, "Error opening test files\n" );
   return 0 ;
}
예제 #2
0
파일: oem6.c 프로젝트: xiaodezhang/cgi
extern int decode(char *filename,int type){

    return type ? decode0(filename) : decode1(filename);
}