os/mm/devsoundextensions/restrictedaudiooutput/RestrictedAudioOutputBase/src/RestrictedAudioOutputImpl.cpp
First public contribution.
2 * Copyright (c) 2007 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: This is the implementation of the CRestrictedAudioOutputImpl class.
23 #include "RestrictedAudioOutputImpl.h"
26 #define DEBPRN0(str) RDebug::Print(str, this)
27 #define DEBPRN1(str) RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str );
33 const TInt KGranularity=20;
36 // -----------------------------------------------------------------------------
37 // CRestrictedAudioOutputImpl::CRestrictedAudioOutputImpl
38 // C++ default constructor can NOT contain any code, that
40 // -----------------------------------------------------------------------------
42 CRestrictedAudioOutputImpl::CRestrictedAudioOutputImpl()
43 : iAllowedOutputPrefArray(KGranularity)
45 DEBPRN0(_L("CRestrictedAudioOutputImpl::[0x%x]::CRestrictedAudioOutputImpl\n"));
46 iAllowedOutputPrefArray.Reset();
50 // -----------------------------------------------------------------------------
51 // CRestrictedAudioOutputImpl::ConstructL
52 // Symbian 2nd phase constructor can leave.
53 // assumes that iParent has already been set up properly
54 // -----------------------------------------------------------------------------
56 void CRestrictedAudioOutputImpl::ConstructL()
62 // Two-phased constructor.
63 CRestrictedAudioOutputImpl* CRestrictedAudioOutputImpl::NewL()
66 RDebug::Print(_L("CRestrictedAudioOutputImpl::NewL\n"));
69 CRestrictedAudioOutputImpl* self = new(ELeave) CRestrictedAudioOutputImpl();
70 CleanupStack::PushL(self);
72 CleanupStack::Pop(self);
77 // -----------------------------------------------------------------------------
78 // CRestrictedAudioOutputImpl::~CRestrictedAudioOutputImpl
80 // -----------------------------------------------------------------------------
82 CRestrictedAudioOutputImpl::~CRestrictedAudioOutputImpl()
84 DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::~CRestrictedAudioOutputImpl\n"));
86 iAllowedOutputPrefArray.Close();
88 DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::~CRestrictedAudioOutputImpl:EXIT"));
91 // ---------------------------------------------------------
92 // CRestrictedAudioOutputImpl::AppendAllowedOutput
93 // ?implementation_description
94 // (other items were commented in a header).
95 // ---------------------------------------------------------
97 TInt CRestrictedAudioOutputImpl::AppendAllowedOutput( CRestrictedAudioOutput::TAllowedOutputPreference aOutput)
99 DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::AppendAllowedOutput\n"));
102 RDebug::Print(_L("Append Output: %d\n"), aOutput);
105 // Check to see if it's in array already
106 TBool found = ExistsInArray(aOutput);
110 RDebug::Print(_L("Append Output ERROR. Output already in List\n"));
112 return KErrAlreadyExists;
116 TRAP(err,iAllowedOutputPrefArray.AppendL(aOutput));
123 // ---------------------------------------------------------
124 // CRestrictedAudioOutputImpl::RemoveAllowedOutput
125 // ?implementation_description
126 // (other items were commented in a header).
127 // ---------------------------------------------------------
129 TInt CRestrictedAudioOutputImpl::RemoveAllowedOutput(CRestrictedAudioOutput::TAllowedOutputPreference aOutput)
132 RDebug::Print(_L("Remove Output: %d\n"), aOutput);
135 // Make sure it's in list
136 TBool found = ExistsInArray(aOutput);
140 RDebug::Print(_L("Remove Output ERROR. Output not in List\n"));
145 for (TInt i = 0; i < iAllowedOutputPrefArray.Count(); i++)
147 if (iAllowedOutputPrefArray[i] == aOutput)
149 iAllowedOutputPrefArray.Remove(i);
151 RDebug::Print(_L("RemoveAllowedOutput: Item Removed\n"));
160 // ---------------------------------------------------------
161 // CRestrictedAudioOutputImpl::GetAllowedOutput
162 // ?implementation_description
163 // (other items were commented in a header).
164 // ---------------------------------------------------------
166 TInt CRestrictedAudioOutputImpl::GetAllowedOutput(TInt aIndex, CRestrictedAudioOutput::TAllowedOutputPreference& aOutput)
169 RDebug::Print(_L("CRestrictedAudioOutputImpl::GetAllowedOutput for index: %d\n"), aIndex);
172 // Verify aIndex valid:
173 if (aIndex >= iAllowedOutputPrefArray.Count())
176 RDebug::Print(_L("GetAllowedOutput ERROR. Invalid Index: %d\n"),aIndex);
180 aOutput = iAllowedOutputPrefArray[aIndex];
182 RDebug::Print(_L("GetAllowedOutput: Returning %d\n"),aOutput);
187 // ---------------------------------------------------------
188 // CRestrictedAudioOutputImpl::GetAllowedOutputCount
189 // ?implementation_description
190 // (other items were commented in a header).
191 // ---------------------------------------------------------
193 TInt CRestrictedAudioOutputImpl::GetAllowedOutputCount(TInt& aSize)
196 RDebug::Print(_L("CRestrictedAudioOutputImpl::GetAllowedOutputCount\n"));
198 aSize = iAllowedOutputPrefArray.Count();
202 // ---------------------------------------------------------
203 // CRestrictedAudioOutputImpl::Reset
204 // ?implementation_description
205 // (other items were commented in a header).
206 // ---------------------------------------------------------
208 TInt CRestrictedAudioOutputImpl::Reset()
210 iAllowedOutputPrefArray.Reset();
214 // ---------------------------------------------------------
215 // CRestrictedAudioOutputImpl::Commit
216 // ?implementation_description
217 // (other items were commented in a header).
218 // ---------------------------------------------------------
220 TInt CRestrictedAudioOutputImpl::Commit()
225 // ---------------------------------------------------------
226 // CRestrictedAudioOutputImpl::ExistsInArray
227 // ?implementation_description
228 // (other items were commented in a header).
229 // ---------------------------------------------------------
231 TBool CRestrictedAudioOutputImpl::ExistsInArray(CRestrictedAudioOutput::TAllowedOutputPreference& aOutput)
234 for (TInt i = 0; i < iAllowedOutputPrefArray.Count(); i++)
236 if (iAllowedOutputPrefArray[i] == aOutput)