Removes Werner modifications from portaudio-hotplug-os.patch.

cusax-fix
Sebastien Vincent 15 years ago
parent 1e451c6679
commit d2dd32a4bc

@ -459,18 +459,6 @@ Index: src/hostapi/alsa/pa_linux_alsa.c
PaUtil_InitializeStreamInterface( &alsaHostApi->callbackStreamInterface,
CloseStream, StartStream,
@@ -802,7 +829,10 @@
}
PaUtil_FreeMemory( alsaHostApi );
- alsa_snd_config_update_free_global();
+// damencho, removed fo compability with pulseaudio versions before 0.9.16
+// segfault application:
+// bugtrack alsa: 0002124: snd_config_update_free_global kills applications using user space alsa plugins
+// snd_config_update_free_global();
/* Close Alsa library. */
PaAlsa_CloseLibrary();
@@ -1075,7 +1105,7 @@
}
@ -574,71 +562,11 @@ Index: src/hostapi/alsa/pa_linux_alsa.c
#ifdef PA_ENABLE_DEBUG_OUTPUT
PA_DEBUG(( "%s: Building device list took %f seconds\n", __FUNCTION__, PaUtil_GetTime() - startTime ));
@@ -2036,8 +2073,9 @@
}
ENSURE_( alsa_snd_pcm_sw_params_set_avail_min( self->pcm, swParams, self->framesPerBuffer ), paUnanticipatedHostError );
- ENSURE_( alsa_snd_pcm_sw_params_set_xfer_align( self->pcm, swParams, 1 ), paUnanticipatedHostError );
+// ENSURE_( alsa_snd_pcm_sw_params_set_xfeir_align( self->pcm, swParams, 1 ), paUnanticipatedHostError );
ENSURE_( alsa_snd_pcm_sw_params_set_tstamp_mode( self->pcm, swParams, SND_PCM_TSTAMP_ENABLE ), paUnanticipatedHostError );
+ ENSURE_( alsa_snd_pcm_sw_params_set_tstamp_mode( self->pcm, swParams, SND_PCM_TSTAMP_ENABLE ), paUnanticipatedHostError );
/* Set the parameters! */
ENSURE_( alsa_snd_pcm_sw_params( self->pcm, swParams ), paUnanticipatedHostError );
@@ -3544,9 +3582,20 @@
snd_pcm_sframes_t framesAvail = alsa_snd_pcm_avail_update( self->pcm );
*xrunOccurred = 0;
- if( -EPIPE == framesAvail )
- {
+ /* Get pcm_state and check for xrun condition. On playback I often see
+ * xrun but avail_update does not return -EPIPE but framesAvail larger
+ * than bufferSize. In case of xrun status set xrun flag, leave framesize
+ * as reported by avail_update, will be fixed below. In case avail_update
+ * returns -EPIPE process as usual. wd-xxx
+ */
+ snd_pcm_state_t state = snd_pcm_state( self->pcm ); /* wd-xxx */
+ if (state == SND_PCM_STATE_XRUN) {
+ // printf("xrun, fav %d\n", framesAvail); fflush(stdout); // DEBUG-WD
*xrunOccurred = 1;
+ }
+ if( -EPIPE == framesAvail) {
+ // printf("xrun-1, fav %d\n", framesAvail); fflush(stdout); // DEBUG-WD
+ *xrunOccurred = 1;
framesAvail = 0;
}
else
@@ -3554,6 +3603,11 @@
ENSURE_( framesAvail, paUnanticipatedHostError );
}
+ /* Fix frames avail, should not be bigger than bufferSize wd-xxx */
+ if (framesAvail > self->bufferSize) {
+ // printf("xrun-2, fav %d\n", framesAvail); fflush(stdout); // DEBUG-WD
+ framesAvail = self->bufferSize;
+ }
*numFrames = framesAvail;
error:
@@ -3603,6 +3657,13 @@
*shouldPoll = 0;
}
+ else
+ {
+ // not actually used
+ unsigned long framesAvail = 0;
+ // now check for xrun
+ PaAlsaStreamComponent_GetAvailableFrames(self, &framesAvail, xrun );
+ }
error:
return result;
@@ -3693,6 +3754,10 @@
framesAvail, &xrun ) );
if( xrun )
{
+ if(*frameAvail == 0)
+ if(*framesAvail == 0)
+ {
+ result = paInternalError;
+ }
@ -661,33 +589,6 @@ Index: src/hostapi/alsa/pa_linux_alsa.c
goto end;/*PA_ENSURE( paTimedOut );*/
}
}
@@ -4326,9 +4393,24 @@
while( frames > 0 )
{
int xrun = 0;
- PA_ENSURE( PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun ) );
+ PA_ENSURE( PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun ) );
+ /*
+ * In case of overrun WaitForFrames leaves the capture stream in STATE_PREPARED
+ * most of the time. handleXrun() restarts the ALSA stream only in case
+ * snd_pcm_recover() fails, which usually does not happen.
+ * Here we start the pcm stream again and go for another try. Another
+ * option is: set result to paOverrun and return to caller. Then
+ * the caller needs to call ReadStream again. This takes more time and
+ * we lose even more frames.
+ */
+ if (xrun) { /* wd-xxx */
+ if( snd_pcm_state( stream->capture.pcm ) == SND_PCM_STATE_PREPARED ) {
+ ENSURE_( snd_pcm_start( stream->capture.pcm ), paUnanticipatedHostError );
+ }
+ continue;
+ }
+
framesGot = PA_MIN( framesAvail, frames );
-
PA_ENSURE( PaAlsaStream_SetUpBuffers( stream, &framesGot, &xrun ) );
if( framesGot > 0 )
{
@@ -4546,3 +4628,75 @@
busyRetries_ = retries;
return paNoError;

Loading…
Cancel
Save