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

Author Topic: Help with the design for selecting audio capture device  (Read 32555 times)

0 Members and 4 Guests are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Help with the design for selecting audio capture device
« Reply #45 on: October 01, 2013, 11:52:08 am »
Thanks :)

I noticed that, in case of a call to setDevice(""), getDevice() will return "" until the next capture starts, and the actual default device name after (even after the capture was stopped). If we don't call setDevice(""), getDevice() will always return the actual name of the default device. This feels a little inconsistent. Maybe you should retrieve the name of the default device in setDevice if the argument if an empty string, and then remove the calls to alcGetString(captureDevice, ALC_CAPTURE_DEVICE_SPECIFIER) in start and setDevice.

Also, what happens if the default device changes (I guess it can be changed in the OS control panel -- or, if you can set your USB webcam as the default device, it can be hot-plugged/unplugged) during runtime? Does the empty string correctly map to the new default device, or does OpenAL always returns the same initial default device? Would you be able to test this use case?
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Help with the design for selecting audio capture device
« Reply #46 on: October 01, 2013, 03:52:34 pm »
That is indeed a bug! :D I fixed it. The name of the default device is now stored if setDevice() is called with an empty string.

I did some test with hot-plugging the devices and it seems like OpenAL doesn't map getDefaultDevice() correctly to the next device, if you unplug the default device. It uses the initial default device. Of course if you try to keep on using it there are OpenAL errors. The list of getAvailableDevices() on the other hand is always up to date.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Help with the design for selecting audio capture device
« Reply #47 on: October 01, 2013, 04:13:01 pm »
Bug: if calling setDevice while recording fails, m_deviceName will never be updated.
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Help with the design for selecting audio capture device
« Reply #48 on: October 01, 2013, 10:45:43 pm »
I am not sure if I'd call that a bug. I think it is the expected behaviour. If the setDevice() fails, the selected device fails to open and captureDevice is not set, so why store the name?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Help with the design for selecting audio capture device
« Reply #49 on: October 01, 2013, 10:56:52 pm »
Because if you were not in the middle of a capture, the device is assigned and all subsequent captures will fail until it is changed again.
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Help with the design for selecting audio capture device
« Reply #50 on: October 01, 2013, 11:01:49 pm »
Ok I updated the code.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Help with the design for selecting audio capture device
« Reply #51 on: October 02, 2013, 10:20:12 pm »
Why don't you just move the "// Store the device name" block at the beginning of the function? The current code is inconsistent, you don't store the same thing in both cases (if an empty string is passed).
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Help with the design for selecting audio capture device
« Reply #52 on: October 03, 2013, 01:38:25 pm »
Sorry for offtopic, but I just stumbled about new GitHub features which intend to make pull requests easier to process (if you use the Git for Windows application). It's not ideal, but might still be worth reading.
Nice new logo, by the way.
Thanks! I found it's time to give my whole website a new look :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Help with the design for selecting audio capture device
« Reply #53 on: October 04, 2013, 01:00:19 pm »
Sorry I won't be near my computer for a couple days. I'll try to fix it next week!

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Help with the design for selecting audio capture device
« Reply #54 on: October 07, 2013, 11:47:07 pm »
OK it is consistend now! :) sorry about that I was distracted when I wrote the last fix...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Help with the design for selecting audio capture device
« Reply #55 on: October 08, 2013, 07:01:15 pm »
Make getDevice return a const reference, merge everything into a single clean commit, and I'll integrate it. Finally :P
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Help with the design for selecting audio capture device
« Reply #56 on: October 08, 2013, 09:01:06 pm »
Awesome! :D
I did the first thing, but I don't know how to merge the whole pull request into a single commit. I only know some basic git commands, so if somebody could explain to me how it's done, that would be great!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Help with the design for selecting audio capture device
« Reply #57 on: October 08, 2013, 09:13:08 pm »
git rebase -i <rev>, where <rev> is the first of your commits. When the text editor opens the file, replace all "pick" words by "squash", store the file and close it.

You may need to force-push (git push -f) to rewrite the history to GitHub.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Help with the design for selecting audio capture device
« Reply #58 on: October 08, 2013, 09:35:32 pm »
Ok. I'm not sure I understood everything, but I'll try. How to I get the <rev>?

edit: Would it be this one: 005396d32f3f302560e2553dc26acb60f4952b33
« Last Edit: October 08, 2013, 09:39:55 pm by Foaly »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Help with the design for selecting audio capture device
« Reply #59 on: October 08, 2013, 10:27:40 pm »
<rev> is the hash of the first commit you made.

It suffices to enter the first 5-7 characters of the hash, as long as it is not ambiguous.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: