javauis/amms_qt/module/src/cammssoundsource3d.cpp
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Module for holding control groups belonging to SoundSource3D.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cammssoundsource3d.h"
       
    21 #include "cammsdopplercontrolgroup.h"
       
    22 #include "cammslocationcontrolgroup.h"
       
    23 #include "cammsreverbsourcecontrolgroup.h"
       
    24 #include "cammsdistanceattenuationcontrolgroup.h"
       
    25 #include "cammspancontrolgroup.h"
       
    26 #include "cammsglobalmanager.h"
       
    27 #include <logger.h>
       
    28 
       
    29 
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CAMMSSoundSource3D::NewLC
       
    35 // Two-phased constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 CAMMSSoundSource3D* CAMMSSoundSource3D::NewLC(CAMMSModule* aSpectator,
       
    38         CAMMSGlobalManager* aGlobalManager)
       
    39 {
       
    40     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::NewLC +");
       
    41 
       
    42     CAMMSSoundSource3D* self = new(ELeave) CAMMSSoundSource3D(aSpectator,
       
    43             aGlobalManager);
       
    44 
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL();
       
    47 
       
    48     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::NewLC -");
       
    49 
       
    50     return self;
       
    51 }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CAMMSSoundSource3D::~CAMMSSoundSource3D()
       
    55 // Destructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CAMMSSoundSource3D::~CAMMSSoundSource3D()
       
    59 {
       
    60     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::~");
       
    61 }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CAMMSSoundSource3D::AddPlayerNoStateCheckL
       
    65 // Adds player without checking its state.
       
    66 // (other items were commented in a header).
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 void CAMMSSoundSource3D::AddPlayerNoStateCheckL(CMMAPlayer* aPlayer)
       
    70 {
       
    71     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::AddPlayerNoStateCheckL +");
       
    72 
       
    73     // Check that the player can be added.
       
    74     User::LeaveIfError(iGlobalManager->PlayerAddingAllowed(aPlayer));
       
    75 
       
    76     // Remove the pan control from the global manager because the pan control
       
    77     // cannot be used when 3D sound is in use.
       
    78     CAMMSPanControlGroup* panControlGroup =
       
    79         (CAMMSPanControlGroup*)iGlobalManager->Find(
       
    80             KAMMSPanControlClassName);
       
    81 
       
    82     // PanControl is not supported in WINSCW builds.
       
    83     if (panControlGroup)
       
    84     {
       
    85         panControlGroup->PlayerRemoved(aPlayer);
       
    86     }
       
    87 
       
    88 
       
    89     // Add the player to the spectator.
       
    90     iSpectator->AddPlayerNoStateCheckL(aPlayer);
       
    91 
       
    92     // Add the player to this module.
       
    93     CAMMSModule::AddPlayerNoStateCheckL(aPlayer);
       
    94 
       
    95     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::AddPlayerNoStateCheckL -");
       
    96 }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CAMMSSoundSource3D::RemovePlayerNoStateCheck
       
   100 // Removes player without checking its state
       
   101 // (other items were commented in a header).
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TInt CAMMSSoundSource3D::RemovePlayerNoStateCheck(CMMAPlayer* aPlayer)
       
   105 {
       
   106     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::RemovePlayerNoStateCheck +");
       
   107 
       
   108     // Remove the player from the module. The method returns the index
       
   109     // of the Player or an error code.
       
   110     TInt error = CAMMSModule::RemovePlayerNoStateCheck(aPlayer);
       
   111 
       
   112     ELOG1( EJavaAMMS, "AMMS:CAMMSSoundSource3D::RemovePlayerNoStateCheck err %d",
       
   113               error);
       
   114 
       
   115     // If the player was found in this module, remove the player also from the
       
   116     // spectator. The method returns the index of the Player or an error code.
       
   117     if (error >= KErrNone)
       
   118     {
       
   119         error = iSpectator->RemovePlayerNoStateCheck(aPlayer);
       
   120 
       
   121         ELOG1( EJavaAMMS, "AMMS:CAMMSSoundSource3D::RemovePlayerNoStateCheck err2 %d",
       
   122                   error);
       
   123     }
       
   124 
       
   125     // If the player is deleted from the module, it is required to add the
       
   126     // pan control to the global manager.
       
   127     if (error >= KErrNone)
       
   128     {
       
   129         CAMMSPanControlGroup* panControlGroup =
       
   130             (CAMMSPanControlGroup*)iGlobalManager->Find(
       
   131                 KAMMSPanControlClassName);
       
   132 
       
   133         // PanControl is not supported in WINSCW builds.
       
   134         if (panControlGroup)
       
   135         {
       
   136             TRAP(error, panControlGroup->PlayerAddedL(aPlayer));
       
   137         }
       
   138 
       
   139         ELOG1( EJavaAMMS, "AMMS:CAMMSSoundSource3D::RemovePlayerNoStateCheck err3 %d",
       
   140                   error);
       
   141     }
       
   142 
       
   143     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::RemovePlayerNoStateCheck -");
       
   144 
       
   145     return error;
       
   146 }
       
   147 
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CAMMSSoundSource3D::ConstructL
       
   151 // Symbian 2nd phase constructor can leave.
       
   152 // -----------------------------------------------------------------------------
       
   153 void CAMMSSoundSource3D::ConstructL()
       
   154 {
       
   155     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::ConstructL +");
       
   156 
       
   157     CAMMSModule::ConstructL();
       
   158 
       
   159     // Add required controls to the SoundSource3D.
       
   160 
       
   161     AddControlGroupAndPopL(CAMMSDopplerControlGroup::NewLC(
       
   162                                EAMMSSoundSource3DControl));
       
   163 
       
   164     AddControlGroupAndPopL(CAMMSLocationControlGroup::NewLC(
       
   165                                EAMMSSoundSource3DControl));
       
   166 
       
   167     AddControlGroupAndPopL(CAMMSDistanceAttenuationControlGroup::NewLC());
       
   168 
       
   169     AddControlGroupAndPopL(CAMMSReverbSourceControlGroup::NewLC());
       
   170 
       
   171     LOG( EJavaAMMS, EInfo, "AMMS:CAMMSSoundSource3D::ConstructL -");
       
   172 }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CAMMSSoundSource3D::CAMMSSoundSource3D
       
   176 // C++ default constructor can NOT contain any code, that
       
   177 // might leave.
       
   178 // -----------------------------------------------------------------------------
       
   179 CAMMSSoundSource3D::CAMMSSoundSource3D(CAMMSModule* aSpectator,
       
   180                                        CAMMSGlobalManager* aGlobalManager)
       
   181         : iSpectator(aSpectator),
       
   182         iGlobalManager(aGlobalManager)
       
   183 {
       
   184 }
       
   185 
       
   186 //  End of File