a solved problem with Exception

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

a solved problem with Exception

Regor
I have tried to integrate the example program "Multiplayer" in my own Lazarus program. The example program "Multiplayer" works fine.

When I loaded the libraries (in my own Lazarus program) an exception occurs.

I thought it couldn't be that the example works, but I put it in I can't do with my program.

I have entered all units in "uses", as in your example program.

Still crashed and always with:

................
(in uos_flat.pas)
uosInit := TUOSINIT.Create; // Create Libraries LoaderInit ===> Exception
................

Finally I came across the fact that my myapp.lpr file only had the following entry:
................
uses
{$IFDEF UNIX} {$IFDEF UseCThreads}
cthreads {$ENDIF} {$ENDIF} ...
................


Then I manually added the following lines to my myapp.lpr file (as in multiplayer.lpr, long time I search for the solution [2 days]):
................
{$Define UseTheads}                <====== was not present
uses
{$IFDEF UNIX} {$IFDEF UseCThreads}
cthreads, cwstring, {$ENDIF} {$ENDIF} ...
................

And then it's working now. I really took over all "uses" and the"project settings" from "Multiplayer"-example as well. Anyway, it's working now, great.

I send you this post, because I don't know if I did something wrong or not (maybe yes, I'm not a university-educated-programmer).

Maybe others might have the same error and I cud help.

Thanks again, uos is very helpful, because this f*** playSound()-function can only play .wav-files, so I can use .ogg now under wingdows too (wav = 230 mb, ogg = 40 mb), so a had done a workaround with mplayer, but uos has fixed many problems. Super, thank you very much Mr. Van Stappen (sorry for my bad-English).
Reply | Threaded
Open this post in threaded view
|

Re: a solved problem with Exception

fredvs
Administrator
Hello Regor and welcome to uos forum.

> {$Define UseTheads}    

Yes, of course it is needed when you use threads.
And I agree with you, it is not the most clear and logic part of fpc.
IMHO, {$Define UseTheads} should be enabled by default, because it is always needed for Unix system.

This was already asked in fpc forum (but without positive reaction).

Anyway, I am happy that you found the solution.

Fe;D

Reply | Threaded
Open this post in threaded view
|

Re: a solved problem with Exception

Regor
Hello Mr. Van Stappen

I thank you very much for your answer. It's a big honor for me.

{$Define UseTheads} is always manually entered in .lpr-file?
Because I don't touch this .lpr-file ever manually by editor eg. pluma.
.....
Please, an other question:
Where can or had I do what to enable {$Define UseTheads} by default?
(in project-options? compiler-options? always only in the .lpr-file).
Or whit other words: «what I should have done to "enable {$Define UseTheads}"?»
.....
It is because I read more the German-fpc forum when possible.
English is a little difficult for me to find the solutions.
.....
But, it works now, I'm very happy, thank you a lot, uos is very helpful, because other Audio-Libs I didn't could install and without uos myApp would be a tinker/handicraft.

PS. Because I have used "unit Process" to start mplayer (whit TProcess)
When I use "Process", {$Define UseTheads} don't will be defined automatically?
..................
  {$ifdef LINUX}
uses
  // LCLIntf für RGB-Funktion
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  Menus, Buttons, Grids, ComCtrls, INIFiles, Process, Types, LCLIntf, LCLType;
  {$endif}

  {$ifdef WINDOWS}
uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  StdCtrls, Menus, Buttons, Grids, ComCtrls, INIFiles, {Process,} mmSystem, LCLIntf;
  {$endif}
..................
procedure TForm1.MySoundPlay(const pSoundfile: word);
...
    try
      AProcess := TProcess.Create(nil);                         // showmessage('Hallo: '+ gPathToSoundFile + pSoundfile);
      AProcess.Executable := 'mplayer';
      AProcess.Parameters.Add(gPathToSoundFile + intToStr(pSoundfile) + '.wav');   //showmessage('gPathToSoundFile  + pSoundfile: ' + gPathToSoundFile  + pSoundfile);
      AProcess.Execute; ...
Reply | Threaded
Open this post in threaded view
|

RE: a solved problem with Exception

fredvs
Administrator
Hello Regor.

About {$Define UseThreads}.
I am not sure to understand what you asked but it is needed if you use threads.
In uos, each player is a independent thread so {$Define UseThreads} is needed.

I do not use Lazarus, maybe there is a option to automatically add this {$Define UseThreads}-code in the main program unit (.lpr in Lazarus).


Fre;D


De : Regor [via uos] <ml+[hidden email]>
Envoyé : jeudi 5 septembre 2019 03:59
À : fredvs <[hidden email]>
Objet : Re: a solved problem with Exception
 
Hello Mr. Van Stappen

I thank you very much for your answer. It's a big honor for me.

{$Define UseTheads} is always manually entered in .lpr-file?
Because I don't touch this .lpr-file ever manually by editor eg. pluma.
.....
Please, an other question:
Where can or had I do what to enable {$Define UseTheads} by default?
(in project-options? compiler-options? always only in the .lpr-file).
Or whit other words: «what I should have done to "enable {$Define UseTheads}"?»
.....
It is because I read more the German-fpc forum when possible.
English is a little difficult for me to find the solutions.
.....
But, it works now, I'm very happy, thank you a lot, uos is very helpful, because other Audio-Libs I didn't could install and without uos myApp would be a tinker/handicraft.

PS. Because I have used "unit Process" to start mplayer (whit TProcess)
When I use "Process", {$Define UseTheads} don't will be defined automatically?
..................
  {$ifdef LINUX}
uses
  // LCLIntf für RGB-Funktion
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  Menus, Buttons, Grids, ComCtrls, INIFiles, Process, Types, LCLIntf, LCLType;
  {$endif}

  {$ifdef WINDOWS}
uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  StdCtrls, Menus, Buttons, Grids, ComCtrls, INIFiles, {Process,} mmSystem, LCLIntf;
  {$endif}
..................
procedure TForm1.MySoundPlay(const pSoundfile: word);
...
    try
      AProcess := TProcess.Create(nil);                         // showmessage('Hallo: '+ gPathToSoundFile + pSoundfile);
      AProcess.Executable := 'mplayer';
      AProcess.Parameters.Add(gPathToSoundFile + intToStr(pSoundfile) + '.wav');   //showmessage('gPathToSoundFile  + pSoundfile: ' + gPathToSoundFile  + pSoundfile);
      AProcess.Execute; ...



If you reply to this email, your message will be added to the discussion below:
http://uos.2369694.n4.nabble.com/a-solved-problem-with-Exception-tp657p659.html
To start a new topic under uos, email ml+[hidden email]
To unsubscribe from uos, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: a solved problem with Exception

Regor
In reply to this post by Regor
Yes, it is all clear now. Thank you very much for your support and answers and for great job with uos, uos is very useful for me.