I am having a devil of a time getting tthe alsa sb16 driver to stay synced even in half duplex.

I have a VoIP app that is half duplex and it woeks fine using the oss free drivers in the kernel tree. I simply close the file discriptor on /dev/dsp, and re-open it, setting the parameters each, mono/16 bit/8Khz, every time you change from reading /dev/dsp, ie transmit, and writing to /dev/dsp, ie receiving.

But, the microphone audio seems to be getting buffered ALL THE TIME and even closing and re-openning does not clear the buffer and start from scratch.

Here the code that is run on every Tx.Rx change over AFTER the audiofd is closed.

int soundInput(void){

int arg, status;
long frag_size = 0x7FFF000B;

audiofd = open(SoundFileIn, O_RDWR);
if(audiofd < 0){
perror(" opening audio input ");
exit(1);
}

if (ioctl(audiofd, SNDCTL_DSP_SETFRAGMENT, &frag_size) == -1) {
perror("SNDCTL_DSP_SETFRAGMENT ioctl failed");
}

arg = SIZE;
status = ioctl(audiofd, SOUND_PCM_WRITE_BITS, &arg);
if(status == -1)
perror("SOUND_PCM_WRITE_BITS ioctl failed");
if(arg != SIZE)
perror("unable to set sample size");

arg = CHANNELS;
status = ioctl(audiofd, SOUND_PCM_WRITE_CHANNELS, &arg);
if(status == -1)
perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
if(arg != CHANNELS)
perror("unable to set number of channels");

arg = RATE;
status = ioctl(audiofd, SOUND_PCM_WRITE_RATE, &arg);
if(status == -1)
perror("SOUND_PCM_WRITE_RATE ioctl failed");

arg = AFMT_S16_LE;
status = ioctl(audiofd, SOUND_PCM_SETFMT, &arg);
if(status == -1)
perror(" SOUND_PCM_SETFMT ioctl failed");

ioctl(audiofd, SOUND_PCM_SYNC, 0);


}

--
Jeff, wd4nmq
[EMAIL PROTECTED]
http://mywebpages.comcast.net/wd4nmq



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Alsa-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to