• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Pa_CloseStream函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Pa_CloseStream函数的典型用法代码示例。如果您正苦于以下问题:C++ Pa_CloseStream函数的具体用法?C++ Pa_CloseStream怎么用?C++ Pa_CloseStream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Pa_CloseStream函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main( void )
{
	PaStreamParameters outputParameters;
	PaError pa_err;
	SF_INFO sfinfo;

	signal( SIGINT, interrupt );

	gen_default_drums();

	pa_err = Pa_Initialize();
	outputParameters.device = Pa_GetDefaultOutputDevice();
	outputParameters.channelCount = CHANNELS;
	outputParameters.sampleFormat = paFloat32;
	outputParameters.suggestedLatency =
		Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
	outputParameters.hostApiSpecificStreamInfo = NULL;
	pa_err = Pa_OpenStream( &stream, NULL, &outputParameters, SAMPLE_RATE,
		BUFFER_SIZE, paClipOff, audio_callback, NULL );

	sfinfo.samplerate = SAMPLE_RATE;
	sfinfo.channels = CHANNELS;
	sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
	wave_output = sf_open( OUTPUT_FILE, SFM_WRITE, &sfinfo );

	srand( time( 0 ) );

	bass_z = 0.0f;
	bass_freq = midi_to_hz( BASE_NOTE );

	pa_err = Pa_StartStream( stream );
	
	while( 1 )
		Pa_Sleep( 1000 );

	sf_close( wave_output );
	pa_err = Pa_StopStream( stream );
	pa_err = Pa_CloseStream( stream );
	Pa_Terminate();

	return 0;
}
开发者ID:deveah,项目名称:jeg,代码行数:42,代码来源:jeg.c


示例2: Pa_AbortStream

	audioSink::~audioSink	(void) {
	if ((ostream != NULL) && !Pa_IsStreamStopped (ostream)) {
	   paCallbackReturn = paAbort;
	   (void) Pa_AbortStream (ostream);
	   while (!Pa_IsStreamStopped (ostream))
	      Pa_Sleep (1);
	   writerRunning = false;
	}
	
	writerRunning	= false;
	if (ostream != NULL)
	   Pa_CloseStream (ostream);
	ostream	= NULL;

	if (portAudio)
	   Pa_Terminate ();

	delete	_O_Buffer;
	delete[]	outTable;
}
开发者ID:JvanKatwijk,项目名称:sdr-j-dab,代码行数:20,代码来源:audiosink.cpp


示例3: delete_fluid_portaudio_driver

/*
 * delete_fluid_portaudio_driver
 */
int
delete_fluid_portaudio_driver(fluid_audio_driver_t *p)
{
  fluid_portaudio_driver_t* dev;
  PaError err;

  dev = (fluid_portaudio_driver_t*)p;
  if (dev == NULL) return FLUID_OK;

  /* PortAudio section */
  if (dev->stream) Pa_CloseStream (dev->stream);

  err = Pa_Terminate();

  if (err != paNoError)
    printf ("PortAudio termination error: %s\n", Pa_GetErrorText (err) );

  FLUID_FREE (dev);
  return FLUID_OK;
}
开发者ID:caomw,项目名称:fluidsynth,代码行数:23,代码来源:fluid_portaudio.c


示例4: stop_portAudio

//-----------------------------------------------------------------------------
// Name: void stop_portAudio() 
// Desc: //Stops Port Audio
//-----------------------------------------------------------------------------
void stop_portAudio() 
{
    PaError err;

    /* Stop audio stream */
    err = Pa_StopStream( g_stream );
    if (err != paNoError) {
        printf(  "PortAudio error: stop stream: %s\n", Pa_GetErrorText(err));
    }
    /* Close audio stream */
    err = Pa_CloseStream(g_stream);
    if (err != paNoError) {
        printf("PortAudio error: close stream: %s\n", Pa_GetErrorText(err));
    }
    /* Terminate audio stream */
    err = Pa_Terminate();
    if (err != paNoError) {
        printf("PortAudio error: terminate: %s\n", Pa_GetErrorText(err));
    }
}
开发者ID:bombsandbottles,项目名称:VinylVisualizer,代码行数:24,代码来源:vinylVisualizer.c


