Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Listener. The app doesn't respond.  (Read 3943 times)

0 Members and 1 Guest are viewing this topic.

Mike__

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf::Listener. The app doesn't respond.
« on: July 11, 2014, 11:01:31 am »
Hello. I use SFML 2.1 inside teamspeak plugin.
I used sf::Sound object like in tutorials.
sf::Sound sound;
The plugin could not be initialised. The application didn't respond.
Ok, I've solved it:
sf::Sound* sound;
...

int ts3plugin_init() {
    sound = new sf::Sound();
    ...
}
After this the application can initialize the plugin successfully and it works properly. (SFML is a very good thing).

But.
If i use sf::Listener in any place of my plugin then teamspeak cannot unload this plugin. It doesn't respond.
If I remove all sf::Listener call then teamspeak can unload plugin properly.
I can't use pointer on sf::Listener object because it has static methods only.
Can you help me?

Upd:
I suppose it happens because:
void ensureALInit()
{
    // The audio device is instantiated on demand rather than at global startup,
    // which solves a lot of weird crashes and errors.
    // It is destroyed at global exit which is fine.

    static AudioDevice globalDevice;
}
 
« Last Edit: July 11, 2014, 11:20:42 am by Mike__ »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: sf::Listener. The app doesn't respond.
« Reply #1 on: July 11, 2014, 12:42:39 pm »
Not sure exactly what you are asking, but it seems to be related to you using global objects. When using SFML (and in most other cases) it is a very good idea to avoid using global variables as they will cause issues (as seems to be the case here).
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mike__

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Listener. The app doesn't respond.
« Reply #2 on: July 11, 2014, 01:15:41 pm »
The plugin based on callback functions and I can't avoid global objects at all.

But the problem is if I use sf::Listener then teamspeak can't unload plugin.

in other words:
If I will write only one SFML row:
sf::Listener::setPosition(5.f, 0.f, 5.f);
Then teamspeak will not be able to unload plugin with this row. If I will delete this row then all will works fine.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::Listener. The app doesn't respond.
« Reply #3 on: July 11, 2014, 01:47:59 pm »
You should try to compile this branch, it changes the way the audio context is managed by SFML and may solve your problems.

https://github.com/SFML/SFML/tree/bugfix/al_context
Laurent Gomila - SFML developer

Mike__

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Listener. The app doesn't respond.
« Reply #4 on: July 12, 2014, 08:56:34 am »
I couldn't use this branch cause I got incorrect static (*-s.lib) files (there was linking error while compiling plugin).
But I've solved my problem this way(SFML 2.1 sources fast fix):

AudioDevice* globalDevice = NULL;
void ensureALInit()
{
        if(globalDevice == NULL){
                globalDevice = new AudioDevice();
        }
}

void aLEnd()
{
                globalDevice->~AudioDevice();
                globalDevice = NULL;
}

I call aLEnd function manually before plugin unloading. In this case I can reload plugin properly.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::Listener. The app doesn't respond.
« Reply #5 on: July 12, 2014, 09:28:27 am »
This is wrong, you should call "delete globalDevice", not just the destructor (otherwise the memory is never deallocated).

But what's your problem with the branch? Whay do you say the lib files were incorrect?
Laurent Gomila - SFML developer

Mike__

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Listener. The app doesn't respond.
« Reply #6 on: July 12, 2014, 09:56:17 am »
This is wrong, you should call "delete globalDevice", not just the destructor (otherwise the memory is never deallocated).
I missed it. Thanks.


If I use sfml-system-s.lib and sfml-audio-s.lib from this branch then I got while plugin compiling:
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alSourcePause"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alGetSourcef"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alGetSourcef"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alSourceQueueBuffers"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alBufferData"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alSourceUnqueueBuffers"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alGetSourcei"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alGetSourcei"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alSourcePlay"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alDeleteBuffers"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alSourcei"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alSourcei"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alSourceStop"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alGetBufferi"
1>sfml-audio-s.lib(SoundStream.obj) : error LNK2001: unresolved external symbol "__imp__alGenBuffers"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alGenSources"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alDeleteSources"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alSourcef"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alSource3f"
1>sfml-audio-s.lib(SoundSource.obj) : error LNK2001: unresolved external symbol "__imp__alGetSource3f"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alcCloseDevice"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alcDestroyContext"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alcMakeContextCurrent"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alListenerf"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alListener3f"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alListenerfv"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alcCreateContext"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alcOpenDevice"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alGetEnumValue"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alIsExtensionPresent"
1>sfml-audio-s.lib(AudioDevice.obj) : error LNK2001: unresolved external symbol "__imp__alcIsExtensionPresent"


Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::Listener. The app doesn't respond.
« Reply #7 on: July 12, 2014, 10:22:55 am »
Define SFML_STATIC. When you link statically, you also have to link SFML's dependencies (such as OpenAL) explicitly.
« Last Edit: July 12, 2014, 10:26:24 am by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mike__

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Listener. The app doesn't respond.
« Reply #8 on: July 12, 2014, 10:27:07 am »
I use it.

SFML alContext:
WIN32;_WINDOWS;NDEBUG;SFML_STATIC;_CRT_SECURE_NO_DEPRECATE;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)

plugin:
SFML_STATIC;WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN2_EXPORTS;QT_THREAD_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions)

upd:
I can't use sfml-audio-s.lib in alContext branch compilation, but v2.1 works for me.
« Last Edit: July 12, 2014, 10:42:11 am by Mike__ »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::Listener. The app doesn't respond.
« Reply #9 on: July 12, 2014, 10:56:55 am »
Read my edit ;)

The linking has changed after 2.1, now you have to do it manually for static libraries.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mike__

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Listener. The app doesn't respond.
« Reply #10 on: July 12, 2014, 11:23:46 am »
Is that means I have to compile SFML dependents as static lib too?

Can you give me an example or short manual on it?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::Listener. The app doesn't respond.
« Reply #11 on: July 12, 2014, 11:43:55 am »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mike__

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Listener. The app doesn't respond.
« Reply #12 on: July 12, 2014, 12:15:44 pm »
Ok, I understood.
Thanks for your help.