Skip to content

Commit

Permalink
Add PA ALSA extension to allow setting number of retries when busy
Browse files Browse the repository at this point in the history
  • Loading branch information
aknuds1 committed May 24, 2009
1 parent 6e6e3ac commit 822c292
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/pa_linux_alsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ PaError PaAlsa_GetStreamOutputCard( PaStream *s, int *card );
*/
PaError PaAlsa_SetNumPeriods( int numPeriods );

/** Set the maximum number of times to retry opening busy device (sleeping for a
* short interval inbetween).
*/
PaError PaAlsa_SetRetriesBusy( int retries );

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 8 additions & 1 deletion src/hostapi/alsa/pa_linux_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@

static int aErr_; /* Used with ENSURE_ */
static int numPeriods_ = 4;
static int busyRetries_ = 100;

int PaAlsa_SetNumPeriods( int numPeriods )
{
Expand Down Expand Up @@ -539,7 +540,7 @@ static int IgnorePlugin( const char *pluginId )
**/
static int OpenPcm( snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode, int waitOnBusy )
{
int tries = 0, maxTries = waitOnBusy ? 100 : 0;
int tries = 0, maxTries = waitOnBusy ? busyRetries_ : 0;
int ret = snd_pcm_open( pcmp, name, stream, mode );
for( tries = 0; tries < maxTries && -EBUSY == ret; ++tries )
{
Expand Down Expand Up @@ -3670,3 +3671,9 @@ PaError PaAlsa_GetStreamOutputCard(PaStream* s, int* card) {
error:
return result;
}

PaError PaAlsa_SetRetriesBusy( int retries )
{
busyRetries_ = retries;
return paNoError;
}

0 comments on commit 822c292

Please sign in to comment.