audiostubs/devsoundextensions_stubs/audiooutputcistub/src/AudioOutputCIStub.cpp
changeset 0 0ce1b5ce9557
child 3 f935d51494d1
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Audio Stubs -  AudioOutput CI Stub
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32svr.h>
       
    19 //#include "AudioOutputCustomInterfaceHandler.h"
       
    20 #include "AudioOutputCI.h"
       
    21 //#include "AudioOutputMessageTypes.h"
       
    22 #include <MAudioOutputObserver.h>
       
    23 #include <AudioOutput.h>
       
    24 
       
    25 EXPORT_C CAudioOutputCI* CAudioOutputCI::NewL(CMMFDevSound& aDevSound)
       
    26 	{
       
    27 	CAudioOutputCI* self = new(ELeave) CAudioOutputCI(aDevSound);
       
    28 	return self;
       
    29 	}
       
    30 
       
    31 CAudioOutputCI::CAudioOutputCI(CMMFDevSound& aDevSound) :
       
    32 	iDevSound(&aDevSound),
       
    33 	iDefault(EPublic)
       
    34 	{
       
    35 	if (!iAudioOutputTimer)
       
    36 		{
       
    37 		iAudioOutputTimer = new (ELeave) CAudioOutputTimer(this);
       
    38 		}
       
    39 	iAudioOutputTimer->After(5000000);
       
    40 	}
       
    41 
       
    42 CAudioOutputCI::~CAudioOutputCI()
       
    43 	{
       
    44 	delete iAudioOutputTimer;
       
    45 	}
       
    46 
       
    47 CAudioOutput::TAudioOutputPreference CAudioOutputCI::AudioOutput()
       
    48 	{
       
    49 	return iOutput;
       
    50 	}
       
    51 
       
    52 CAudioOutput::TAudioOutputPreference CAudioOutputCI::DefaultAudioOutput()
       
    53 	{
       
    54 	return iDefault;
       
    55 	}
       
    56 
       
    57 void CAudioOutputCI::RegisterObserverL( MAudioOutputObserver& aObserver )
       
    58 	{
       
    59 	iObserver = &aObserver;
       
    60 	}
       
    61 
       
    62 TBool CAudioOutputCI::SecureOutput()
       
    63 	{
       
    64 #ifdef _DEBUG
       
    65 	RDebug::Print(_L("CAudioOutputCI::SecureOutput"));
       
    66 #endif
       
    67 	return iSecureOutput;
       
    68 	}
       
    69 
       
    70 void CAudioOutputCI::SetAudioOutputL( TAudioOutputPreference aAudioOutput )
       
    71 	{
       
    72 #ifdef _DEBUG
       
    73 	RDebug::Print(_L("CAudioOutputCI::SetAudioOutputL"));
       
    74 #endif
       
    75 	iOutput = aAudioOutput;
       
    76 	}
       
    77 
       
    78 void CAudioOutputCI::SetSecureOutputL( TBool aSecure )
       
    79 	{
       
    80 #ifdef _DEBUG
       
    81 	RDebug::Print(_L("CAudioOutputCI::SetSecureOutputL"));
       
    82 #endif
       
    83 	iSecureOutput = aSecure;
       
    84 	}
       
    85 
       
    86 void CAudioOutputCI::UnregisterObserver( MAudioOutputObserver&/* aObserver */)
       
    87 	{
       
    88 	iObserver = NULL;
       
    89 	}
       
    90 
       
    91 void CAudioOutputCI::DefaultChanged()
       
    92 	{
       
    93 
       
    94 	if (iCount % 4 == 0)
       
    95 		{
       
    96 		iDefault = EAll;
       
    97 		}
       
    98 	else if (iCount % 4 == 1)
       
    99 		{
       
   100 		iDefault = ENoOutput;
       
   101 		}
       
   102 	else if ( iCount % 4 == 2)
       
   103 		{
       
   104 		iDefault = EPrivate;
       
   105 		}
       
   106 	else if (iCount % 4 == 3)
       
   107 		{
       
   108 		iDefault = EPublic;
       
   109 		}
       
   110 
       
   111 	if (iObserver)
       
   112 		{
       
   113 		iObserver->DefaultAudioOutputChanged(*this,iDefault);
       
   114 		}
       
   115 	iCount++;
       
   116 	iAudioOutputTimer->After(5000000);
       
   117 
       
   118 	}
       
   119 
       
   120 EXPORT_C CAudioOutputCI* CAudioOutputCI::NewL()
       
   121 	{
       
   122 	CAudioOutputCI* self = new(ELeave) CAudioOutputCI();
       
   123 	return self;
       
   124 	}
       
   125 
       
   126 CAudioOutputCI::CAudioOutputCI() :
       
   127 	iDefault(EPublic)
       
   128 	{
       
   129 	if (!iAudioOutputTimer)
       
   130 		{
       
   131 		iAudioOutputTimer = new (ELeave) CAudioOutputTimer(this);
       
   132 		}
       
   133 	iAudioOutputTimer->After(5000000);
       
   134 	}
       
   135 
       
   136 CAudioOutputTimer::CAudioOutputTimer(CAudioOutputCI* aCustomInterface) :
       
   137 								CTimer(0),
       
   138 								iCustomInterface(aCustomInterface)
       
   139 	{
       
   140     CTimer::ConstructL();
       
   141     CActiveScheduler::Add(this);
       
   142 	}
       
   143 
       
   144 CAudioOutputTimer::~CAudioOutputTimer()
       
   145 	{
       
   146 	Cancel();
       
   147 	}
       
   148 
       
   149 void CAudioOutputTimer::RunL()
       
   150 	{
       
   151 #ifdef _DEBUG
       
   152 	RDebug::Print(_L("CAudioOutputTimer::RunL"));
       
   153 #endif
       
   154 	iCustomInterface->DefaultChanged();
       
   155 	}
       
   156 
       
   157 void CAudioOutputTimer::DoCancel()
       
   158 	{
       
   159 	}
       
   160 
       
   161 
       
   162 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   163 
       
   164 
       
   165 
       
   166 
       
   167 // End of File