[vlc-devel] [PATCH 1/2] Fnordlicht support added. Fnordlicht-Class is based on the MoMo-Class. The Fnordlicht-Class implements oly parts of the fnordlicht-protocol: sync, stop and fade_rgb Have a look at http://github.com/fd0/fnordlicht/raw/master/doc/PROTOCOL for more details.
Rémi Denis-Courmont
remi at remlab.net
Fri May 14 11:55:35 CEST 2010
On Thu, 13 May 2010 19:43:51 +0200, Kai Lauterbach <lauterbach.kai at web.de>
wrote:
> + int amount = getAmountFnordlichter();
> + DWORD bufSize = 15;
> + unsigned char *buffer = new unsigned char[ bufSize ];
A stack buffer would be simpler and faster here.
> + DWORD bufSize = 16; // the sync package length is 16 bytes
> + unsigned char *buffer = new unsigned char[ bufSize ];
Same comment.
> + DWORD bufSize = 15; // command package length is 15 bytes
> + unsigned char *buffer = new unsigned char[ bufSize ];
Again.
> + DWORD iBytesWritten;
> +
> + Lock();
> +
> + buffer[0] = addr; // fnordlicht address (255 = broadcast)
> + buffer[1] = 0x08; // stop command
> + buffer[2] = 1; // fading
> +
> + for ( int i = 3; i < bufSize; i++ )
> + buffer[i] = 0x00; // fill with zero Bytes...
Use memset().
> +#if !defined(_ATMO_VLC_PLUGIN_)
> +
> +char *CFnordlichtConnection::getChannelName(int ch)
> +{
> + if(ch < 0) return NULL;
> + char buf[30];
> +
> + switch(ch) {
> + case 0:
> + sprintf(buf,"Number [%d]",ch);
> + break;
> + case 1:
> + sprintf(buf,"Number [%d]",ch);
> + break;
> + case 2:
> + sprintf(buf,"Number [%d]",ch);
> + break;
> + case 3:
> + sprintf(buf,"Number [%d]",ch);
> + break;
> + default:
> + sprintf(buf,"Number [%d]",ch);
> + break;
> + }
> +
> + return strdup(buf);
> +}
While this code will not be compiled, it really makes no sense. Those 21
lines could be replaced with just two:
char *ret;
return (asprintf(&ret, "Number [%d], ch) != -1) ? ret : NULL;
--
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis
More information about the vlc-devel
mailing list