Pa_RefreshDevice functionality
This commit is contained in:
parent
16884fc201
commit
1f01a3ddc0
8 changed files with 337 additions and 2 deletions
|
|
@ -258,7 +258,6 @@ static int recordCallback( const void *inputBuffer, void *outputBuffer,
|
|||
|
||||
data->frameIndex += PaUtil_WriteRingBuffer(&data->ringBuffer, rptr, elementsToWrite);
|
||||
|
||||
return paContinue;
|
||||
}
|
||||
|
||||
/* This routine will be called by the PortAudio engine when audio is needed.
|
||||
|
|
@ -272,8 +271,11 @@ static int playCallback( const void *inputBuffer, void *outputBuffer,
|
|||
void *userData )
|
||||
{
|
||||
paTestData *data = (paTestData*)userData;
|
||||
|
||||
ring_buffer_size_t elementsToPlay = PaUtil_GetRingBufferReadAvailable(&data->ringBuffer);
|
||||
ring_buffer_size_t elementsToRead = rbs_min(elementsToPlay, (ring_buffer_size_t)(framesPerBuffer * NUM_CHANNELS));
|
||||
|
||||
ring_buffer_size_t elementsToRead = rbs_min( elementsToPlay,
|
||||
(ring_buffer_size_t)(framesPerBuffer * NUM_CHANNELS) );
|
||||
SAMPLE* wptr = (SAMPLE*)outputBuffer;
|
||||
|
||||
(void) inputBuffer; /* Prevent unused variable warnings. */
|
||||
|
|
|
|||
46
examples/paex_refresh_devs.c
Normal file
46
examples/paex_refresh_devs.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "portaudio.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
PaError err = paNoError;
|
||||
|
||||
PaDeviceIndex defaultOutputDevice;
|
||||
PaDeviceIndex defaultInputDevice;
|
||||
|
||||
err = Pa_Initialize();
|
||||
if( err != paNoError )
|
||||
{
|
||||
printf( "ERROR: Pa_Initialize returned 0x%x\n", err );
|
||||
goto error;
|
||||
}
|
||||
|
||||
printf( "PortAudio version: 0x%08X\n", Pa_GetVersion());
|
||||
// printf( "Version text: '%s'\n", Pa_GetVersionInfo()->versionText );
|
||||
|
||||
const int count = 20;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
defaultInputDevice = Pa_GetDefaultInputDevice();
|
||||
defaultOutputDevice = Pa_GetDefaultOutputDevice();
|
||||
printf("Input: %i, Output: %i\n", defaultInputDevice, defaultOutputDevice);
|
||||
|
||||
err = Pa_RefreshDevices();
|
||||
if( err != paNoError )
|
||||
{
|
||||
printf( "ERROR: Pa_RefreshDevices returned 0x%x\n", err );
|
||||
goto error;
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
Pa_Terminate();
|
||||
|
||||
printf("----------------------------------------------\n");
|
||||
return 0;
|
||||
error:
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -154,6 +154,7 @@ int main(void)
|
|||
if( err != paNoError ) goto error;
|
||||
|
||||
printf("Play for %d seconds.\n", NUM_SECONDS );
|
||||
|
||||
Pa_Sleep( NUM_SECONDS * 1000 );
|
||||
|
||||
err = Pa_StopStream( stream );
|
||||
|
|
|
|||
Loading…
Reference in a new issue