Issue with focus

Posted By: TehV

Issue with focus - 01/05/14 18:41

Hi,
For a project I'm working on I need a program that runs on a secondary monitor. This has to be possible under the following conditions:

-The engine runs in fullscreen mode. This is required so that VSync is used, which is of highest importance to the program.
-The engine must be able to play sounds reliably.
-The program must continue working even if it is no longer in focus.


The problems I have are that when the engine loses focus (when I try to switch to another window):
-The engine is instantly minimized, and only becomes visible again when it regains focus.
-The snd_play functions do not play a sound when the engine is not in focus.


I have tried the following to work around these issues:
-I have tried fake fullscreens (setting an engine window without border to the same size as the monitor), but according to several sources, it is impossible to make a window mode application use VSync (I absolutely need VSync for this program).
-I have tried switching to the media_play functions, which are not suitable for this project. They appear to cut out a short bit of audio at the beginning of a sound - my sounds are only a fraction of a second long, and so it is possible (and this has happened!) that the whole sound is skipped.


Are there any possible workarounds to these problems that I may have missed?
Is it possible to trick the engine into 'thinking' it is in focus?
Posted By: rayp

Re: Issue with focus - 01/05/14 19:06

Quote:
Are there any possible workarounds to these problems that I may have missed?
Is it possible to trick the engine into 'thinking' it is in focus?

I dont have a solution sorry but i guess(!) this is caused by operating system / directx itself not the engine. A dirty hack would be a second (hidden) process controlled via sendmessage fex doing the job, setting focus / playing a sound then. But why do u want to switch to another window, while engine is in fullscreen ? Maybe theres a simple trick. HeelX well knows api-calls from lite-c, could be useable here. Just wild-guessing ^^. greets.
Posted By: TehV

Re: Issue with focus - 01/05/14 19:10

The engine is displayed on a secondary monitor, and it's controlled through another program that runs on the primary monitor - that's why I want to switch to another window while the engine is in fullscreen.
Posted By: pegamode

Re: Issue with focus - 01/05/14 19:19

For our Meteor Mess project we use FMOD for all audio stuff. With this the sound is played even if the engine is not in focus.

Have you checked the OpenAL sound feature? Maybe its behaviour is similiar to FMOD.
Posted By: TehV

Re: Issue with focus - 01/05/14 19:33

OpenAL plays the sound even if the engine is out of focus. Thanks!

...only it appears unable to play the sounds I used. I'll export them again and see if that fixes the problem.

EDIT: Out of the 20 sound files I have, only one can be loaded with OpenAL for some reason. This sound was created from scratch within Audacity. The rest can't be loaded, even though they could be loaded before (snd_createoal returns NULL for those sounds).
Posted By: pegamode

Re: Issue with focus - 01/05/14 20:10

Did you check if those sounds are stereo or mono? I haven't used OpenAL so far, but I think I read that it can only handle mono sounds.
Posted By: TehV

Re: Issue with focus - 01/05/14 20:22

The original sounds (apart from the one that does play) were stereo sounds, but I've converted them into mono sounds - Perhaps the stereo track wasn't fully removed. I'll further investigate this and post here whether or not the problem could be fixed.
Posted By: TehV

Re: Issue with focus - 01/06/14 15:50

Converting all my sounds to mono sounds has fixed this issue. Thanks for the help!

The problem that remains is that the engine is minimized when it loses focus. Does anyone have a workaround for this?
© 2024 lite-C Forums