From 97e987a9d9bd562b8f1475ca16e5340ee57d2920 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 3 Mar 2009 20:59:16 +0000 Subject: [PATCH] Added SDL audio path --- examples/osgmovie/osgmovie.cpp | 42 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/examples/osgmovie/osgmovie.cpp b/examples/osgmovie/osgmovie.cpp index 232c4b201..a7a2d91ad 100644 --- a/examples/osgmovie/osgmovie.cpp +++ b/examples/osgmovie/osgmovie.cpp @@ -348,26 +348,26 @@ class SDLAudioSink : public osg::AudioSink { _playing = true; osg::notify(osg::NOTICE)<<"SDLAudioSink()::startPlaying()"<audioFrequency(); + wanted_specs.format = AUDIO_S16SYS; + wanted_specs.channels = _audioStream->audioNbChannels(); + wanted_specs.silence = 0; + wanted_specs.samples = 1024; + wanted_specs.callback = soundReadCallback; + wanted_specs.userdata = this; - SDL_PauseAudio(0); + if (SDL_OpenAudio(&wanted_specs, &specs) < 0) + throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")"; + + SDL_PauseAudio(0); } virtual bool playing() const { return _playing; } @@ -381,14 +381,12 @@ class SDLAudioSink : public osg::AudioSink void SDLAudioSink::soundReadCallback(void * const user_data, Uint8 * const data, const int datalen) { - osg::notify(osg::NOTICE)<<"SDLAudioSink::soundReadCallback"<(user_data); - osg::ref_ptr as = sink->_audioStream.get(); - if (as.valid()) - { - as->consumeAudioBuffer(data, datalen); - } + SDLAudioSink * sink = reinterpret_cast(user_data); + osg::ref_ptr as = sink->_audioStream.get(); + if (as.valid()) + { + as->consumeAudioBuffer(data, datalen); + } } #endif