$OpenBSD: patch-src_psk31-transmitter_C,v 1.2 2010/07/01 01:57:33 jakemsr Exp $ --- src/psk31-transmitter.C.orig Fri Aug 5 09:03:20 2005 +++ src/psk31-transmitter.C Wed Jun 30 17:33:04 2010 @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include "psk31-coder.h" #include "psk31-transmitter.h" #include @@ -22,6 +21,8 @@ extern int full_duplex; // from psk31-main.C extern int chans; // from server-main.C extern int bits; +extern long long realpos, playpos; // from server-main.C + /* Morse code encoding table */ /* 0=space, 1=dot; from msb to lsb; lowest 1 = end of code */ unsigned int psk31_transmitter::cwtab[58] = @@ -432,64 +433,22 @@ int psk31_transmitter::processor() { static int wcnt = 0; - int res, odelay; + int res; + long long odelay; static int write_pending; static int len, buflen; static int odd = 0; static short val, obuf[BLOCKSIZE]; - count_info cinfo; - audio_buf_info ospace; + struct pollfd pfd; + int events = 0, revents, n; - // Get free space in write buffer.... - res=ioctl(audiofd, SNDCTL_DSP_GETOSPACE, &ospace); - if(res) - { - if(errno==EBUSY) - { - // simplex card in read mode - // assume that there is enough space! - // (i.e. avoid check...) - // set odelay (this is not the real value, this - // echo will be too fast, but thats better than - // nothing... - odelay = 0; - } - else - { - perror("ERROR: GETOSPACE failed"); - return TX_ERROR; - } - } - else - { - // ToDo: adjustable buffer limit --- a small buffer increases the - // possibility of buffer underruns, but reduces the delay between - // typing and actual transmission - if(ospace.fragments realpos) + odelay = playpos - realpos; if(!write_pending) { @@ -515,7 +474,7 @@ int psk31_transmitter::processor() } if(echo_char) { - add_echo_char(echo_char, cinfo.bytes+odelay+len*sizeof(short)); + add_echo_char(echo_char, playpos+len*sizeof(short)); echo_char=0; } @@ -568,32 +527,20 @@ int psk31_transmitter::processor() } } - res=write(audiofd, &obuf, len*sizeof(short)); + res=sio_write(hdl, &obuf, len*sizeof(short)); + playpos += res; if(res>0) wcnt+=res; if(res!=(int)(len*sizeof(short))) { - if(res<0 && (errno==EINTR||errno==EAGAIN)) - { - write_pending=1; return TX_BUSY; - } - if(res==0 || (res<0 && (errno==EBUSY))) - { - write_pending=1; return TX_BUSY; - } - if(res<0) - { - fprintf(stderr,"tx: write error... res=%d\n",res); - return TX_ERROR; - } fprintf(stderr,"tx: partial write (%d/%d)...\n", res,BLOCKSIZE*sizeof(short)); return TX_ERROR; } write_pending=0; - res = get_echo_char( cinfo.bytes ); + res = get_echo_char( realpos ); #if 0 if(res!=TX_BUSY)