Ejemplo n.º 1
0
 void run()
 {
     do
     {
         kxMovieError errCode = openInput(_file.c_str());
         if (errCode == kxMovieErrorNone) {
             errCode = openAudioStream();
         }
         if (errCode == kxMovieErrorNone) {
             _signals.fileOpen(errCode == kxMovieErrorNone, _audioCodecCtx->channels, _audioCodecCtx->sample_rate, _signals._pusr);
         } else {
             _signals.fileOpen(errCode == kxMovieErrorNone, 0, 0, _signals._pusr);
             break;
         }
         
         
         do {
             decodeFrames(0.1);
             IceUtil::Mutex::Lock lock(_mutex);
             if (_stopFlag || _isEOF) {
                 break;
             }
         } while (true);
         
         if (_isEOF) {
             _signals.fileEOF(_signals._pusr);
             //SP::printf("download finished!!!!!!! \n");
         } else {
             //SP::printf("download aborted !!!!!!! \n");
         }
         
     } while (false) ;
     
     closeAudioStream();
 }
Ejemplo n.º 2
0
int main(void)
{
    //=============================================================================
    //Variables and Data Structures
    //=============================================================================
    USERDATA data;
    AUDIOSTREAM outStream;
    int i;

    //=============================================================================
    //STEP 0 - Preliminary set-up and initialisation
    //=============================================================================

    //Initialise sinusoidal wavetable
    for( i=0; i<TABLE_SIZE; i++ )
    {
        data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
    }
    data.left_phase = data.right_phase = 0;

    //Initialise message of data structure
    sprintf( data.message, "No Message" );

    //Set up AUDIOSTREAM structure
    outStream.stream=NULL; //Will get a value after openDefaultAudioStream call
    outStream.sampleRate=44100;//The stream sample rate
    outStream.sampleFormat=paFloat32;//The stream sample format (float 32-bit in this case)
    outStream.inChannels=0;//Zero input channels indicates that we need an output only stream
    outStream.outChannels=2;//Two-channels for stereo output
    outStream.framesPerBuffer=512;//Number of frames of the buffers in the processing callback function

    //=============================================================================
    //STEP 1 - Initialise audio system.
    //=============================================================================
    initialiseAudioSystem();

    //=============================================================================
    //STEP 2 - Open an audio stream
    //=============================================================================
    openDefaultAudioStream(&outStream,processingCallback,&data);

    //Also register a callback function to be called as soon as
    //the stream stops. Handy to have here although it does not
    //do much in this example.
    setAudioStreamFinishedCallback(&outStream,&StreamFinished);

    //=============================================================================
    //STEP 3 - Main control loop
    //=============================================================================

    //Start the audio stream
    startAudioStream(&outStream);

    //Pause for NUM_SECONDS seconds
    printf("Pause for %i seconds\n",NUM_SECONDS);
    pause(NUM_SECONDS*1000);

    //Stop the audio stream
    stopAudioStream(&outStream);

    //=============================================================================
    //PART4 - Clean up
    //=============================================================================

    //Close the audio stream
    closeAudioStream(&outStream);

    //Terminate the audio system.
    terminateAudioSystem();

    printf("Example completed.\n");

    return 0;
}