Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: mschneider on February 04, 2008, 12:12:52 PM

Title: comparing strings
Post by: mschneider on February 04, 2008, 12:12:52 PM
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: [Select]
   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);
    fd = rb->open(current_track, O_RDONLY);
    if (fd >= 0 && rb->get_metadata(&id3, fd, current_track))
    if (!rb->mp3info(&id3, current_track));
    rb->remove(TEMP_PATH); /* Get rid of the temp file */

    return id3.album;

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: [Select]
int seek_ci(void)
    center_index = 1;

    while ( (rb->strcmp(goto_slide, album_names[center_index])) != 0 )
    return center_index;

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.
Title: Re: comparing strings
Post by: NicolasP on February 10, 2008, 02:25:20 PM
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.
Title: Re: comparing strings
Post by: mschneider on February 11, 2008, 06:16:41 PM
thanks for clearing things up. (This is a general question) what does rb->open return if it is not able to open a file?
Title: Re: comparing strings
Post by: NicolasP on February 11, 2008, 06:20:42 PM
It will return a strictly negative value.