--- a/phoneplugins/csplugin/src/cspaudiohandler.cpp Mon Aug 23 15:42:12 2010 +0300
+++ b/phoneplugins/csplugin/src/cspaudiohandler.cpp Fri Sep 03 13:33:36 2010 +0300
@@ -17,7 +17,9 @@
#include "cspaudiohandler.h"
#include "tmshandler.h"
+#include "csptimer.h"
#include "csplogger.h"
+#include "mcspaudiohandlerobserver.h"
// ---------------------------------------------------------------------------
// CSPAudioHandler::NewL.
@@ -25,7 +27,7 @@
//
CSPAudioHandler* CSPAudioHandler::NewL()
{
- CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::NewL()" );
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::NewL()");
CSPAudioHandler* self = new (ELeave) CSPAudioHandler();
CleanupStack::PushL(self);
self->ConstructL();
@@ -39,22 +41,42 @@
//
CSPAudioHandler::~CSPAudioHandler()
{
- CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::~CSPAudioHandler()" );
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::~CSPAudioHandler()");
+ if (iTimer)
+ {
+ iTimer->CancelNotify();
+ delete iTimer;
+ }
delete iTmsHandler;
}
// ---------------------------------------------------------------------------
+// CSPAudioHandler::SetObserver
+// ---------------------------------------------------------------------------
+//
+void CSPAudioHandler::SetObserver(MCSPAudioHandlerObserver& aObserver)
+ {
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::SetObserver()");
+ iObserver = &aObserver;
+ }
+
+// ---------------------------------------------------------------------------
// CSPAudioHandler::Start
+// Note: Client must pass the observer through SetObserver() prior to calling
+// Start(), otherwise MTmsHandlerObserver callbacks will be missed.
// ---------------------------------------------------------------------------
//
void CSPAudioHandler::Start()
{
iCallCount++;
CSPLOGSTRING2(CSPINT, "CSPAudioHandler::Start callcount: %d", iCallCount);
-
if (iTmsHandler && iCallCount == 1)
{
- iTmsHandler->StartStreams();
+ TInt err = iTmsHandler->StartStreams();
+ if (err != KErrNone)
+ {
+ AudioStreamsError(err);
+ }
}
}
@@ -65,6 +87,10 @@
void CSPAudioHandler::Stop()
{
CSPLOGSTRING2(CSPINT, "CSPAudioHandler::Stop callcount: %d", iCallCount);
+ if (iTimer)
+ {
+ iTimer->CancelNotify();
+ }
if (iTmsHandler && iCallCount == 1)
{
iTmsHandler->StopStreams();
@@ -77,6 +103,82 @@
}
// ---------------------------------------------------------------------------
+// CSPAudioHandler::ReportAudioFailureAfterTimeout
+// ---------------------------------------------------------------------------
+//
+void CSPAudioHandler::ReportAudioFailureAfterTimeout(TInt aTimeout)
+ {
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::ReportAudioFailureAfterTimeout()");
+
+ if (iTmsHandler)
+ {
+ // Make sure audio streams are not already active, so we don't
+ // accidentaly hangup the call by setting the timer.
+ if (iTimer && !iTmsHandler->AreStreamsStarted())
+ {
+ if (iTimer->IsNotifyOngoing())
+ {
+ iTimer->CancelNotify();
+ }
+ iTimer->NotifyAfter(aTimeout, *this);
+ }
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// CSPAudioHandler::AudioStreamsStarted
+// From MTmsHandlerObserver
+// ---------------------------------------------------------------------------
+//
+void CSPAudioHandler::AudioStreamsStarted()
+ {
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::AudioStreamsStarted()");
+ if (iTimer)
+ {
+ iTimer->CancelNotify();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// CSPAudioHandler::AudioStreamsError
+// From MTmsHandlerObserver
+// ---------------------------------------------------------------------------
+//
+void CSPAudioHandler::AudioStreamsError(TInt /*aError*/)
+ {
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::AudioStreamsError()");
+ if (iTimer)
+ {
+ iTimer->CancelNotify();
+ }
+
+ // Note: The observer must be provided in SetObserver() prior to Start()
+ // request, otherwise error conditions will not be propagated to the client.
+ if (iObserver)
+ {
+ iObserver->AudioStartingFailed();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// CSPAudioHandler::TimerEvent
+// From MCSPTimerObserver
+// ---------------------------------------------------------------------------
+//
+void CSPAudioHandler::TimerEvent()
+ {
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::TimerEvent()");
+ if (iObserver)
+ {
+ iObserver->AudioStartingFailed();
+ }
+ if (iTmsHandler)
+ {
+ iTmsHandler->StopStreams();
+ }
+ }
+
+// ---------------------------------------------------------------------------
// Constructs the monitor.
// ---------------------------------------------------------------------------
//
@@ -92,10 +194,9 @@
//
void CSPAudioHandler::ConstructL()
{
- if (!iTmsHandler)
- {
- iTmsHandler = TmsHandler::NewL();
- }
+ CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::ConstructL()");
+ iTmsHandler = TmsHandler::NewL(*this);
+ iTimer = CSPTimer::NewL();
}
// End of file