Show
Ignore:
Timestamp:
03/03/09 21:59:16 (6 years ago)
Author:
robert
Message:

Added SDL audio path

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp

    r9849 r9851  
    349349            _playing = true;  
    350350            osg::notify(osg::NOTICE)<<"SDLAudioSink()::startPlaying()"<<std::endl; 
    351              
     351 
    352352            osg::notify(osg::NOTICE)<<"  audioFrequency()="<<_audioStream->audioFrequency()<<std::endl; 
    353353            osg::notify(osg::NOTICE)<<"  audioNbChannels()="<<_audioStream->audioNbChannels()<<std::endl; 
    354354            osg::notify(osg::NOTICE)<<"  audioSampleFormat()="<<_audioStream->audioSampleFormat()<<std::endl; 
    355              
    356             SDL_AudioSpec specs = { 0 }; 
    357             SDL_AudioSpec wanted_specs = { 0 }; 
    358  
    359             wanted_specs.freq = _audioStream->audioFrequency(); 
    360             wanted_specs.format = AUDIO_S16SYS; 
    361             wanted_specs.channels = _audioStream->audioNbChannels(); 
    362             wanted_specs.silence = 0; 
    363             wanted_specs.samples = 1024; 
    364             wanted_specs.callback = soundReadCallback; 
    365             wanted_specs.userdata = this; 
    366  
    367             if (SDL_OpenAudio(&wanted_specs, &specs) < 0) 
    368                     throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")"; 
    369  
    370             SDL_PauseAudio(0); 
     355 
     356            SDL_AudioSpec specs = { 0 }; 
     357            SDL_AudioSpec wanted_specs = { 0 }; 
     358 
     359            wanted_specs.freq = _audioStream->audioFrequency(); 
     360            wanted_specs.format = AUDIO_S16SYS; 
     361            wanted_specs.channels = _audioStream->audioNbChannels(); 
     362            wanted_specs.silence = 0; 
     363            wanted_specs.samples = 1024; 
     364            wanted_specs.callback = soundReadCallback; 
     365            wanted_specs.userdata = this; 
     366 
     367            if (SDL_OpenAudio(&wanted_specs, &specs) < 0) 
     368                throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")"; 
     369 
     370            SDL_PauseAudio(0); 
    371371 
    372372        } 
     
    382382void SDLAudioSink::soundReadCallback(void * const user_data, Uint8 * const data, const int datalen) 
    383383{ 
    384     osg::notify(osg::NOTICE)<<"SDLAudioSink::soundReadCallback"<<std::endl; 
    385  
    386         SDLAudioSink * sink = reinterpret_cast<SDLAudioSink*>(user_data); 
    387         osg::ref_ptr<osg::AudioStream> as = sink->_audioStream.get(); 
    388         if (as.valid()) 
    389         {             
    390             as->consumeAudioBuffer(data, datalen); 
    391         } 
     384    SDLAudioSink * sink = reinterpret_cast<SDLAudioSink*>(user_data); 
     385    osg::ref_ptr<osg::AudioStream> as = sink->_audioStream.get(); 
     386    if (as.valid()) 
     387    {             
     388        as->consumeAudioBuffer(data, datalen); 
     389    } 
    392390} 
    393391