reopen with "plug:dmix" failure
Dear Jaroslav Kysela.
I wrote some example which illustrates problem described in previous message. Also I want you to make some fixes in your library which can avoid this problem. First of all I discommented lines 325-326 in file pcm_direct.c (because even after application stopped server still process and device /dev/snd/pcmC0D0p locked). After that I added one line, which unlink temporary file /tmp/alsa-dmix*.
//----------- example ------------------------------ #include <alsa/asoundlib.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
void *thread_routine( void *param ) {
snd_pcm_t *pcm;
int err;
printf( "%d: start\n", getpid() );
err = snd_pcm_open( &pcm,
"plug:dmix", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK );
if( err < 0 ) {
fprintf( stderr, "%s\n", snd_strerror(err) );
return NULL;
}
snd_pcm_close( pcm ); printf( "%d: finish\n", getpid() );
return NULL;
}
int main( void ) {
pthread_t thread;
int i =0;
printf( "main pid: %d\n", getpid() );
for( i=0; i<2; ++i ) {
if( pthread_create( &thread, 0, thread_routine, NULL ) ) {
fprintf( stderr, "pthread_create failure\n" );
exit( -1 );
}
pthread_join( thread, 0 );
} return 0;
}
//----------- patch ------------------------------
pcm_direct.c renamed from pcm_direct.c.orig +3 -2
@@ -322,13 +322,14 @@int snd_pcm_direct_server_discard (snd_pcm_direct_t *dmix) {if (dmix->server) { -//kill(dmix->server_pid, SIGTERM); -//waitpid(dmix->server_pid, NULL, 0); +kill (dmix->server_pid,SIGTERM ); +waitpid (dmix->server_pid,NULL ,0 ); dmix->server_pid = (pid_t)-1 ; }if (dmix->server_fd >0 ) {close (dmix->server_fd); dmix->server_fd =-1 ; +unlink ( dmix->shmptr->socket_name ); } dmix->server =0 ;return 0 ;
Signature · 9 lines
Cheers, Konstantin Stepaniuk ------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps1
Quoted 8 lines · Konstantin Stepaniuk
Dear Jaroslav Kysela.
I wrote some example which illustrates problem described in previous message. Also I want you to make some fixes in your library which can avoid this problem. First of all I discommented lines 325-326 in file
pcm_direct.c(because even after application stopped server still process and device/dev/snd/pcmC0D0plocked). After that I added one line, which unlink temporary file/tmp/alsa-dmix*.
Your fixes does not solve the real problem and causes another deadlock.
I have tried to solve the problem. Could you try the current CVS code?
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps1