Ticket #31: portaudio_dmix_default.patch
| File portaudio_dmix_default.patch, 3.7 KB (added by rossb, 2 years ago) |
|---|
-
src/hostapi/alsa/pa_linux_alsa.c
467 467 */ 468 468 static int IgnorePlugin( const char *pluginId ) 469 469 { 470 /* XXX: dmix and default ignored because after opening and closing, they seem to keep hogging resources.471 */472 470 static const char *ignoredPlugins[] = {"hw", "plughw", "plug", "dsnoop", "tee", 473 "file", "null", "shm", "cards", "dmix", "default",NULL};471 "file", "null", "shm", "cards", NULL}; 474 472 int i = 0; 475 473 while( ignoredPlugins[i] ) 476 474 { … … 484 482 return 0; 485 483 } 486 484 485 static int snd_pcm_open_with_retry(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode) 486 { 487 int ret = snd_pcm_open(pcmp, name, stream, mode); 488 if (ret==EBUSY) { 489 sleep(1); 490 int ret = snd_pcm_open(pcmp, name, stream, mode); 491 } 492 return ret; 493 } 494 487 495 /* Build PaDeviceInfo list, ignore devices for which we cannot determine capabilities (possibly busy, sigh) */ 488 496 static PaError BuildDeviceList( PaAlsaHostApiRepresentation *alsaApi ) 489 497 { … … 681 689 682 690 /* Query capture */ 683 691 if( deviceNames[i].hasCapture && 684 snd_pcm_open ( &pcm, deviceNames[i].alsaName, SND_PCM_STREAM_CAPTURE, blocking ) >= 0 )692 snd_pcm_open_with_retry( &pcm, deviceNames[i].alsaName, SND_PCM_STREAM_CAPTURE, blocking ) >= 0 ) 685 693 { 686 694 if( GropeDevice( pcm, deviceNames[i].isPlug, StreamDirection_In, blocking, deviceInfo, 687 695 &canMmap ) != paNoError ) … … 694 702 695 703 /* Query playback */ 696 704 if( deviceNames[i].hasPlayback && 697 snd_pcm_open ( &pcm, deviceNames[i].alsaName, SND_PCM_STREAM_PLAYBACK, blocking ) >= 0 )705 snd_pcm_open_with_retry( &pcm, deviceNames[i].alsaName, SND_PCM_STREAM_PLAYBACK, blocking ) >= 0 ) 698 706 { 699 707 if( GropeDevice( pcm, deviceNames[i].isPlug, StreamDirection_Out, blocking, deviceInfo, 700 708 &canMmap ) != paNoError ) … … 726 734 baseApi->info.defaultInputDevice = devIdx; 727 735 if( baseApi->info.defaultOutputDevice == paNoDevice && baseDeviceInfo->maxOutputChannels > 0 ) 728 736 baseApi->info.defaultOutputDevice = devIdx; 737 if( strcmp(deviceNames[i].alsaName, "default")==0 ) 738 baseApi->info.defaultOutputDevice = devIdx; 729 739 PA_DEBUG(("%s: Adding device %s\n", __FUNCTION__, deviceNames[i].name)); 730 740 baseApi->deviceInfos[devIdx++] = (PaDeviceInfo *) deviceInfo; 731 741 } … … 869 879 deviceName = streamInfo->deviceString; 870 880 871 881 PA_DEBUG(( "%s: Opening device %s\n", __FUNCTION__, deviceName )); 872 if( (ret = snd_pcm_open ( pcm, deviceName, streamDir == StreamDirection_In ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK,882 if( (ret = snd_pcm_open_with_retry( pcm, deviceName, streamDir == StreamDirection_In ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, 873 883 SND_PCM_NONBLOCK )) < 0 ) 874 884 { 875 885 /* Not to be closed */ … … 1981 1991 if( stream->playback.pcm ) 1982 1992 { 1983 1993 ENSURE_( snd_pcm_nonblock( stream->playback.pcm, 0 ), paUnanticipatedHostError ); 1984 if( snd_pcm_drain( stream->playback.pcm ) < 0 ) 1994 /* draining causes deadlock when we are using dmix */ 1995 /* if( snd_pcm_drain( stream->playback.pcm ) < 0 ) */ 1996 if( snd_pcm_drop( stream->playback.pcm ) < 0 ) 1985 1997 { 1986 1998 PA_DEBUG(( "%s: Draining playback handle failed!\n", __FUNCTION__ )); 1987 1999 }
