uifw/EikStd/srvuisrc/eikkeysoundserver.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
child 64 85902f042028
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
    34 
    34 
    35 _LIT(KKeySoundServerThreadName,"KeySoundServerThread");
    35 _LIT(KKeySoundServerThreadName,"KeySoundServerThread");
    36 _LIT(KKeySoundServerSemaphoreName,"KeySoundServerSemaphore");
    36 _LIT(KKeySoundServerSemaphoreName,"KeySoundServerSemaphore");
    37 _LIT(KKeySoundServerDll,"AtSoundServerClient.dll");
    37 _LIT(KKeySoundServerDll,"AtSoundServerClient.dll");
    38 
    38 
    39 const TInt KKeySoundServerStackSize     = 1024*4; // 4K
    39 const TInt KKeySoundServerStackSize     = 1024*8; // 8K
    40 const TInt KAknSoundInfoMapGranularity  = 16;
    40 const TInt KAknSoundInfoMapGranularity  = 16;
    41 const TInt KKeyClickPreference          = 0x00140001;
    41 const TInt KKeyClickPreference          = 0x00140001;
    42 const TInt KKeySoundServerBufExpandSize = 1024*1; // 1K
    42 const TInt KKeySoundServerBufExpandSize = 1024*1; // 1K
    43 const TInt KKeysoundServerDllUid        = 0x10281C86;
    43 const TInt KKeysoundServerDllUid        = 0x10281C86;
    44 
    44 
   280     }
   280     }
   281 
   281 
   282 void CEikKeySoundServer::Complete(TInt aError, TAudioThemeEvent aEvent)
   282 void CEikKeySoundServer::Complete(TInt aError, TAudioThemeEvent aEvent)
   283 	{
   283 	{
   284 	if( aError != KErrNone && aError != ESilencedError 
   284 	if( aError != KErrNone && aError != ESilencedError 
   285 	    && aError != EEventCurrentlyPlaying )
   285 	    && aError != EEventCurrentlyPlaying && aError != KErrUnderflow)
   286 		{
   286 		{
   287 		PlaySid(aEvent, ETrue);
   287 		PlaySid(aEvent, ETrue);
   288 		}
   288 		}
   289 	}
   289 	}
   290 
   290 
   312         aSid == EAvkonSIDInformationTone || aSid == EAvkonSIDConfirmationTone ) 
   312         aSid == EAvkonSIDInformationTone || aSid == EAvkonSIDConfirmationTone ) 
   313         {
   313         {
   314         aPlaySelf = ETrue;
   314         aPlaySelf = ETrue;
   315         }
   315         }
   316 
   316 
       
   317 	if(!iATSoundServerAPI)
       
   318         {
       
   319     	aPlaySelf = ETrue;
       
   320     	}
       
   321 
   317     if(!aPlaySelf && iATSoundServerAPI)
   322     if(!aPlaySelf && iATSoundServerAPI)
   318         {
   323         {
   319         TAudioThemeEvent event = static_cast<TAudioThemeEvent>(aSid);
   324         TAudioThemeEvent event = static_cast<TAudioThemeEvent>(aSid);
   320         TRAP(error, iATSoundServerAPI->SendAudioEventL(event, EFalse));
   325         TRAP(error, iATSoundServerAPI->SendAudioEventL(event, EFalse));
   321         }
   326         }
   423 CEikKeySoundSession::~CEikKeySoundSession()
   428 CEikKeySoundSession::~CEikKeySoundSession()
   424     {
   429     {
   425     RemoveSids(iClientUid);
   430     RemoveSids(iClientUid);
   426     if (iHasLockedContext)
   431     if (iHasLockedContext)
   427         {
   432         {
   428         iServer->SetContextLocked(EFalse);
   433         if( iServer )
       
   434             {
       
   435             iServer->SetContextLocked(EFalse);
       
   436             }
   429         }
   437         }
   430     if (iOwnsDefaultSounds)
   438     if (iOwnsDefaultSounds)
   431         {
   439         {
   432         RemoveSids(0);
   440         RemoveSids(0);
   433         iServer->iInit = EFalse;
   441         iServer->iInit = EFalse;
  1118     }
  1126     }
  1119 
  1127 
  1120 CAknFileSoundInfo::~CAknFileSoundInfo()
  1128 CAknFileSoundInfo::~CAknFileSoundInfo()
  1121     {
  1129     {
  1122     delete iAudioPlayer;
  1130     delete iAudioPlayer;
  1123     delete iAudioData;
       
  1124     }
  1131     }
  1125 
  1132 
  1126 void CAknFileSoundInfo::InitL(const TDesC& aFileName, CMdaServer* aMdaServer)
  1133 void CAknFileSoundInfo::InitL(const TDesC& aFileName, CMdaServer* aMdaServer)
  1127     {
  1134     {
  1128     LOGTEXT(_L("CAknFileSoundInfo::InitL() - Filename:"));
  1135     LOGTEXT(_L("CAknFileSoundInfo::InitL() - Filename:"));
  1129     LOGTEXT(aFileName);
  1136     LOGTEXT(aFileName);
  1130 
  1137     iFileName = aFileName;
  1131     iMdaServer = aMdaServer;
       
  1132 
       
  1133     delete iAudioData;
       
  1134     iAudioData = NULL;
       
  1135 
       
  1136     RFs fsSession;
       
  1137     User::LeaveIfError( fsSession.Connect() );
       
  1138     CleanupClosePushL(fsSession);
       
  1139 
       
  1140     TEntry entry;
       
  1141     User::LeaveIfError(fsSession.Entry(aFileName, entry));
       
  1142     TInt fileSize = entry.iSize;
       
  1143 
       
  1144     LOGTEXT1(_L(" CAknFileSoundInfo::InitL() - File size:%d"), fileSize);
       
  1145 
       
  1146     iAudioData = HBufC8::NewMaxL(fileSize);
       
  1147 
       
  1148     TPtr8 dataPtr = iAudioData->Des();
       
  1149     LoadAudioDataL(fsSession, aFileName, dataPtr);
       
  1150 
       
  1151     CleanupStack::PopAndDestroy();   // fsSession
       
  1152 
       
  1153     LOGTEXT(_L(" CAknFileSoundInfo::InitL() - Exit"));
  1138     LOGTEXT(_L(" CAknFileSoundInfo::InitL() - Exit"));
  1154     }
  1139     }
  1155 
       
  1156 
       
  1157 void CAknFileSoundInfo::LoadAudioDataL(RFs& aFs, const TDesC& aFileName, TDes8& aDes)
       
  1158     {
       
  1159     RDebug::Print(_L("CAknFileSoundInfo::LoadAudioDataL()."));
       
  1160 
       
  1161     RFile file;
       
  1162     User::LeaveIfError( file.Open(aFs, aFileName,EFileRead|EFileShareAny) );
       
  1163     CleanupClosePushL(file);
       
  1164     TInt error = file.Read(aDes, aDes.Length());
       
  1165     file.Close();
       
  1166     CleanupStack::Pop();    //file
       
  1167     User::LeaveIfError(error);
       
  1168 
       
  1169     LOGTEXT(_L(" CAknFileSoundInfo::LoadAudioDataL() - Exit"));
       
  1170     }
       
  1171 
       
  1172 
  1140 
  1173 void CAknFileSoundInfo::PlayL()
  1141 void CAknFileSoundInfo::PlayL()
  1174     {
  1142     {
  1175     LOGTEXT(_L("CAknFileSoundInfo::PlayL()."));
  1143     LOGTEXT(_L("CAknFileSoundInfo::PlayL()."));
  1176     LOGTEXT3(_L(" This:%d, iPriority:%d, iPreference:%d"), (TInt)this, iPriority, iPreference);
  1144     LOGTEXT3(_L(" This:%d, iPriority:%d, iPreference:%d"), (TInt)this, iPriority, iPreference);
  1177 
  1145 
  1178     // Stops playing and deletes audio player instance if it exist.
  1146     // Stops playing and deletes audio player instance if it exist.
  1179     Stop();
  1147     Stop();
  1180 
  1148 
  1181     // Create audio player. DoPlay() will be called in all circumstances.
  1149     // Create audio player. DoPlay() will be called in all circumstances.
  1182     iAudioPlayer = CMdaAudioPlayerUtility::NewDesPlayerReadOnlyL(
  1150     iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this, iPriority,(TMdaPriorityPreference)iPreference );
  1183         *iAudioData, *this, iPriority, (TMdaPriorityPreference)iPreference, iMdaServer);
       
  1184 
       
  1185     LOGTEXT(_L(" CAknFileSoundInfo::PlayL() - Exit"));
  1151     LOGTEXT(_L(" CAknFileSoundInfo::PlayL() - Exit"));
  1186     }
  1152     }
  1187 
  1153 
  1188 
  1154 
  1189 void CAknFileSoundInfo::DoPlay()
  1155 void CAknFileSoundInfo::DoPlay()
  1261 
  1227 
  1262     TInt volume = 0;
  1228     TInt volume = 0;
  1263 
  1229 
  1264     if ( Preference() != KKeyClickPreference ) // Other sounds than key click
  1230     if ( Preference() != KKeyClickPreference ) // Other sounds than key click
  1265         {
  1231         {
  1266         aAudioPlayer->SetVolume( ((TInt)iVolume * max )/(TInt)ESoundVolume9);
  1232 		//change (TInt)ESoundVolume9 to ((TInt)ESoundVolume9 + 1)) to keep consistent with audiotheme
       
  1233         aAudioPlayer->SetVolume( ((TInt)iVolume * max )/((TInt)ESoundVolume9 + 1));
  1267         return;
  1234         return;
  1268         }
  1235         }
  1269 
  1236 
  1270     switch (iVolume)
  1237     switch (iVolume)
  1271         {
  1238         {