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

Author Topic: Test sound device  (Read 5650 times)

0 Members and 1 Guest are viewing this topic.

AndyOrange

  • Newbie
  • *
  • Posts: 13
    • View Profile
Test sound device
« on: August 15, 2017, 12:54:28 pm »
Greetings,
I really hope this is not some kind of duplicate, but I could not find a similar question. How can I test for validity of a sound device both initially and during playback of a file (in my case Windows)? I other words, consider, when no headphones or speakers are connected I am getting tons of openAL error message logs, and if I unplug them during playback, things even crash. I would prefer an sfml only sfml way without having to fal back to openal.
Looking forward to hearing from you,
Andy
« Last Edit: August 16, 2017, 10:01:33 am by AndyOrange »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Test sound device
« Reply #1 on: August 15, 2017, 02:48:06 pm »
No, SFML doesn't have such a functionality. Neither has SFML been design to support on-the-fly audio device changes. It may work, as SFML just uses OpenAL, but there's no strong guarantee to always work.

I think being able to choose a playback device similar to how one pick a recording device might be a good idea to implement. With it, one would also have to consider situations where the device gets removed.

You mention, you get OpenAL errors, what kind of errors are those? And in which situation exactly do you get those?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

AndyOrange

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Test sound device
« Reply #2 on: August 16, 2017, 08:09:29 am »
Greetings,
first of all I absolutely agree with your proposal of chosing a playback device in the same manner as the recording device!

Now for the problems: I get masses of internal errors, as my CI machines have no headphones plugged in. See below. I really would need some way to check for validity of the main audio device at least initially...

Those errors spam my log:

MMDevApiOpenPlayback: Device init failed: 0x80070490
Failed to open the audio device
(and another lots of hundreds when trying to access the device)

and lots of those:

 Failed to open the audio device
[07:34:46][Step 2/6] An internal OpenAL call failed in SoundSource.cpp(37).
[07:34:46][Step 2/6] Expression:
[07:34:46][Step 2/6]    alGenSources(1, &m_source)
[07:34:46][Step 2/6] Error description:
[07:34:46][Step 2/6]    AL_INVALID_OPERATION
[07:34:46][Step 2/6]    The specified operation is not allowed in the current state.
[07:34:46][Step 2/6]
[07:34:46][Step 2/6] An internal OpenAL call failed in SoundSource.cpp(38).
[07:34:46][Step 2/6] Expression:
[07:34:46][Step 2/6]    alSourcei(m_source, AL_BUFFER, 0)
[07:34:46][Step 2/6] Error description:
[07:34:46][Step 2/6]    AL_INVALID_OPERATION
[07:34:46][Step 2/6]    The specified operation is not allowed in the current state.
[07:34:46][Step 2/6]
[07:34:46][Step 2/6] An internal OpenAL call failed in SoundBuffer.cpp(46).
[07:34:46][Step 2/6] Expression:
[07:34:46][Step 2/6]    alGenBuffers(1, &m_buffer)
[07:34:46][Step 2/6] Error description:
[07:34:46][Step 2/6]    AL_INVALID_OPERATION
[07:34:46][Step 2/6]    The specified operation is not allowed in the current state.
[07:34:46][Step 2/6]
[07:34:46][Step 2/6] An internal OpenAL call failed in SoundSource.cpp(103).
[07:34:46][Step 2/6] Expression:
[07:34:46][Step 2/6]    alSourcef(m_source, AL_REFERENCE_DISTANCE, distance)
[07:34:46][Step 2/6] Error description:
[07:34:46][Step 2/6]    AL_INVALID_OPERATION
[07:34:46][Step 2/6]    The specified operation is not allowed in the current state.
:
:
:
(and another 400 of those)
« Last Edit: August 16, 2017, 08:17:47 am by AndyOrange »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Test sound device
« Reply #3 on: August 16, 2017, 08:20:03 am »
my CI machines have no headphones plugged in.
What kind of headphones are those? I assume not simple line-in ones? Are they their own audio device?
What other audio devices have you installed?

Could you try the feature/update_openal branch? The OpenAL version that is shipped with master is slightly outdated.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

AndyOrange

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Test sound device
« Reply #4 on: August 16, 2017, 08:42:43 am »
I will try your updated library. The problem is not just related to one machine. As soon as no audio device is available, which on windows happens if for instance you disconnect all chinch cables from output channels of your sound card/onboard device, openAL dumps those messages. It would help a lot, really, to be able to just test the audio device before accessing it.

Using openal directly, something like
device = alcOpenDevice(NULL);
if (!device)
        ...
might work, and sfml could offer such a test for instance...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Test sound device
« Reply #5 on: August 16, 2017, 08:51:05 am »
which on windows happens if for instance you disconnect all chinch cables from output channels of your sound card/onboard device
What kind of sound card are you running then?
A sound card/device should still be available even if you have nothing plugged into it, everything else seems kind of weird to me.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

AndyOrange

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Test sound device
« Reply #6 on: August 16, 2017, 09:01:03 am »
It is like this with basically all sound card/ on board sound with connectors currently. I don't like it either, but this is the way it is and it is quite normal, actually. Plug headphones out, sound device gets deactivated...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Test sound device
« Reply #7 on: August 16, 2017, 09:24:37 am »
Also make sure you're really using the driver from your soundcard vendor and not just whatever Microsoft managed to find for your device.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

AndyOrange

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Test sound device
« Reply #8 on: August 16, 2017, 10:00:02 am »
Yes, I did that. Creative on one system, Realtek on the other. Vendor. See attached image for an example when things are unplugged, this is really normal behaviour, the state of a sound device is different when having no output device attached!

Be things as they are, a check for audio device readyness would really help. I will do it by eluding sfml now and accessing openal directly -- this is, however, by far not the prefered option.

Best regards,
Andy