本文整理汇总了C++中osg::observer_ptr::audioNbChannels方法的典型用法代码示例。如果您正苦于以下问题:C++ observer_ptr::audioNbChannels方法的具体用法?C++ observer_ptr::audioNbChannels怎么用?C++ observer_ptr::audioNbChannels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::observer_ptr
的用法示例。
在下文中一共展示了observer_ptr::audioNbChannels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: play
void SDLAudioSink::play()
{
if (_started)
{
if (_paused)
{
SDL_PauseAudio(0);
_paused = false;
}
return;
}
_started = true;
_paused = false;
osg::notify(osg::NOTICE)<<"SDLAudioSink()::startPlaying()"<<std::endl;
osg::notify(osg::NOTICE)<<" audioFrequency()="<<_audioStream->audioFrequency()<<std::endl;
osg::notify(osg::NOTICE)<<" audioNbChannels()="<<_audioStream->audioNbChannels()<<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();
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;
if (SDL_OpenAudio(&wanted_specs, &specs) < 0)
throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")";
SDL_PauseAudio(0);
}
示例2: play
void SDLAudioSink::play()
{
if (_started)
{
if (_paused)
{
SDL_PauseAudio(0);
_paused = false;
}
return;
}
_started = true;
_paused = false;
osg::notify(osg::NOTICE)<<"SDLAudioSink()::startPlaying()"<<std::endl;
osg::notify(osg::NOTICE)<<" audioFrequency()="<<_audioStream->audioFrequency()<<std::endl;
osg::notify(osg::NOTICE)<<" audioNbChannels()="<<_audioStream->audioNbChannels()<<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();
wanted_specs.channels = _audioStream->audioNbChannels();
wanted_specs.silence = 0;
wanted_specs.samples = 1024;
wanted_specs.callback = soundReadCallback;
wanted_specs.userdata = this;
wanted_specs.format = 0;
#if SDL_MAJOR_VERSION>=2
switch(_audioStream->audioSampleFormat())
{
case(osg::AudioStream::SAMPLE_FORMAT_U8): { wanted_specs.format = AUDIO_U8; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_U8"<<std::endl; break;}
case(osg::AudioStream::SAMPLE_FORMAT_S16): { wanted_specs.format = AUDIO_S16SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S16"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S24): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S24 NOT Supported by SDL."<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S32): { wanted_specs.format = AUDIO_S32SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S32"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_F32): { wanted_specs.format = AUDIO_F32SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_F32"<<std::endl; break; }
}
#else
switch(_audioStream->audioSampleFormat())
{
case(osg::AudioStream::SAMPLE_FORMAT_U8): { wanted_specs.format = AUDIO_U8; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_U8"<<std::endl; break;}
case(osg::AudioStream::SAMPLE_FORMAT_S16): { wanted_specs.format = AUDIO_S16SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S16"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S24): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S24 NOT Supported by SDL1.x."<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S32): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S32 NOT Supported by SDL1.x"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_F32): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_F32 NOT Supported by SDL1.x"<<std::endl; break; }
}
#endif
if (wanted_specs.format!=0)
{
if (SDL_OpenAudio(&wanted_specs, &specs) < 0)
throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")";
SDL_PauseAudio(0);
}
else
{
throw "SDL_OpenAudio() does not support audio format";
}
}