Subject: potential wss driver bug
To: None <tech-kern@netbsd.org>
From: Sachin Goel <sgoel@nc.com>
List: tech-kern
Date: 02/05/1999 01:44:32
I have been facing this strange problem and i believe somebody else must
have experienced it too. The RealVideo Player-G5( on netbsd-current)
works flawlessly with SB16 device and the same program fails to work
with wss driver (it is CS4235 sound system which is probed and attached
as wss driver). The program is linked with libossaudio. The player opens
the device in non-blocking mode and does a select() on fd. The player
does couple of writes to the audio device and then just stops writing to
the device (Basically, select() after couple of write() never indicates
that the device is ready for writing). BTW, the len field in write()
call is not fixed though i don't see this to be any reason for it to
fail.

The strange thing is that my little program which simulates this
behaviour works fine with sb and wss as well. (see the program at the
end).

Any ideas what potentially could be causing this wierd thing?

Any info will be greatly appreciated.

Cheers,

Sachin(sgoel@nc.com) 



#include <fcntl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <unistd.h>
#include <sys/audioio.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int fd;

int open_recorder( void )
{
  audio_info_t info;
  char buffer[512];

    AUDIO_INITINFO( &info );

    info.blocksize = 512;
    info.mode = AUMODE_PLAY;
    info.play.encoding = AUDIO_ENCODING_ULAW;
    info.play.sample_rate = 8000;
    info.play.precision = 8;
    info.play.channels = 2;
    info.hiwat = 15;
    info.lowat = 5;

 if( ( fd = open( "/dev/audio", O_WRONLY | O_NONBLOCK) ) == -1 )
    {
      perror( "open device" );
      return( -1 );
    }

    if( ioctl( fd, AUDIO_SETINFO, &info ) == -1 )
    {
      perror("set info" );
      return( -1 );
    }

    return 0;
}

main( int argc, char** argv )
{
int outfd, nbytes;
fd_set writefds;
struct timeval to;
int err, bufout;
char buf[512];

  if( open_recorder() == -1 )
    exit(0);

  to.tv_sec = 10;
  to.tv_usec = 0;
  FD_ZERO( &writefds );
  FD_SET( fd, &writefds );


  if( ( outfd = open( "/rafiles/g144.ra", O_RDONLY) ) < 0 ) {
    perror( "test.out");
    exit(0);
  }
  while( (err = select( fd+1, NULL, &writefds, NULL, &to ) ) > 0 )
  {
    nbytes = read(outfd, buf, 512);
    bufout = write( fd, buf, nbytes);
    printf("no of bytes written = %d\n", bufout);
  }

  close( outfd );
  close( fd );
    if( err < 0 ) perror( "select");
    if( err == 0 ) printf( "timeout\n");
    else printf( "number of fds: %d\n",err);

}