Rockbox Development > Starting Development and Compiling
comparing strings
(1/1)
mschneider:
I'm working with the pictureflow plugin and I'm trying to get the slide being displayed (center_index) to be the stopped track. I've written some code (with help) to stop audio and save the path, and then load the id3 information of that track. The function returns the album name since pictureflow really runs off an album index.
--- Code: ---/*
Load id3 info for the stopped track and return the album name
*/
char goto_slide(void)
{
int fd;
char current_track[MAX_PATH];
struct mp3entry id3;
fd = rb->open(TEMP_PATH, O_RDONLY);
rb->read_line(fd, current_track, MAX_PATH);
rb->close(fd);
fd = rb->open(current_track, O_RDONLY);
#if (CONFIG_CODEC == SWCODEC)
if (fd >= 0 && rb->get_metadata(&id3, fd, current_track))
#else
if (!rb->mp3info(&id3, current_track));
#endif
rb->close(fd);
rb->remove(TEMP_PATH); /* Get rid of the temp file */
return id3.album;
}
--- End code ---
the center_index is an int so i need to get the number in the album index of the album I have id3 info for. This is where I have my problem. Here is what I am doing:
--- Code: ---int seek_ci(void)
{
center_index = 1;
while ( (rb->strcmp(goto_slide, album_names[center_index])) != 0 )
center_index++;
return center_index;
}
--- End code ---
The album_names array is just a character array that stores the names of all the albums. I figured that when these were equal I would have a match and I could set the center_index to that number- however this is not the case. I get the start screen for pictureflow and then nothing happens..
If someone who knows the plugin could help out it would be greatly appreciated. Thanks.
NicolasP:
album_names is a buffer where all strings are stored. To access the strings, you can to use the get_album_name() function. Also you probably need a couple of parenthesise to call the goto_slide() function in that strcmp() call.
mschneider:
thanks for clearing things up. (This is a general question) what does rb->open return if it is not able to open a file?
NicolasP:
It will return a strictly negative value.
Navigation
[0] Message Index
Go to full version