本文整理汇总了C++中AudioStream::close方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioStream::close方法的具体用法?C++ AudioStream::close怎么用?C++ AudioStream::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioStream
的用法示例。
在下文中一共展示了AudioStream::close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AAudioStream_close
AAUDIO_API aaudio_result_t AAudioStream_close(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
ALOGD("AAudioStream_close(%p)", stream);
if (audioStream != nullptr) {
audioStream->close();
audioStream->unregisterPlayerBase();
delete audioStream;
return AAUDIO_OK;
}
return AAUDIO_ERROR_NULL;
}
示例2: checkAndSave
void Laboratory::checkAndSave(TrialsSet& trialsSet, AudioStream& audioStream, InputAudioParameters& str, CheckMethodType checkMethod, std::string folderForAudioResults ) {
//Check - write result to file
if(str.data_source == AudioStream::AUDIO_FILE_AS_SOURCE) {
audioStream.close (resultsPath_ + folderForAudioResults + std::string("/") + str.outFileName, true);
audioStream.cutAndClose (resultsPath_ + folderForAudioResults + std::string("/") + std::string("cutted__") +str.outFileName, trialsSet, false );
}
if(str.data_source == AudioStream::RANDOM_DATA_AS_SOURCE)
if(checkMethod == CheckMethodType::ifOutSilence)
if(audioStream.checkIfOutSilence())
throw UnkownInternalProcessingError_Exception();
if(checkMethod == CheckMethodType::ifTheInTheSameAsOut)
if(!audioStream.checkIfOutTheSameAsIn())
throw UnkownInternalProcessingError_Exception();
//.
}
示例3: if
/**
* The playback thread code
* \internal
*/
void *narrator_thread(void *narrator)
{
//Narrator *n = static_cast<Narrator *>(narrator);
Narrator *n = (Narrator*)narrator;
int queueitems;
// Set initial values to 0 so that they get updated when thread gets play signal
float gain = 0;
float tempo = 0;
float pitch = 0;
PortAudio portaudio;
Filter filter;
Narrator::threadState state = n->getState();
LOG4CXX_INFO(narratorLog, "Starting playback thread");
do {
queueitems = n->numPlaylistItems();
if(queueitems == 0) {
// Wait a little before calling callback
long waitms = portaudio.getRemainingms();
if(waitms != 0) {
LOG4CXX_DEBUG(narratorLog, "Waiting " << waitms << " ms for playback to finish");
while(waitms > 0 && queueitems == 0) {
usleep(100000);
queueitems = n->numPlaylistItems();
waitms -= 100;
}
}
// Break if we during the pause got some more queued items to play
if(queueitems == 0) {
if(state != Narrator::DEAD)
n->audioFinishedPlaying();
n->setState(Narrator::WAIT);
LOG4CXX_INFO(narratorLog, "Narrator in WAIT state");
portaudio.stop();
while(queueitems == 0) {
state = n->getState();
if(state == Narrator::EXIT) break;
usleep(10000);
queueitems = n->numPlaylistItems();
}
}
LOG4CXX_INFO(narratorLog, "Narrator starting playback");
}
if(state == Narrator::EXIT) break;
n->setState(Narrator::PLAY);
n->bResetFlag = false;
Narrator::PlaylistItem pi;
pthread_mutex_lock(n->narratorMutex);
if(n->mPlaylist.size() > 0) {
pi = n->mPlaylist.front();
n->mPlaylist.pop();
} else {
LOG4CXX_ERROR(narratorLog, "Narrator started playback thread without playlistitems");
pthread_mutex_unlock(n->narratorMutex);
continue;
}
string lang = n->mLanguage;
pthread_mutex_unlock(n->narratorMutex);
// If trying to play a file, open it
if(pi.mClass == "file") {
LOG4CXX_DEBUG(narratorLog, "Playing file: " << pi.mIdentifier);
AudioStream *audioStream;
std::string fileExtension = getFileExtension(pi.mIdentifier);
if (fileExtension == "ogg")
{
audioStream = new OggStream;
}
else if (fileExtension == "mp3")
{
audioStream = new Mp3Stream;
}
else
{
LOG4CXX_ERROR(narratorLog, "extension '" << fileExtension << "' not supported");
continue;
}
if(!audioStream->open(pi.mIdentifier)) {
LOG4CXX_ERROR(narratorLog, "error opening audio stream: " << pi.mIdentifier);
audioStream->close();
continue;
//.........这里部分代码省略.........