示例5: Pa_CloseStream

int AudioStreamManager::StopAudio() {

	PaError err;

	err = Pa_CloseStream(audioStream);
	if (err != paNoError) goto error;
	soundDelegate->didEndPlay();

	printf("Finished. gNumNoInputs = %d\n", numNoInputs);
	Pa_Terminate();
	return 0;

error:
	Pa_Terminate();
	fprintf(stderr, "An error occured while using the portaudio stream\n");
	fprintf(stderr, "Error number: %d\n", err);
	fprintf(stderr, "Error message: %s\n", Pa_GetErrorText(err));
	soundDelegate->didEndPlay();
	return -1;
}
开发者ID:garbagemza,项目名称:fv1-emu,代码行数:20,代码来源:AudioStreamManager.cpp


示例6: uninit

static void uninit(struct ao *ao, bool cut_audio)
{
    struct priv *priv = ao->priv;

    if (priv->stream) {
        if (!cut_audio && Pa_IsStreamActive(priv->stream) == 1) {
            pthread_mutex_lock(&priv->ring_mutex);

            priv->play_remaining = true;

            pthread_mutex_unlock(&priv->ring_mutex);

            check_pa_ret(Pa_StopStream(priv->stream));
        }
        check_pa_ret(Pa_CloseStream(priv->stream));
    }

    pthread_mutex_destroy(&priv->ring_mutex);
    Pa_Terminate();
}
开发者ID:CrimsonVoid,项目名称:mpv,代码行数:20,代码来源:ao_portaudio.c


示例7: Pa_StopStream

bool PaInstance::stopStream ()
{
    PaError error;
    
	error = Pa_StopStream(mAudioStream);
    if (error != paNoError)
    {
        errorHandler(error);
        return false;
    }
    
	error = Pa_CloseStream(mAudioStream);
    if (error != paNoError)
    {
        errorHandler(error);
        return false;
    }
    
    return true;
}
开发者ID:cocochotirut,项目名称:csdelay-win,代码行数:20,代码来源:PaInstance.cpp


示例8: while

/*
   Blocks until data can be written.
   If no data can be written in 2ms*100 the stream gets restarted.
   returns the amount of data that can be written.
*/
unsigned int PortAudio::getWriteAvailable()
{
    size_t writeAvailable = 0;
    int waitCount = 0;
    int failCount = 0;

    while( writeAvailable == 0 ) {
        writeAvailable = ringbuf.getWriteAvailable();

        if( writeAvailable == 0 ) {
            usleep(200000); //200 ms
            //LOG4CXX_DEBUG(narratorPaLog, "getWriteAvailable = 0, Pa_IsStreamActive = " << Pa_IsStreamActive(pStream));
        }

        if(waitCount++ > 10) {
            LOG4CXX_ERROR(narratorPaLog, "getWriteAvailable waittime exceeded, restarting stream");

            mError = Pa_AbortStream(pStream);
            // If abortstream fails, try reopening
            if(failCount++ > 0 || ( mError != paNoError && mError != paStreamIsStopped )) {
                LOG4CXX_ERROR(narratorPaLog, "Failed to abort stream, trying to close and reopen: " << Pa_GetErrorText(mError));

                mError = Pa_CloseStream(pStream);
                if(mError != paNoError)
                    LOG4CXX_ERROR(narratorPaLog, "Failed to close stream: " << Pa_GetErrorText(mError));

                isOpen = false;
                open(mRate, mChannels);
            }

            mError = Pa_StartStream(pStream);
            if(mError != paNoError) LOG4CXX_ERROR(narratorPaLog, "Failed to start stream: " << Pa_GetErrorText(mError));
            isStarted = true;

            waitCount = 0;
        }
    }

    //LOG4CXX_DEBUG(narratorPaLog, "getWriteAvailable = " << writeAvailable << ", Pa_IsStreamActive = " << Pa_IsStreamActive(pStream));
    return writeAvailable;
}
开发者ID:kolibre,项目名称:libkolibre-narrator,代码行数:46,代码来源:PortAudio.cpp


示例9: Pa_StopStream

