mmserv/tms/tmscallserver/src/cspdevsound.cpp
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2  * Copyright (c) 2009 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: Telephony Multimedia Service
       
    15  *
       
    16  */
       
    17 
       
    18 #include <AudioPreference.h>
       
    19 #include <glib.h>
       
    20 #include <S60FourCC.h>
       
    21 #include "cspdevsound.h"
       
    22 #include "mcspdevsoundobserver.h"
       
    23 
       
    24 using namespace TMS;
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CSPDevSound
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CSPDevSound::CSPDevSound(MCSPDevSoundObserver& aObserver) :
       
    31     iObserver(aObserver)
       
    32     {
       
    33     }
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // ConstructL
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 void CSPDevSound::ConstructL(TMMFState aMode, gint aAudioPreference,
       
    40         gint aAudioPriority)
       
    41     {
       
    42     TMMFPrioritySettings audioPriority;
       
    43     TFourCC modemFourCC;
       
    44     modemFourCC.Set(KS60FourCCCodeModem);
       
    45     iDevSound = CMMFDevSound::NewL();
       
    46     if (iDevSound)
       
    47         {
       
    48 #ifndef __WINSCW__
       
    49         iDevSound->InitializeL(*this, modemFourCC, aMode);
       
    50 #else //For testing TMS in WINSCW
       
    51         iDevSound->InitializeL(*this, KMMFFourCCCodePCM16, aMode);
       
    52 #endif
       
    53         iStreamType = aAudioPreference;
       
    54         audioPriority.iPriority = aAudioPriority;
       
    55         audioPriority.iPref = aAudioPreference;
       
    56         audioPriority.iState = aMode;
       
    57         iDevSound->SetPrioritySettings(audioPriority);
       
    58         }
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // From class MDevSoundObserver
       
    63 // Not implemented
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CSPDevSound::~CSPDevSound()
       
    67     {
       
    68     delete iDevSound;
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // Tries to activate the audio stream if not active or activating
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 void CSPDevSound::Activate()
       
    76     {
       
    77     if (!IsActive() && !IsActivationOngoing())
       
    78         {
       
    79         iActivationOngoing = ETrue;
       
    80         gint err = KErrNone;
       
    81         TRAP(err, DoActivateL());
       
    82         }
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // Deactivates the audio device.
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CSPDevSound::Deactivate()
       
    90     {
       
    91     if (iDevSound && (IsActive() || IsActivationOngoing()))
       
    92         {
       
    93         iDevSound->Stop();
       
    94         iActive = EFalse;
       
    95         iActivationOngoing = EFalse;
       
    96         }
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // ActivationOngoing
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 TBool CSPDevSound::IsActivationOngoing() const
       
   104     {
       
   105     return iActivationOngoing;
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // IsActive
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 TBool CSPDevSound::IsActive() const
       
   113     {
       
   114     return iActive;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // DevSound
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 CMMFDevSound& CSPDevSound::DevSound()
       
   122     {
       
   123     return *iDevSound;
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // From class MDevSoundObserver
       
   128 // Not implemented
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CSPDevSound::InitializeComplete(TInt aError)
       
   132     {
       
   133     if (iStreamType == KAudioPrefCSCallDownlink)
       
   134         {
       
   135         iObserver.DownlinkInitCompleted(aError);
       
   136         }
       
   137     else
       
   138         {
       
   139         iObserver.UplinkInitCompleted(aError);
       
   140         }
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // From class MDevSoundObserver
       
   145 // Not implemented
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 void CSPDevSound::BufferToBeFilled(CMMFBuffer* /*aBuffer*/)
       
   149     {
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // From class MDevSoundObserver
       
   154 // Not implemented
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CSPDevSound::PlayError(TInt /*aError*/)
       
   158     {
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // From class MDevSoundObserver
       
   163 // Not implemented
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CSPDevSound::ToneFinished(TInt /*aError*/)
       
   167     {
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // From class MDevSoundObserver
       
   172 // Not implemented
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 void CSPDevSound::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
       
   176     {
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // From class MDevSoundObserver
       
   181 // Not implemented
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void CSPDevSound::RecordError(TInt /*aError*/)
       
   185     {
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // From class MDevSoundObserver
       
   190 // Not implemented
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 void CSPDevSound::ConvertError(TInt /*aError*/)
       
   194     {
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // From class MDevSoundObserver
       
   199 // Not implemented
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 void CSPDevSound::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
       
   203     {
       
   204     }
       
   205 
       
   206 //  End of File