Recent

Author Topic: OpenAl compiles but does not run  (Read 1136 times)

murph

  • Newbie
  • Posts: 2
OpenAl compiles but does not run
« on: March 10, 2019, 06:39:43 pm »
Hi,
I am quite new to FPC and recently installed Lazarus v.1.8.2+dfsg-3 and FPC under Ubuntu Linux 18.04. It seems to work normally.
I also installed the fp-units-multimedia package of Ubuntu, as I wanted to work with OpenAl.

I copied the files of /usr/share/fpcsrc/3.0.4/packages/openal/ to my home directory and tried to compile the wavopenal.pas with FPC:
fpc wavopenal.pas

The output was:

Free Pascal Compiler version 3.0.4+dfsg-18ubuntu2 [2018/08/29] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling wavopenal.pas
Linking wavopenal
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
330 lines compiled, 0.3 sec


When I try to execute the binary it gives me some errors:

Blocksize    : 4
Rate         : 44100
Channels     : 2
OpenAL Buffers     : 4
OpenAL Buffer Size : 20000
An unhandled exception occurred at $00007F13A86C204B:
EDivByZero: Division by zero
  $00007F13A86C204B

An unhandled exception occurred at $00007F13A831D66E:
EAccessViolation:
  $00007F13A831D66E
  $00007F13A83F14C6


The problem seems to occur when the context is created:
  al_context := alcCreateContext(al_device, nil);
which I found out aftter inserting some writeln's. Does anyone know what to do to get this to work?

Thanks a lot!

JernejL

  • Jr. Member
  • **
  • Posts: 56
Re: OpenAl compiles but does not run
« Reply #1 on: March 11, 2019, 07:39:38 am »
Show more code - parameter al_device in alcCreateContext call should be result from alcOpenDevice, alcOpenDevice requires device name - or a nil pointer, to choose default audio device.
 
Also, check with alcGetError if alcOpenDevice fails. 
 

Thaddy

  • Hero Member
  • *****
  • Posts: 8969
Re: OpenAl compiles but does not run
« Reply #2 on: March 11, 2019, 08:13:31 am »
Show more code - parameter al_device in alcCreateContext call should be result from alcOpenDevice, alcOpenDevice requires device name - or a nil pointer, to choose default audio device.
 
Also, check with alcGetError if alcOpenDevice fails.
The code is provided as standard: it is in de example directory of the openal package. The first call to openal is alcOpenDevice. Indeed, you can add alcGetError after alcOpenDevice to get some more info.
Here the example works. try re-installing libopenal1 and libopenal-dev.
Most people that want to use threading should learn to patch their jeans first: use a needle.

Mr.Madguy

  • Sr. Member
  • ****
  • Posts: 455
Re: OpenAl compiles but does not run
« Reply #3 on: March 11, 2019, 10:12:52 am »
First of all try to disable FPU/SSE exceptions.
Code: Pascal  [Select]
  1.   SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
  2.     exOverflow, exUnderflow, exPrecision]);
  3.  
DynamicData 3.0 is released!
Since now development is frozen - only optimization passes will be made at some point.
Lack of multiple inheritance turns it into abomination.

Thaddy

  • Hero Member
  • *****
  • Posts: 8969
Re: OpenAl compiles but does not run
« Reply #4 on: March 11, 2019, 10:19:37 am »
Ah, yes, I missed the Intel platform somehow, but he uses Linux afaikt and such non-IEEE 754 conformant masking should be only needed on Windows: Target OS: Linux for x86-64
I still think this is not the issue, because by now I also tested win64.
« Last Edit: March 11, 2019, 10:24:19 am by Thaddy »
Most people that want to use threading should learn to patch their jeans first: use a needle.

murph

  • Newbie
  • Posts: 2
Re: OpenAl compiles but does not run
« Reply #5 on: March 11, 2019, 10:58:10 am »
First of all try to disable FPU/SSE exceptions.
Code: Pascal  [Select]
  1.   SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
  2.     exOverflow, exUnderflow, exPrecision]);
  3.  

This did it (alothough I am on Linux)! Thanks a lot!

Thaddy

  • Hero Member
  • *****
  • Posts: 8969
Re: OpenAl compiles but does not run
« Reply #6 on: March 11, 2019, 11:21:43 am »
Note it can mask away other issues.... Afaik most Linux compilers are compliant, VS compilers are not. But hey, if it works for now? Just make a note in your code please...
(I did not need to mask the FPU....)
Most people that want to use threading should learn to patch their jeans first: use a needle.

Mr.Madguy

  • Sr. Member
  • ****
  • Posts: 455
Re: OpenAl compiles but does not run
« Reply #7 on: March 11, 2019, 01:07:21 pm »
Note it can mask away other issues.... Afaik most Linux compilers are compliant, VS compilers are not. But hey, if it works for now? Just make a note in your code please...
(I did not need to mask the FPU....)
Many drivers are written with FPU/SSE exceptions off in mind. Not all, but many. Even from exactly the same manufacturer. For example GTX660 drivers may be ok, but GT210 aren't. Such note even exists in some SDK documents, like OpenGL and Direct3D ones. I guess, that's because FPU/SSE exceptions are off in C++ by default. I noticed this problem, when I was testing my own 3D application on different computers. It was working properly at home, but was crashing during device creation at work. I wrote a ticket to NVidia's support, but they treated me as crazy. And after that I realized, that exceptions must be off. So, it looks like this rule is applicable to OpenAL too.
DynamicData 3.0 is released!
Since now development is frozen - only optimization passes will be made at some point.
Lack of multiple inheritance turns it into abomination.