Re: [fpc-pascal] Get value of PPChar ?
Am 2017-04-16 um 19:45 schrieb fredvs: >> And how you'll need to use it will depend upon the function's documentation > With audio libraries there is a law: NO doc (other that the C header) and NO > demos. > So you must guess and explore all by your self. Now that's a useful working mode! No bugs will ever exist because no code behaviour can violate the documentation! How programming has degraded... ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Hello. For those who are interested, Thomas Orgis (the creator of mpg123) did answer: ---> https://sourceforge.net/p/mpg123/bugs/248/ Fre;D - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728291.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Free Pascal - General mailing list wrote > No, your "var PPChar" was still wrong. It's either "var PChar" or "PPChar" > and nothing else. Huh, in last commit (5e680a4 10 hours ago) ---> https://github.com/fredvs/uos/blob/master/src/uos_mpg123.pas#L673 Fre;D PS: Do you agree if I add you to the great contributors ? - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728290.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Am 17.04.2017 00:47 schrieb "fredvs": > > Free Pascal - General mailing list wrote > > According to the code it also returns 0 with icy_meta being Nil if there > > is no corresponding data: > > https://github.com/georgi/mpg123/blob/master/src/libmpg123/libmpg123.c#L1384 > > Ha, nice, you did find the only doc available : the source code (that > contains no comment, of course ;-) ) > > Yep, this would solve everything. > In fact solve nothing because the code was ok then ;-) No, your "var PPChar" was still wrong. It's either "var PChar" or "PPChar" and nothing else. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Free Pascal - General mailing list wrote > According to the code it also returns 0 with icy_meta being Nil if there > is no corresponding data: > https://github.com/georgi/mpg123/blob/master/src/libmpg123/libmpg123.c#L1384 Ha, nice, you did find the only doc available : the source code (that contains no comment, of course ;-) ) Yep, this would solve everything. In fact solve nothing because the code was ok then ;-) OK, I keep the doubt that this web-radio is not sending ivy like they say: http://stream-uk1.radioparadise.com/mp3-128 Thanks Sven. Fre;D PS: If somebody knows a web-radio that really sent ivy-data, you are welcome to give the url (to test it). - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728288.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
On 16.04.2017 18:52, fredvs wrote: > Free Pascal - General mailing list wrote >> function mpg123_icy(mh: Tmpg123_handle; var icy_meta: PChar): Integer; >> cdecl; > > Thanks for your answer. > > I did try with this but : > > res := mpg123_icy(mph,theicytag); > > if (res = 0) then writeln('resu = ' + inttostr(res)); // OK = 0 > > if Assigned(theicytag) then writeln('theicytag = assigned') > else writeln('theicytag NOT assigned') ; /// always theicytag NOT assigned According to the code it also returns 0 with icy_meta being Nil if there is no corresponding data: https://github.com/georgi/mpg123/blob/master/src/libmpg123/libmpg123.c#L1384 Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
>And how you'll need to use it will depend upon the function's documentation Huh, you did not know ? With audio libraries there is a law: NO doc (other that the C header) and NO demos. So you must guess and explore all by your self. Fre;D - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728286.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Bart-48 wrote > If you know that res equals 0, then a simple writeln('resu = 0'); would > suffice. > Second, there is no need do an inttostr(res) inside write(ln). > Write(ln) is perfectly capable of writing integers (as it has been Huh, of course I know all this, sorry, I just mixed copy paste of some code. So the problem remain, why icydata is never assigned ? (even with a result = 0). Should it by assigned before, .(assigning memory) ? Fre;D - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728285.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Free Pascal - General mailing list wrote > function mpg123_icy(mh: Tmpg123_handle; var icy_meta: PChar): Integer; > cdecl; Thanks for your answer. I did try with this but : res := mpg123_icy(mph,theicytag); if (res = 0) then writeln('resu = ' + inttostr(res)); // OK = 0 if Assigned(theicytag) then writeln('theicytag = assigned') else writeln('theicytag NOT assigned') ; /// always theicytag NOT assigned - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728283.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Christo Crause wrote > I suppose you have to allocate memory and create a pointer to a pointer to > this memory which you pass to the function. Hello and thanks for answer. Huh, ok, but how do you do this by code ? Fre;D - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728282.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
On 16.04.2017 16:58, fredvs wrote: > Hello. > > A C method is defined like this: > > MPG123_EXPORT int mpg123_icy(mpg123_handle *mh, char **icy_meta); > > and translated in Pascal with this: > > function mpg123_icy(mh: Tmpg123_handle; var icy_meta: PPChar): integer; > cdecl; This is wrong. "var" essentially results in a "char***". What you want is either function mpg123_icy(mh: Tmpg123_handle; icy_meta: PPChar): integer; cdecl; or function mpg123_icy(mh: Tmpg123_handle; var icy_meta: PChar): Integer; cdecl; And how you'll need to use it will depend upon the function's documentation: if the function will allocate the buffer then you simply need to pass in a PChar variable (second case) or a pointer to one (first case). If you need to allocate the buffer yourself then you first need to do a GetMem with an appropriate size before you do the same. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
Free Pascal - General mailing list wrote > resu := mpg123_icy(ahandle, theicytag); > if (resu = 0) and Assigned(theicytag) and Assigned(theicytag^) > then writeln(theicytag^); Hello and thanks for answer. Indeed, that way no more crash but also nothing from writeln(theicytag^). I did a check with this: resu := mpg123_icy(ahandle, theicytag); if (resu = 0) then writeln('resu = ' + inttostr(resu)); ---> OK if Assigned(theicytag) then writeln('theicytag = assigned') else writeln('theicytag NOT assigned') ; ---> theicytag NOT assigned if Assigned(theicytag^) then writeln('theicytag^ = assigned') else writeln('theicytag^ NOT assigned') ; ---> raise exception + crash ? Fre;D - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277p5728280.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
I suppose you have to allocate memory and create a pointer to a pointer to this memory which you pass to the function. On 16 Apr 2017 4:58 PM, "fredvs"wrote: > Hello. > > A C method is defined like this: > > MPG123_EXPORT int mpg123_icy(mpg123_handle *mh, char **icy_meta); > > and translated in Pascal with this: > > function mpg123_icy(mh: Tmpg123_handle; var icy_meta: PPChar): integer; > cdecl; > > OK, the function seems to work because the result = 0 (no error). > > But how to retrieve the data icy_meta (PPChar) ? > > var > theicytag : PPChar; > resu : integer; > ... > > resu := mpg123_icy(ahandle, theicytag); > if resu = 0 then writeln(theicytag^); --> raise exception + crash > > resu := mpg123_icy(ahandle, theicytag); > if resu = 0 then writeln(theicytag^^); --> also raise exception + crash > > Fre;D > > > > > > - > Many thanks ;-) > -- > View this message in context: http://free-pascal-general. > 1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277.html > Sent from the Free Pascal - General mailing list archive at Nabble.com. > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get value of PPChar ?
On 04/16/2017 10:58 AM, fredvs wrote: K, the function seems to work because the result = 0 (no error). But how to retrieve the data icy_meta (PPChar) ? var theicytag : PPChar; resu : integer; ... resu := mpg123_icy(ahandle, theicytag); if resu = 0 then writeln(theicytag^); --> raise exception + crash resu := mpg123_icy(ahandle, theicytag); if resu = 0 then writeln(theicytag^^); --> also raise exception + crash You haven't checked if theicytag is nil. The call to mpg123_icy may succeed but still the tag may be nil. resu := mpg123_icy(ahandle, theicytag); if (resu = 0) and Assigned(theicytag) and Assigned(theicytag^) then writeln(theicytag^); Regards, Andrew ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal