当前位置: 首页>>代码示例>>C++>>正文


C++ AudioStream::close方法代码示例

本文整理汇总了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;
}
开发者ID:MIPS,项目名称:frameworks-av,代码行数:12,代码来源:AAudioAudio.cpp

示例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();
    //.
}
开发者ID:felidadae,项目名称:dsp_opencl_gpu,代码行数:16,代码来源:Laboratory.cpp

示例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;
//.........这里部分代码省略.........
开发者ID:kolibre,项目名称:libkolibre-narrator,代码行数:101,代码来源:Narrator.cpp


注:本文中的AudioStream::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。