alsa-xmms-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Alsa-xmms-user] dmix plugin / will it work one day?


From: Steve Leung
Subject: Re: [Alsa-xmms-user] dmix plugin / will it work one day?
Date: Sat, 14 Jun 2003 00:21:03 -0600 (MDT)

On 2003/06/13 23:00:24 +0000, Matthieu Sozeau wrote:

> I tested the same configuration and have no problems at all
> (play/stop/pause/seek works, mplayer+xmms also). I still see, as

Matthieu, what sound hardware are you testing with?  I don't know all
that much about ALSA, but I imagine there are some cards that allow
multiple processes to open the sound device.  My hardware only allows
one process to open the sound device (cmipci on an ASUS A7S333
motherboard).  I wonder if my cheap sound hardware is making this
problem appear.

I wrote a test program to try to confirm the problem.  It opens and
closes the default sound device in one thread, and later opens and
closes the same sound device in a separate thread.  If dmix is enabled
as the default output device, the program consistently hangs on my box
when it calls snd_pcm_open the second time, much like alsa-xmms.
Once I disable dmix, the program runs to completion.

This seems like very bizarre behaviour to me, so I've sent this code
to the alsa-user mailing list to see if I'm doing anything wrong.
I've included the source below.  Perhaps you can also try it.

Steve

/* PROGRAM STARTS HERE */
#include <alsa/asoundlib.h>
#include <alsa/pcm.h>
#include <pthread.h>
#include <stdio.h>

void* threadFunc( void* unused )
  {
  int err;
  snd_pcm_t *alsa_pcm = NULL;
  printf( "%d opening\n", pthread_self() );
  err = snd_pcm_open(&alsa_pcm, "default", SND_PCM_STREAM_PLAYBACK, 0);
  printf( "%d opened %d\n", pthread_self(), err );

  printf( "%d closing\n", pthread_self() );
  err = snd_pcm_close(alsa_pcm);
  printf( "%d closed %d\n", pthread_self(), err );
  return NULL;
  }

int main(void)
  {
  pthread_t firstThread;
  pthread_create( &firstThread, NULL, threadFunc, NULL );
  pthread_join( firstThread, NULL );

  sleep( 1 );

  pthread_t secondThread;
  pthread_create( &secondThread, NULL, threadFunc, NULL );
  pthread_join( secondThread, NULL );

  getc( stdin );
  return 0;
  }







reply via email to

[Prev in Thread] Current Thread [Next in Thread]