/* This routine will be called by the PortAudio engine when audio is needed. ** It may called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). */ static int patestCallback( const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ) { paTestData *data = (paTestData*)userData; float *out = (float*)outputBuffer; unsigned long i; (void) timeInfo; /* Prevent unused variable warnings. */ (void) statusFlags; (void) inputBuffer; printf( "Timing info given to callback: Adc: %g, Current: %g, Dac: %g\n", timeInfo->inputBufferAdcTime, timeInfo->currentTime, timeInfo->outputBufferDacTime ); printf( "getStreamTime() returns: %g\n", Pa_GetStreamTime(data->stream) - data->start ); for( i=0; i<framesPerBuffer; i++ ) { *out++ = data->sine[data->left_phase]; /* left */ *out++ = data->sine[data->right_phase]; /* right */ data->left_phase += 1; if( data->left_phase >= TABLE_SIZE ) data->left_phase -= TABLE_SIZE; data->right_phase += 3; /* higher pitch so we can distinguish left and right. */ if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE; } return paContinue; }
// starts recording to a file as defined by the class parameters int PortAudioSound::StartRecord() { if (!recordflag){ startRecording = TRUE; recordedBlocks = 0L; stopTime = -1.0; sfinfo.channels = 1; sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; sfinfo.frames = framesPerBuffer; sfinfo.samplerate = iSampleRate; timeStr = ""; outfile = sf_open("c:/bat recordings/testfile.wav", SFM_WRITE, &sfinfo); if (outfile == NULL){ int err = sf_error(NULL); const char *errstr = sf_error_number(err); logFile.WriteString((LPCWSTR) errstr); } logFile.WriteString(L"Recording started\n"); startTime = (double) Pa_GetStreamTime(pStream); recordflag = true; } return(0); }
std::vector<short> AudioInput::record(unsigned msecs) { if (!stream) return std::vector<short>(); std::cout << "AudioInput::record(" << msecs << ")\n"; PaTime startTime = Pa_GetStreamTime(stream); std::vector<short> samples; while (Pa_GetStreamTime(stream) < startTime + msecs * .001) { samples.resize(samples.size() + CHUNK_SIZE); PaError err = Pa_ReadStream(stream, &samples[samples.size() - CHUNK_SIZE], CHUNK_SIZE); if (err != paInputOverflowed && err != paNoError) { std::cerr << "Pa_ReadStream(): " << Pa_GetErrorText(err) << '\n'; return samples; } } std::cout << "Recorded " << (Pa_GetStreamTime(stream) - startTime) << "s worth of audio\n"; return samples; }
static void ReportStreamTime( PaStream *stream, paTestData *data ) { PaTime streamTime, latency, outTime; streamTime = Pa_GetStreamTime( stream ); outTime = data->outTime; if( outTime < 0.0 ) { printf("Stream time = %8.1f\n", streamTime ); } else { latency = outTime - streamTime; printf("Stream time = %8.4f, outTime = %8.4f, latency = %8.4f\n", streamTime, outTime, latency ); } fflush(stdout); }
/*-----------------------------------------------------------------------------------------*/ 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; }
// stops recording to the file and closes it with appropriate log entries int PortAudioSound::StopRecord() { if (recordflag){ recordflag = false; startRecording = FALSE; stopTime = (double) Pa_GetStreamTime(pStream); sf_close(outfile); CString str; str.Format(L"Min=%f, Max=%f after recording %ld blocks \n", mini, maxi,recordedBlocks); logFile.WriteString(str); str.Format(L"Duration of recording= %f to %f = %f seconds\n",(double)startTime,(double)stopTime, (double)stopTime - (double)startTime); logFile.WriteString(str); logFile.WriteString(L"Recording stopped\n\n"); logFile.WriteString(timeStr); Pa_Sleep(2000); } return 0; }
double AudioIOData::time() const { return Pa_GetStreamTime(mImpl->mStream); }
int AudioDevice_streamTime(AudioDevice *self) { return AudioDevice_isOpen(self) ? Pa_GetStreamTime( self->stream ) : 0; }
int PortAudioSound::myMemberCallback(const void * input, void * output, unsigned long frameCount, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags) { if (!Processing){ Processing = TRUE; double t = Pa_GetStreamTime(pStream); short *rdr = (short *) input; CString tstr; /* if (startRecording){ startRecording = FALSE; startTime = (double)timeInfo->inputBufferAdcTime; }*/ if (recordflag){ int written = (int) sf_writef_short(outfile, rdr, (sf_count_t) frameCount); recordedBlocks++; tstr.Format(L"%f\n", t); timeStr = timeStr + tstr; //stopTime = (double)timeInfo->inputBufferAdcTime; } int pos = 0; int DisplayFramesPerBuffer; if (overlap){ DisplayFramesPerBuffer = (FFTsPerBuffer * 2) - 1; } else{ DisplayFramesPerBuffer = FFTsPerBuffer; } for (int i = 0; i < (FFTsPerBuffer*2)-1; i++){ for (int j = 0; j < FFTSize && pos < framesPerBuffer; j++, pos++){ FFTin[j] = hamming[j] * (double) rdr[pos]; } if (overlap){// only move the read pointer back for overlap pos = pos - FFTSize / 2; } fftw_execute(FFTplan); WriteIndex = (WriteIndex + 1)%numBuffers; if (WriteIndex == ReadIndex) ReadIndex = (++ReadIndex%numBuffers); //ppPowSpect[WriteIndex][0] = 0.0; ppShade[WriteIndex][0] = 0; for (int j = 0; j < FFTSize/2; j++){ //ppPowSpect[WriteIndex][j + 1] = log10(FFTout[j]); //ppPowSpect[WriteIndex][j + 1] = (FFTout[j] * FFTout[j]) /2000000.0; //ppPowSpect[WriteIndex][j + 1] = log10(.000001 + abs(FFTout[j])); ppShade[WriteIndex][j + 1] = 255-(BYTE) (((log10(.000001 + abs(FFTout[j]))+6)/6)*255); } //ppPowSpect[WriteIndex][0] = 1.0; ppShade[WriteIndex][0] = 1; } //displayWindow.PostMessageW(WM_USER, (WPARAM) WriteIndex); //SendMessage(); PostMessage(ChildWindowHwnd, WM_USER, 0, 0L); Processing = FALSE; } else{ logFile.WriteString(L"*"); } return paContinue; }
double GetStreamTime() { return Pa_GetStreamTime(Stream); }
int main(void) { PaStreamParameters outputParameters; PaStream* stream; PaError err; paTestData data; PaTime streamOpened; int i, totalSamps; #if TEST_UNSIGNED printf("PortAudio Test: output UNsigned 8 bit sine wave.\n"); #else printf("PortAudio Test: output signed 8 bit sine wave.\n"); #endif /* initialise sinusoidal wavetable */ for( i=0; i<TABLE_SIZE; i++ ) { data.sine[i] = (char) (127.0 * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. )); #if TEST_UNSIGNED data.sine[i] += (unsigned char) 0x80; #endif } data.left_phase = data.right_phase = 0; data.framesToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */ 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 = TEST_FORMAT; outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; err = Pa_OpenStream( &stream, NULL, /* No input. */ &outputParameters, SAMPLE_RATE, 256, /* 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; streamOpened = Pa_GetStreamTime( stream ); /* Time in seconds when stream was opened (approx). */ err = Pa_StartStream( stream ); if( err != paNoError ) goto error; /* Watch until sound is halfway finished. */ /* (Was ( Pa_StreamTime( stream ) < (totalSamps/2) ) in V18. */ while( (Pa_GetStreamTime( stream ) - streamOpened) < (PaTime)NUM_SECONDS / 2.0 ) Pa_Sleep(10); /* Stop sound. */ printf("Stopping Stream.\n"); err = Pa_StopStream( stream ); if( err != paNoError ) goto error; printf("Pause for 2 seconds.\n"); Pa_Sleep( 2000 ); printf("Starting again.\n"); err = Pa_StartStream( stream ); if( err != paNoError ) goto error; printf("Waiting for sound to finish.\n"); while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) Pa_Sleep(100); if( err < 0 ) 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; }
static int init(struct ao *ao) { struct priv *priv = ao->priv; if (!check_pa_ret(Pa_Initialize())) return -1; pthread_mutex_init(&priv->ring_mutex, NULL); int pa_device = Pa_GetDefaultOutputDevice(); if (priv->cfg_device && priv->cfg_device[0]) pa_device = find_device(priv->cfg_device); if (pa_device == paNoDevice) goto error_exit; // The actual channel order probably depends on the platform. struct mp_chmap_sel sel = {0}; mp_chmap_sel_add_waveext_def(&sel); if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) goto error_exit; PaStreamParameters sp = { .device = pa_device, .channelCount = ao->channels.num, .suggestedLatency = Pa_GetDeviceInfo(pa_device)->defaultHighOutputLatency, }; ao->format = af_fmt_from_planar(ao->format); const struct format_map *fmt = format_maps; while (fmt->pa_format) { if (fmt->mp_format == ao->format) { PaStreamParameters test = sp; test.sampleFormat = fmt->pa_format; if (Pa_IsFormatSupported(NULL, &test, ao->samplerate) == paNoError) break; } fmt++; } if (!fmt->pa_format) { MP_VERBOSE(ao, "Unsupported format, using default.\n"); fmt = format_maps; } ao->format = fmt->mp_format; sp.sampleFormat = fmt->pa_format; priv->framelen = ao->channels.num * (af_fmt2bits(ao->format) / 8); ao->bps = ao->samplerate * priv->framelen; if (!check_pa_ret(Pa_IsFormatSupported(NULL, &sp, ao->samplerate))) goto error_exit; if (!check_pa_ret(Pa_OpenStream(&priv->stream, NULL, &sp, ao->samplerate, paFramesPerBufferUnspecified, paNoFlag, stream_callback, ao))) goto error_exit; priv->ring = mp_ring_new(priv, seconds_to_bytes(ao, 0.5)); return 0; error_exit: uninit(ao, true); return -1; } static int play(struct ao *ao, void **data, int samples, int flags) { struct priv *priv = ao->priv; pthread_mutex_lock(&priv->ring_mutex); int write_len = mp_ring_write(priv->ring, data[0], samples * ao->sstride); if (flags & AOPLAY_FINAL_CHUNK) priv->play_remaining = true; pthread_mutex_unlock(&priv->ring_mutex); if (Pa_IsStreamStopped(priv->stream) == 1) check_pa_ret(Pa_StartStream(priv->stream)); return write_len / ao->sstride; } static int get_space(struct ao *ao) { struct priv *priv = ao->priv; pthread_mutex_lock(&priv->ring_mutex); int free = mp_ring_available(priv->ring); pthread_mutex_unlock(&priv->ring_mutex); return free / ao->sstride; } static float get_delay(struct ao *ao) { struct priv *priv = ao->priv; double stream_time = Pa_GetStreamTime(priv->stream); pthread_mutex_lock(&priv->ring_mutex); float frame_time = priv->play_time ? priv->play_time - stream_time : 0; float buffer_latency = (mp_ring_buffered(priv->ring) + priv->play_silence) / (float)ao->bps; pthread_mutex_unlock(&priv->ring_mutex); return buffer_latency + frame_time; } static void reset(struct ao *ao) { struct priv *priv = ao->priv; if (Pa_IsStreamStopped(priv->stream) != 1) check_pa_ret(Pa_AbortStream(priv->stream)); pthread_mutex_lock(&priv->ring_mutex); mp_ring_reset(priv->ring); priv->play_remaining = false; priv->play_time = 0; priv->play_silence = 0; pthread_mutex_unlock(&priv->ring_mutex); } static void pause(struct ao *ao) { struct priv *priv = ao->priv; check_pa_ret(Pa_AbortStream(priv->stream)); double stream_time = Pa_GetStreamTime(priv->stream); pthread_mutex_lock(&priv->ring_mutex); // When playback resumes, replace the lost audio (due to dropping the // portaudio/driver/hardware internal buffers) with silence. float frame_time = priv->play_time ? priv->play_time - stream_time : 0; priv->play_silence += seconds_to_bytes(ao, FFMAX(frame_time, 0)); priv->play_time = 0; pthread_mutex_unlock(&priv->ring_mutex); } static void resume(struct ao *ao) { struct priv *priv = ao->priv; check_pa_ret(Pa_StartStream(priv->stream)); } #define OPT_BASE_STRUCT struct priv const struct ao_driver audio_out_portaudio = { .description = "PortAudio", .name = "portaudio", .init = init, .uninit = uninit, .reset = reset, .get_space = get_space, .play = play, .get_delay = get_delay, .pause = pause, .resume = resume, .priv_size = sizeof(struct priv), .options = (const struct m_option[]) { OPT_STRING_VALIDATE("device", cfg_device, 0, validate_device_opt), {0} }, };
_JATTA_EXPORT double Jatta::PortAudio::Stream::GetTime() { return (double)Pa_GetStreamTime(stream); }
JNIEXPORT jdouble JNICALL Java_org_jpab_PortAudio_getStreamTime(JNIEnv *env, jclass paClass, jlong stream_id) { return Pa_GetStreamTime((PaStream *) stream_id); }
int main(void) { PaStreamParameters outputParameters; PaStream *stream; PaError err; paTestData data; int i; printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER); /* 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; outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ 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, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff, /* we won't output out of range samples so don't bother clipping them */ patestCallback, &data ); data.stream = stream; data.start = Pa_GetStreamTime(stream); if( err != paNoError ) goto error; err = Pa_StartStream( stream ); data.start = Pa_GetStreamTime(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"); printf("The tone should have been heard for about 5 seconds and all the timing info above should report that about 5 seconds elapsed (except Adc, which is undefined since there was no input device opened).\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; }
int main(void) { PaStreamParameters outputParameters; PaStream *stream; PaError err; paTestData data; PaTime startTime; printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER); data.left_phase = data.right_phase = 0; err = Pa_Initialize(); if( err != paNoError ) goto error; outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ 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, 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; /* Watch until sound is halfway finished. */ printf("Play for %d seconds.\n", NUM_SECONDS/2 ); fflush(stdout); data.outTime = -1.0; /* mark time for callback as undefined */ err = Pa_StartStream( stream ); if( err != paNoError ) goto error; startTime = Pa_GetStreamTime( stream ); do { ReportStreamTime( stream, &data ); Pa_Sleep(100); } while( (Pa_GetStreamTime( stream ) - startTime) < (NUM_SECONDS/2) ); /* Stop sound for 2 seconds. */ err = Pa_StopStream( stream ); if( err != paNoError ) goto error; printf("Pause for 2 seconds.\n"); fflush(stdout); Pa_Sleep( 2000 ); data.outTime = -1.0; /* mark time for callback as undefined */ err = Pa_StartStream( stream ); if( err != paNoError ) goto error; startTime = Pa_GetStreamTime( stream ); printf("Play until sound is finished.\n"); fflush(stdout); do { ReportStreamTime( stream, &data ); Pa_Sleep(100); } while( (Pa_GetStreamTime( stream ) - startTime) < (NUM_SECONDS/2) ); 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; }
_CGUL_EXPORT double CGUL::PortAudio::Stream::GetTime() { return (double)Pa_GetStreamTime(stream); }
static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate, int numChannels, PaSampleFormat format ) { PaStreamParameters inputParameters, outputParameters, *ipp, *opp; PaStream *stream = NULL; PaError result = paNoError; PaQaData myData; #define FRAMES_PER_BUFFER (64) /* Setup data for synthesis thread. */ myData.framesLeft = (unsigned long) (sampleRate * 100); /* 100 seconds */ myData.numChannels = numChannels; myData.mode = mode; myData.format = format; switch( format ) { case paFloat32: case paInt32: case paInt24: myData.bytesPerSample = 4; break; /* case paPackedInt24: myData.bytesPerSample = 3; break; */ default: myData.bytesPerSample = 2; break; } if( mode == MODE_INPUT ) { inputParameters.device = deviceID; inputParameters.channelCount = numChannels; inputParameters.sampleFormat = format; inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency; inputParameters.hostApiSpecificStreamInfo = NULL; ipp = &inputParameters; } else ipp = NULL; if( mode == MODE_OUTPUT ) /* Pa_GetDeviceInfo(paNoDevice) COREDUMPS!!! */ { outputParameters.device = deviceID; outputParameters.channelCount = numChannels; outputParameters.sampleFormat = format; outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; opp = &outputParameters; } else opp = NULL; if(paFormatIsSupported == Pa_IsFormatSupported( ipp, opp, sampleRate )) { printf("------ TestAdvance: %s, device = %d, rate = %g, numChannels = %d, format = %lu -------\n", ( mode == MODE_INPUT ) ? "INPUT" : "OUTPUT", deviceID, sampleRate, numChannels, (unsigned long)format); EXPECT( ((result = Pa_OpenStream( &stream, ipp, opp, sampleRate, FRAMES_PER_BUFFER, paClipOff, /* we won't output out of range samples so don't bother clipping them */ QaCallback, &myData ) ) == 0) ); if( stream ) { PaTime oldStamp, newStamp; unsigned long oldFrames; int minDelay = ( mode == MODE_INPUT ) ? 1000 : 400; /* Was: int minNumBuffers = Pa_GetMinNumBuffers( FRAMES_PER_BUFFER, sampleRate ); int msec = (int) ((minNumBuffers * 3 * 1000.0 * FRAMES_PER_BUFFER) / sampleRate); */ int msec = (int)( 3.0 * (( mode == MODE_INPUT ) ? inputParameters.suggestedLatency : outputParameters.suggestedLatency )); if( msec < minDelay ) msec = minDelay; printf("msec = %d\n", msec); /**/ EXPECT( ((result=Pa_StartStream( stream )) == 0) ); /* Check to make sure PortAudio is advancing timeStamp. */ oldStamp = Pa_GetStreamTime(stream); Pa_Sleep(msec); newStamp = Pa_GetStreamTime(stream); printf("oldStamp = %g,newStamp = %g\n", oldStamp, newStamp ); /**/ EXPECT( (oldStamp < newStamp) ); /* Check to make sure callback is decrementing framesLeft. */ oldFrames = myData.framesLeft; Pa_Sleep(msec); printf("oldFrames = %lu, myData.framesLeft = %lu\n", oldFrames, myData.framesLeft ); /**/ EXPECT( (oldFrames > myData.framesLeft) ); EXPECT( ((result=Pa_CloseStream( stream )) == 0) ); stream = NULL; } } error: if( stream != NULL ) Pa_CloseStream( stream ); return result; }
JNIEXPORT jdouble JNICALL Java_com_github_rjeschke_jpa_JPA_paGetStreamTime(JNIEnv *env, jclass clazz, jlong jPtr) { JPA_DATA *j = (JPA_DATA*)long2Ptr(jPtr); return (jdouble)Pa_GetStreamTime(j->stream); }