os/mm/devsoundextensions/telephonyaudiorouting/TelephonyAudioRoutingManager/src/TelephonyAudioRoutingManager.cpp
Update contrib.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Methods for CTelephonyAudioRoutingManager class
25 #include "TelephonyAudioRoutingManager.h"
26 #include "TelephonyAudioRoutingClientServer.h"
27 #include "TelephonyAudioRoutingServer.h"
28 #include "TelephonyAudioRoutingManagerSession.h"
30 const TUid KTelAudRtngServerUid = {0x10207A93};
32 const TInt KTelAudRtngServerStackSize=0x2000; // 8KB
33 const TInt KTelAudRtngServerInitHeapSize=0x1000; // 4KB
34 const TInt KTelAudRtngServerMaxHeapSize=0x1000000; // 16MB
36 // ================= MEMBER FUNCTIONS =======================
38 // C++ default constructor can NOT contain any code, that
41 CTelephonyAudioRoutingManager::CTelephonyAudioRoutingManager(
42 MTelephonyAudioRoutingPolicyObserver& aObserver)
43 : iObserver(aObserver)
48 // -----------------------------------------------------------------------------
49 // CAudioOutputProxy::ConstructL
50 // Symbian 2nd phase constructor can leave.
51 // -----------------------------------------------------------------------------
53 void CTelephonyAudioRoutingManager::ConstructL(
54 const TArray<CTelephonyAudioRouting::TAudioOutput>& aArray)
56 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::ConstructL "));
58 User::LeaveIfError(StartServer());
59 iMgrSession = new (ELeave)RTelephonyAudioRoutingManagerSession;
60 User::LeaveIfError(iMgrSession->Connect(*this, iObserver));
62 iMgrSession->SetPolicySessionIdL();
63 iMgrSession->MonitorOutputChangeRequest();
64 iMgrSession->AvailableOutputsChangedL(aArray);
68 // Two-phased constructor.
69 EXPORT_C CTelephonyAudioRoutingManager* CTelephonyAudioRoutingManager::NewL(
70 MTelephonyAudioRoutingPolicyObserver& aObserver,
71 const TArray<CTelephonyAudioRouting::TAudioOutput>& aArray)
73 CTelephonyAudioRoutingManager* self = new(ELeave) CTelephonyAudioRoutingManager(aObserver);
74 CleanupStack::PushL(self);
75 self->ConstructL(aArray);
76 CleanupStack::Pop(self);
82 CTelephonyAudioRoutingManager::~CTelephonyAudioRoutingManager()
84 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::~CTelephonyAudioRoutingManager "));
93 // ---------------------------------------------------------
94 // CAudioOutput::OutputChanged
95 // Policy is sending out notification that the output has changed
96 // (a change initiated by policy)
97 // (other items were commented in a header).
98 // ---------------------------------------------------------
101 EXPORT_C void CTelephonyAudioRoutingManager::OutputChanged(CTelephonyAudioRouting::TAudioOutput aOutput)
103 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::OutputChanged to: %d"), aOutput);
104 iMgrSession->OutputChanged(aOutput);
107 // ---------------------------------------------------------
108 // CAudioOutput::AvailableOutputsChanged
109 // Policy is sending out notification that the available outputs have changed
110 // (other items were commented in a header).
111 // ---------------------------------------------------------
114 EXPORT_C void CTelephonyAudioRoutingManager::AvailableOutputsChanged(const TArray<CTelephonyAudioRouting::TAudioOutput>& aArray)
116 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::AvailableOutputsChanged "));
117 TRAPD(err,iMgrSession->AvailableOutputsChangedL(aArray));
120 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::AvailableOutputsChanged: ERROR from Adaptation: %d "), err);
124 // ---------------------------------------------------------
125 // CAudioOutput::OutputChangeRequestCompleted
126 // Policy is sending out notification that the request change in output has been completed
127 // (other items were commented in a header).
128 // ---------------------------------------------------------
130 EXPORT_C void CTelephonyAudioRoutingManager::OutputChangeRequestCompleted(CTelephonyAudioRouting::TAudioOutput aOutput, TInt aError)
132 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::OutputChangeRequestCompleted "));
133 if (aError != KErrNone)
135 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::OutputChangeRequestCompleted: ERROR from Adaptation: %d "), aError);
138 iMgrSession->OutputChangeCompleted(aOutput, aError);
142 // -----------------------------------------------------------------------------
143 // CStartTelephonyAudioRoutingServer::StartServer
144 // Start TelephonyAudioRouting Server
145 // (other items were commented in a header).
146 // -----------------------------------------------------------------------------
148 TInt CTelephonyAudioRoutingManager::StartServer()
150 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingManager::StartServer "));
152 const TUidType serverUid(KNullUid,KNullUid,KTelAudRtngServerUid);
154 TThreadFunction serverFunc=CTelephonyAudioRoutingServer::StartThreadL;
157 TName name(KTelAudRtngServName);
159 err = iServer.Create(name, serverFunc, KTelAudRtngServerStackSize,
160 KTelAudRtngServerInitHeapSize, KTelAudRtngServerMaxHeapSize,
161 /*&start*/ NULL, EOwnerProcess);
166 // Synchronise with the server
167 TRequestStatus reqStatus;
168 iServer.Rendezvous(reqStatus);
170 if (reqStatus!=KRequestPending)
176 // Start the test harness
178 // Server will call the reciprocal static synchronise call
181 User::WaitForRequest(reqStatus); // wait for start or death
182 if(reqStatus.Int() != KErrNone)
185 return reqStatus.Int();