Added SDL audio path
This commit is contained in:
parent
ac49ca81ca
commit
97e987a9d9
@ -348,26 +348,26 @@ class SDLAudioSink : public osg::AudioSink
|
|||||||
{
|
{
|
||||||
_playing = true;
|
_playing = true;
|
||||||
osg::notify(osg::NOTICE)<<"SDLAudioSink()::startPlaying()"<<std::endl;
|
osg::notify(osg::NOTICE)<<"SDLAudioSink()::startPlaying()"<<std::endl;
|
||||||
|
|
||||||
osg::notify(osg::NOTICE)<<" audioFrequency()="<<_audioStream->audioFrequency()<<std::endl;
|
osg::notify(osg::NOTICE)<<" audioFrequency()="<<_audioStream->audioFrequency()<<std::endl;
|
||||||
osg::notify(osg::NOTICE)<<" audioNbChannels()="<<_audioStream->audioNbChannels()<<std::endl;
|
osg::notify(osg::NOTICE)<<" audioNbChannels()="<<_audioStream->audioNbChannels()<<std::endl;
|
||||||
osg::notify(osg::NOTICE)<<" audioSampleFormat()="<<_audioStream->audioSampleFormat()<<std::endl;
|
osg::notify(osg::NOTICE)<<" audioSampleFormat()="<<_audioStream->audioSampleFormat()<<std::endl;
|
||||||
|
|
||||||
SDL_AudioSpec specs = { 0 };
|
|
||||||
SDL_AudioSpec wanted_specs = { 0 };
|
|
||||||
|
|
||||||
wanted_specs.freq = _audioStream->audioFrequency();
|
SDL_AudioSpec specs = { 0 };
|
||||||
wanted_specs.format = AUDIO_S16SYS;
|
SDL_AudioSpec wanted_specs = { 0 };
|
||||||
wanted_specs.channels = _audioStream->audioNbChannels();
|
|
||||||
wanted_specs.silence = 0;
|
|
||||||
wanted_specs.samples = 1024;
|
|
||||||
wanted_specs.callback = soundReadCallback;
|
|
||||||
wanted_specs.userdata = this;
|
|
||||||
|
|
||||||
if (SDL_OpenAudio(&wanted_specs, &specs) < 0)
|
wanted_specs.freq = _audioStream->audioFrequency();
|
||||||
throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")";
|
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; }
|
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)
|
void SDLAudioSink::soundReadCallback(void * const user_data, Uint8 * const data, const int datalen)
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"SDLAudioSink::soundReadCallback"<<std::endl;
|
SDLAudioSink * sink = reinterpret_cast<SDLAudioSink*>(user_data);
|
||||||
|
osg::ref_ptr<osg::AudioStream> as = sink->_audioStream.get();
|
||||||
SDLAudioSink * sink = reinterpret_cast<SDLAudioSink*>(user_data);
|
if (as.valid())
|
||||||
osg::ref_ptr<osg::AudioStream> as = sink->_audioStream.get();
|
{
|
||||||
if (as.valid())
|
as->consumeAudioBuffer(data, datalen);
|
||||||
{
|
}
|
||||||
as->consumeAudioBuffer(data, datalen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user