void AudioDevice::addCallback(AudioProcessor *audioProcessor_)
{
    audioProcessor = audioProcessor_;
    audioProcessor->setNumInputChannels(numInputs);
    audioProcessor->setNumOutputChannels(numOutputs);
    
    audioProcessor->setSampleRate(sampleRate);
    audioProcessor->setBufferSize(bufferSize);
    
    audioProcessor->prepareToPlay(sampleRate, bufferSize);
    
    if(stream)
    {
        Pa_StopStream(&stream);
        Pa_CloseStream(&stream);
    }
    
    err = Pa_OpenStream(&stream,
                        &inputParameters,
                        &outputParameters,
                        sampleRate,
                        bufferSize,
                        paClipOff,
                        &callback,
                        audioProcessor);
    
    if( err != paNoError )
    {
        std::cout<<"Couldn't open stream"<<std::endl;
        std::cout<< "Error message: "<< Pa_GetErrorText( err )<<std::endl;
    }
    
    std::cout<< "Error message: "<< Pa_GetErrorText( err )<<std::endl;
    
    err = Pa_StartStream( stream );
    if( err != paNoError )
    {
        std::cout<<"Couldn't start stream"<<std::endl;
        std::cout<< "Error message: "<< Pa_GetErrorText( err )<<std::endl;
    }
}
开发者ID:DannyvanSwieten,项目名称:APAudioFramework,代码行数:41,代码来源:AudioDevice.cpp


示例10: play_sound

//void* play_sound(void* void_input) {
void* play_sound(void* void_input) {
    (void) void_input;
    PaStream *stream;
    printf("PortAudio Test: output sawtooth wave.\n");
    /* Initialize our data for use by callback. */
    data.left_phase = data.right_phase = 0.0;
    /* Initialize library before making any other calls. */
    err = Pa_Initialize();
    if( err != paNoError ) goto error;

    /* Open an audio I/O stream. */
    err = Pa_OpenDefaultStream( &stream,
                                0,          /* no input channels */
                                2,          /* stereo output */
                                paFloat32,  /* 32 bit floating point output */
                                SAMPLE_RATE,
                                256,        /* frames per buffer */
                                patestCallback,
                                &data );
    if( err != paNoError ) goto error;

    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;

    /* Sleep for several seconds. */
    Pa_Sleep(NUM_SECONDS*1000);

    err = Pa_StopStream( stream );
    if( err != paNoError ) goto error;
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    Pa_Terminate();
    printf("Test finished.\n");
    return NULL;
error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return NULL;
}
开发者ID:Wribbe,项目名称:learnopengl,代码行数:42,代码来源:test.c


示例11: Pa_StopStream

int PortAudioRecordBackend::closeVuMeterStream() {
    int err;

    if(vuMeterStream != NULL) {
        err = Pa_StopStream(vuMeterStream);
        if(err != paNoError) {
            qDebug("Error stopping stream:\n %s", Pa_GetErrorText(err));
            return -1;
        }

        err = Pa_CloseStream(vuMeterStream);
        if(err != paNoError) {
            qDebug("Error closing stream:\n %s", Pa_GetErrorText(err));
            return -2;
        }

        vuMeterStream = NULL;
    }

    return 0;
}
开发者ID:ruedigergad,项目名称:stultitiasimplex,代码行数:21,代码来源:portaudiorecordbackend.cpp


示例12: Q_ASSERT

void AudioCapturePortAudio::uninitialize()
{
    Q_ASSERT(stream != NULL);

    PaError err;

    /* -- Now we stop the stream -- */
    err = Pa_StopStream( stream );
    if( err != paNoError )
        qDebug() << "PortAudio error: " << Pa_GetErrorText( err );

    /* -- don't forget to cleanup! -- */
    err = Pa_CloseStream( stream );
    if( err != paNoError )
        qDebug() << "PortAudio error: " << Pa_GetErrorText( err );
    stream = NULL;

    err = Pa_Terminate();
    if( err != paNoError )
        qDebug() << "PortAudio error: " << Pa_GetErrorText( err );
}
开发者ID:PML369,项目名称:qlcplus,代码行数:21,代码来源:audiocapture_portaudio.cpp


示例13: snd_close

