Rockbox Development > Starting Development and Compiling

converting char* to char *

<< < (2/2)

linuxstb:
Also, (as you can see in properties.c), you should use the more general get_metadata() function on the swcodec targets (i.e. everything apart from Archos), and mp3info for hwcodec (i.e. Archos).

EDIT: Your call to read_line is also wrong - it will write into the buffer pointed to by "buf", but it doesn't point anywhere...  Instead of declaring buf as "char* buf", you should declare it as "char buf[MAX_PATH];".

GodEater:
...and looking again, in your first post, I see you have two definitions of your id3 struct.

First you had :

--- Code: ---struct mp3entry *id3 = audio_current_track();

--- End code ---

and then further down you had:

--- Code: ---struct mp3entry *id3;    //although yours was missing the ';' :D

--- End code ---

The first one is ok, because the audio_current_track() call sorts out getting the memory that the id3* pointer is "looking" at.

The second one (I assume in another function? Although it's hard to tell without seeing all your code) *isn't* okay - because all you've said is "this is a pointer", you've not actually got it pointing to any memory anywhere.

So either you need to pass the value obtained from the first call to audio_current_track() into the second definition of id3 somehow, or do the call again.

And in any event, when you have it defined as a pointer, when you end up calling mp3info() - (although don't - do what linuxstb said!) - you do it like this :


--- Code: ---rb->mp3info(id3,buf2);      // i.e. without the '*' on the front of id3

--- End code ---

Using the '*' tells the compiler to dereference the pointer (i.e. use what it's pointing at), and you just want the value of the pointer itself to go to mp3info (i.e. where it's pointing).

mschneider:
First off, thanks for all of your help. I've tried doing what you advised and as far as I can tell it should work for what I am trying to accomplish - but I've run into a few compiler warnings. Here's my entire code (the first section in my first post refers to how I am saving the path of the currently playing file), this is how I am trying to access the ID3 information:

--- Code: ---int goto_track(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);

}
--- End code ---

Here are the compiler warnings I am getting:


--- Code: ---CC tesplugin.c
testplugin.c: In function 'goto_track':
testplugin.c:375: warning: passing argument 2 of 'rb->read_line' from incompatible pointer type
testplugin.c:377: warning: passing argument 1 of 'rb->open' from incompatible pointer type
testplugin.c:379: warning: passing argument 3 of 'rb->get_metadata' from incompatible pointer type
testplugin.c:385: warning: control reaches end of non-void function
LD testplugin.elf
OBJCOPY testplugin.rock
MAKE in shortcuts
make[3]: Nothing to be done for `all
--- End code ---

Again, thanks for all the help.

linuxstb:
You've defined "current_track" to be an array of pointers to char.

It should be "char current_track[MAX_PATH]";

The last warning is because you've defined your function to be of type "int" - meaning that it should return an integer (e.g. you could use 0 for success, -1 for failure).  

Navigation

[0] Message Index

[*] Previous page

Go to full version