本文整理汇总了C++中Pa_GetErrorText函数的典型用法代码示例。如果您正苦于以下问题:C++ Pa_GetErrorText函数的具体用法?C++ Pa_GetErrorText怎么用?C++ Pa_GetErrorText使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pa_GetErrorText函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PAOpenStream
static int PAOpenStream( aout_instance_t *p_aout )
{
aout_sys_t *p_sys = p_aout->output.p_sys;
const PaHostErrorInfo* paLastHostErrorInfo = Pa_GetLastHostErrorInfo();
PaStreamParameters paStreamParameters;
vlc_value_t val;
int i_channels, i_err;
uint32_t i_channel_mask;
if( var_Get( p_aout, "audio-device", &val ) < 0 )
{
return VLC_EGENERIC;
}
if( val.i_int == AOUT_VAR_5_1 )
{
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE;
}
else if( val.i_int == AOUT_VAR_3F2R )
{
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
}
else if( val.i_int == AOUT_VAR_2F2R )
{
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
}
else if( val.i_int == AOUT_VAR_MONO )
{
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
}
else
{
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
}
i_channels = aout_FormatNbChannels( &p_aout->output.output );
msg_Dbg( p_aout, "nb_channels requested = %d", i_channels );
i_channel_mask = p_aout->output.output.i_physical_channels;
/* Calculate the frame size in bytes */
p_sys->i_sample_size = 4 * i_channels;
p_aout->output.i_nb_samples = FRAME_SIZE;
aout_FormatPrepare( &p_aout->output.output );
aout_VolumeSoftInit( p_aout );
/* Check for channel reordering */
p_aout->output.p_sys->i_channel_mask = i_channel_mask;
p_aout->output.p_sys->i_bits_per_sample = 32; /* forced to paFloat32 */
p_aout->output.p_sys->i_channels = i_channels;
p_aout->output.p_sys->b_chan_reorder =
aout_CheckChannelReorder( NULL, pi_channels_out,
i_channel_mask, i_channels,
p_aout->output.p_sys->pi_chan_table );
if( p_aout->output.p_sys->b_chan_reorder )
{
msg_Dbg( p_aout, "channel reordering needed" );
}
paStreamParameters.device = p_sys->i_device_id;
paStreamParameters.channelCount = i_channels;
paStreamParameters.sampleFormat = paFloat32;
paStreamParameters.suggestedLatency =
p_sys->deviceInfo->defaultLowOutputLatency;
paStreamParameters.hostApiSpecificStreamInfo = NULL;
i_err = Pa_OpenStream( &p_sys->p_stream, NULL /* no input */,
&paStreamParameters, (double)p_aout->output.output.i_rate,
FRAME_SIZE, paClipOff, paCallback, p_sys );
if( i_err != paNoError )
{
msg_Err( p_aout, "Pa_OpenStream returns %d : %s", i_err,
Pa_GetErrorText( i_err ) );
if( i_err == paUnanticipatedHostError )
{
msg_Err( p_aout, "type %d code %ld : %s",
paLastHostErrorInfo->hostApiType,
paLastHostErrorInfo->errorCode,
paLastHostErrorInfo->errorText );
}
p_sys->p_stream = 0;
return VLC_EGENERIC;
}
i_err = Pa_StartStream( p_sys->p_stream );
if( i_err != paNoError )
{
msg_Err( p_aout, "Pa_StartStream() failed" );
Pa_CloseStream( p_sys->p_stream );
return VLC_EGENERIC;
}
//.........这里部分代码省略.........
开发者ID:Kafay,项目名称:vlc,代码行数:101,代码来源:portaudio.c
示例2: main
//.........这里部分代码省略.........
outputParameters.hostApiSpecificStreamInfo = NULL;
err = Pa_OpenStream(
&stream,
NULL, /* no input */
&outputParameters,
SAMPLE_RATE,
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
&data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
printf("Establishing load conditions...\n" );
/* Determine number of sines required to get to 50% */
do
{
Pa_Sleep( 100 );
load = Pa_GetStreamCpuLoad( stream );
printf("sineCount = %d, CPU load = %f\n", data.sineCount, load );
if( load < 0.3 )
{
data.sineCount += 10;
}
else if( load < 0.4 )
{
data.sineCount += 2;
}
else
{
data.sineCount += 1;
}
}
while( load < 0.5 && data.sineCount < (MAX_SINES-1));
safeSineCount = data.sineCount;
/* Calculate target stress value then ramp up to that level*/
stressedSineCount = (int) (2.0 * data.sineCount * MAX_LOAD );
if( stressedSineCount > MAX_SINES )
stressedSineCount = MAX_SINES;
for( ; data.sineCount < stressedSineCount; data.sineCount+=4 )
{
Pa_Sleep( 100 );
load = Pa_GetStreamCpuLoad( stream );
printf("STRESSING: sineCount = %d, CPU load = %f\n", data.sineCount, load );
}
printf("Counting underflows for 5 seconds.\n");
data.countUnderflows = 1;
Pa_Sleep( 5000 );
stressedUnderflowCount = data.outputUnderflowCount;
data.countUnderflows = 0;
data.sineCount = safeSineCount;
printf("Resuming safe load...\n");
Pa_Sleep( 1500 );
data.outputUnderflowCount = 0;
Pa_Sleep( 1500 );
load = Pa_GetStreamCpuLoad( stream );
printf("sineCount = %d, CPU load = %f\n", data.sineCount, load );
printf("Counting underflows for 5 seconds.\n");
data.countUnderflows = 1;
Pa_Sleep( 5000 );
safeUnderflowCount = data.outputUnderflowCount;
printf("Stop stream.\n");
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
Pa_Terminate();
if( stressedUnderflowCount == 0 )
printf("Test failed, no output underflows detected under stress.\n");
else if( safeUnderflowCount != 0 )
printf("Test failed, %d unexpected underflows detected under safe load.\n", safeUnderflowCount);
else
printf("Test passed, %d expected output underflows detected under stress, 0 unexpected underflows detected under safe load.\n", stressedUnderflowCount );
return err;
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 err;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:101,代码来源:patest_out_underflow.c
示例3: main
int main(void)
{
PaError err;
paTestData data = { 0 };
long totalFrames;
long numBytes;
long i;
printf("patest_record.c\n"); fflush(stdout);
/* Set up test data structure and sample array. */
data.frameIndex = 0;
data.samplesPerFrame = 2;
data.maxFrameIndex = totalFrames = NUM_SECONDS*SAMPLE_RATE;
printf("totalFrames = %d\n", totalFrames ); fflush(stdout);
data.numSamples = totalFrames * data.samplesPerFrame;
numBytes = data.numSamples * sizeof(SAMPLE);
data.recordedSamples = (SAMPLE *) malloc( numBytes );
if( data.recordedSamples == NULL )
{
printf("Could not allocate record array.\n");
exit(1);
}
for( i=0; i<data.numSamples; i++ ) data.recordedSamples[i] = 0;
err = Pa_Initialize();
if( err != paNoError ) goto error;
/* Record and playback multiple times. */
for( i=0; i<2; i++ )
{
err = TestRecording( &data );
if( err != paNoError ) goto error;
err = TestPlayback( &data );
if( err != paNoError ) goto error;
}
/* Clean up. */
err = Pa_CloseStream( data.inputStream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( data.outputStream );
if( err != paNoError ) goto error;
if( err != paNoError ) goto error;
free( data.recordedSamples );
Pa_Terminate();
printf("Test complete.\n"); fflush(stdout);
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 ) );
if( err == paHostError )
{
fprintf( stderr, "Host Error number: %d\n", Pa_GetHostError() );
}
return -1;
}
开发者ID:andreipaga,项目名称:audacity,代码行数:65,代码来源:debug_record_reuse.c
示例4: OpenStream
PaError OpenStream(PaStream **mStream, PaDeviceIndex Device, double Rate, void* Sound, double &dLatency, PaStreamCallback Callback)
{
PaStreamParameters outputParams;
outputParams.device = Device;
outputParams.channelCount = 2;
outputParams.sampleFormat = paFloat32;
if (!Configuration::GetConfigf("UseHighLatency", "Audio"))
outputParams.suggestedLatency = Pa_GetDeviceInfo(outputParams.device)->defaultLowOutputLatency;
else
outputParams.suggestedLatency = Pa_GetDeviceInfo(outputParams.device)->defaultHighOutputLatency;
#ifndef WIN32
outputParams.hostApiSpecificStreamInfo = NULL;
#else
PaWasapiStreamInfo StreamInfo;
PaWinDirectSoundStreamInfo DSStreamInfo;
if (UseWasapi)
{
outputParams.hostApiSpecificStreamInfo = &StreamInfo;
StreamInfo.hostApiType = paWASAPI;
StreamInfo.size = sizeof(PaWasapiStreamInfo);
StreamInfo.version = 1;
if (!Configuration::GetConfigf("WasapiDontUseExclusiveMode", "Audio"))
{
StreamInfo.threadPriority = eThreadPriorityProAudio;
StreamInfo.flags = paWinWasapiExclusive;
}
else
{
StreamInfo.threadPriority = eThreadPriorityAudio;
StreamInfo.flags = 0;
}
StreamInfo.hostProcessorOutput = NULL;
StreamInfo.hostProcessorInput = NULL;
}
else
{
outputParams.hostApiSpecificStreamInfo = &DSStreamInfo;
DSStreamInfo.size = sizeof(PaWinDirectSoundStreamInfo);
DSStreamInfo.hostApiType = paDirectSound;
DSStreamInfo.version = 2;
DSStreamInfo.flags = 0;
}
#endif
dLatency = outputParams.suggestedLatency;
// fire up portaudio
PaError Err = Pa_OpenStream(mStream, NULL, &outputParams, Rate, 0, paClipOff, Callback, (void*)Sound);
if (Err)
{
Log::Logf("%ls\n", Utility::Widen(Pa_GetErrorText(Err)).c_str());
Log::Logf("Device Selected %d\n", Device);
}
#ifdef LINUX
else
{
Log::Logf("Audio: Enabling real time scheduling\n");
PaAlsa_EnableRealtimeScheduling( mStream, true );
}
#endif
return Err;
}
开发者ID:Sp3ct3r2k11,项目名称:raindrop,代码行数:72,代码来源:Audio.cpp
示例5: main
//.........这里部分代码省略.........
{ //else, it's a button press
buttonPress = FALSE; //acknowledged, reset flag
//printf("button pressed\n"); //fflush(stdout);
}
// Measure maximum peak amplitude.
// we could indicate over-driving/clipping the audio
// or AGC it
max = 0;
average = 0.0;
for( i=0; i<numSamples; i++ )
{
val = data.recordedSamples[i];
if( val < 0 ) val = -val; // ABS
if( val > max )
{
max = val;
}
average += val;
}
average = average / (double)numSamples;
//printf("sample max amplitude = "PRINTF_S_FORMAT"\n", max );
//printf("sample average = %lf\n", average );
// Write recorded data to a file.
#if WRITE_TO_FILE
{ // the file size should be 5 minutes of 8K samples * 2
// the entire ring buffer is recorded without regard to the
// read/write pointers. Make sense of the file by editing it in
// Audacity
// todo: write the file in correct time order using rd/wr pointers
FILE *fid;
fid = fopen("recorded.raw", "wb");
if( fid == NULL )
{
//printf("Could not open file.");
}
else
{
fwrite( data.recordedSamples, NUM_CHANNELS * sizeof(SAMPLE),
totalFrames, fid );
fclose( fid );
//printf("Wrote data to 'recorded.raw'\n");
}
}
#endif
// initial state after recording
// all future state changes from within state machine
if(buttonHold == FALSE)
{
// ******************************************
doState(S_REWIND_10, (void*) NULL);
// ******************************************
}
else
{
// ******************************************
doState(S_REWIND_PLAYBACK, (void*) NULL);
// ******************************************
}
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
while (1)
{
// advance state in the state machine
// ******************************************
doState(currentSTATE, (void*) NULL);
// ******************************************
Pa_Sleep(100);
if(terminate != FALSE)
goto done;
}
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
done:
Pa_Terminate();
if( data.recordedSamples ) // Sure it is NULL or valid.
free( data.recordedSamples );
if( err != paNoError )
{
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 ) );
fatalError();
err = 1; // Always return 0 or 1, but no other return codes.
}
return err;
}
开发者ID:bobh,项目名称:ILooperPiZero,代码行数:101,代码来源:LoopRecord.c
示例6: main
int main(void)
{
char pad[256];
PortAudioStream *stream;
PaError err;
const PaDeviceInfo *pdi;
paTestData data = {0};
printf("PortAudio Test: output sine wave on each channel.\n" );
err = Pa_Initialize();
if( err != paNoError ) goto error;
pdi = Pa_GetDeviceInfo( OUTPUT_DEVICE );
data.numChannels = pdi->maxOutputChannels;
if( data.numChannels > MAX_CHANNELS ) data.numChannels = MAX_CHANNELS;
printf("Number of Channels = %d\n", data.numChannels );
data.amplitude = 1.0;
err = Pa_OpenStream(
&stream,
paNoDevice, /* default input device */
0, /* no input */
paFloat32, /* 32 bit floating point input */
NULL,
OUTPUT_DEVICE,
data.numChannels,
paFloat32, /* 32 bit floating point output */
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 */
patestCallback,
&data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
do
{
printf("Current amplitude = %f\n", data.amplitude );
printf("Enter new amplitude or 'q' to quit.\n");
fflush(stdout);
gets( pad );
if( pad[0] != 'q' )
{
// I tried to use atof but it seems to be broken on Mac OS X 10.1
float amp;
sscanf( pad, "%f", & );
data.amplitude = amp;
}
} while( pad[0] != 'q' );
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
Pa_CloseStream( stream );
Pa_Terminate();
printf("Test finished.\n");
return err;
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 err;
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:68,代码来源:debug_sine_amp.c
示例7: Init
s32 Init()
{
started=false;
stream=NULL;
ReadSettings();
PaError err = Pa_Initialize();
if( err != paNoError )
{
fprintf(stderr,"* SPU2-X: PortAudio error: %s\n", Pa_GetErrorText( err ) );
return -1;
}
started=true;
int deviceIndex = -1;
fprintf(stderr,"* SPU2-X: Enumerating PortAudio devices:");
for(int i=0;i<Pa_GetDeviceCount();i++)
{
const PaDeviceInfo * info = Pa_GetDeviceInfo(i);
const PaHostApiInfo * apiinfo = Pa_GetHostApiInfo(info->hostApi);
fprintf(stderr," *** Device %d: '%s' (%s)", i, info->name, apiinfo->name);
if(apiinfo->type == m_ApiId)
{
static wchar_t buffer [1000];
mbstowcs(buffer,info->name,1000);
buffer[999]=0;
if(m_Device == buffer)
{
deviceIndex = i;
fprintf(stderr," (selected)");
}
}
fprintf(stderr,"\n");
}
if(deviceIndex<0 && m_ApiId>=0)
{
for(int i=0;i<Pa_GetHostApiCount();i++)
{
const PaHostApiInfo * apiinfo = Pa_GetHostApiInfo(i);
if(apiinfo->type == m_ApiId)
{
deviceIndex = apiinfo->defaultOutputDevice;
}
}
}
if(deviceIndex>=0)
{
void* infoPtr = NULL;
#ifdef __WIN32__
PaWasapiStreamInfo info = {
sizeof(PaWasapiStreamInfo),
paWASAPI,
1,
paWinWasapiExclusive
};
if((m_ApiId == paWASAPI) && m_WasapiExclusiveMode)
{
// Pass it the Exclusive mode enable flag
infoPtr = &info;
}
#endif
PaStreamParameters outParams = {
// PaDeviceIndex device;
// int channelCount;
// PaSampleFormat sampleFormat;
// PaTime suggestedLatency;
// void *hostApiSpecificStreamInfo;
deviceIndex,
2,
paInt32,
0.2f,
infoPtr
};
err = Pa_OpenStream(&stream,
NULL, &outParams, SampleRate,
SndOutPacketSize,
paNoFlag,
#ifndef __LINUX__
PaCallback,
#else
PaLinuxCallback,
#endif
NULL);
}
else
{
//.........这里部分代码省略.........
开发者ID:madnessw,项目名称:thesnow,代码行数:101,代码来源:SndOut_Portaudio.cpp
示例8: main
int main(void)
{
PaStream *stream;
PaStreamParameters outputParameters;
PaError err;
paTestData data;
int i;
printf("Play different tone sine waves that alternate between left and right channel.\n");
printf("The low tone should be on the left channel.\n");
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
data.left_phase = data.right_phase = 0;
data.currentBalance = 0.0;
data.targetBalance = 0.0;
err = Pa_Initialize();
if( err != paNoError ) goto error;
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
err = Pa_OpenStream( &stream,
NULL, /* No input. */
&outputParameters, /* As above. */
SAMPLE_RATE,
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
&data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
printf("Play for several seconds.\n");
for( i=0; i<4; i++ )
{
printf("Hear low sound on left side.\n");
data.targetBalance = 0.01;
Pa_Sleep( 1000 );
printf("Hear high sound on right side.\n");
data.targetBalance = 0.99;
Pa_Sleep( 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 err;
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 err;
}
开发者ID:AntiMoron,项目名称:portaudio,代码行数:71,代码来源:patest_leftright.c
示例9: main
int main(void)
{
PaStreamParameters outputParameters;
PaStream *stream;
PaError err;
paTestData data;
#ifdef __APPLE__
PaMacCoreStreamInfo macInfo;
const SInt32 channelMap[4] = { -1, -1, 0, 1 };
#endif
int i;
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
printf("Output will be mapped to channels 2 and 3 instead of 0 and 1.\n");
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
data.left_phase = data.right_phase = 0;
err = Pa_Initialize();
if( err != paNoError ) goto error;
/** setup host specific info */
#ifdef __APPLE__
PaMacCore_SetupStreamInfo( &macInfo, paMacCorePlayNice );
PaMacCore_SetupChannelMap( &macInfo, channelMap, 4 );
for( i=0; i<4; ++i )
printf( "channel %d name: %s\n", i, PaMacCore_GetChannelName( Pa_GetDefaultOutputDevice(), i, false ) );
#else
printf( "Channel mapping not supported on this platform. Reverting to normal sine test.\n" );
#endif
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
#ifdef __APPLE__
outputParameters.hostApiSpecificStreamInfo = &macInfo;
#else
outputParameters.hostApiSpecificStreamInfo = NULL;
#endif
err = Pa_OpenStream(
&stream,
NULL, /* no input */
&outputParameters,
SAMPLE_RATE,
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
&data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
printf("Play for %d seconds.\n", NUM_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 err;
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 err;
}
开发者ID:NewCell,项目名称:Call-Text-v1,代码行数:85,代码来源:patest_sine_channelmaps.c
示例10: pa_open_capture
static ALCenum pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
PaStreamParameters inParams;
ALuint frame_size;
pa_data *data;
PaError err;
if(!deviceName)
deviceName = pa_device;
else if(strcmp(deviceName, pa_device) != 0)
return ALC_INVALID_VALUE;
data = (pa_data*)calloc(1, sizeof(pa_data));
if(data == NULL)
return ALC_OUT_OF_MEMORY;
frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
data->ring = CreateRingBuffer(frame_size, device->UpdateSize*device->NumUpdates);
if(data->ring == NULL)
goto error;
inParams.device = -1;
if(!ConfigValueInt("port", "capture", &inParams.device) || inParams.device < 0)
inParams.device = Pa_GetDefaultOutputDevice();
inParams.suggestedLatency = 0.0f;
inParams.hostApiSpecificStreamInfo = NULL;
switch(device->FmtType)
{
case DevFmtByte:
inParams.sampleFormat = paInt8;
break;
case DevFmtUByte:
inParams.sampleFormat = paUInt8;
break;
case DevFmtShort:
inParams.sampleFormat = paInt16;
break;
case DevFmtFloat:
inParams.sampleFormat = paFloat32;
break;
case DevFmtUShort:
ERR("Unsigned short samples not supported\n");
goto error;
}
inParams.channelCount = ChannelsFromDevFmt(device->FmtChans);
err = Pa_OpenStream(&data->stream, &inParams, NULL, device->Frequency,
paFramesPerBufferUnspecified, paNoFlag, pa_capture_cb, device);
if(err != paNoError)
{
ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err));
goto error;
}
device->szDeviceName = strdup(deviceName);
device->ExtraData = data;
return ALC_NO_ERROR;
error:
DestroyRingBuffer(data->ring);
free(data);
return ALC_INVALID_VALUE;
}
开发者ID:GlenDC,项目名称:love-native-android,代码行数:65,代码来源:portaudio.c
示例11: main
//.........这里部分代码省略.........
while( Pa_StreamActive( stream ) )
{
Pa_Sleep(1000);
printf("index = %d\n", data.frameIndex ); fflush(stdout);
}
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
/* Measure maximum peak amplitude. */
max = 0;
average = 0;
for( i=0; i<numSamples; i++ )
{
val = data.recordedSamples[i];
if( val < 0 ) val = -val; /* ABS */
if( val > max )
{
max = val;
}
average += val;
}
average = average / numSamples;
if( PA_SAMPLE_TYPE == paFloat32 ) /* This should be done at compile-time with "#if" ?? */
{ /* MIPS-compiler warns at the int-version below. */
printf("sample max amplitude = %f\n", max );
printf("sample average = %f\n", average );
}
else
{
printf("sample max amplitude = %d\n", max ); /* <-- This IS compiled anyhow. */
printf("sample average = %d\n", average );
}
/* Write recorded data to a file. */
#if 0
{
FILE *fid;
fid = fopen("recorded.raw", "wb");
if( fid == NULL )
{
printf("Could not open file.");
}
else
{
fwrite( data.recordedSamples, NUM_CHANNELS * sizeof(SAMPLE), totalFrames, fid );
fclose( fid );
printf("Wrote data to 'recorded.raw'\n");
}
}
#endif
/* Playback recorded data. -------------------------------------------- */
data.frameIndex = 0;
printf("Begin playback.\n"); fflush(stdout);
err = Pa_OpenStream(
&stream,
paNoDevice,
0, /* NO input */
PA_SAMPLE_TYPE,
NULL,
Pa_GetDefaultOutputDeviceID(),
NUM_CHANNELS,
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,
&data );
if( err != paNoError ) goto error;
if( stream )
{
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
printf("Waiting for playback to finish.\n"); fflush(stdout);
while( Pa_StreamActive( stream ) ) Pa_Sleep(100);
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
printf("Done.\n"); fflush(stdout);
}
free( data.recordedSamples );
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:vinay,项目名称:Transcend,代码行数:101,代码来源:patest_record.c
示例12: pa_open_playback
static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
PaStreamParameters outParams;
pa_data *data;
PaError err;
if(!deviceName)
deviceName = pa_device;
else if(strcmp(deviceName, pa_device) != 0)
return ALC_INVALID_VALUE;
data = (pa_data*)calloc(1, sizeof(pa_data));
data->update_size = device->UpdateSize;
device->ExtraData = data;
outParams.device = -1;
if(!ConfigValueInt("port", "device", &outParams.device) || outParams.device < 0)
outParams.device = Pa_GetDefaultOutputDevice();
outParams.suggestedLatency = (device->UpdateSize*device->NumUpdates) /
(float)device->Frequency;
outParams.hostApiSpecificStreamInfo = NULL;
switch(device->FmtType)
{
case DevFmtByte:
outParams.sampleFormat = paInt8;
break;
case DevFmtUByte:
outParams.sampleFormat = paUInt8;
break;
case DevFmtUShort:
device->FmtType = DevFmtShort;
/* fall-through */
case DevFmtShort:
outParams.sampleFormat = paInt16;
break;
case DevFmtFloat:
outParams.sampleFormat = paFloat32;
break;
}
outParams.channelCount = ((device->FmtChans == DevFmtMono) ? 1 : 2);
SetDefaultChannelOrder(device);
err = Pa_OpenStream(&data->stream, NULL, &outParams, device->Frequency,
device->UpdateSize, paNoFlag, pa_callback, device);
if(err != paNoError)
{
ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err));
device->ExtraData = NULL;
free(data);
return ALC_INVALID_VALUE;
}
device->szDeviceName = strdup(deviceName);
if((ALuint)outParams.channelCount != ChannelsFromDevFmt(device->FmtChans))
{
if(outParams.channelCount != 1 && outParams.channelCount != 2)
{
ERR("Unhandled channel count: %u\n", outParams.channelCount);
Pa_CloseStream(data->stream);
device->ExtraData = NULL;
free(data);
return ALC_INVALID_VALUE;
}
if((device->Flags&DEVICE_CHANNELS_REQUEST))
ERR("Failed to set %s, got %u channels instead\n", DevFmtChannelsString(device->FmtChans), outParams.channelCount);
device->Flags &= ~DEVICE_CHANNELS_REQUEST;
device->FmtChans = ((outParams.channelCount==1) ? DevFmtMono : DevFmtStereo);
}
return ALC_NO_ERROR;
}
开发者ID:GlenDC,项目名称:love-native-android,代码行数:75,代码来源:portaudio.c
示例13: Java_com_github_rjeschke_jpa_JPA_paGetErrorText
JNIEXPORT jstring JNICALL Java_com_github_rjeschke_jpa_JPA_paGetErrorText(JNIEnv *env, jclass clazz, jint error)
{
return makeString(env, (char*)Pa_GetErrorText((PaError)error));
}
开发者ID:rjeschke,项目名称:jpa,代码行数:4,代码来源:jpa.c
示例14: PORTAUDIOThread
/*****************************************************************************
* PORTAUDIOThread: all interactions with libportaudio.a are handled
* in this single thread. Otherwise libportaudio.a is _not_ happy :-(
*****************************************************************************/
static void* PORTAUDIOThread( vlc_object_t *p_this )
{
pa_thread_t *pa_thread = (pa_thread_t*)p_this;
aout_instance_t *p_aout;
aout_sys_t *p_sys;
int i_err;
int canc = vlc_savecancel ();
while( vlc_object_alive (pa_thread) )
{
/* Wait for start of stream */
vlc_mutex_lock( &pa_thread->lock_signal );
if( !pa_thread->b_signal )
vlc_cond_wait( &pa_thread->signal, &pa_thread->lock_signal );
vlc_mutex_unlock( &pa_thread->lock_signal );
pa_thread->b_signal = false;
p_aout = pa_thread->p_aout;
p_sys = p_aout->output.p_sys;
if( PAOpenDevice( p_aout ) != VLC_SUCCESS )
{
msg_Err( p_aout, "cannot open portaudio device" );
pa_thread->b_error = true;
}
if( !pa_thread->b_error && PAOpenStream( p_aout ) != VLC_SUCCESS )
{
msg_Err( p_aout, "cannot open portaudio device" );
pa_thread->b_error = true;
i_err = Pa_Terminate();
if( i_err != paNoError )
{
msg_Err( p_aout, "Pa_Terminate: %d (%s)", i_err,
Pa_GetErrorText( i_err ) );
}
}
/* Tell the main thread that we are ready */
vlc_mutex_lock( &pa_thread->lock_wait );
pa_thread->b_wait = true;
vlc_cond_signal( &pa_thread->wait );
vlc_mutex_unlock( &pa_thread->lock_wait );
/* Wait for end of stream */
vlc_mutex_lock( &pa_thread->lock_signal );
if( !pa_thread->b_signal )
vlc_cond_wait( &pa_thread->signal, &pa_thread->lock_signal );
vlc_mutex_unlock( &pa_thread->lock_signal );
pa_thread->b_signal = false;
if( pa_thread->b_error ) continue;
i_err = Pa_StopStream( p_sys->p_stream );
if( i_err != paNoError )
{
msg_Err( p_aout, "Pa_StopStream: %d (%s)", i_err,
Pa_GetErrorText( i_err ) );
}
i_err = Pa_CloseStream( p_sys->p_stream );
if( i_err != paNoError )
{
msg_Err( p_aout, "Pa_CloseStream: %d (%s)", i_err,
Pa_GetErrorText( i_err ) );
}
i_err = Pa_Terminate();
if( i_err != paNoError )
{
msg_Err( p_aout, "Pa_Terminate: %d (%s)", i_err,
Pa_GetErrorText( i_err ) );
}
/* Tell the main thread that we are ready */
vlc_mutex_lock( &pa_thread->lock_wait );
pa_thread->b_wait = true;
vlc_cond_signal( &pa_thread->wait );
vlc_mutex_unlock( &pa_thread->lock_wait );
}
vlc_restorecancel (canc);
return NULL;
}
开发者ID:Kafay,项目名称:vlc,代码行数:86,代码来源:portaudio.c
示例15: main
int main(int argc, char *argv[])
{
QString cfg_file;
std::string conf;
std::string style;
bool clierr = false;
bool edit_conf = false;
int return_code;
QApplication app(argc, argv);
QCoreApplication::setOrganizationName(GQRX_ORG_NAME);
QCoreApplication::setOrganizationDomain(GQRX_ORG_DOMAIN);
QCoreApplication::setApplicationName(GQRX_APP_NAME);
QCoreApplication::setApplicationVersion(VERSION);
// setup controlport via environment variables
// see http://lists.gnu.org/archive/html/discuss-gnuradio/2013-05/msg00270.html
// Note: tried using gr::prefs().save() but that doesn't have effect until the next time
if (qputenv("GR_CONF_CONTROLPORT_ON", "False"))
qDebug() << "Controlport disabled";
else
qDebug() << "Failed to disable controlport";
// setup the program options
po::options_description desc("Command line options");
desc.add_options()
("help,h", "This help message")
("style,s", po::value<std::string>(&style), "Use the give style (fusion, windows)")
("list,l", "List existing configurations")
("conf,c", po::value<std::string>(&conf), "Start with this config file")
("edit,e", "Edit the config file before using it")
("reset,r", "Reset configuration file")
;
po::variables_map vm;
try
{
po::store(po::parse_command_line(argc, argv, desc), vm);
}
catch(const boost::program_options::invalid_command_line_syntax& ex)
{
/* happens if e.g. -c without file name */
clierr = true;
}
catch(const boost::program_options::unknown_option& ex)
{
/* happens if e.g. -c without file name */
clierr = true;
}
po::notify(vm);
// print the help message
if (vm.count("help") || clierr)
{
std::cout << "Gqrx software defined radio receiver " << VERSION << std::endl;
std::cout << desc << std::endl;
return 1;
}
if (vm.count("style"))
QApplication::setStyle(QString::fromStdString(style));
if (vm.count("list"))
{
list_conf();
return 0;
}
// check whether audio backend is functional
#ifdef WITH_PORTAUDIO
PaError err = Pa_Initialize();
if (err != paNoError)
{
QString message = QString("Portaudio error: %1").arg(Pa_GetErrorText(err));
qCritical() << message;
QMessageBox::critical(0, "Audio Error", message,
QMessageBox::Abort, QMessageBox::NoButton);
return 1;
}
#endif
#ifdef WITH_PULSEAUDIO
int error = 0;
pa_simple *test_sink;
pa_sample_spec ss;
ss.format = PA_SAMPLE_FLOAT32LE;
ss.rate = 48000;
ss.channels = 2;
test_sink = pa_simple_new(NULL, "Gqrx Test", PA_STREAM_PLAYBACK, NULL,
"Test stream", &ss, NULL, NULL, &error);
if (!test_sink)
{
QString message = QString("Pulseaudio error: %1").arg(pa_strerror(error));
qCritical() << message;
QMessageBox::critical(0, "Audio Error", message,
QMessageBox::Abort, QMessageBox::NoButton);
return 1;
}
//.........这里部分代码省略.........
开发者ID:Cat-Ion,项目名称:gqrx,代码行数:101,代码来源:main.cpp
示例16: main
int main(int argc, char** argv)
{
struct sockaddr_in server;
int chan;
PaStream *stream;
PaStreamParameters output_parameters;
PaError err;
voice = NULL;
srand(time(NULL));
atexit(at_exit);
set_signal_handlers();
init();
if (argc != 4)
return usage(argv[0]);
set_output_parameters(&output_parameters, atoi(argv[3]));
/* connect to server */
sock = udp_create_socket(&server, sizeof(server), inet_addr(argv[1]), atoi(argv[2]), WAIT_FOR_RECEIVE);
if (sock < 0)
error_and_exit("Cannot create socket", __FILE__, __LINE__);
/* create speech thingies */
si.w = malloc(sizeof(cst_wave) * si.channel_count);
si.pos = malloc(sizeof(long) * si.channel_count);
si.done = malloc(sizeof(int) * si.channel_count);
si.cur_delay = malloc(sizeof(double) * si.channel_count);
si.rate_delay = malloc(sizeof(double) * si.channel_count);
for (chan = 0; chan < si.channel_count; ++chan) {
si.w[chan] = NULL;
next_tweet(&server, chan);
}
err = Pa_OpenStream(&stream, NULL, &output_parameters,
44100., 0, paNoFlag, say_text_callback, &si);
if (paNoError != err) {
fprintf(stderr, "Cannot open stream: %s\n", Pa_GetErrorText(err));
exit(-1);
}
/* Pa_OpenDefaultStream(&stream, 0, si.channel_count, paInt16,
si.w->sample_rate, 0, say_text_callback, &si); */
err = Pa_StartStream(stream);
if (paNoError != err) {
fprintf(stderr, "Cannot start stream: %s\n", Pa_GetErrorText(err));
exit(-1);
}
while (1)
{
usleep(100);
for (chan = 0; chan < si.channel_count; ++chan)
{
if (si.done[chan])
next_tweet(&server, chan);
}
}
//Pa_StopStream(stream);
return 0;
}
开发者ID:vrld,项目名称:twat,代码行数:62,代码来源:twatc.c
示例17: main
//.........这里部分代码省略.........
}
if( i == Pa_GetDefaultOutputDevice() )
{
printf( (defaultDisplayed ? "," : "[") );
printf( " Default Output" );
defaultDisplayed = 1;
}
else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultOutputDevice )
{
const PaHostApiInfo
|
请发表评论