[Opalvoip-svn] SF.net SVN: opalvoip:[20660] opal/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2008-08-13 01:58:32
|
Revision: 20660 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=20660&view=rev Author: rjongbloed Date: 2008-08-13 01:58:41 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Added output of "ring" to speaker at maximum volume, if line interface device does not support a RingLine function natively. Modified Paths: -------------- opal/trunk/include/lids/lidpluginmgr.h opal/trunk/src/lids/lidpluginmgr.cxx Modified: opal/trunk/include/lids/lidpluginmgr.h =================================================================== --- opal/trunk/include/lids/lidpluginmgr.h 2008-08-13 01:00:29 UTC (rev 20659) +++ opal/trunk/include/lids/lidpluginmgr.h 2008-08-13 01:58:41 UTC (rev 20660) @@ -640,6 +640,8 @@ protected: PDECLARE_NOTIFIER(PThread, OpalPluginLID, TonePlayer); + bool StartTonePlayerThread(int tone); + void StopTonePlayerThread(); #if PTRACING bool BadContext() const; Modified: opal/trunk/src/lids/lidpluginmgr.cxx =================================================================== --- opal/trunk/src/lids/lidpluginmgr.cxx 2008-08-13 01:00:29 UTC (rev 20659) +++ opal/trunk/src/lids/lidpluginmgr.cxx 2008-08-13 01:58:41 UTC (rev 20660) @@ -394,13 +394,27 @@ cadence.SetSize(times.GetSize()); for (PINDEX i = 0; i < cadence.GetSize(); i++) cadence[i] = (unsigned)(times[i].AsReal()*1000); - return CHECK_FN(RingLine, (m_context, line, cadence.GetSize(), cadence, newFrequency)) == PluginLID_NoError; + nCadence = cadence.GetSize(); + pattern = cadence; + frequency = newFrequency; } } } } - return CHECK_FN(RingLine, (m_context, line, nCadence, pattern, frequency)) == PluginLID_NoError; + switch (CHECK_FN(RingLine, (m_context, line, nCadence, pattern, frequency))) { + case PluginLID_UnimplementedFunction : + if (nCadence > 0) + return StartTonePlayerThread(RingTone+NumTones); + StopTonePlayerThread(); + return true; + + case PluginLID_NoError : + return true; + + default : ; + } + return PFalse; } @@ -924,11 +938,26 @@ void OpalPluginLID::TonePlayer(PThread &, INT tone) { + // CHeck if we have NumTones added to value which means high volume output + // typically if handset has no ringer, then just hammer the speaker. + bool highVolume = tone > NumTones; + if (highVolume) + tone -= NumTones; + if (!PAssert(tone < NumTones, PInvalidParameter)) return; PTRACE(4, "LID Plugin\tStarting manual tone generation for \"" << m_callProgressTones[tone] << '"'); + // Get old volume level, if can't then do not do high volume + unsigned oldVolume; + if (!m_player.GetVolume(oldVolume)) + highVolume = false; + + // Max out the volume level for player + if (highVolume) + m_player.SetVolume(100); + PTones toneData; if (toneData.Generate(m_callProgressTones[tone])) { while (!m_stopTone.Wait(0)) { @@ -943,10 +972,41 @@ } m_player.Abort(); + + // If we adjusted the volume, then put it back + if (highVolume) + m_player.SetVolume(oldVolume); + PTRACE(4, "LID Plugin\tEnded manual tone generation for \"" << m_callProgressTones[tone] << '"'); } +bool OpalPluginLID::StartTonePlayerThread(int tone) +{ + StopTonePlayerThread(); + + // Clear out extraneous signals + while (m_stopTone.Wait(0)) + ; + + // Start new tone thread + m_tonePlayer = PThread::Create(PCREATE_NOTIFIER(TonePlayer), tone, PThread::NoAutoDeleteThread, PThread::NormalPriority, "TonePlayer"); + return m_tonePlayer != NULL; +} + + +void OpalPluginLID::StopTonePlayerThread() +{ + // Stop previous tone, if running + if (m_tonePlayer != NULL) { + m_stopTone.Signal(); + m_tonePlayer->WaitForTermination(1000); + delete m_tonePlayer; + m_tonePlayer = NULL; + } +} + + PBoolean OpalPluginLID::PlayTone(unsigned line, CallProgressTones tone) { if (m_lockOutTones) @@ -954,21 +1014,8 @@ switch (CHECK_FN(PlayTone, (m_context, line, tone))) { case PluginLID_UnimplementedFunction : - // Stop previous tone, if running - if (m_tonePlayer != NULL) { - m_stopTone.Signal(); - m_tonePlayer->WaitForTermination(1000); - delete m_tonePlayer; - } + return StartTonePlayerThread(tone); - // Clear out extraneous signals - while (m_stopTone.Wait(0)) - ; - - // Start new tone thread - m_tonePlayer = PThread::Create(PCREATE_NOTIFIER(TonePlayer), tone, PThread::NoAutoDeleteThread, PThread::NormalPriority, "TonePlayer"); - return m_tonePlayer != NULL; - case PluginLID_NoError : return PTrue; @@ -991,13 +1038,7 @@ PBoolean OpalPluginLID::StopTone(unsigned line) { - if (m_tonePlayer != NULL) { - m_stopTone.Signal(); - m_tonePlayer->WaitForTermination(1000); - delete m_tonePlayer; - m_tonePlayer = NULL; - return true; - } + StopTonePlayerThread(); switch (CHECK_FN(StopTone, (m_context, line))) { case PluginLID_UnimplementedFunction : This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |