Trying to display names from soundtrack
#1
i'm trying to display the name of song instead of the filename. i created a function that does it, but whenever pass it to the setlabel function, it passes the pointers info instead of the song.

example... should display my immortal but displays "|||||||||||| ||"

here's the codes that passes it.
if(dwsongid==songid)
{

char name[64];
wcstombs(name,songname,64);
clog::log("%s",name);
char* ptr2= name;
return ptr2;
//return "this is a test!!!";
}

it is a char* function.

i can't seem to figure this out. can someone help me?
Reply
#2
it's because ptr2 is a pointer to the front of the statically allocated character array name. as soon as you go out of scope (ie when you return), name is deleted, and so you have a pointer to nothing. that's why you get garbage.

one way you could achieve what you want is by dynamically allocating the character string and send it back, and making sure you delete[] it correctly after you've finished with it.

also, note that name is a pointer to a char (it's an array), so you should be able to just return name, assuming it was dynamically allocated.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
thanks for the help jmarshall....i believe i figured out how to do it now.
Reply
#4
Thumbs Up 
when you say "soundtrack" do you mean the xboxdash ripped music/soundtracks?, as in reading from xboxdash st.db database?

if so then you can much info on it here: access/read/display/play xbox dash st.db music, download the research/code here (link)
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#5
the xbox has a function to read from the st.db, so i just used that function instead of reading the bytes of the header and such.
Reply

Logout Mark Read Team Forum Stats Members Help
Trying to display names from soundtrack0