[Openal-devel] Initializing openal/alut second time crashes.
Joni Yrjana
joyr at netikka.fi
Sat Feb 25 10:33:53 PST 2006
Hello,
I'm trying to make it possible in my application to turn sound on and
off whenever user wants to. But after trying to initialize OpenAL/alut
second time after closing it, the program crashes. As far as I can tell
reading the manual, this should be possible to do.
This is on linux system (Fedora Core 4), I have included my testing
session below. Let me know if you need more information.
Also when alutInit() (or more precisly alcOpenDevice()) fails because of
device is busy it outputs error message to stderr. This is not very good
for an application that uses terminal for other purposes (like when
using curses). But I suppose this gets fixed eventually, when the
library reaches more mature version.
$ gcc -ggdb -O0 $(pkg-config --cflags --libs openal freealut) x.c
$ gdb ./a.out
GNU gdb Red Hat Linux (6.3.0.0-1.84rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/libthread_db.so.1".
(gdb) r
Starting program: /tmp/a.out
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0xceb000
[Thread debugging using libthread_db enabled]
[New Thread -1209076032 (LWP 27583)]
[New Thread -1209078864 (LWP 27586)]
[Thread -1209078864 (zombie) exited]
[New Thread -1209078864 (LWP 27587)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1209076032 (LWP 27583)]
0x002cf868 in alcCloseDevice () from /usr/lib/libopenal.so.0
(gdb) bt
#0 0x002cf868 in alcCloseDevice () from /usr/lib/libopenal.so.0
#1 0x002ceb41 in alcMakeContextCurrent () from /usr/lib/libopenal.so.0
#2 0x001e3ef6 in alutInit () from /usr/lib/libalut.so.0
#3 0x080485fb in main () at x.c:15
(gdb) q
The program is running. Exit anyway? (y or n) y
$ nl -ba x.c
1 #include <AL/alc.h>
2 #include <AL/al.h>
3 #include <AL/alut.h>
4 #include <stdio.h>
5
6 int main(void)
7 {
8 ALenum e;
9
10 e = ALUT_ERROR_NO_ERROR;
11 if(alutInit(0, NULL) == AL_TRUE)
12 {
13 if(alutExit() == AL_TRUE)
14 {
15 if(alutInit(0, NULL) == AL_TRUE)
16 {
17 if(alutExit() == AL_TRUE)
18 {
19 printf("All ok\n");
20 }
21 else
22 e = alutGetError();
23 }
24 else
25 e = alutGetError();
26 }
27 else
28 e = alutGetError();
29 }
30 else
31 e = alutGetError();
32
33 if(e != ALUT_ERROR_NO_ERROR)
34 printf("error %x: %s\n", (unsigned int) e,
alutGetErrorString(e));
35
36 return 0;
37 }
38
$ rpm -q openal freealut
openal-0.0.9-0.2.20060204cvs.fc4
freealut-1.0.0-2.fc4
$ pkg-config --modversion openal freealut
0.0.8
1.0.0
$ uname -a
Linux doors.joyr.fi 2.6.15-1.1831_FC4 #1 Tue Feb 7 13:37:42 EST 2006
i686 athlon i386 GNU/Linux
$
Here's a shorter version of the program that crashes:
#include <AL/al.h>
#include <AL/alut.h>
#include <stdio.h>
int main(void)
{
alutInit(0, NULL);
alutExit();
alutInit(0, NULL);
alutExit();
return 0;
}
Best regards,
Joni Yrjana
More information about the Openal-devel
mailing list