Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/pa_asio.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ PaError PaAsio_GetAvailableBufferSizes( PaDeviceIndex device,
long *minBufferSizeFrames, long *maxBufferSizeFrames, long *preferredBufferSizeFrames, long *granularity );


typedef void (*PaAsioResetRequestCallback)();

/** Register callback to detect reset requests.

This correponds to the ASIO kAsioResetRequest and kAsioBufferSizeChange
messages.

@param callback The function to call on ASIO reset request. This is called
when the driver's buffer size has changed or it needs a reset, usually in
response to a user changing the configuration. Call Pa_Terminate followed by
Pa_Initialize to have the changes reflected in Portaudio's API. Pass NULL to
unregister a callback.
*/
void PaAsio_RegisterResetRequestCallback( PaAsioResetRequestCallback callback );

/** Backwards compatibility alias for PaAsio_GetAvailableBufferSizes

@see PaAsio_GetAvailableBufferSizes
Expand Down
14 changes: 14 additions & 0 deletions src/hostapi/asio/pa_asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3199,6 +3199,13 @@ static void sampleRateChanged(ASIOSampleRate sRate)
PA_DEBUG( ("sampleRateChanged : %d \n", sRate));
}

static PaAsioResetRequestCallback resetRequestCallback_;

void PaAsio_RegisterResetRequestCallback( PaAsioResetRequestCallback callback )
{
resetRequestCallback_ = callback;
}

static long asioMessages(long selector, long value, void* message, double* opt)
{
// TAKEN FROM THE ASIO SDK
Expand Down Expand Up @@ -3226,6 +3233,10 @@ static long asioMessages(long selector, long value, void* message, double* opt)

case kAsioBufferSizeChange:
//printf("kAsioBufferSizeChange \n");
if (resetRequestCallback_) {
resetRequestCallback_();
ret = 1L;
}
break;

case kAsioResetRequest:
Expand All @@ -3240,6 +3251,9 @@ static long asioMessages(long selector, long value, void* message, double* opt)
http://www.portaudio.com/trac/ticket/108
*/
//asioDriverInfo.stopped; // In this sample the processing will just stop
if (resetRequestCallback_) {
resetRequestCallback_();
}
ret = 1L;
break;

Expand Down