Re: [Opalvoip-user] Some basic questions and comments about Set/Get Volume and Mute
Brought to you by:
csoutheren,
rjongbloed
From: Dmitry <gor...@mt...> - 2012-08-30 23:19:02
|
Hello Robert, >Though I changed your unsigned to a bool As for bool mute, I agree with you. OK. But tell me please: Is if fully correct to arbitrarily use virtual bool SetMute in sound.h and PBoolean PSoundChannel::GetMute in sound.cxx I am understanding that "bool" and "PBoolean" is the same, but it looks that due to this mix the compiller does not see "Go to defenition/Go to declaration" in some places. If to compare with GetVolume, the "PBoolean style" will be nicely. May be you will fix? I think should check in all changed files. ======= >Even then, I think you actually have the API you want by accessing PSoundChannel directly. >I am also confused about what API you are using. If you are using the "C" API then all this non OPAL stuff , the PTLib stuff, is not part of that API, Well will try to explain: ptlib use Win32 "sound" API -Correct? opal use ptlib -Correct? my VB6 app use "C" API - I am very happy now that I was able to do it working but this is only a single way to use "PTLib stuff" from my app. Win32 API -> Ptlib -> Opal ->("C" API )-> VB6 On the other hand I can do: >actually have the API you want by accessing PSoundChannel directly Win32 "sound" API -> VB6 But this means that I need to re-write the same, that already present in c:\ptlib\src\ptlib\msos\sound_win32.cxx. Or not? I did not say that you SHOULD add "C" API (I want to have) to Opal branch or trunk. I am only asked: How to? What I want? I want to access Set/Get Volume/Mute independently from "Opal call". I even added now the following code (include all structures etc...) to "C" API : === void OpalManager_C::HandleAudioMixer(const OpalMessage & command, OpalMessageBuffer & response) PSoundChannel channel; if (!channel.Open(direction ? m_pcssEP->GetSoundChannelPlayDevice() : m_pcssEP->GetSoundChannelRecordDevice(), direction ? PSoundChannel::Player : PSoundChannel::Recorder)) { if (direction) response.SetError("Not possible to open Player"); else response.SetError("Not possible to open Recorder"); return; } response->m_param.m_audioMixer.m_direction = direction; ... <do set/get volume/mute> channel.Close(); } ==== The code works, but have a problem. If I Open "Recorder/mute" on XP, the channel.GetMute(mute) gives FALSE (like need) If then I do other call of C-API to set/get "Recorder/volume", "Player/volume" or "Player/mute" and then (in the next API call) trying to set/get "Recorder/mute" again. the channel.GetMute(mute) gives TRUE , but need to give FALSE. And I don't understand why. If to do the same via void OpalManager_C::HandleMediaStream(const OpalMessage & command, OpalMessageBuffer & response) ... if (!connection->SetAudioMute(stream->IsSource(), mute)) { (when call is active) then all works fine (always FALSE if "Recorder/mute" on XP). May be to use PSoundChannel this way (to Open then Close) every time I want to access set/get volume/mute "directly" is absolutly not correct? Tell me please. I want to say that PSoundChannel is MORE than "access to mixer controls"...??? If not correct and I need to write new class in Ptlib to do this, then it is simpler for me to take ideas from sound_win32.cxx, and to write modules in VB6 and to do Set/Get Volume/Mute directly Win32 API -> VB6 Please advise! (See the full code I have tried below) ============================================================ void OpalManager_C::HandleAudioMixer(const OpalMessage & command, OpalMessageBuffer & response) { bool direction = command.m_param.m_audioMixer.m_direction; //false-Recorder;true-Player PSoundChannel channel; if (!channel.Open(direction ? m_pcssEP->GetSoundChannelPlayDevice() : m_pcssEP->GetSoundChannelRecordDevice(), direction ? PSoundChannel::Player : PSoundChannel::Recorder)) { if (direction) response.SetError("Not possible to open Player"); else response.SetError("Not possible to open Recorder"); return; } response->m_param.m_audioMixer.m_direction = direction; unsigned volume; if (command.m_param.m_audioMixer.m_volume == -2) { if (!channel.GetVolume(volume)) { response->m_param.m_audioMixer.m_volume = -2; //not possible to get volume } else { if (volume == 0) response->m_param.m_audioMixer.m_volume = -1; else response->m_param.m_audioMixer.m_volume = volume; } } else if (command.m_param.m_audioMixer.m_volume != 0) { if (command.m_param.m_audioMixer.m_volume < 0) volume = 0; else if (command.m_param.m_audioMixer.m_volume > 100) volume = 100; else volume = command.m_param.m_audioMixer.m_volume; channel.SetVolume(volume); } bool mute; if (command.m_param.m_audioMixer.m_mute == -2) { if (!channel.GetMute(mute)) { response->m_param.m_audioMixer.m_mute = -2; //not possible to get mute state } else { if (mute) response->m_param.m_audioMixer.m_mute = 1; else response->m_param.m_audioMixer.m_mute = -1; } } else { if (command.m_param.m_audioMixer.m_mute != 0) { if (command.m_param.m_audioMixer.m_mute < 0) mute = false; else //(command.m_param.m_audioMixer.m_mute > 0) mute = true; if (!channel.SetMute(mute)) { response->m_param.m_audioMixer.m_mute = -3; //not possible to set mute state } } } channel.Close(); } ============================================================ Best Regards, Dmitry. ----- Original Message ----- From: Robert Jongbloed To: opa...@li... Sent: Thursday, August 30, 2012 6:54 AM Subject: Re: [Opalvoip-user] Some basic questions and comments about Set/Get Volume and Mute While I don't understand why setting the volume to zero wasn't good enough, I have committed your patch. Though I changed your unsigned to a bool, as, well, that's what it is. Robert Jongbloed OPAL/OpenH323/PTLib Architect and Co-founder. Commercial support at http://www.voxlucida.com.au On 30/08/2012 11:23 AM, Dmitry wrote: ----- Original Message ----- From: Robert Jongbloed To: opa...@li... Sent: Wednesday, August 29, 2012 4:23 AM Subject: Re: [Opalvoip-user] Some basic questions and comments about Set/Get Volume and Mute I have added OpalPCSSConnection::GetAudioVolume() as it is trivial. As to the rest, it is really hard to work out what you are after, and I do simply do not have time to do anything major. Much of what talk about, including the bit in bold, really are application issues. Even then, I think you actually have the API you want by accessing PSoundChannel directly. I am also confused about what API you are using. If you are using the "C" API then all this non OPAL stuff , the PTLib stuff, is not part of that API, and I am unwilling to complicate it any further. |