Index: a2play.c =================================================================== RCS file: /cvsroot/bluetooth-alsa/btsco/a2play.c,v retrieving revision 1.64 diff -u -b -B -w -p -r1.64 a2play.c --- a2play.c 7 May 2005 02:43:00 -0000 1.64 +++ a2play.c 9 May 2005 06:30:36 -0000 @@ -56,6 +56,7 @@ #define BUFS 1024 static volatile int terminate = 0; +static volatile int xmitpause = 0; static int cmdfd; struct sbc_frame_header sbc_info; @@ -102,6 +103,16 @@ static void sig_term(int sig) terminate = 1; } +static void sig_alrm(int sig) +{ + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_flags = SA_NOCLDSTOP; + sa.sa_handler = sig_alrm; + sigaction(SIGALRM, &sa, NULL); + xmitpause = 0; +} + // Usage static void usage() { @@ -404,6 +415,8 @@ s_config was set from sbc_info before: int main(int argc, char *argv[]) { + int timerset = 0; + struct itimerval itimer; struct sigaction sa; struct timeval start, end; int streamfd; @@ -619,6 +632,8 @@ int main(int argc, char *argv[]) timestamp = 0; + sig_alrm(0); + while (!terminate) { // a2dp headers: avdtp p.45 @@ -698,8 +713,18 @@ int main(int argc, char *argv[]) memcpy(buf + sizeof(packet_header), &payload_header, sizeof(payload_header)); write(streamfd, buf, psize); - //printf("\nSending packet:%d, size %d no. of sbc frames:%d", seq_num, psize, payload_header.frame_count); + if(!timerset) { + timerset = 1; + itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0; + itimer.it_interval.tv_usec = itimer.it_value.tv_usec = (sleeptime*95)/100; + if(setitimer(ITIMER_REAL, &itimer, NULL)) printf("couldn't setitimer\n"); + } + + while(xmitpause) usleep(10); + xmitpause = 1; +#if 0 + //printf("\nSending packet:%d, size %d no. of sbc frames:%d", seq_num, psize, payload_header.frame_count); pending++; if (pending > 4) { @@ -717,7 +742,7 @@ int main(int argc, char *argv[]) sleeptime = 0; pending = 0; } - +#endif /* END: NONSPECAUDIO == FALSE */ }