[sane-devel] Fwd: sanei_usb limitations

Reinhold Kainhofer reinhold at kainhofer.com
Wed Jan 5 01:01:08 UTC 2011


Am Dienstag, 4. Januar 2011, um 22:19:16 schrieb m. allan noah:
> I think your previous idea of adding a a new function to set the
> currently 'active' endpoint would be simpler. 

Actually, that was never my idea for overriding the endpoints for a single 
transactions, only for setting the global defaults. For the defaults, it is 
definitely cleaner/easier to use one function to set the default endpoints.

For overriding the ep of a single transaction I don't like this approach too 
much. Having to call a setter function first to set a global variable, before 
you do the actual function call is highly thread-unsafe, and I would prefer to 
pass the ep right to the function itself.

> something like:
> 
> /*endpoint types*/
> #define SANEI_USB_BULK_OUT 0
> #define SANEI_USB_BULK_IN  1
> ...

What do you have against bitmasks like (USB_DIR_IN | USB_ENDPOINT_TYPE_BULK)? 
Then we don't need any new constants...

> sanei_usb_set_endpoint(SANE_Int dn, SANE_Int endpoint_type, SANE_Int
> endpoint_number){
>   switch/case setting devices[devcount].xxxx
> }
> 
> Then you've only got one new function, and no other code changes?


Cheers,
Reinhold
-- 
------------------------------------------------------------------
Reinhold Kainhofer, reinhold at kainhofer.com, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org



More information about the sane-devel mailing list