linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] First try
@ 2006-05-30 17:03 Frédéric DALLEAU
  2006-06-01  7:19 ` Brad Midgley
  0 siblings, 1 reply; 6+ messages in thread
From: Frédéric DALLEAU @ 2006-05-30 17:03 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 414 bytes --]

Hi brad,

I just tried to move global variables to pcm_a2dp struct... However, I 
seem to experience a loss in quality. I'm really unsure about it. I 
don't understand why as it is a straight forward fix. Could you please 
review it?
It's based on the latest cvs.

I also tried a "make dist", but I got a btsco-0.2.tar.gz, which makes me 
say configure.in is not up to date !

Thank you,
Frédéric



[-- Attachment #2: pcm_a2dp.c.diff --]
[-- Type: text/x-patch, Size: 5673 bytes --]

Index: pcm_a2dp.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/alsa-plugins/pcm_a2dp.c,v
retrieving revision 1.9
diff -r1.9 pcm_a2dp.c
52,54d51
< time_t timestamp=0;
< uint16_t seq_num=1;
< int frame_count=0;
56,66d52
< static char bufe[BUFS];
< int lenbufe=0;
< 
< unsigned long nbytes=0;
< unsigned long total_time=0;
< struct timeval t0;
< struct itimerval itimer;
< struct sigaction sa;
< struct timeval tsend;
< int fpr=0;
< 
563a550,563
> 
>    char bufe[BUFS];
>   int lenbufe;//=0;
> 
>   unsigned long nbytes;//=0;
> 
> 
> 
>   struct timeval tsend;
> 
>   time_t timestamp;//=0;
>   uint16_t seq_num;//=1;
>   int frame_count;//=0;
> 
671,673c671,673
<     	if(lenbufe<codesize && lenbufe+datatoread<sizeof(bufe)){ // if not enough data in bufe to encode and there is space in bufe
< 		memcpy(bufe+lenbufe,buf,datatoread);// we read data to bufe
< 		lenbufe+=datatoread;
---
>     	if(a2dp->lenbufe<codesize && a2dp->lenbufe+datatoread<sizeof(a2dp->bufe)){ // if not enough data in bufe to encode and there is space in bufe
> 		memcpy(a2dp->bufe+a2dp->lenbufe,buf,datatoread);// we read data to bufe
> 		a2dp->lenbufe+=datatoread;
677,682c677,682
< 	if(lenbufe>=codesize && a2dp->len + a2dp->sbc.len < 678){ // if enough data in bufe to encode and not enough frame to fill up mtu: encoding
< 		change_endian(bufe,codesize); // changing the endianness
< 		len = sbc_encode(&(a2dp->sbc), bufe, codesize); //encode
< 		memmove(bufe, bufe + len, lenbufe - len); //shift the bufe                                 
< 		lenbufe-=len;
< 		nbytes+=len;
---
> 	if(a2dp->lenbufe>=codesize && a2dp->len + a2dp->sbc.len < 678){ // if enough data in bufe to encode and not enough frame to fill up mtu: encoding
> 		change_endian(a2dp->bufe,codesize); // changing the endianness
> 		len = sbc_encode(&(a2dp->sbc), a2dp->bufe, codesize); //encode
> 		memmove(a2dp->bufe, a2dp->bufe + len, a2dp->lenbufe - len); //shift the bufe                                 
> 		a2dp->lenbufe-=len;
> 		a2dp->nbytes+=len;
686c686
< 		frame_count++;
---
> 		a2dp->frame_count++;
695c695
< 		dt.tv_usec=1000000*a2dp->sbc.subbands*a2dp->sbc.blocks*frame_count/io->rate; // time interval between transmitions
---
> 		dt.tv_usec=1000000*a2dp->sbc.subbands*a2dp->sbc.blocks*a2dp->frame_count/io->rate; // time interval between transmitions
697c697
< 		if(time_to_wait(&tsend, &dt)==0){ // time to send data
---
> 		if(time_to_wait(&a2dp->tsend, &dt)==0){ // time to send data
700c700
< 			payload_header.frame_count=frame_count;
---
> 			payload_header.frame_count=a2dp->frame_count;
703,704c703,704
< 			packet_header.sequence_number = htons(seq_num);
< 			packet_header.timestamp = htonl(timestamp);
---
> 			packet_header.sequence_number = htons(a2dp->seq_num);
> 			packet_header.timestamp = htonl(a2dp->timestamp);
706c706
< 			timestamp += (a2dp->sbc.blocks + 1)*4 * (a2dp->sbc.subbands + 1)*4;
---
> 			a2dp->timestamp += (a2dp->sbc.blocks + 1)*4 * (a2dp->sbc.subbands + 1)*4;
711c711
< 			frame_count=0;
---
> 			a2dp->frame_count=0;
713c713
< 			seq_num++;
---
> 			a2dp->seq_num++;
734d733
< 	
737a737,754
> 
> 	struct timeval timeofday;
> 	gettimeofday(&timeofday, NULL);
> 	/*
> 	DBG("(%2d%3d): %d + %d * %d (=%d)",
> 	    (timeofday.tv_sec      )%100,  // s
> 	    (timeofday.tv_usec/1000)%1000, // ms
> 	    (int)areas->first, (int)areas->step, offset, (areas->first + areas->step * offset));
> 	/*
> 	DBG("(%2d%3d): %d * %d * %d * 2 (=%d) x %d",
> 	    (timeofday.tv_sec      )%100,  // s
> 	    (timeofday.tv_usec/1000)%1000, // ms
> 	    a2dp->sbc.subbands, // 8
> 	    a2dp->sbc.blocks, // 16
> 	    a2dp->sbc.channels, // 2
> 	    codesize, // 512
> 	    datatoread); // 512
> 	*/
739,741c756,758
<     	if(lenbufe<codesize){
< 		memcpy(bufe+lenbufe,buf,datatoread);
< 		lenbufe+=datatoread;
---
>     	if(a2dp->lenbufe<codesize){
> 		memcpy(a2dp->bufe+a2dp->lenbufe,buf,datatoread);
> 		a2dp->lenbufe+=datatoread;
745,750c762,767
< 	if(lenbufe>=codesize){ //enough data to encode
< 		change_endian(bufe,codesize); // changing the endianness
< 		len = sbc_encode(&(a2dp->sbc), bufe, codesize); //encode
< 		memmove(bufe, bufe + len, lenbufe - len); //shift the bufe                                 
< 		lenbufe-=len;
< 		nbytes+=len;
---
> 	if(a2dp->lenbufe>=codesize){ //enough data to encode
> 		change_endian(a2dp->bufe,codesize); // changing the endianness
> 		len = sbc_encode(&(a2dp->sbc), a2dp->bufe, codesize); //encode
> 		memmove(a2dp->bufe, a2dp->bufe + len, a2dp->lenbufe - len); //shift the bufe                                 
> 		a2dp->lenbufe-=len;
> 		a2dp->nbytes+=len;
756c773
< 			dt.tv_usec=1000000*a2dp->sbc.subbands*a2dp->sbc.blocks*frame_count/io->rate;
---
> 			dt.tv_usec=1000000*a2dp->sbc.subbands*a2dp->sbc.blocks*a2dp->frame_count/io->rate;
759c776
< 			payload_header.frame_count=frame_count;
---
> 			payload_header.frame_count=a2dp->frame_count;
762,763c779,780
< 			packet_header.sequence_number = htons(seq_num);
< 			packet_header.timestamp = htonl(timestamp);
---
> 			packet_header.sequence_number = htons(a2dp->seq_num);
> 			packet_header.timestamp = htonl(a2dp->timestamp);
765c782
< 			timestamp += (a2dp->sbc.blocks + 1)*4 * (a2dp->sbc.subbands + 1)*4;
---
> 			a2dp->timestamp += (a2dp->sbc.blocks + 1)*4 * (a2dp->sbc.subbands + 1)*4;
768c785
< 			sleeptill(&tsend, &dt);
---
> 			sleeptill(&a2dp->tsend, &dt);
774c791
< 			frame_count=0;
---
> 			a2dp->frame_count=0;
776c793
< 			seq_num++;
---
> 			a2dp->seq_num++;
778c795
< 		frame_count++;
---
> 		a2dp->frame_count++;
974c991
< 	DBG("a2dp %p", a2dp);
---
> 	DBG("TEST a2dp %p", a2dp);
1042a1060
> 	a2dp->seq_num = 1;

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-06-19  8:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-30 17:03 [Bluez-devel] First try Frédéric DALLEAU
2006-06-01  7:19 ` Brad Midgley
2006-06-01  8:07   ` Frédéric DALLEAU
2006-06-01  8:27     ` Marcel Holtmann
2006-06-06  5:05     ` Brad Midgley
2006-06-19  8:03       ` Frédéric DALLEAU

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).