本文整理汇总了C++中Pa_GetStreamInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ Pa_GetStreamInfo函数的具体用法?C++ Pa_GetStreamInfo怎么用?C++ Pa_GetStreamInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pa_GetStreamInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: strm_get_cap
/* API: get capability */
static pj_status_t strm_get_cap(pjmedia_aud_stream *s,
pjmedia_aud_dev_cap cap,
void *pval)
{
struct pa_aud_stream *strm = (struct pa_aud_stream*)s;
PJ_ASSERT_RETURN(strm && pval, PJ_EINVAL);
if (cap==PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY && strm->rec_strm) {
const PaStreamInfo *si = Pa_GetStreamInfo(strm->rec_strm);
if (!si)
return PJMEDIA_EAUD_SYSERR;
*(unsigned*)pval = (unsigned)(si->inputLatency * 1000);
return PJ_SUCCESS;
} else if (cap==PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY && strm->play_strm) {
const PaStreamInfo *si = Pa_GetStreamInfo(strm->play_strm);
if (!si)
return PJMEDIA_EAUD_SYSERR;
*(unsigned*)pval = (unsigned)(si->outputLatency * 1000);
return PJ_SUCCESS;
} else {
return PJMEDIA_EAUD_INVCAP;
}
}
开发者ID:avble,项目名称:natClientEx,代码行数:27,代码来源:pa_dev.c
示例2: PJ_DEF
/*
* Get stream info.
*/
PJ_DEF(pj_status_t) pjmedia_snd_stream_get_info(pjmedia_snd_stream *strm,
pjmedia_snd_stream_info *pi)
{
const PaStreamInfo *paPlaySI = NULL, *paRecSI = NULL;
PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL);
PJ_ASSERT_RETURN(strm->play_strm || strm->rec_strm, PJ_EINVALIDOP);
if (strm->play_strm) {
paPlaySI = Pa_GetStreamInfo(strm->play_strm);
}
if (strm->rec_strm) {
paRecSI = Pa_GetStreamInfo(strm->rec_strm);
}
pj_bzero(pi, sizeof(*pi));
pi->dir = strm->dir;
pi->play_id = strm->play_id;
pi->rec_id = strm->rec_id;
pi->clock_rate = (unsigned)(paPlaySI ? paPlaySI->sampleRate :
paRecSI->sampleRate);
pi->channel_count = strm->channel_count;
pi->samples_per_frame = strm->samples_per_frame;
pi->bits_per_sample = strm->bytes_per_sample * 8;
pi->rec_latency = (unsigned)(paRecSI ? paRecSI->inputLatency *
paRecSI->sampleRate : 0);
pi->play_latency = (unsigned)(paPlaySI ? paPlaySI->outputLatency *
paPlaySI->sampleRate : 0);
return PJ_SUCCESS;
}
开发者ID:tibastral,项目名称:symphonie,代码行数:34,代码来源:pasound.c
示例3: kwlEngine_hostSpecificInitialize
/**
* Initializes PortAudio with a callback that fills output buffers mixed by the Kowalski Engine.
* @param engine
* @param sampleRate
* @param numChannels
* @param bufferSize
* @return A Kowalski error code.
*/
kwlError kwlEngine_hostSpecificInitialize(kwlEngine* engine, int sampleRate, int numOutChannels, int numInChannels, int bufferSize)
{
PaError err = Pa_Initialize();
KWL_ASSERT(err == paNoError && "error initializing portaudio");
/* Open an audio I/O stream. */
err = Pa_OpenDefaultStream(&stream,
numInChannels,
numOutChannels,
paFloat32, /* 32 bit floating point output. */
sampleRate,
bufferSize, /* frames per buffer, i.e. the number
of sample frames that PortAudio will
request from the callback. Many apps
may want to use
paFramesPerBufferUnspecified, which
tells PortAudio to pick the best,
possibly changing, buffer size.*/
(PaStreamCallback*)&paCallback,
engine->mixer);
//printf("PortAudio error: %s\n", Pa_GetErrorText(err));
KWL_ASSERT(err == paNoError);
err = Pa_StartStream(stream);
//printf("PortAudio error: %s\n", Pa_GetErrorText(err));
KWL_ASSERT(err == paNoError);
const PaStreamInfo* si = Pa_GetStreamInfo(stream);
return KWL_NO_ERROR;
}
开发者ID:JamesLinus,项目名称:kowalski,代码行数:39,代码来源:kwl_engine_portaudio.c
示例4: Pa_GetStreamInfo
void JackPortAudioDriver::UpdateLatencies()
{
jack_latency_range_t input_range;
jack_latency_range_t output_range;
jack_latency_range_t monitor_range;
const PaStreamInfo* info = Pa_GetStreamInfo(fStream);
assert(info);
for (int i = 0; i < fCaptureChannels; i++) {
input_range.max = input_range.min = fEngineControl->fBufferSize + (info->inputLatency * fEngineControl->fSampleRate) + fCaptureLatency;
fGraphManager->GetPort(fCapturePortList[i])->SetLatencyRange(JackCaptureLatency, &input_range);
}
for (int i = 0; i < fPlaybackChannels; i++) {
output_range.max = output_range.min = (info->outputLatency * fEngineControl->fSampleRate) + fPlaybackLatency;
if (fEngineControl->fSyncMode) {
output_range.max = output_range.min += fEngineControl->fBufferSize;
} else {
output_range.max = output_range.min += fEngineControl->fBufferSize * 2;
}
fGraphManager->GetPort(fPlaybackPortList[i])->SetLatencyRange(JackPlaybackLatency, &output_range);
if (fWithMonitorPorts) {
monitor_range.min = monitor_range.max = fEngineControl->fBufferSize;
fGraphManager->GetPort(fMonitorPortList[i])->SetLatencyRange(JackCaptureLatency, &monitor_range);
}
}
}
开发者ID:agraf,项目名称:jack2,代码行数:28,代码来源:JackPortAudioDriver.cpp
示例5: deviceInputClose
void DevicePortAudio::deviceInputOpen( const PaDeviceInfo *DevInf )
{
deviceInputClose();
PaStreamParameters StrPrm;
memset( &StrPrm, 0, sizeof( StrPrm ) );
StrPrm.device = mDeviceIndex;
StrPrm.channelCount = DevInf->maxInputChannels;
StrPrm.sampleFormat = paNonInterleaved | paFloat32;
StrPrm.suggestedLatency = DevInf->defaultLowInputLatency;
if( Pa_OpenStream( &mStreamInput, &StrPrm, nullptr, outputSampleRate(), paFramesPerBufferUnspecified, paNoFlag, &DevicePortAudio::streamCallbackStatic, this ) != paNoError )
{
return;
}
mInputChannelCount = DevInf->maxInputChannels;
const PaStreamInfo *StreamInfo = Pa_GetStreamInfo( mStreamInput );
qDebug() << DevInf->name << StreamInfo->sampleRate << StreamInfo->inputLatency << mInputChannelCount;
mInputSampleRate = StreamInfo->sampleRate;
mInputTimeLatency = StreamInfo->inputLatency;
mInputAudioOffset = 0; //QDateTime::currentMSecsSinceEpoch() * qint64( mSampleRate / 1000.0 );
mInputSampleFormat = fugio::AudioSampleFormat::Format32FS;
if( Pa_StartStream( mStreamInput ) != paNoError )
{
return;
}
}
开发者ID:Daandelange,项目名称:Fugio,代码行数:34,代码来源:deviceportaudio.cpp
示例6: pa_reset_playback
static ALCboolean pa_reset_playback(ALCdevice *device)
{
pa_data *data = (pa_data*)device->ExtraData;
const PaStreamInfo *streamInfo;
PaError err;
streamInfo = Pa_GetStreamInfo(data->stream);
if(device->Frequency != streamInfo->sampleRate)
{
if((device->Flags&DEVICE_FREQUENCY_REQUEST))
ERR("PortAudio does not support changing sample rates (wanted %dhz, got %.1fhz)\n", device->Frequency, streamInfo->sampleRate);
device->Flags &= ~DEVICE_FREQUENCY_REQUEST;
device->Frequency = streamInfo->sampleRate;
}
device->UpdateSize = data->update_size;
err = Pa_StartStream(data->stream);
if(err != paNoError)
{
ERR("Pa_StartStream() returned an error: %s\n", Pa_GetErrorText(err));
return ALC_FALSE;
}
return ALC_TRUE;
}
开发者ID:GlenDC,项目名称:love-native-android,代码行数:25,代码来源:portaudio.c
示例7: paqaCheckLatency
PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr,
paTestData *dataPtr, double sampleRate, unsigned long framesPerBuffer )
{
PaError err;
PaStream *stream;
const PaStreamInfo* streamInfo;
dataPtr->minFramesPerBuffer = 9999999;
dataPtr->maxFramesPerBuffer = 0;
dataPtr->minDeltaDacTime = 9999999.0;
dataPtr->maxDeltaDacTime = 0.0;
dataPtr->callbackCount = 0;
printf("Stream parameter: suggestedOutputLatency = %g\n", outputParamsPtr->suggestedLatency );
if( framesPerBuffer == paFramesPerBufferUnspecified ){
printf("Stream parameter: user framesPerBuffer = paFramesPerBufferUnspecified\n" );
}else{
printf("Stream parameter: user framesPerBuffer = %lu\n", framesPerBuffer );
}
err = Pa_OpenStream(
&stream,
NULL, /* no input */
outputParamsPtr,
sampleRate,
framesPerBuffer,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
dataPtr );
if( err != paNoError ) goto error1;
streamInfo = Pa_GetStreamInfo( stream );
printf("Stream info: inputLatency = %g\n", streamInfo->inputLatency );
printf("Stream info: outputLatency = %g\n", streamInfo->outputLatency );
err = Pa_StartStream( stream );
if( err != paNoError ) goto error2;
printf("Play for %d seconds.\n", NUM_SECONDS );
Pa_Sleep( NUM_SECONDS * 1000 );
printf(" minFramesPerBuffer = %4d\n", dataPtr->minFramesPerBuffer );
printf(" maxFramesPerBuffer = %4d\n", dataPtr->maxFramesPerBuffer );
printf(" minDeltaDacTime = %f\n", dataPtr->minDeltaDacTime );
printf(" maxDeltaDacTime = %f\n", dataPtr->maxDeltaDacTime );
err = Pa_StopStream( stream );
if( err != paNoError ) goto error2;
err = Pa_CloseStream( stream );
Pa_Sleep( 1 * 1000 );
printf("-------------------------------------\n");
return err;
error2:
Pa_CloseStream( stream );
error1:
printf("-------------------------------------\n");
return err;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:60,代码来源:paqa_latency.c
示例8: main
int main(int argc, char *argv[])
{
// system("./soxclient '80/C#5 40/C6'");
if (argc < 3) {
displayOption();
exit(0);
}
loadMidiHzTxt();
int InDeviceId = atoi(argv[1]);
int OutDeviceId = atoi(argv[2]);
const int SamplingRate = 44100;
const int BufLength = SamplingRate / 50;
// FFT用に2のべき乗を計算する
for (double i = 1.0; i < 1000; i = i + 1.0) {
fft_num = pow(2.0, i);
if (fft_num > BufLength * 2) {
break;
}
}
Pa_Initialize();
PaStreamParameters in_param;
in_param.channelCount = 2;
in_param.device = InDeviceId;
in_param.hostApiSpecificStreamInfo = NULL;
in_param.sampleFormat = paInt16;
in_param.suggestedLatency = Pa_GetDeviceInfo(in_param.device)->defaultLowInputLatency;
PaStreamParameters out_param;
out_param.channelCount = 1;
out_param.device = OutDeviceId;
out_param.hostApiSpecificStreamInfo = NULL;
out_param.sampleFormat = paInt16;
out_param.suggestedLatency = Pa_GetDeviceInfo(out_param.device)->defaultLowInputLatency;
PaStream *Stream;
Pa_OpenStream(&Stream, &in_param, &out_param, SamplingRate, BufLength, NULL, CallBack, NULL);
const PaStreamInfo *info = Pa_GetStreamInfo(Stream);
fprintf(stderr, "----------Start----------\n");
Pa_StartStream(Stream);
getchar();
Pa_CloseStream(Stream);
Pa_Terminate();
fftw_destroy_plan(p);
fftw_free(fft_in);
fftw_free(fft_out);
(void) pclose(file_p);
}
开发者ID:DMPinc,项目名称:portaudio,代码行数:59,代码来源:portaudio-test.cpp
示例9: start_portaudio
int start_portaudio(int *nominal_sample_rate, double *real_sample_rate)
{
PaStream *stream;
if(pthread_mutex_init(&audio_mutex,NULL)) {
error("Failed to setup audio mutex");
return 1;
}
PaError err = Pa_Initialize();
if(err!=paNoError)
goto error;
#ifdef DEBUG
if(testing) {
*nominal_sample_rate = PA_SAMPLE_RATE;
*real_sample_rate = PA_SAMPLE_RATE;
goto end;
}
#endif
PaDeviceIndex default_input = Pa_GetDefaultInputDevice();
if(default_input == paNoDevice) {
error("No default audio input device found");
return 1;
}
long channels = Pa_GetDeviceInfo(default_input)->maxInputChannels;
if(channels == 0) {
error("Default audio device has no input channels");
return 1;
}
if(channels > 2) channels = 2;
err = Pa_OpenDefaultStream(&stream,channels,0,paFloat32,PA_SAMPLE_RATE,paFramesPerBufferUnspecified,paudio_callback,(void*)channels);
if(err!=paNoError)
goto error;
err = Pa_StartStream(stream);
if(err!=paNoError)
goto error;
const PaStreamInfo *info = Pa_GetStreamInfo(stream);
#ifdef LIGHT
*nominal_sample_rate = PA_SAMPLE_RATE / 2;
*real_sample_rate = info->sampleRate / 2;
#else
*nominal_sample_rate = PA_SAMPLE_RATE;
*real_sample_rate = info->sampleRate;
#endif
#ifdef DEBUG
end:
#endif
debug("sample rate: nominal = %d real = %f\n",*nominal_sample_rate,*real_sample_rate);
return 0;
error:
error("Error opening audio input: %s", Pa_GetErrorText(err));
return 1;
}
开发者ID:vacaboja,项目名称:tg,代码行数:59,代码来源:audio.c
示例10: Pa_Initialize
bool Portaudio::init()
{
PaError err = Pa_Initialize();
if (err != paNoError) {
qDebug("Portaudio initialize failed: %s", Pa_GetErrorText(err));
return false;
}
initialized = true;
if (MScore::debugMode)
qDebug("using PortAudio Version: %s", Pa_GetVersionText());
PaDeviceIndex idx = preferences.portaudioDevice;
if (idx < 0)
idx = Pa_GetDefaultOutputDevice();
const PaDeviceInfo* di = Pa_GetDeviceInfo(idx);
_sampleRate = int(di->defaultSampleRate);
/* Open an audio I/O stream. */
struct PaStreamParameters out;
memset(&out, 0, sizeof(out));
out.device = idx;
out.channelCount = 2;
out.sampleFormat = paFloat32;
out.suggestedLatency = 0.020;
out.hostApiSpecificStreamInfo = 0;
err = Pa_OpenStream(&stream, 0, &out, double(_sampleRate), 0, 0, paCallback, (void*)this);
if (err != paNoError) {
// fall back to default device:
out.device = Pa_GetDefaultOutputDevice();
err = Pa_OpenStream(&stream, 0, &out, double(_sampleRate), 0, 0, paCallback, (void*)this);
if (err != paNoError) {
qDebug("Portaudio open stream %d failed: %s", idx, Pa_GetErrorText(err));
return false;
}
}
const PaStreamInfo* si = Pa_GetStreamInfo(stream);
if (si)
_sampleRate = int(si->sampleRate);
#ifdef USE_ALSA
midiDriver = new AlsaMidiDriver(seq);
#endif
#ifdef USE_PORTMIDI
midiDriver = new PortMidiDriver(seq);
#endif
if (midiDriver && !midiDriver->init()) {
qDebug("Init midi driver failed");
delete midiDriver;
midiDriver = 0;
#ifdef USE_PORTMIDI
return true; // return OK for audio driver; midi is only input
#else
return false;
#endif
}
return true;
}
开发者ID:dalematt,项目名称:MuseScore,代码行数:59,代码来源:pa.cpp
示例11: report_latency
void report_latency()
{
const PaStreamInfo *psi = Pa_GetStreamInfo(stream);
if (psi){
fprintf(stdout," Sample rate: %.3f\n", psi->sampleRate);
fprintf(stdout," Latency (in/out): %.3f / %.3f sec\n", psi->inputLatency, psi->outputLatency);
}
}
开发者ID:giuliomoro,项目名称:supercollider,代码行数:8,代码来源:portaudio_backend.hpp
示例12: qDebug
/* Returns true on success, false on failure */
bool PortAudioStreamer::Start(const PaStreamParameters *inputParams,
const PaStreamParameters *outputParams,
double sampleRate)
{
PaError error;
qDebug("Trying Pa_OpenStream() with sampleRate %g inputLatency %g outputLatency %g innch %d outnch %d",
sampleRate,
inputParams->suggestedLatency,
outputParams->suggestedLatency,
inputParams->channelCount,
outputParams->channelCount);
const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(inputParams->device);
if (deviceInfo) {
const PaHostApiInfo *hostApiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
qDebug("Input device: %s (%s)", deviceInfo->name,
hostApiInfo ? hostApiInfo->name : "<invalid host api>");
}
deviceInfo = Pa_GetDeviceInfo(outputParams->device);
if (deviceInfo) {
const PaHostApiInfo *hostApiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
qDebug("Output device: %s (%s)", deviceInfo->name,
hostApiInfo ? hostApiInfo->name : "<invalid host api>");
}
error = Pa_OpenStream(&stream, inputParams, outputParams,
sampleRate, paFramesPerBufferUnspecified,
paPrimeOutputBuffersUsingStreamCallback,
streamCallbackTrampoline, this);
if (error != paNoError) {
logPortAudioError("Pa_OpenStream() failed", error);
stream = NULL;
return false;
}
m_srate = sampleRate;
m_innch = inputParams->channelCount;
m_outnch = outputParams->channelCount;
m_bps = 32;
error = Pa_StartStream(stream);
if (error != paNoError) {
logPortAudioError("Pa_StartStream() failed", error);
Pa_CloseStream(stream);
stream = NULL;
return false;
}
const PaStreamInfo *streamInfo = Pa_GetStreamInfo(stream);
if (streamInfo) {
qDebug("Stream started with sampleRate %g inputLatency %g outputLatency %g",
streamInfo->sampleRate,
streamInfo->inputLatency,
streamInfo->outputLatency);
}
return true;
}
开发者ID:akinsgre,项目名称:wahjam,代码行数:59,代码来源:audiostream_pa.cpp
示例13: Pa_GetStreamInfo
int PortAudioStreamer::streamCallback(const void *input, void *output,
unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo,
PaStreamCallbackFlags statusFlags)
{
float **inbuf = (float**)input; // const-cast due to SPLPROC prototype
float **outbuf = static_cast<float**>(output);
const PaStreamInfo *info = Pa_GetStreamInfo(stream);
splproc(inbuf, m_innch, outbuf, m_outnch, frameCount, info->sampleRate);
return paContinue;
}
开发者ID:akinsgre,项目名称:wahjam,代码行数:11,代码来源:audiostream_pa.cpp
示例14: Pa_OpenStream
portaudio_decoder *quiet_portaudio_decoder_create(const decoder_options *opt, PaDeviceIndex device, PaTime latency, double sample_rate, size_t sample_buffer_size) {
PaStream *stream;
PaStreamParameters param = {
.device = device,
.channelCount = 2,
.sampleFormat = paFloat32,
.suggestedLatency = latency,
.hostApiSpecificStreamInfo = NULL,
};
PaError err = Pa_OpenStream(&stream, ¶m, NULL, sample_rate,
sample_buffer_size, paNoFlag, NULL, NULL);
if (err != paNoError) {
printf("failed to open port audio stream, %s\n", Pa_GetErrorText(err));
return NULL;
}
err = Pa_StartStream(stream);
if (err != paNoError) {
printf("failed to start port audio stream, %s\n", Pa_GetErrorText(err));
return NULL;
}
const PaStreamInfo *info = Pa_GetStreamInfo(stream);
decoder *d = quiet_decoder_create(opt, info->sampleRate);
quiet_sample_t *sample_buffer = malloc(2 * sample_buffer_size * sizeof(quiet_sample_t));
quiet_sample_t *mono_buffer = malloc(sample_buffer_size * sizeof(quiet_sample_t));
portaudio_decoder *decoder = malloc(1 * sizeof(portaudio_decoder));
decoder->dec = d;
decoder->stream = stream;
decoder->sample_buffer = sample_buffer;
decoder->mono_buffer = mono_buffer;
decoder->sample_buffer_size = sample_buffer_size;
return decoder;
}
ssize_t quiet_portaudio_decoder_recv(quiet_portaudio_decoder *d, uint8_t *data, size_t len) {
return quiet_decoder_recv(d->dec, data, len);
}
void quiet_portaudio_decoder_consume(quiet_portaudio_decoder *d) {
PaError err = Pa_ReadStream(d->stream, d->sample_buffer, d->sample_buffer_size);
if (err != paNoError) {
printf("failed to read port audio stream, %s\n", Pa_GetErrorText(err));
return;
}
for (size_t i = 0; i < d->sample_buffer_size; i++) {
d->mono_buffer[i] = d->sample_buffer[i * 2] + d->sample_buffer[i * 2 + 1];
}
quiet_decoder_consume(d->dec, d->mono_buffer, d->sample_buffer_size);
}
开发者ID:quiet,项目名称:quiet,代码行数:52,代码来源:portaudio_decoder.c
示例15: strm_get_param
/* API: Get stream parameters */
static pj_status_t strm_get_param(pjmedia_aud_stream *s,
pjmedia_aud_param *pi)
{
struct pa_aud_stream *strm = (struct pa_aud_stream*)s;
const PaStreamInfo *paPlaySI = NULL, *paRecSI = NULL;
PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL);
PJ_ASSERT_RETURN(strm->play_strm || strm->rec_strm, PJ_EINVALIDOP);
if (strm->play_strm) {
paPlaySI = Pa_GetStreamInfo(strm->play_strm);
}
if (strm->rec_strm) {
paRecSI = Pa_GetStreamInfo(strm->rec_strm);
}
pj_bzero(pi, sizeof(*pi));
pi->dir = strm->dir;
pi->play_id = strm->play_id;
pi->rec_id = strm->rec_id;
pi->clock_rate = (unsigned)(paPlaySI ? paPlaySI->sampleRate :
paRecSI->sampleRate);
pi->channel_count = strm->channel_count;
pi->samples_per_frame = strm->samples_per_frame;
pi->bits_per_sample = strm->bytes_per_sample * 8;
if (paRecSI) {
pi->flags |= PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY;
pi->input_latency_ms = (unsigned)(paRecSI ? paRecSI->inputLatency *
1000 : 0);
}
if (paPlaySI) {
pi->flags |= PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY;
pi->output_latency_ms = (unsigned)(paPlaySI? paPlaySI->outputLatency *
1000 : 0);
}
return PJ_SUCCESS;
}
开发者ID:avble,项目名称:natClientEx,代码行数:39,代码来源:pa_dev.c
示例16: DPTR_D
bool CCPortAudio::open()
{
DPTR_D(CCPortAudio);
//
d.outputParameters->channelCount = d.channels;
PaError err = Pa_OpenStream(&d.stream, NULL, d.outputParameters, d.sample_rate, 0, paNoFlag, NULL, NULL);
if (err == paNoError) {
d.outputLatency = Pa_GetStreamInfo(d.stream)->outputLatency;
d.available = true;
} else {
qWarning("Open portaudio stream error: %s", Pa_GetErrorText(err));
d.available = false;
}
return err == paNoError;
}
开发者ID:juno52wendy,项目名称:CFlayer,代码行数:15,代码来源:port_audio.cpp
示例17: Initialize
void Initialize(bool StartThread)
{
RingbufData = new char[BUFF_SIZE*sizeof(float)];
WaitForRingbufferSpace = false;
PaUtil_InitializeRingBuffer(&RingBuf, sizeof(float), BUFF_SIZE, RingbufData);
Threaded = StartThread;
Stream = nullptr;
if (StartThread)
{
thread(&PaMixer::Run, this).detach();
}
#ifdef WIN32
if (UseWasapi)
{
OpenStream(&Stream, GetWasapiDevice(), 44100, (void*) this, Latency, Mix);
if (!Stream)
{
// This was a Wasapi problem. Retry without it.
Log::Logf("Problem initializing WASAPI. Falling back to default API.");
UseWasapi = false;
OpenStream(&Stream, Pa_GetDefaultOutputDevice(), 44100, (void*) this, Latency, Mix);
}
}
else
{
OpenStream(&Stream, DefaultDSDevice, 44100, (void*) this, Latency, Mix);
}
#else
OpenStream( &Stream, Pa_GetDefaultOutputDevice(), 44100, (void*) this, Latency, Mix );
#endif
if (Stream)
{
Pa_StartStream(Stream);
std::this_thread::sleep_for(std::chrono::milliseconds(16));
Latency = Pa_GetStreamInfo(Stream)->outputLatency;
Log::Logf("AUDIO: Latency after opening stream = %f \n", Latency);
}
ConstFactor = 1.0;
}
开发者ID:Sp3ct3r2k11,项目名称:raindrop,代码行数:48,代码来源:Audio.cpp
示例18: qDebug
void SoundOutThread::run()
{
PaError paerr;
PaStreamParameters outParam;
PaStream *outStream;
paUserData udata;
quitExecution = false;
outParam.device=m_nDevOut; //Output device number
outParam.channelCount=2; //Number of analog channels
outParam.sampleFormat=paInt16; //Send short ints to PortAudio
outParam.suggestedLatency=0.05;
outParam.hostApiSpecificStreamInfo=NULL;
udata.nTRperiod=m_TRperiod;
paerr=Pa_IsFormatSupported(NULL,&outParam,11025.0);
if(paerr<0) {
qDebug() << "PortAudio says requested output format not supported.";
qDebug() << paerr;
return;
}
paerr=Pa_OpenStream(&outStream, //Output stream
NULL, //No input parameters
&outParam, //Output parameters
11025.0, //Sample rate
FRAMES_PER_BUFFER, //Frames per buffer
paClipOff, //No clipping
d2aCallback, //output callbeck routine
&udata); //userdata
paerr=Pa_StartStream(outStream);
if(paerr<0) {
qDebug() << "Failed to start audio output stream.";
return;
}
const PaStreamInfo* p=Pa_GetStreamInfo(outStream);
outputLatency = p->outputLatency;
bool qe = quitExecution;
//---------------------------------------------- Soundcard output loop
while (!qe) {
qe = quitExecution;
if (qe) break;
msleep(100);
}
Pa_StopStream(outStream);
Pa_CloseStream(outStream);
}
开发者ID:BackupTheBerlios,项目名称:wsjt-svn,代码行数:48,代码来源:soundout.cpp
示例19: DPTR_D
//TODO: call open after audio format changed?
bool AudioOutputPortAudio::open()
{
DPTR_D(AudioOutputPortAudio);
QMutexLocker lock(&d.mutex);
Q_UNUSED(lock);
d.outputParameters->sampleFormat = toPaSampleFormat(audioFormat().sampleFormat());
d.outputParameters->channelCount = audioFormat().channels();
PaError err = Pa_OpenStream(&d.stream, NULL, d.outputParameters, audioFormat().sampleRate(), 0, paNoFlag, NULL, NULL);
if (err == paNoError) {
d.outputLatency = Pa_GetStreamInfo(d.stream)->outputLatency;
d.available = true;
} else {
qWarning("Open portaudio stream error: %s", Pa_GetErrorText(err));
d.available = false;
}
return err == paNoError;
}
开发者ID:NickD2039,项目名称:QtAV,代码行数:18,代码来源:AudioOutputPortAudio.cpp
示例20: TestBadActions
/*-----------------------------------------------------------------------------------------*/
static int TestBadActions( void )
{
PaStream* stream = NULL;
PaError result;
PaQaData myData;
PaStreamParameters opp;
const PaDeviceInfo* info = NULL;
/* Setup data for synthesis thread. */
myData.framesLeft = (unsigned long)(SAMPLE_RATE * 100); /* 100 seconds */
myData.numChannels = 1;
myData.mode = MODE_OUTPUT;
opp.device = Pa_GetDefaultOutputDevice(); /* Default output. */
opp.channelCount = 2; /* Stereo output. */
opp.hostApiSpecificStreamInfo = NULL;
opp.sampleFormat = paFloat32;
info = Pa_GetDeviceInfo(opp.device);
opp.suggestedLatency = info ? info->defaultLowOutputLatency : 0.100;
if (opp.device != paNoDevice) {
HOPEFOR(((result = Pa_OpenStream(&stream, NULL, /* Take NULL as input parame- */
&opp, /* ters, meaning try only output. */
SAMPLE_RATE, FRAMES_PER_BUFFER,
paClipOff, QaCallback, &myData )) == paNoError));
}
HOPEFOR(((result = Pa_StartStream(NULL)) == paBadStreamPtr));
HOPEFOR(((result = Pa_StopStream(NULL)) == paBadStreamPtr));
HOPEFOR(((result = Pa_IsStreamStopped(NULL)) == paBadStreamPtr));
HOPEFOR(((result = Pa_IsStreamActive(NULL)) == paBadStreamPtr));
HOPEFOR(((result = Pa_CloseStream(NULL)) == paBadStreamPtr));
HOPEFOR(((result = Pa_SetStreamFinishedCallback(NULL, NULL)) == paBadStreamPtr));
HOPEFOR(((result = !Pa_GetStreamInfo(NULL))));
HOPEFOR(((result = Pa_GetStreamTime(NULL)) == 0.0));
HOPEFOR(((result = Pa_GetStreamCpuLoad(NULL)) == 0.0));
HOPEFOR(((result = Pa_ReadStream(NULL, NULL, 0)) == paBadStreamPtr));
HOPEFOR(((result = Pa_WriteStream(NULL, NULL, 0)) == paBadStreamPtr));
/** @todo test Pa_GetStreamReadAvailable and Pa_GetStreamWriteAvailable */
if (stream != NULL) Pa_CloseStream(stream);
return result;
}
开发者ID:andreipaga,项目名称:audacity,代码行数:45,代码来源:paqa_errs.c
注:本文中的Pa_GetStreamInfo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论