void snd_close(void)
{
    Pa_StopStream(stream);
    Pa_CloseStream(stream);
    Pa_Terminate();

    free((void*) srconv_stream.data_in);
    free(srconv_stream.data_out);

    free((void*) srconv_record.data_in);
    free(srconv_record.data_out);

    free(pa_pcm_buf);
    free(encode_buf);

    delete[] stream_buf;
    delete[] record_buf;
    stream_buf = record_buf = nullptr;
    delete dsp;
    dsp = nullptr;
}
开发者ID:melchor629,项目名称:butt,代码行数:21,代码来源:port_audio.cpp


示例14: Pa_AbortStream

void
CPaCommon::Close()
{
    if (stream)
    {
        int err = Pa_AbortStream(stream);
        if (err != paNoError)
        {
            cout << "PortAudio error: " << Pa_GetErrorText(err) << endl;
        }

        err = Pa_CloseStream(stream);
        if (err != paNoError)
        {
            cout << "PortAudio error: " << Pa_GetErrorText(err) << endl;
        }

        stream = NULL;
        device_changed = true;
    }
}
开发者ID:castrouk,项目名称:LinDrm,代码行数:21,代码来源:drm_portaudio.cpp


示例15: Pa_CloseStream

void CVoiceRecorder::DeInit(void)
{
    if (m_bEnabled)
    {
        m_bEnabled = false;

        Pa_CloseStream(m_pAudioStream);
        Pa_Terminate();

        // Assumes now that PACallback will not be called in this context
        m_CS.Lock();
        m_CS.Unlock();
        // Assumes now that PACallback is not executing in this context

        m_pAudioStream = NULL;

        m_iSpeexOutgoingFrameSampleCount = 0;

        speex_encoder_destroy(m_pSpeexEncoderState);
        m_pSpeexEncoderState = NULL;

        speex_preprocess_state_destroy(m_pSpeexPreprocState);
        m_pSpeexPreprocState = NULL;

        free(m_pOutgoingBuffer);
        m_pOutgoingBuffer = NULL;

        m_VoiceState = VOICESTATE_AWAITING_INPUT;
        m_SampleRate = SAMPLERATE_WIDEBAND;

        m_pAudioStream = NULL;

        m_iSpeexOutgoingFrameSampleCount = 0;
        m_uiOutgoingReadIndex = 0;
        m_uiOutgoingWriteIndex = 0;
        m_bIsSendingVoiceData = false;
        m_ulTimeOfLastSend = 0;
        m_uiBufferSizeBytes = 0;
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:40,代码来源:CVoiceRecorder.cpp


示例16: TestPlayback

PaError TestPlayback( paTestData *dataPtr )
{
    PortAudioStream *stream;
    PaError    err;
    int        i;

    /* Playback recorded data. */
    dataPtr->frameIndex = 0;
    printf("Begin playback.\n"); fflush(stdout);
    err = Pa_OpenStream(
              &stream,
              paNoDevice,
              0,               /* NO input */
              PA_SAMPLE_TYPE,
              NULL,
              Pa_GetDefaultOutputDeviceID(),
              dataPtr->samplesPerFrame,               /* stereo output */
              PA_SAMPLE_TYPE,
              NULL,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,            /* frames per buffer */
              0,               /* number of buffers, if zero then use default minimum */
              paClipOff,       /* we won't output out of range samples so don't bother clipping them */
              playCallback,
              dataPtr );
    if( err != paNoError ) goto error;
    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;
    printf("Waiting for playback to finish.\n"); fflush(stdout);
    for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
    {
        Pa_Sleep(100);
        printf("index = %d\n", dataPtr->frameIndex );
    }
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    
error:
    return err;
}
开发者ID:MatthiasWM,项目名称:Einstein,代码行数:40,代码来源:debug_record.c


示例17: main

int main( int argc, char * argv[] ) {
	FILE * file = 0;
	size_t size = 0;
	void * data = 0;
	openmpt_module * mod = 0;
	size_t count = 0;
	PaStream * stream = 0;
	PaStreamParameters streamparameters;
	memset( &streamparameters, 0, sizeof( PaStreamParameters ) );
	(void)argc;
	file = fopen( argv[1], "rb" );
	fseek( file, 0, SEEK_END );
	size = ftell( file );
	fseek( file, 0, SEEK_SET );
	data = malloc( size );
	size = fread( data, 1, size, file );
	fclose( file );
	mod = openmpt_module_create_from_memory( data, size, NULL, NULL, NULL );
	free( data );
	Pa_Initialize();
	streamparameters.device = Pa_GetDefaultOutputDevice();
	streamparameters.channelCount = 2;
	streamparameters.sampleFormat = paInt16 | paNonInterleaved;
	streamparameters.suggestedLatency = Pa_GetDeviceInfo( streamparameters.device )->defaultHighOutputLatency;
	Pa_OpenStream( &stream, NULL, &streamparameters, SAMPLERATE, paFramesPerBufferUnspecified, 0, NULL, NULL );
	Pa_StartStream( stream );
	while ( 1 ) {
		count = openmpt_module_read_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right );
		if ( count == 0 ) {
			break;
		}
		Pa_WriteStream( stream, buffers, count );
	}
	Pa_StopStream( stream );
	Pa_CloseStream( stream );
	Pa_Terminate();
	openmpt_module_destroy( mod );
	return 0;
}
开发者ID:Kinglions,项目名称:modizer,代码行数:39,代码来源:libopenmpt_example_c_mem.c


示例18: main

int main(void)
{
	PortAudioStream *stream;
	PaError err;
	err = Pa_Initialize();
	if( err != paNoError ) goto error;
	err = Pa_OpenStream(
				&stream,
				Pa_GetDefaultInputDeviceID(), /* default output device */
				2,               /* stereo input */
				PA_SAMPLE_TYPE,	
				NULL,
				Pa_GetDefaultOutputDeviceID(), /* default output device */
				2,               /* stereo output */
				PA_SAMPLE_TYPE, 
				NULL,
				SAMPLE_RATE,
				64,            /* frames per buffer */
				0,             /* number of buffers, if zero then use default minimum */
				paClipOff,     /* we won't output out of range samples so don't bother clipping them */
				fuzzCallback,
				NULL );
	if( err != paNoError ) goto error;
	err = Pa_StartStream( stream );
	if( err != paNoError ) goto error;
	printf("Hit ENTER to stop program.\n");
	getchar();
	err = Pa_CloseStream( stream );
	if( err != paNoError ) goto error;
	printf("Finished. gNumNoInputs = %d\n", gNumNoInputs );
	Pa_Terminate();
	return 0;
error:
	Pa_Terminate();
	fprintf( stderr, "An error occured while using the portaudio stream\n" ); 
	fprintf( stderr, "Error number: %d\n", err );
	fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
	return -1;
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:39,代码来源:pa_fuzz.c


示例19: Pa_StopStream

int AudioRecorder::stop()
{
  PaError err;

  if (recording_status_ != STOPPED && stream_) {
    err = Pa_StopStream( stream_ );
    if(err != paNoError) {
      HANDLE_PA_ERROR(err);
    }
  }
  if (stream_) {
    err = Pa_CloseStream( stream_ );
    if(err != paNoError) {
      HANDLE_PA_ERROR(err);
    }
    stream_ = 0;
  }

  Pa_Terminate();

  return 0;
}
开发者ID:padenot,项目名称:AudioTechnology,代码行数:22,代码来源:AudioRecorder.cpp


示例20: Pa_CloseStream

void DevicePortAudio::deviceInputClose()
{
	if( mStreamInput )
	{
		Pa_CloseStream( mStreamInput );

		mStreamInput = nullptr;
	}

	for( AudioBuffer &AB : mAudioBuffers )
	{
		for( int i = 0 ; i < AB.mChannels ; i++ )
		{
			delete [] AB.mData[ i ];
		}

		delete [] AB.mData;
	}

	mInputTimeLatency  = 0;
	mInputChannelCount = 0;
}
开发者ID:Daandelange,项目名称:Fugio,代码行数:22,代码来源:deviceportaudio.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Pa_GetDefaultInputDevice函数代码示例发布时间:2022-05-30
下一篇:
C++ PaUtil_FreeMemory函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap