Speedup hack enable/disable

Richard Low <[email protected]> Sun, 25 Sep 2005 12:45:38 +0100
Newsgroups gmane.comp.multimedia.libnjb.user
Message-ID <[email protected]>
Hello,

I probably should have done this right from the start - can we make  
the speedup hack I submitted configurable at runtime rather than  
compile time only?  Some users - it seems only Dell DJ users - have  
problems with the speedup.  Making it runtime configurable means a  
preferences option can disable the speedup should transfers be  
unstable.  The attached patches against CVS implement this by adding  
a NJB_Set_Turbo function, with corresponding function njb_turbo to  
determine if the speedup is enabled or not.  Then the preprocessor  
directive #ifdef NO_TURBO is replaced with if ( !njb_turbo() ) etc.

I have an ebayed Zen Sleek on its way!

Richard.
base.c.diff (application/octet-stream, 324 B)
22,23d21
< /** Whether we use speedup hack or not (global) */
< int njb_turbo_flags = 1;
419,433d416
< /**
<  * Defines if we use speedup hack or not
<  */
< void njb_set_turbo (int flags)
< {
< 	njb_turbo_flags = flags;
< }
< 
< /**
<  * get the speedup setting
<  */
< int njb_turbo ()
< {
<   return njb_turbo_flags;
< }
base.h.diff (application/octet-stream, 63 B)
12,13d11
< void njb_set_turbo (int flags);
< int njb_turbo ();
libnjb.h.in.diff (application/octet-stream, 48 B)
429d428
< void NJB_Set_Turbo (int turbo_flags);
procedure.c.diff (application/octet-stream, 1.8 KB)
1143,1159c1143,1155
<   if ( !njb_turbo() )
< 	{
< 		blocksize = NJB3_DEFAULT_GET_FILE_BLOCK_SIZE;
< 	}
< 	else
< 	{
< 		/*
< 		 * This speed-up hack comes courtesy of Richard Low.
< 		 * files of size 8192 or 8191 modulo 0x4000 are known to hang when 
< 		 * downloading if request is 0x4000 bytes, so we avoid this 
< 		 * scenario
< 		 */
< 		if (chunk_remain <= 0x2000U) {
< 			blocksize = 0x2000U;
< 		} else {
< 			blocksize = 0x4000U;
< 		}
---
> #ifdef NO_TURBO
> 	blocksize = NJB3_DEFAULT_GET_FILE_BLOCK_SIZE;
> #else
> 	/*
> 	 * This speed-up hack comes courtesy of Richard Low.
> 	 * files of size 8192 or 8191 modulo 0x4000 are known to hang when 
> 	 * downloading if request is 0x4000 bytes, so we avoid this 
> 	 * scenario
> 	 */
> 	if (chunk_remain <= 0x2000U) {
> 	  blocksize = 0x2000U;
> 	} else {
> 	  blocksize = 0x4000U;
1160a1157
> #endif
1353,1365c1350,1359
< 				if ( !njb_turbo() )
< 				{
< 					maxblock = NJB3_DEFAULT_SEND_FILE_BLOCK_SIZE;
< 				}
< 				else
< 				{
< 					/*
< 					 * This hack courtesy of Richard Low.
< 					 * Increasing the send max block by a factor of seven speeds up
< 					 * transfers considerably.
< 					 */
< 					maxblock = 0xE000U;
< 				}
---
> #ifdef NO_TURBO
> 	maxblock = NJB3_DEFAULT_SEND_FILE_BLOCK_SIZE;
> #else
> 	/*
> 	 * This hack courtesy of Richard Low.
> 	 * Increasing the send max block by a factor of seven speeds up
> 	 * transfers considerably.
> 	 */
> 	maxblock = 0xE000U;
> #endif
2819,2830d2812
<  * Defines if we use Richard Low's speedup hack or not
<  * Disable if there are stability problems when transfering
<  * to/from player (in particular with Dell DJ)
<  *
<  * @param turbo_flag 0 for no turbo, otherwise turbo enabled
<  */
< void NJB_Set_Turbo (int turbo_flag)
< {
< 	njb_set_turbo(turbo_flag);
< }
< 
< /**