forked from len0rd/rockbox
PDBox: Minor addition and bugfixes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22148 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bec80ca7dd
commit
11ac0b3f2a
4 changed files with 48 additions and 6 deletions
|
@ -1118,7 +1118,9 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s,
|
||||||
if (finalsize > bytelimit / (channels * bytespersamp))
|
if (finalsize > bytelimit / (channels * bytespersamp))
|
||||||
finalsize = bytelimit / (channels * bytespersamp);
|
finalsize = bytelimit / (channels * bytespersamp);
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
fp = open(filename, O_RDONLY);
|
fp = open_soundfile(canvas_getdir(x->x_canvas)->s_name, filename,
|
||||||
|
headersize, &bytespersamp, &bigendian, &channels, &bytelimit,
|
||||||
|
skipframes);
|
||||||
#else
|
#else
|
||||||
fp = fdopen(fd, "rb");
|
fp = fdopen(fd, "rb");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -317,6 +317,7 @@ static void *netreceive_new(t_symbol *compatflag,
|
||||||
|
|
||||||
x = (t_netreceive *) pd_new(netreceive_class);
|
x = (t_netreceive *) pd_new(netreceive_class);
|
||||||
x->x_msgout = outlet_new(&x->x_obj, &s_anything);
|
x->x_msgout = outlet_new(&x->x_obj, &s_anything);
|
||||||
|
x->x_connectout = 0;
|
||||||
x->x_nconnections = 0;
|
x->x_nconnections = 0;
|
||||||
x->x_udp = udp;
|
x->x_udp = udp;
|
||||||
|
|
||||||
|
@ -428,8 +429,8 @@ static void netreceive_free(t_netreceive *x)
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
/* Basically a reimplementation of socketreceiver_getudp()
|
/* Basically a reimplementation of socketreceiver_getudp()
|
||||||
from s_inter.c */
|
from s_inter.c */
|
||||||
t_binbuf* inbinbuf;
|
extern t_binbuf* inbinbuf;
|
||||||
void outlet_setstacklim(void);
|
extern void outlet_setstacklim(void);
|
||||||
|
|
||||||
void rockbox_receive_callback(struct datagram* dg)
|
void rockbox_receive_callback(struct datagram* dg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -263,8 +263,14 @@ void rb_ftoan(float f, char* out, int size)
|
||||||
strcat(out, ".");
|
strcat(out, ".");
|
||||||
size--;
|
size--;
|
||||||
|
|
||||||
/* Calculate first rest and convert it. */
|
/* Calculate first rest. */
|
||||||
float rest1 = (f - (float) int_part) * 1000000000.0;
|
float rest1 = (f - (float) int_part) * 1000000000.0;
|
||||||
|
|
||||||
|
/* If there is no fractional part, return here. */
|
||||||
|
if(rest1 == 0.0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Convert the first rest to string. */
|
||||||
int irest1 = (int) rest1;
|
int irest1 = (int) rest1;
|
||||||
snprintf(sbuf, SBUFSIZE-1, "%09d", irest1);
|
snprintf(sbuf, SBUFSIZE-1, "%09d", irest1);
|
||||||
|
|
||||||
|
@ -278,8 +284,26 @@ void rb_ftoan(float f, char* out, int size)
|
||||||
if(size <= 0)
|
if(size <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Calculate second rest and convert it. */
|
/* Calculate second rest. */
|
||||||
float rest2 = (rest1 - (float) irest1) * 1000000000.0;
|
float rest2 = (rest1 - (float) irest1) * 1000000000.0;
|
||||||
|
|
||||||
|
/* If no second rest, check whether
|
||||||
|
the output string has unwanted zero trail,
|
||||||
|
remove it and end processing here. */
|
||||||
|
if(rest2 == 0.0f)
|
||||||
|
{
|
||||||
|
char* zerotrail = out + strlen(out) - 1;
|
||||||
|
|
||||||
|
for(; zerotrail >= out; zerotrail--)
|
||||||
|
{
|
||||||
|
if(*zerotrail == '0')
|
||||||
|
*zerotrail = '\0';
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert second rest. */
|
||||||
int irest2 = (int) rest2;
|
int irest2 = (int) rest2;
|
||||||
snprintf(sbuf, SBUFSIZE-1, "%09d", irest2);
|
snprintf(sbuf, SBUFSIZE-1, "%09d", irest2);
|
||||||
|
|
||||||
|
@ -287,6 +311,16 @@ void rb_ftoan(float f, char* out, int size)
|
||||||
int rest2_len = strlen(sbuf);
|
int rest2_len = strlen(sbuf);
|
||||||
int rest2_minlen = MIN(size, rest2_len);
|
int rest2_minlen = MIN(size, rest2_len);
|
||||||
strncat(out, sbuf, rest2_minlen);
|
strncat(out, sbuf, rest2_minlen);
|
||||||
|
|
||||||
|
/* Cut trailing zeroes. */
|
||||||
|
char* zerotrail = out + strlen(out) - 1;
|
||||||
|
for(;zerotrail >= out; zerotrail--)
|
||||||
|
{
|
||||||
|
if(*zerotrail == '0')
|
||||||
|
*zerotrail = '\0';
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,12 @@ bool receive_datagram(struct event_queue* route,
|
||||||
/* Copy datagram. */
|
/* Copy datagram. */
|
||||||
memcpy(buffer, (struct datagram*) event.data, sizeof(struct datagram));
|
memcpy(buffer, (struct datagram*) event.data, sizeof(struct datagram));
|
||||||
|
|
||||||
/* Free datagram buffer. */
|
/* Clear datagram event. */
|
||||||
|
memset(((struct datagram*) event.data)->data,
|
||||||
|
0,
|
||||||
|
((struct datagram*) event.data)->size);
|
||||||
|
|
||||||
|
/* Free datagram event. */
|
||||||
((struct datagram*) event.data)->used = false;
|
((struct datagram*) event.data)->used = false;
|
||||||
|
|
||||||
/* Everything went ok. */
|
/* Everything went ok. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue