Rockbox Development > Starting Development and Compiling
converting char* to char *
mschneider:
I'm switching between two different plugins with the audio stopped, and I'm trying to retain some ID3 information. What I'm doing is stopping the audio and saving the path of the currently playing track as a file. I then enter the plugin and try to load ID3 information about the stopped file from the saved path. The functions i am using take different pointers though and the strings seem to be incompatible.
Here is the information saving:
--- Code: ---struct mp3entry *id3 = audio_current_track();
fd = rb->open("./path.txt", O_RDWR|O_CREAT);
rb->fdprintf(fd, id3->path);
rb->close(fd);
audio_stop();
--- End code ---
I then try to read the line of the file with the path into a buffer and then use that path to get the id3 information with rb->mp3info.
--- Code: ---char* buf;
char *buf2;
struct mp3entry *id3
fd = rb->open("./path.txt", O_RDONLY);
rb->read_line(fd, buf, 150);
buf2 = buf;
rb->mp3info(*id3, buf2);
--- End code ---
The read_line function takes char* buf though and the rb->mp3info function takes char *filename. Is there any way to do this?
saratoga:
--- Quote from: mschneider on January 16, 2008, 08:28:30 PM ---
The read_line function takes char* buf though and the rb->mp3info function takes char *filename. Is there any way to do this?
--- End quote ---
Both of those have type "char *". "buf" and "filename" are just variable names, not types themselves. Have you tried printing buf ? My guess is it contains something other then the file path and therefore the call to mp3info() fails, but I'm not really sure.
mschneider:
I have tried nearly everything I can think of. Everything either says that the pointer is without a cast or prints nothing into the buffer. Are there any other ways to load the Id3 information of a stopped track?
GodEater:
Looking at your code again, I don't think it's the char* that's causing the error message you're seeing, I think it's your id3 struct.
You have :
--- Code: ---struct mp3entry *id3
rb->mp3info(*id3, buf2);
--- End code ---
And what I *think* you should have is :
--- Code: ---struct mp3entry id3;
rb->mp3info(&id3, buf2);
--- End code ---
LinusN:
GodEater is correct. Check out apps/plugins/properties.c to see how it is done.
Navigation
[0] Message Index
[#] Next page
Go to full version