本文整理汇总了C++中AudioDeviceManager::closeAudioDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioDeviceManager::closeAudioDevice方法的具体用法?C++ AudioDeviceManager::closeAudioDevice怎么用?C++ AudioDeviceManager::closeAudioDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioDeviceManager
的用法示例。
在下文中一共展示了AudioDeviceManager::closeAudioDevice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Play
// Play audio samples for this frame
void Frame::Play()
{
// Check if samples are present
if (!audio->getNumSamples())
return;
AudioDeviceManager deviceManager;
deviceManager.initialise (0, /* number of input channels */
2, /* number of output channels */
0, /* no XML settings.. */
true /* select default device on failure */);
//deviceManager.playTestSound();
AudioSourcePlayer audioSourcePlayer;
deviceManager.addAudioCallback (&audioSourcePlayer);
ScopedPointer<AudioBufferSource> my_source;
my_source = new AudioBufferSource(audio.get());
// Create TimeSliceThread for audio buffering
TimeSliceThread my_thread("Audio buffer thread");
// Start thread
my_thread.startThread();
AudioTransportSource transport1;
transport1.setSource (my_source,
5000, // tells it to buffer this many samples ahead
&my_thread,
(double) sample_rate,
audio->getNumChannels()); // sample rate of source
transport1.setPosition (0);
transport1.setGain(1.0);
// Create MIXER
MixerAudioSource mixer;
mixer.addInputSource(&transport1, false);
audioSourcePlayer.setSource (&mixer);
// Start transports
transport1.start();
while (transport1.isPlaying())
{
cout << "playing" << endl;
Sleep(1);
}
cout << "DONE!!!" << endl;
transport1.stop();
transport1.setSource (0);
audioSourcePlayer.setSource (0);
my_thread.stopThread(500);
deviceManager.removeAudioCallback (&audioSourcePlayer);
deviceManager.closeAudioDevice();
deviceManager.removeAllChangeListeners();
deviceManager.dispatchPendingMessages();
cout << "End of Play()" << endl;
}