Inserting large quantities of fids in /proc/empeg_notify

Posted by: cushman

Inserting large quantities of fids in /proc/empeg_notify - 04/09/2004 01:47

I'm using /proc/empeg_notify to insert tunes into the playlist programatically from Empire.

What I've found is that when inserting many songs at the same time , the player may crash (I guess it does, it just exits to the shell). Here is the end of the serial output when attempting to enqueue 66 songs:

<61 fids before this point>
#0000052F0-
#00000CBF0-
#00000CC00-
#00000CC10-
#00000CC20-
Restored terminal settings
Remounting first music partition read-only
Remounting second music partition read-only
Player exited normally: 1
Switching to shell-player loop
Starting bash.
empeg:/empeg/bin#


Here is the relevant code I'm using to write to /proc/empeg_notify:

Code:

// uint8_t_body is the OBEX object, which is a string of 8 digit fids
// with no delimiter, I just copy the next 8 characters
// notify_fd is a file handle for /proc/empeg_notify

for(i = 0; i <= body_len - 8; i += 8) {
strcpy(fid, "#XXXXXXXX0-");
memcpy(fid + 1, (uint8_t_body + i), 8);
fid_command(fid, notify_fd);
}

void fid_command(const uint8_t *fid, int notify_fd) {
char *serial_cmd;
serial_cmd = malloc(strlen(fid) + 9);
snprintf(serial_cmd, strlen(fid) + 9, "SERIAL=%s\n", fid);
empeg_command(serial_cmd, notify_fd);
free(serial_cmd);
}

void empeg_command(char *serial_cmd, int notify_fd) {
write(notify_fd, serial_cmd, strlen(serial_cmd));
}


The enqueue action fails around 66 songs. I can enqueue 65 at once ok, but more than that it exits to the shell as above. I do not think this is a constant number though, because I seem to remember being able to enqueue more earlier. Any insight as to why this would happen would be greatly appreciated. Full source to my test version of empire is attached.
Posted by: mlord

Re: Inserting large quantities of fids in /proc/empeg_notify - 04/09/2004 10:45

Could be the same thing that causes it to crash when simply hitting the "Next Track" button (remote or front panel) a few gadzillion times in a row, as well.

Cheers
Posted by: cushman

Re: Inserting large quantities of fids in /proc/empeg_notify - 06/09/2004 16:43

Thanks, Mark. I think as a workaround I will just insert a delay after x number of serial commands to allow the player to "catch up". I can see when I insert a lot of songs the playlist size slowly increments over a matter of 5 or so seconds to match the amount of songs actually inserted. It should not be a problem for someone who is inserting/enqueueing 50+ songs to have to wait an additional 5-10 seconds for the entire playlist to be up on the player. The first track will be sent immediately, so no wait there.

Unless this is something that can be fixed in the player software for a later release.
Posted by: genixia

Re: Inserting large quantities of fids in /proc/empeg_notify - 06/09/2004 16:48

Which player version?
Posted by: cushman

Re: Inserting large quantities of fids in /proc/empeg_notify - 06/09/2004 17:55

2.00

Edit: Just in case anyone who has the power to fix the player software is reading this, please also fix the bug where inserting or enqueueing to an empty playlist (like after an upgrade or crash) crashes the player. This exists also in 2.00 final.
Posted by: tms13

Re: Inserting large quantities of fids in /proc/empeg_notify - 07/09/2004 09:12

That number 66 looks suspicious. Assuming that the player gets around to acting on the first FID you send, that's 64 that work, and then the 66th fails. 64 looks suspiciously like it might be the size of some buffer in the code...
Posted by: cushman

Re: Inserting large quantities of fids in /proc/empeg_notify - 07/09/2004 15:08

Ok, workaround complete. Here was my stress test:

Posted by: SE_Sport_Driver

Re: Inserting large quantities of fids in /proc/empeg_notify - 07/09/2004 21:04

Sweet!

Is this empire (version 0.25)?
Posted by: cushman

Re: Inserting large quantities of fids in /proc/empeg_notify - 07/09/2004 21:11

Most definately not! It was the reason I had to code the workaround. Empire 0.25 probably only handles ~65 or so tunes. I'm busy packaging a new version that should be out later tonight or tomorrow. I would like to include an install script this time around, so I'm stealing some of Tony C's work in that area. The install should be very simple by the time I'm done.
Posted by: SE_Sport_Driver

Re: Inserting large quantities of fids in /proc/empeg_notify - 07/09/2004 21:14

Oh nice! I thought the fix would have to be on the Palm side but didn't notice a newer version number. The latest empire version I had in my saved folder was .20, but I wasn't sure if the version you cooked up for me was in that same folder or not...

I'm willing to test your script on my player that already has empire on it if you need..