[comp.unix.questions] ioctl, flush fails - help!

sidana@leland.Stanford.EDU (Ashmeet Sidana) (03/03/91)

I am trying to flush the audio device to which I have previously written
a large no of bytes on a SUN SparcStation 1. However, the ioctl fails
with an "invalid argument" error.

My sample code is as follows:

#include <fcntl.h>
#include <stropts.h>

char notes[20000];

main()
{
    int  i,fdaudio;

    fdopen ((fdaudio = open("/dev/audio",O_WRONLY)),"w");
    fill_notes_array();
    write (fdaudio,notes,20000);
    if ((ioctl (fdaudio,I_FLUSH,FLUSHW)) < 0) {   /*this is where it fails !*/
	perror ("Fatal Error: ioctl failed"); 
	exit (-1);
    }
    else 
	printf ("ioctl succeeded! \n");
}

Any help would be appreciated !!!

Please send me email at: sidana@leland.stanford.edu

Thank you,

---Ashmeet Sidana
   sidana@leland.stanford.edu