Updates devices in uos_GetInfoDevice

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Updates devices in uos_GetInfoDevice

sudiv
Hello all
When used repeatedly, the function does not populate the uosDeviceInfos array with fresh information
in the deviceinfos example, when, for example, the microphone is disconnected and the reload button is pressed, the values ​​with the microphone connected are returned.
Maybe I'm doing something wrong?
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
This post was updated on .
Hello and welcome to uos forum.

deviceinfos demo list all the audio devices connected.
If you connect a new audio device, like a audio-usb, after refresh, the list should be updated.

But deviceinfos does not give the status of each device, like micro connected or disabled by the system.

What OS are you using (Linux, Windows, Mac, ...)?

uos does not have not yet feature to get/change the settings of the system.
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
I'm using the Win10 package (for Lazarus2). I plan to use it on Ubuntu too.
The package is convenient and easy to use. Thanks 8-)

it is a pity that it is impossible to quickly get the status of the input or output device.

To suppress errors, it would be nice to check the availability of the device by default before initializing the player.
Such as
...
  if uos_LoadLib(PChar(LibPortAudio), PChar(LibSNDFile), PChar(LibMpg123), nil, nil, nil) = 0 then Lib_LoadOK := true;
  if Lib_LoadOK and
     uosDefaultDeviceOUT > -1 and
     FileExists(FileSrcSoundStream) then
  begin
    PlayerIndex1 := 1;
    uos_CreatePlayer(PlayerIndex1)
...

the uosDefaultDeviceOUT > -1 part is meaningless if the user is actually muting the usb audio device

but at the same time, starting the player when switching the device by default is normal.
does it mean that there is capabilities no status and list update devices  in uosDeviceInfos ? and is it possible to implement it somehow?
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
Hello.

You dont need to re-load the libraries,  use only uosDefaultDeviceOUT > -1 before to create the player.

About status of devices ( mic connected, enabled, ... ) it is very OS dependent.
I just did a quick search for Windows 10 and it is much more protected than previous versions.

Sure there must be Windows API to get/set status but, sorry, I never try this.
Maybe ask to a Windows forum how to retrieve those infos.
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
If you are explorer maybe this could help you.

It is a project to get-set the general volume of a sound-card for Windows:
It is only for the main volume but you could easy find how to do it for mic.

https://github.com/fredvs/win_mixer
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
Yes. Seems like this should help. Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
I get those infos via Lazarus forum.
Maybe you can try asking there how to do for mic...
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
from your example win_mixer it became clear how to get the state of the input and output device, and not only the state 8)
but it's only for Win  (

CoCreateInstance(CLASS_IMMDeviceEnumerator, nil, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, deviceEnumerator);
  if deviceEnumerator.GetDefaultAudioEndpoint(eRender, DEVICE_STATE_ACTIVE, defaultOUTDevice) <> nil then
  begin
  // Current Active Default OUT Device
  end;
  if deviceEnumerator.GetDefaultAudioEndpoint(eCapture, DEVICE_STATE_ACTIVE, defaultINDevice) <> nil then
  begin
  // Current Active Default IN Device
  end;
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
In reply to this post by fredvs
fredvs
thanks again. with this code it works as i intended
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
If you want the (nearly) same for Linux:
https://github.com/fredvs/alsa_mixer
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
fredvs wrote
If you want the (nearly) same for Linux:
https://github.com/fredvs/alsa_mixer
Yes. this will come in handy too 8-) Tnx
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
Hello

anyway, the behavior when connecting and disconnecting devices of any orientation is inadequate.

simplerecorder
launching the program, connecting the microphone, pressing the start button -> access violation

similar with the simpleplayer,
launching the program, pressing the play button, turning off the headphones -> the program is frozen (no msg about err). even though there is still an output point, which automatically became the default.

and did not find the possibility of self-handling such exceptions.
only on one's own trying to rewrite part the package code uos
but not sure if it's right
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
Hello.

The demos were done for "classical" use.

Of course, in your case, you should add some code for re-initializing.

By the way, uos is open source and you are welcome for pull-request for some new features.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
This post was updated on .
plugging and unplugging devices meant to be hot plugged and unplugged is not a "classic" use. funny.

how in this case to reinitialize uos ?

upd:
OK. let uos not be able to switch the stream to the sound input / output channel that has changed by default, but how should this fact be handled, and not throw an exception?
in extreme cases, simply stop input / output, turn off the player.
how to handle the exception that occurs in this case?
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
This post was updated on .
Hello.
Sorry for the delay.
In last commit was added "uos_UpdateDevice()".
Just use it before to deal with devices, it will reinitialize all.
Also, you may add "application.processmessages;" after update devices.
I hope it helps.

But to catch when a device was changed, it is too much OS dependent, sorry not yet plan for uos.

[EDIT]
 in the deviceinfos example, when, for example, the microphone is disconnected and the reload button is pressed, the values ​​with the microphone connected are returned.
It should be fixed in last commit.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

fredvs
Administrator
Re-hello.

I opened a issue in PortAudio: https://github.com/PortAudio/portaudio/issues/750
Maybe some solution from there...

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Updates devices in uos_GetInfoDevice

sudiv
Thanks.
Useful addition.

It's great that the problem is confirmed and work is underway to improve portaudio
Let's wait for the results