os/mm/mmlibs/mmfw/tsrc/mmfunittest/MidiClnt/MidiTestCntrl/Ts_cmmfmiditestcontroller.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/MidiClnt/MidiTestCntrl/Ts_cmmfmiditestcontroller.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1231 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <e32svr.h>
1.20 +
1.21 +//const TInt KOpenDelay =500000;; // EABI warning removal
1.22 +//const TInt KPrepareDelay = 500000;; // EABI warning removal
1.23 +//const TInt KFrameReadyDelay = 500000;; // EABI warning removal
1.24 +//const TInt KDuration = 1000000; // EABI warning removal
1.25 +//const TInt KFrameLength = 100000; // EABI warning removal
1.26 +
1.27 +//const TInt KMaxVolume = 100; // EABI warning removal
1.28 +//const TInt KFrameWidth = 100; // EABI warning removal
1.29 +//const TInt KFrameHeight = 50; // EABI warning removal
1.30 +
1.31 +//const TInt KBufMimeTypeGranularity = 4; // EABI warning removal
1.32 +
1.33 +const TUint8 KMaxChannelNumber = 15;
1.34 +
1.35 +#include <mmf/server/mmffile.h>
1.36 +#include "Ts_cmmfmiditestcontroller.h"
1.37 +
1.38 +#include <mmf/common/mmfmidi.h>
1.39 +
1.40 +
1.41 +
1.42 +/*
1.43 +_LIT(KMmfTestControllerCategory, "CMMFTestController");
1.44 +GLDEF_C void Panic(TMmfTestControllerPanic aReason)
1.45 + {
1.46 + User::Panic(KMmfTestControllerCategory, aReason);
1.47 + }
1.48 +*/
1.49 +_LIT(KMidiClntChunk, "MidiClntChunk");
1.50 +_LIT(KMidiClntSemaphore, "MidiClntSemaphore");
1.51 +
1.52 +
1.53 +CMMFMidiTestController* CMMFMidiTestController::NewL()
1.54 + {
1.55 + CMMFMidiTestController* self = CMMFMidiTestController::NewLC();
1.56 + CleanupStack::Pop();
1.57 + return self;
1.58 + }
1.59 +
1.60 +CMMFMidiTestController* CMMFMidiTestController::NewLC(void)
1.61 + {
1.62 + CMMFMidiTestController* self = new (ELeave) CMMFMidiTestController();
1.63 + CleanupStack::PushL(self);
1.64 + self->ConstructL();
1.65 + return self;
1.66 + }
1.67 +
1.68 +CMMFMidiTestController::CMMFMidiTestController()
1.69 + {
1.70 + iPlayBackRate = 1001;
1.71 + iMinRate = 1002;
1.72 + iMaxRate = 1003;
1.73 + iTempoMicroBeatsPerMinute = 1004;
1.74 + iPitchTranspositionCents= 1005;
1.75 + iCentsApplied = 1006;
1.76 + iDurationMicroSeconds = 1007;
1.77 + iDurationMicroBeats = 1008;
1.78 + iNumTracks = 1009;
1.79 + iPositionMicroSeconds = 1010;
1.80 + iPositionMicroBeats = 1011;
1.81 + iNumBanks = 1012;
1.82 + iNumInstruments = 1013;
1.83 + iStopTime = 999;
1.84 + iNumNotes = 57;
1.85 + iChannels = 15;
1.86 + iMaxVol = 60000;
1.87 + iMaxVolume = 100000;
1.88 + iBalance = 2;
1.89 + iRepeatNumberOfTimes = 0;
1.90 + iTrailingSilence = TTimeIntervalMicroSeconds(0);
1.91 + iCurrentMidiTestControllerState = EMidiStateClosedDisengaged;
1.92 + }
1.93 +
1.94 +CMMFMidiTestController::~CMMFMidiTestController(void)
1.95 + {
1.96 + delete iDelayEvent;
1.97 + delete iMidiEventGenerator;
1.98 + delete iChanVolumeValues;
1.99 + }
1.100 +
1.101 +void CMMFMidiTestController::ConstructL (void)
1.102 + {
1.103 + iDelayEvent = CControllerTimer::NewL(this);
1.104 + CActiveScheduler::Add(iDelayEvent);
1.105 +
1.106 + iMidiEventGenerator = CMidiEventGenerator::NewL(this);
1.107 + CActiveScheduler::Add(iMidiEventGenerator);
1.108 +
1.109 + //TUid uid = {0x101F945C};
1.110 + CMidiCustomCommandParser* midiParser = CMidiCustomCommandParser::NewL(*this);
1.111 + iMidiEventHandler = midiParser;
1.112 + CleanupStack::PushL(midiParser);
1.113 + AddCustomCommandParserL(*midiParser);
1.114 + CleanupStack::Pop();
1.115 +
1.116 + CMMFDRMCustomCommandParser* drmParser = CMMFDRMCustomCommandParser::NewL(*this);
1.117 + CleanupStack::PushL(drmParser);
1.118 + AddCustomCommandParserL(*drmParser);
1.119 + CleanupStack::Pop();
1.120 +
1.121 + iChanVolumeValues = new(ELeave)CArrayFixFlat<TReal32>(KMaxChannelNumber);
1.122 + if (iChanVolumeValues)
1.123 + {
1.124 + for (TInt i=0; i<=KMaxChannelNumber; i++)
1.125 + iChanVolumeValues->AppendL(0);
1.126 + }
1.127 + }
1.128 +
1.129 +// The method below need to be filled in with the correct responses
1.130 +
1.131 +void CMMFMidiTestController::AddDataSourceL(MDataSource& aDataSource)
1.132 + {
1.133 + iDataSource = &aDataSource;
1.134 + iDelayEvent->DelayOpen(TTimeIntervalMicroSeconds(1000000));//1sec
1.135 + }
1.136 +
1.137 +void CMMFMidiTestController::AddDataSinkL(MDataSink& /*aDataSink*/)
1.138 + {
1.139 + }
1.140 +
1.141 +void CMMFMidiTestController::RemoveDataSourceL(MDataSource& /*aDataSource*/)
1.142 + {
1.143 + iDataSource = NULL;
1.144 + }
1.145 +
1.146 +void CMMFMidiTestController::RemoveDataSinkL(MDataSink& /*aDataSink*/)
1.147 + {
1.148 + }
1.149 +
1.150 +void CMMFMidiTestController::RemoveSourceSinkL()
1.151 + {
1.152 + }
1.153 +
1.154 +
1.155 +void CMMFMidiTestController::ResetL() //XXX - replacement for RemoveSourceSink()
1.156 + {
1.157 + }
1.158 +
1.159 +/*No leave happens when there is no iDataSource here because a
1.160 + user suppose to perform Midi Live Event even when there
1.161 + is no resource (file) opened.*/
1.162 +void CMMFMidiTestController::PrimeL()
1.163 + {
1.164 + if (iDataSource)
1.165 + {
1.166 + iDataSource->SourcePrimeL();
1.167 + }
1.168 + }
1.169 +
1.170 +void CMMFMidiTestController::PlayL()
1.171 + {
1.172 + if (iDataSource)
1.173 + {
1.174 + if (!iDisableAutoIntent)
1.175 + {
1.176 + User::LeaveIfError( MdcExecuteIntent(ContentAccess::EPlay) );
1.177 + }
1.178 + }
1.179 + iDelayEvent->DelayPlayStarted(TTimeIntervalMicroSeconds(100000));//1 sec
1.180 + }
1.181 +
1.182 +void CMMFMidiTestController::PauseL()
1.183 + {
1.184 + if (iDataSource)
1.185 + {
1.186 + iDataSource->SourcePauseL();
1.187 + }
1.188 + else
1.189 + {
1.190 + User::Leave(KErrNotReady);
1.191 + }
1.192 + }
1.193 +
1.194 +void CMMFMidiTestController::StopL()
1.195 + {
1.196 + if(iDelayEvent->IsActive())
1.197 + {
1.198 + iDelayEvent->Cancel();
1.199 + }
1.200 + iDelayEvent->DelayStop(TTimeIntervalMicroSeconds(0));
1.201 + if (iDataSource)
1.202 + {
1.203 + iDataSource->SourceStopL();
1.204 + }
1.205 + }
1.206 +
1.207 +TTimeIntervalMicroSeconds CMMFMidiTestController::PositionL() const
1.208 + {
1.209 + if (!iDataSource)
1.210 + {
1.211 + User::Leave(KErrNotReady);
1.212 + }
1.213 + return iPositionMicroSeconds;
1.214 +
1.215 + }
1.216 +
1.217 +void CMMFMidiTestController::SetPositionL(const TTimeIntervalMicroSeconds& /*aPosition*/)
1.218 + {
1.219 + }
1.220 +
1.221 +TTimeIntervalMicroSeconds CMMFMidiTestController::DurationL() const
1.222 + {
1.223 + return iDurationMicroSeconds;
1.224 + }
1.225 +
1.226 +void CMMFMidiTestController::CustomCommand(TMMFMessage& aMessage)
1.227 + {
1.228 + if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFDRMControl)
1.229 + {
1.230 + aMessage.Complete(KErrNotSupported);
1.231 + }
1.232 + else
1.233 + {
1.234 + aMessage.Complete(KErrNone);
1.235 + }
1.236 + }
1.237 +
1.238 +void CMMFMidiTestController::SetPrioritySettings(const TMMFPrioritySettings& /*aPrioritySettings*/)
1.239 + {
1.240 + }
1.241 +
1.242 +void CMMFMidiTestController::GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries)
1.243 + {
1.244 + aNumberOfEntries = 10;
1.245 + }
1.246 +
1.247 +CMMFMetaDataEntry* CMMFMidiTestController::GetMetaDataEntryL(TInt /*aIndex*/)
1.248 + {
1.249 + CMMFMetaDataEntry* metaDataEntry = NULL;
1.250 + return metaDataEntry;
1.251 + }
1.252 +
1.253 +TInt CMMFMidiTestController::SendEventToClient(const TMMFEvent& aEvent)
1.254 + {
1.255 + //send event to client...
1.256 + TInt result = DoSendEventToClient(aEvent);
1.257 + return result;
1.258 + }
1.259 +
1.260 +TInt CMMFMidiTestController::OpenComplete()
1.261 + {
1.262 + CMMFMidiEvent* opencomplete = new CMMFMidiEvent(KMMFEventCategoryMidiOpenDataSourceComplete, KErrNone);
1.263 + if(!opencomplete)
1.264 + return KErrNoMemory;
1.265 + switch (iCurrentMidiTestControllerState)
1.266 + {
1.267 + case EMidiStateClosedDisengaged:
1.268 + opencomplete->iOldState = EMidiStateClosedDisengaged;
1.269 + opencomplete->iNewState = EMidiStateOpenDisengaged;
1.270 + iCurrentMidiTestControllerState = EMidiStateOpenDisengaged;
1.271 + break;
1.272 + case EMidiStateOpenPlaying:
1.273 + opencomplete->iOldState = EMidiStateOpenPlaying;
1.274 + opencomplete->iNewState = EMidiStateOpenEngaged;
1.275 + iCurrentMidiTestControllerState = EMidiStateOpenEngaged;
1.276 + break;
1.277 + default:
1.278 + opencomplete->iOldState = iCurrentMidiTestControllerState;
1.279 + opencomplete->iNewState = iCurrentMidiTestControllerState;
1.280 + opencomplete->iEventType = KMMFErrorCategoryControllerGeneralError;
1.281 + break;
1.282 + }
1.283 + opencomplete->iMicroSeconds = iDurationMicroSeconds;
1.284 + iMidiEventHandler->SendMidiEventToClient(*opencomplete);
1.285 + delete opencomplete;
1.286 + return KErrNone;
1.287 + }
1.288 +
1.289 +TInt CMMFMidiTestController::PlayStarted()
1.290 + {
1.291 + CMMFMidiEvent* playStarted = new CMMFMidiEvent(KMMFEventCategoryMidiPlaying, KErrNone);
1.292 + if(!playStarted)
1.293 + return KErrNoMemory;
1.294 + // decide which is the state the MIDI controller can go into when Play is called
1.295 + switch (iCurrentMidiTestControllerState)
1.296 + {
1.297 + case EMidiStateClosedDisengaged:
1.298 + playStarted->iOldState = EMidiStateClosedDisengaged;
1.299 + playStarted->iNewState = EMidiStateClosedEngaged;
1.300 + iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
1.301 + playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
1.302 + iMidiEventHandler->SendMidiEventToClient(*playStarted);
1.303 + delete playStarted;
1.304 + iDelayEvent->PlayFinished(TTimeIntervalMicroSeconds(20000000));//20 sec
1.305 + iMidiEventGenerator->MidiEventTrigger();
1.306 + break;
1.307 +
1.308 + case EMidiStateOpenDisengaged:
1.309 + playStarted->iOldState = EMidiStateOpenDisengaged;
1.310 + playStarted->iNewState = EMidiStateOpenPlaying;
1.311 + iCurrentMidiTestControllerState = EMidiStateOpenPlaying;
1.312 + playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
1.313 + iMidiEventHandler->SendMidiEventToClient(*playStarted);
1.314 + delete playStarted;
1.315 + iDelayEvent->PlayFinished(TTimeIntervalMicroSeconds(20000000));//20 sec
1.316 + iMidiEventGenerator->MidiEventTrigger();
1.317 + break;
1.318 +
1.319 + case EMidiStateOpenEngaged:
1.320 + playStarted->iOldState = EMidiStateOpenEngaged;
1.321 + playStarted->iNewState = EMidiStateOpenPlaying;
1.322 + iCurrentMidiTestControllerState = EMidiStateOpenPlaying;
1.323 + playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
1.324 + iMidiEventHandler->SendMidiEventToClient(*playStarted);
1.325 + delete playStarted;
1.326 + iDelayEvent->PlayFinished(TTimeIntervalMicroSeconds(20000000));//20 sec
1.327 + iMidiEventGenerator->MidiEventTrigger();
1.328 + break;
1.329 +
1.330 + default:
1.331 + playStarted->iOldState = iCurrentMidiTestControllerState;
1.332 + playStarted->iNewState = iCurrentMidiTestControllerState;
1.333 + playStarted->iEventType = KMMFErrorCategoryControllerGeneralError;
1.334 + playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
1.335 + iMidiEventHandler->SendMidiEventToClient(*playStarted);
1.336 + delete playStarted;
1.337 + break;
1.338 + }
1.339 + return KErrNone;
1.340 + }
1.341 +
1.342 +TInt CMMFMidiTestController::PlayFinished()
1.343 + {
1.344 + TUid tmp;
1.345 + tmp.iUid = 0 ;
1.346 + CMMFMidiEvent* playFinished = new CMMFMidiEvent(tmp, KErrNone);
1.347 + if(!playFinished)
1.348 + return KErrNoMemory;
1.349 + switch (iCurrentMidiTestControllerState)
1.350 + {
1.351 + case EMidiStateClosedEngaged:
1.352 + playFinished->iOldState = EMidiStateClosedEngaged;
1.353 + playFinished->iNewState = EMidiStateClosedEngaged;
1.354 + iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
1.355 + break;
1.356 +
1.357 + case EMidiStateOpenPlaying:
1.358 + playFinished->iOldState = EMidiStateOpenPlaying;
1.359 + playFinished->iNewState = EMidiStateOpenEngaged;
1.360 + iCurrentMidiTestControllerState = EMidiStateOpenEngaged;
1.361 + break;
1.362 +
1.363 + default:
1.364 + playFinished->iOldState = iCurrentMidiTestControllerState;
1.365 + playFinished->iNewState = iCurrentMidiTestControllerState;
1.366 + playFinished->iEventType = KMMFErrorCategoryControllerGeneralError;
1.367 + break;
1.368 + }
1.369 +
1.370 + playFinished->iMicroSeconds = iDurationMicroSeconds;
1.371 + iMidiEventHandler->SendMidiEventToClient(*playFinished);
1.372 + delete playFinished;
1.373 + return KErrNone;
1.374 + }
1.375 +
1.376 +TInt CMMFMidiTestController::Stop()
1.377 + {
1.378 + CMMFMidiEvent* playStop = new CMMFMidiEvent(KMMFEventCategoryMidiPlayingComplete, KErrNone);
1.379 + if(!playStop)
1.380 + return KErrNoMemory;
1.381 +
1.382 + switch (iCurrentMidiTestControllerState)
1.383 + {
1.384 + case EMidiStateOpenPlaying:
1.385 + playStop->iOldState = EMidiStateOpenPlaying;
1.386 + playStop->iNewState = EMidiStateOpenDisengaged;
1.387 + iCurrentMidiTestControllerState = EMidiStateOpenDisengaged;
1.388 + break;
1.389 +
1.390 + case EMidiStateClosedEngaged:
1.391 + playStop->iOldState = EMidiStateClosedEngaged;
1.392 + playStop->iNewState = EMidiStateClosedDisengaged;
1.393 + iCurrentMidiTestControllerState = EMidiStateClosedDisengaged;
1.394 + break;
1.395 +
1.396 + case EMidiStateOpenEngaged:
1.397 + playStop->iOldState = EMidiStateOpenEngaged;
1.398 + playStop->iNewState = EMidiStateOpenDisengaged;
1.399 + iCurrentMidiTestControllerState = EMidiStateOpenDisengaged;
1.400 + break;
1.401 +
1.402 + default:
1.403 + playStop->iOldState = iCurrentMidiTestControllerState;
1.404 + playStop->iNewState = iCurrentMidiTestControllerState;
1.405 + playStop->iEventType = KMMFErrorCategoryControllerGeneralError;
1.406 + break;
1.407 + }
1.408 +
1.409 + playStop->iMicroSeconds = iPositionMicroSeconds;
1.410 + iMidiEventHandler->SendMidiEventToClient(*playStop);
1.411 + delete playStop;
1.412 + return KErrNone;
1.413 + }
1.414 +
1.415 +TInt CMMFMidiTestController::Close()
1.416 + {
1.417 + CMMFMidiEvent* close = new CMMFMidiEvent(KMMFEventCategoryMidiClose, KErrNone);
1.418 + if(!close)
1.419 + return KErrNoMemory;
1.420 +
1.421 + switch (iCurrentMidiTestControllerState)
1.422 + {
1.423 + case EMidiStateOpenDisengaged:
1.424 + close->iOldState = EMidiStateOpenDisengaged;
1.425 + close->iNewState = EMidiStateClosedDisengaged;
1.426 + iCurrentMidiTestControllerState = EMidiStateClosedDisengaged;
1.427 + break;
1.428 +
1.429 + case EMidiStateOpenPlaying:
1.430 + close->iOldState = EMidiStateOpenPlaying;
1.431 + close->iNewState = EMidiStateClosedDisengaged;
1.432 + iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
1.433 + break;
1.434 +
1.435 + case EMidiStateOpenEngaged:
1.436 + close->iOldState = EMidiStateOpenEngaged;
1.437 + close->iNewState = EMidiStateClosedEngaged;
1.438 + iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
1.439 + break;
1.440 +
1.441 + default:
1.442 + close->iOldState = iCurrentMidiTestControllerState;
1.443 + close->iNewState = iCurrentMidiTestControllerState;
1.444 + close->iEventType = KMMFErrorCategoryControllerGeneralError;
1.445 + break;
1.446 + }
1.447 + close->iMicroSeconds = TTimeIntervalMicroSeconds(0);
1.448 + iMidiEventHandler->SendMidiEventToClient(*close);
1.449 + delete close;
1.450 + return KErrNone;
1.451 + }
1.452 +
1.453 +TInt CMMFMidiTestController::SyncUpdate()
1.454 + {
1.455 + CMMFMidiEvent* syncUpd = new CMMFMidiEvent(KMMFEventCategoryMidiSyncUpdate, KErrNone);
1.456 + if(!syncUpd)
1.457 + return KErrNoMemory;
1.458 + iMidiEventHandler->SendMidiEventToClient(*syncUpd);
1.459 + delete syncUpd;
1.460 + return KErrNone;
1.461 + }
1.462 +
1.463 +TInt CMMFMidiTestController::TempoChanged()
1.464 + {
1.465 + CMMFMidiEvent* tempoChanged = new CMMFMidiEvent(KMMFEventCategoryTempoChanged, KErrNone);
1.466 + if(!tempoChanged)
1.467 + return KErrNoMemory;
1.468 + tempoChanged->iTempoMicroBeats = 60; //Adagio
1.469 + iMidiEventHandler->SendMidiEventToClient(*tempoChanged);
1.470 + delete tempoChanged;
1.471 + iMidiEventGenerator->MidiEventTrigger();
1.472 + return KErrNone;
1.473 + }
1.474 +
1.475 +TInt CMMFMidiTestController::VolumeChanged()
1.476 + {
1.477 + CMMFMidiEvent* volumeChanged = new CMMFMidiEvent(KMMFEventCategoryVolumeChanged, KErrNone);
1.478 + if(!volumeChanged)
1.479 + return KErrNoMemory;
1.480 + volumeChanged->iVolumeInDecibels = 50000;
1.481 + volumeChanged->iChannel = 14;
1.482 + iMidiEventHandler->SendMidiEventToClient(*volumeChanged);
1.483 + delete volumeChanged;
1.484 + iMidiEventGenerator->MidiEventTrigger();
1.485 + return KErrNone;
1.486 + }
1.487 +
1.488 +TInt CMMFMidiTestController::MuteChanged()
1.489 + {
1.490 + CMMFMidiEvent* muteChanged = new CMMFMidiEvent(KMMFEventCategoryMuteChanged, KErrNone);
1.491 + if(!muteChanged)
1.492 + return KErrNoMemory;
1.493 + muteChanged->iChannel = 15;
1.494 + muteChanged->iMute = ETrue;
1.495 + iMidiEventHandler->SendMidiEventToClient(*muteChanged);
1.496 + delete muteChanged;
1.497 + iMidiEventGenerator->MidiEventTrigger();
1.498 + return KErrNone;
1.499 + }
1.500 +
1.501 +TInt CMMFMidiTestController::PolyphonyChanged()
1.502 + {
1.503 + CMMFMidiEvent* polyphonyChanged = new CMMFMidiEvent(KMMFEventCategoryPolyphonyChanged, KErrNone);
1.504 + if(!polyphonyChanged)
1.505 + return KErrNoMemory;
1.506 + polyphonyChanged->iPolyphony = 10;
1.507 + iMidiEventHandler->SendMidiEventToClient(*polyphonyChanged);
1.508 + delete polyphonyChanged;
1.509 + iMidiEventGenerator->MidiEventTrigger();
1.510 + return KErrNone;
1.511 + }
1.512 +
1.513 +TInt CMMFMidiTestController::InstrumentChanged()
1.514 + {
1.515 + CMMFMidiEvent* instrumentChanged = new CMMFMidiEvent(KMMFEventCategoryInstrumentChanged, KErrNone);
1.516 + if(!instrumentChanged )
1.517 + return KErrNoMemory;
1.518 + instrumentChanged->iChannel = 3;
1.519 + instrumentChanged->iBankId = 4;
1.520 + instrumentChanged->iInstrumentId = 5;
1.521 + iMidiEventHandler->SendMidiEventToClient(*instrumentChanged);
1.522 + delete instrumentChanged ;
1.523 + iMidiEventGenerator->MidiEventTrigger();
1.524 + return KErrNone;
1.525 + }
1.526 +
1.527 +TInt CMMFMidiTestController::SmfMetaDataEntryFound()
1.528 + {
1.529 + TTimeIntervalMicroSeconds position(200000);
1.530 + CMMFMidiEvent* smfMetaDataEntryFound = new CMMFMidiEvent(KMMFEventCategoryMetaDataEntryFound, KErrNone);
1.531 + if(!smfMetaDataEntryFound )
1.532 + return KErrNoMemory;
1.533 + smfMetaDataEntryFound->iMetaDataEntryId = 15;//Not supported in this test controller
1.534 + smfMetaDataEntryFound->iMicroSeconds = position;
1.535 + iMidiEventHandler->SendMidiEventToClient(*smfMetaDataEntryFound);
1.536 + delete smfMetaDataEntryFound;
1.537 + iMidiEventGenerator->MidiEventTrigger();
1.538 + return KErrNone;
1.539 + }
1.540 +
1.541 +TInt CMMFMidiTestController::MipMessageReceived()
1.542 + {
1.543 + TMipMessageEntry mipMessageEntry;
1.544 + mipMessageEntry.iChannel = 11;
1.545 + mipMessageEntry.iMIPValue = 21;
1.546 +
1.547 + TMipMessageEntry mipMessageEntry2;
1.548 + mipMessageEntry2.iChannel = 1;
1.549 + mipMessageEntry2.iMIPValue = 2;
1.550 +
1.551 + CMMFMidiEvent* mipMessageReceived = new CMMFMidiEvent(KMMFEventCategoryMipMessageReceived, KErrNone);
1.552 + if(!mipMessageReceived )
1.553 + return KErrNoMemory;
1.554 + mipMessageReceived->iMipMessage.Append(mipMessageEntry);
1.555 +
1.556 + CMMFMidiEvent* mipMessageReceived2 = new CMMFMidiEvent(KMMFEventCategoryMipMessageReceived, KErrNone);
1.557 + if(!mipMessageReceived2 )
1.558 + return KErrNoMemory;
1.559 + mipMessageReceived2->iMipMessage.Append(mipMessageEntry2);
1.560 +
1.561 +
1.562 + iMidiEventHandler->SendMidiEventToClient(*mipMessageReceived);
1.563 + iMidiEventHandler->SendMidiEventToClient(*mipMessageReceived2);
1.564 + delete mipMessageReceived;
1.565 + delete mipMessageReceived2;
1.566 + return KErrNone;
1.567 + }
1.568 +
1.569 +void CMMFMidiTestController::MmcSetPositionMicroBeatsL(TInt64 /*aMicroBeats*/)
1.570 + {
1.571 + InsertInterfaceNameInChunk(_L8("SetPositionMicroBeatsL"));
1.572 + }
1.573 +
1.574 +void CMMFMidiTestController::MmcPositionMicroBeatsL(TInt64& aMicroBeats)
1.575 + {
1.576 + aMicroBeats = iPositionMicroBeats;
1.577 + InsertInterfaceNameInChunk(_L8("PositionMicroBeatsL"));
1.578 + }
1.579 +
1.580 +void CMMFMidiTestController::MmcPlayNoteL(TInt /*aChannel*/,TInt /*aNote*/,const TTimeIntervalMicroSeconds& /*aDuration*/,TInt /*aNoteOnVelocity*/,TInt /*aNoteOffVelocity*/)
1.581 + {
1.582 + InsertInterfaceNameInChunk(_L8("PlayNoteL"));
1.583 + }
1.584 +
1.585 +void CMMFMidiTestController::MmcPlayNoteL(TInt /*aChannel*/,TInt /*aNote*/,const TTimeIntervalMicroSeconds& /*aStartTime*/, const TTimeIntervalMicroSeconds& /*aDuration*/,TInt /*aNoteOnVelocity*/,TInt /*aNoteOffVelocity*/)
1.586 + {
1.587 + InsertInterfaceNameInChunk(_L8("PlayNoteWithStartTime"));
1.588 + }
1.589 +
1.590 +void CMMFMidiTestController::MmcStopNotesL(TInt /*aChannel*/)
1.591 + {
1.592 + InsertInterfaceNameInChunk(_L8("StopNotes"));
1.593 + }
1.594 +
1.595 +void CMMFMidiTestController::MmcNoteOnL(TInt /*aChannel*/,TInt /*aNote*/,TInt /*aVelocity*/)
1.596 + {
1.597 + InsertInterfaceNameInChunk(_L8("NoteOnL"));
1.598 + }
1.599 +
1.600 +void CMMFMidiTestController::MmcNoteOffL(TInt /*aChannel*/,TInt /*aNote*/,TInt /*aVelocity*/)
1.601 + {
1.602 + InsertInterfaceNameInChunk(_L8("NoteOffL"));
1.603 + }
1.604 +
1.605 +void CMMFMidiTestController::MmcPlaybackRateL(TInt& aPlayBackRate)
1.606 + {
1.607 + aPlayBackRate = iPlayBackRate;
1.608 + InsertInterfaceNameInChunk(_L8("PlaybackRateL"));
1.609 + }
1.610 +
1.611 +void CMMFMidiTestController::MmcSetPlaybackRateL(TInt /*aPlayBackRate*/)
1.612 + {
1.613 + InsertInterfaceNameInChunk(_L8("SetPlaybackRateL"));
1.614 + }
1.615 +
1.616 +void CMMFMidiTestController::MmcMaxPlaybackRateL(TInt& aMaxRate)
1.617 + {
1.618 + aMaxRate = iMaxRate;
1.619 + InsertInterfaceNameInChunk(_L8("MaxPlaybackRateL"));
1.620 + }
1.621 +
1.622 +void CMMFMidiTestController::MmcMinPlaybackRateL(TInt& aMinRate)
1.623 + {
1.624 + aMinRate = iMinRate;
1.625 + InsertInterfaceNameInChunk(_L8("MinPlaybackRateL"));
1.626 + }
1.627 +
1.628 +void CMMFMidiTestController::MmcTempoMicroBeatsPerMinuteL(TInt& aMicroBeatsPerMinute)
1.629 + {
1.630 + aMicroBeatsPerMinute = iTempoMicroBeatsPerMinute;
1.631 + InsertInterfaceNameInChunk(_L8("TempoMicroBeatsPerMinuteL"));
1.632 + }
1.633 +
1.634 +void CMMFMidiTestController::MmcSetTempoL(TInt /*aMicroBeatsPerMinute*/)
1.635 + {
1.636 + InsertInterfaceNameInChunk(_L8("SetTempoL"));
1.637 + }
1.638 +
1.639 +void CMMFMidiTestController::MmcPitchTranspositionCentsL(TInt& aPitch)
1.640 + {
1.641 + aPitch = iPitchTranspositionCents;
1.642 + InsertInterfaceNameInChunk(_L8("PitchTranspositionCentsL"));
1.643 + }
1.644 +
1.645 +void CMMFMidiTestController::MmcSetPitchTranspositionL(TInt /*aCents*/, TInt& aCentsApplied)
1.646 + {
1.647 + aCentsApplied = iCentsApplied;
1.648 + InsertInterfaceNameInChunk(_L8("SetPitchTranspositionL"));
1.649 + }
1.650 +
1.651 +void CMMFMidiTestController::MmcDurationMicroBeatsL(TInt64& aDuration)
1.652 + {
1.653 + aDuration = iDurationMicroBeats;
1.654 + InsertInterfaceNameInChunk(_L8("DurationMicroBeatsL"));
1.655 + }
1.656 +
1.657 +void CMMFMidiTestController::MmcNumTracksL(TInt& aTracks)
1.658 + {
1.659 + aTracks = iNumTracks;
1.660 + InsertInterfaceNameInChunk(_L8("NumTracksL"));
1.661 + }
1.662 +
1.663 +void CMMFMidiTestController::MmcSetTrackMuteL(TInt /*aTrack*/, TBool /*aMuted*/)
1.664 + {
1.665 + InsertInterfaceNameInChunk(_L8("SetTrackMuteL"));
1.666 + }
1.667 +
1.668 +void CMMFMidiTestController::MmcMimeTypeL(TDes8& aMimeType)
1.669 + {
1.670 + _LIT(K,"Midi-x");
1.671 + aMimeType.Copy(K);
1.672 + InsertInterfaceNameInChunk(_L8("MimeTypeL"));
1.673 + }
1.674 +
1.675 +void CMMFMidiTestController::MmcSetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 /*aMicroBeats*/)
1.676 + {
1.677 + InsertInterfaceNameInChunk(_L8("SetSyncUpdateCallbackIntervalL"));
1.678 + iDelayEvent->DelaySyncUpdate(aMicroSeconds);
1.679 + }
1.680 +
1.681 +void CMMFMidiTestController::MmcSendMessageL(const TDesC8& aMidiMessage, TInt& aBytes)
1.682 + {
1.683 + aBytes = aMidiMessage.Length();
1.684 + InsertInterfaceNameInChunk(_L8("SendMessageL"));
1.685 + }
1.686 +
1.687 +void CMMFMidiTestController::MmcSendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& /*aTime*/, TInt& aBytes)
1.688 + {
1.689 + aBytes = aMidiMessage.Length();
1.690 + InsertInterfaceNameInChunk(_L8("SendMessageWithTimeStamp"));
1.691 + }
1.692 +
1.693 +void CMMFMidiTestController::MmcSendMipMessageL(const TArray<TMipMessageEntry>& aEntry)
1.694 + {
1.695 + for(TInt i=0; i< aEntry.Count(); i++)
1.696 + {
1.697 + TMipMessageEntry tmp = aEntry[i];
1.698 + tmp.iChannel++;//to remove the warning
1.699 + }
1.700 + InsertInterfaceNameInChunk(_L8("SendMipMessageL"));
1.701 + }
1.702 +
1.703 +void CMMFMidiTestController::MmcNumberOfBanksL(TBool /*aCustom*/, TInt& aNumBanks)
1.704 + {
1.705 + aNumBanks = iNumBanks;
1.706 + InsertInterfaceNameInChunk(_L8("NumberOfBanksL"));
1.707 + }
1.708 +
1.709 +void CMMFMidiTestController::MmcGetBankIdL(TBool /*aCustom*/, TInt aBankIndex, TInt& aBankId)
1.710 + {
1.711 + aBankId = ++aBankIndex;
1.712 + InsertInterfaceNameInChunk(_L8("GetBankIdL"));
1.713 + }
1.714 +
1.715 +void CMMFMidiTestController::MmcLoadCustomBankL(const TDesC& /*aFileName*/,TInt& aBankId)
1.716 + {
1.717 + aBankId = 60;
1.718 + InsertInterfaceNameInChunk(_L8("LoadCustomBankL"));
1.719 + }
1.720 +
1.721 +void CMMFMidiTestController::MmcUnloadCustomBankL(TInt /*aBankId*/)
1.722 + {
1.723 + InsertInterfaceNameInChunk(_L8("UnloadCustomBankL"));
1.724 + }
1.725 +
1.726 +void CMMFMidiTestController::MmcCustomBankLoadedL(TInt /*aBankId*/, TBool& aBankLoaded)
1.727 + {
1.728 + aBankLoaded = ETrue;
1.729 + InsertInterfaceNameInChunk(_L8("CustomBankLoadedL"));
1.730 + }
1.731 +
1.732 +void CMMFMidiTestController::MmcUnloadAllCustomBanksL()
1.733 + {
1.734 + InsertInterfaceNameInChunk(_L8("UnloadAllCustomBanksL"));
1.735 + }
1.736 +
1.737 +void CMMFMidiTestController::MmcNumberOfInstrumentsL(TInt /*aBankId*/, TBool /*aCustom*/, TInt& aNumInstruments)
1.738 + {
1.739 + aNumInstruments = iNumInstruments;
1.740 + InsertInterfaceNameInChunk(_L8("NumberOfInstrumentsL"));
1.741 + }
1.742 +
1.743 +void CMMFMidiTestController::MmcGetInstrumentIdL(TInt /*aBankId*/,TBool /*aCustom*/,TInt /*aInstrumentIndex*/, TInt& aInstrumentId)
1.744 + {
1.745 + aInstrumentId = 89;
1.746 + InsertInterfaceNameInChunk(_L8("GetInstrumentIdL"));
1.747 + }
1.748 +
1.749 +const TDesC& CMMFMidiTestController::MmcInstrumentNameL(TInt /*aBankId*/, TBool /*aCustom*/, TInt /*aInstrumentId*/)
1.750 + {
1.751 + _LIT(KInstrumentName, "Guitar");
1.752 + InsertInterfaceNameInChunk(_L8("InstrumentNameL"));
1.753 + return KInstrumentName;
1.754 + }
1.755 +
1.756 +void CMMFMidiTestController::MmcSetInstrumentL(TInt /*aChannel*/,TInt /*aBankId*/,TInt /*aInstrumentId*/)
1.757 + {
1.758 + InsertInterfaceNameInChunk(_L8("SetInstrumentL"));
1.759 + }
1.760 +
1.761 +void CMMFMidiTestController::MmcLoadCustomInstrumentL(const TDesC& /*aFileName*/, TInt /*aFileBankId*/, TInt /*aFileInstrumentId*/, TInt /*aMemoryBankId*/, TInt /*aMemoryInstrumentId*/)
1.762 + {
1.763 + InsertInterfaceNameInChunk(_L8("LoadCustomInstrumentL"));
1.764 + }
1.765 +
1.766 +void CMMFMidiTestController::MmcUnloadCustomInstrumentL(TInt /*aCustomBankId*/,TInt /*aInstrumentId*/)
1.767 + {
1.768 + InsertInterfaceNameInChunk(_L8("UnloadCustomInstrumentL"));
1.769 + }
1.770 +
1.771 +const TDesC& CMMFMidiTestController::MmcPercussionKeyNameL(TInt /*aNote*/, TInt /*aBankId*/, TBool /*aCustom*/, TInt /*aInstrumentId*/)
1.772 + {
1.773 + _LIT(KPercussionKeyName, "Do");
1.774 + InsertInterfaceNameInChunk(_L8("PercussionKeyNameL"));
1.775 + return KPercussionKeyName;
1.776 + }
1.777 +
1.778 +void CMMFMidiTestController::MmcStopTimeL(TTimeIntervalMicroSeconds& aStopTime)
1.779 + {
1.780 + aStopTime = iStopTime;
1.781 + InsertInterfaceNameInChunk(_L8("StopTimeL"));
1.782 + }
1.783 +
1.784 +void CMMFMidiTestController::MmcSetStopTimeL(const TTimeIntervalMicroSeconds& /*aStopTime*/)
1.785 + {
1.786 + InsertInterfaceNameInChunk(_L8("SetStopTimeL"));
1.787 + }
1.788 +
1.789 +void CMMFMidiTestController::MmcPolyphonyL(TInt& aNumNotes)
1.790 + {
1.791 + aNumNotes = iNumNotes;
1.792 + InsertInterfaceNameInChunk(_L8("PolyphonyL"));
1.793 + }
1.794 +
1.795 +void CMMFMidiTestController::MmcMaxPolyphonyL(TInt& aMaxNotes)
1.796 + {
1.797 + aMaxNotes = iMaxNotes;
1.798 + InsertInterfaceNameInChunk(_L8("MaxPolyphonyL"));
1.799 + }
1.800 +
1.801 +
1.802 +void CMMFMidiTestController::MmcChannelsSupportedL(TInt& aChannels)
1.803 + {
1.804 + aChannels = iChannels;
1.805 + InsertInterfaceNameInChunk(_L8("ChannelsSupportedL"));
1.806 + }
1.807 +
1.808 +void CMMFMidiTestController::MmcChannelVolumeL(TInt aChannel, TReal32& aChannelVol)
1.809 + {
1.810 + aChannelVol = iChanVolumeValues->At(aChannel);
1.811 + InsertInterfaceNameInChunk(_L8("ChannelVolumeL"));
1.812 + }
1.813 +
1.814 +void CMMFMidiTestController::MmcMaxChannelVolumeL(TReal32& aMaxVol)
1.815 + {
1.816 + aMaxVol = iMaxVol;
1.817 + InsertInterfaceNameInChunk(_L8("MaxChannelVolumeL"));
1.818 + }
1.819 +
1.820 +void CMMFMidiTestController::MmcSetChannelVolumeL(TInt aChannel,TReal32 aVolume)
1.821 + {
1.822 + iChanVolumeValues->InsertL(aChannel, aVolume);
1.823 + InsertInterfaceNameInChunk(_L8("SetChannelVolumeL"));
1.824 + }
1.825 +
1.826 +void CMMFMidiTestController::MmcSetChannelMuteL(TInt /*aChannel*/,TBool /*aMuted*/)
1.827 + {
1.828 + InsertInterfaceNameInChunk(_L8("SetChannelMuteL"));
1.829 + }
1.830 +
1.831 +void CMMFMidiTestController::MmcVolumeL(TInt& aVolume)
1.832 + {
1.833 + aVolume = 70000;
1.834 + InsertInterfaceNameInChunk(_L8("VolumeL"));
1.835 + }
1.836 +
1.837 +void CMMFMidiTestController::MmcMaxVolumeL(TInt& aMaxVolume)
1.838 + {
1.839 + aMaxVolume = iMaxVolume;
1.840 + InsertInterfaceNameInChunk(_L8("MaxVolumeL"));
1.841 + }
1.842 +
1.843 +void CMMFMidiTestController::MmcSetVolumeL(TInt /*aVolume*/)
1.844 + {
1.845 + InsertInterfaceNameInChunk(_L8("SetVolumeL"));
1.846 + }
1.847 +
1.848 +void CMMFMidiTestController::MmcSetVolumeRampL(const TTimeIntervalMicroSeconds& /*aRampDuration*/)
1.849 + {
1.850 + InsertInterfaceNameInChunk(_L8("SetVolumeRampL"));
1.851 + }
1.852 +
1.853 +void CMMFMidiTestController::MmcGetBalanceL(TInt& aBalance)
1.854 + {
1.855 + aBalance = iBalance;
1.856 + InsertInterfaceNameInChunk(_L8("GetBalanceL"));
1.857 + }
1.858 +
1.859 +void CMMFMidiTestController::MmcSetBalanceL(TInt /*aBalance*/)
1.860 + {
1.861 + InsertInterfaceNameInChunk(_L8("SetBalanceL"));
1.862 + }
1.863 +
1.864 +void CMMFMidiTestController::MmcLoadCustomBankDataL(const TDesC8& /*aBankData*/,TInt& aBankId)
1.865 + {
1.866 + aBankId = 20;
1.867 + InsertInterfaceNameInChunk(_L8("LoadCustomBankDataL"));
1.868 + }
1.869 +
1.870 +void CMMFMidiTestController::MmcLoadCustomInstrumentDataL(const TDesC8& /*aInstrumentData*/, TInt /*aBankDataId*/, TInt /*aInstrumentDataId*/, TInt /*aMemoryBankId*/, TInt /*aMemoryInstrumentId*/)
1.871 + {
1.872 + InsertInterfaceNameInChunk(_L8("LoadCustomInstrumentDataL"));
1.873 + }
1.874 +
1.875 +void CMMFMidiTestController::MmcSetMaxPolyphonyL(TInt aMaxNotes)
1.876 + {
1.877 + iMaxNotes = aMaxNotes;
1.878 + InsertInterfaceNameInChunk(_L8("SetMaxPolyphonyL"));
1.879 + }
1.880 +
1.881 +void CMMFMidiTestController::MmcGetRepeatsL(TInt& aNumRepeats)
1.882 + {
1.883 + aNumRepeats = iRepeatNumberOfTimes;
1.884 + InsertInterfaceNameInChunk(_L8("GetRepeats"));
1.885 + }
1.886 +
1.887 +void CMMFMidiTestController::MmcSetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
1.888 + {
1.889 + iRepeatNumberOfTimes = aRepeatNumberOfTimes;
1.890 + iTrailingSilence = aTrailingSilence;
1.891 + InsertInterfaceNameInChunk(_L8("SetRepeatsL"));
1.892 + }
1.893 +
1.894 +void CMMFMidiTestController::MmcSetBankL(TBool /*aCustom*/)
1.895 + {
1.896 + InsertInterfaceNameInChunk(_L8("SetBankL"));
1.897 + }
1.898 +
1.899 +void CMMFMidiTestController::MmcIsTrackMuteL(TInt /*aTrack*/, TBool& aTrackMute)
1.900 + {
1.901 + aTrackMute = ETrue;
1.902 + InsertInterfaceNameInChunk(_L8("IsTrackMuteL"));
1.903 + }
1.904 +
1.905 +void CMMFMidiTestController::MmcIsChannelMuteL(TInt /*aChannel*/, TBool& aChannelMute)
1.906 + {
1.907 + aChannelMute = ETrue;
1.908 + InsertInterfaceNameInChunk(_L8("IsChannelMuteL"));
1.909 + }
1.910 +
1.911 +void CMMFMidiTestController::MmcGetInstrumentL(TInt /*aChannel*/, TInt& aInstrumentId, TInt& aBankId)
1.912 + {
1.913 + aInstrumentId = 10;
1.914 + aBankId = 11;
1.915 + InsertInterfaceNameInChunk(_L8("GetInstrumentL"));
1.916 + }
1.917 +
1.918 +void CMMFMidiTestController::MmcCloseL()
1.919 + {
1.920 + iDelayEvent->DelayClose(TTimeIntervalMicroSeconds(0));
1.921 + }
1.922 +
1.923 +void CMMFMidiTestController::MmcStopL(const TTimeIntervalMicroSeconds& /*aFadeOutDuration*/)
1.924 + {
1.925 + if(iDelayEvent->IsActive())
1.926 + iDelayEvent->Cancel();
1.927 + if(iMidiEventGenerator->IsActive())
1.928 + iMidiEventGenerator->Cancel();
1.929 +
1.930 + iDelayEvent->DelayStop(TTimeIntervalMicroSeconds(0));
1.931 + }
1.932 +
1.933 +
1.934 +
1.935 +//
1.936 +//
1.937 +//
1.938 +CMMFMidiTestController::CControllerTimer* CMMFMidiTestController::CControllerTimer::NewL(CMMFMidiTestController* aController)
1.939 + {
1.940 + CControllerTimer* self = new (ELeave) CControllerTimer(aController);
1.941 + CleanupStack::PushL(self);
1.942 + self->ConstructL();
1.943 + CleanupStack::Pop(self);
1.944 + return self;
1.945 + }
1.946 +
1.947 +CMMFMidiTestController::CControllerTimer::CControllerTimer(CMMFMidiTestController* aController)
1.948 + :CTimer(EPriorityStandard)
1.949 + {
1.950 + iController = aController;
1.951 + }
1.952 +
1.953 +void CMMFMidiTestController::CControllerTimer::DelayOpen(TTimeIntervalMicroSeconds aDelay)
1.954 + {
1.955 + ASSERT(iController);
1.956 + iType = ETmrOpenComplete;
1.957 + After(I64INT(aDelay.Int64()));
1.958 + }
1.959 +
1.960 +void CMMFMidiTestController::CControllerTimer::DelayPlayStarted(TTimeIntervalMicroSeconds aDelay)
1.961 + {
1.962 + ASSERT(iController);
1.963 + iType = ETmrDelayPlayStarted;
1.964 + After(I64INT(aDelay.Int64()));
1.965 + }
1.966 +
1.967 +void CMMFMidiTestController::CControllerTimer::PlayFinished(TTimeIntervalMicroSeconds aDelay)
1.968 + {
1.969 + ASSERT(iController);
1.970 + iType = ETmrPlayFinished;
1.971 + After(I64INT(aDelay.Int64()));
1.972 + }
1.973 +
1.974 +void CMMFMidiTestController::CControllerTimer::DelaySyncUpdate(TTimeIntervalMicroSeconds aDelay)
1.975 + {
1.976 + ASSERT(iController);
1.977 + iType = ETmrSyncUpdate;
1.978 + After(I64INT(aDelay.Int64()));
1.979 + }
1.980 +
1.981 +void CMMFMidiTestController::CControllerTimer::DelayStop(TTimeIntervalMicroSeconds aDelay)
1.982 + {
1.983 + ASSERT(iController);
1.984 + iType = ETmrDelayStop;
1.985 + After(I64INT(aDelay.Int64()));
1.986 + }
1.987 +
1.988 +void CMMFMidiTestController::CControllerTimer::DelayClose(TTimeIntervalMicroSeconds aDelay)
1.989 + {
1.990 + ASSERT(iController);
1.991 + iType = ETmrDelayClose;
1.992 + After(I64INT(aDelay.Int64()));
1.993 + }
1.994 +
1.995 +void CMMFMidiTestController::CControllerTimer::RunL()
1.996 + {
1.997 + ASSERT(iController);
1.998 + switch(iType)
1.999 + {
1.1000 + case ETmrOpenComplete :
1.1001 + User::LeaveIfError(iController->OpenComplete());
1.1002 + break;
1.1003 + case ETmrSyncUpdate :
1.1004 + User::LeaveIfError(iController->SyncUpdate());
1.1005 + break;
1.1006 + case ETmrDelayPlayStarted :
1.1007 + User::LeaveIfError(iController->PlayStarted());
1.1008 + break;
1.1009 + case ETmrPlayFinished :
1.1010 + User::LeaveIfError(iController->PlayFinished());
1.1011 + break;
1.1012 + case ETmrDelayStop :
1.1013 + User::LeaveIfError(iController->Stop());
1.1014 + break;
1.1015 + case ETmrDelayClose :
1.1016 + User::LeaveIfError(iController->Close());
1.1017 + break;
1.1018 + }
1.1019 + }
1.1020 +//
1.1021 +//
1.1022 +//
1.1023 +CMMFMidiTestController::CMidiEventGenerator* CMMFMidiTestController::CMidiEventGenerator::NewL(CMMFMidiTestController* aController)
1.1024 + {
1.1025 + CMidiEventGenerator* self = new (ELeave) CMidiEventGenerator(aController);
1.1026 + CleanupStack::PushL(self);
1.1027 + self->ConstructL();
1.1028 + CleanupStack::Pop(self);
1.1029 + return self;
1.1030 + }
1.1031 +
1.1032 +CMMFMidiTestController::CMidiEventGenerator::CMidiEventGenerator(CMMFMidiTestController* aController)
1.1033 + :CTimer(EPriorityStandard)
1.1034 + {
1.1035 + iController = aController;
1.1036 + iDelay = TTimeIntervalMicroSeconds(0);//2 secs
1.1037 + iTriggerCount = 0;
1.1038 + }
1.1039 +
1.1040 +void CMMFMidiTestController::CMidiEventGenerator::MidiEventTrigger()
1.1041 + {
1.1042 + switch(iTriggerCount)
1.1043 + {
1.1044 + case 0:
1.1045 + iType = EEventTempoChanged;
1.1046 + break;
1.1047 + case 1:
1.1048 + iType = EEventVolumeChanged;
1.1049 + break;
1.1050 + case 2:
1.1051 + iType = EEventMuteChanged;
1.1052 + break;
1.1053 + case 3:
1.1054 + iType = EEventPolyphonyChanged;
1.1055 + break;
1.1056 + case 4:
1.1057 + iType = EEventInstrumentChanged;
1.1058 + break;
1.1059 + case 5:
1.1060 + iType = EEventSmfMetaDataEntryFound;
1.1061 + break;
1.1062 + case 6:
1.1063 + iType = EEventVolumeChanged;
1.1064 + break;
1.1065 + case 7:
1.1066 + iType = EEventMuteChanged;
1.1067 + break;
1.1068 + case 8:
1.1069 + iType = EEventPolyphonyChanged;
1.1070 + break;
1.1071 + case 9:
1.1072 + iType = EEventInstrumentChanged;
1.1073 + break;
1.1074 + case 10:
1.1075 + iType = EEventSmfMetaDataEntryFound;
1.1076 + break;
1.1077 + case 11:
1.1078 + iType = EEventMipMessageReceived;
1.1079 + break;
1.1080 + }
1.1081 + ++iTriggerCount;
1.1082 + After(I64INT(iDelay.Int64()));
1.1083 + }
1.1084 +
1.1085 +/*
1.1086 +void CMMFMidiTestController::CMidiEventGenerator::DelaySyncUpdate(TTimeIntervalMicroSeconds aDelay)
1.1087 + {
1.1088 + ASSERT(iController);
1.1089 + iType = ETmrSyncUpdate;
1.1090 + After(I64INT(aDelay.Int64()));
1.1091 + }
1.1092 +*/
1.1093 +
1.1094 +void CMMFMidiTestController::CMidiEventGenerator::RunL()
1.1095 + {
1.1096 + ASSERT(iController);
1.1097 +
1.1098 + switch(iType)
1.1099 + {
1.1100 + case EEventTempoChanged:
1.1101 + User::LeaveIfError(iController->TempoChanged());
1.1102 + break;
1.1103 + case EEventVolumeChanged:
1.1104 + User::LeaveIfError(iController->VolumeChanged());
1.1105 + break;
1.1106 + case EEventMuteChanged:
1.1107 + User::LeaveIfError(iController->MuteChanged());
1.1108 + break;
1.1109 + case EEventPolyphonyChanged:
1.1110 + User::LeaveIfError(iController->PolyphonyChanged());
1.1111 + break;
1.1112 + case EEventInstrumentChanged:
1.1113 + User::LeaveIfError(iController->InstrumentChanged());
1.1114 + break;
1.1115 + case EEventSmfMetaDataEntryFound:
1.1116 + User::LeaveIfError(iController->SmfMetaDataEntryFound());
1.1117 + break;
1.1118 + case EEventMipMessageReceived:
1.1119 + User::LeaveIfError(iController->MipMessageReceived());
1.1120 + break;
1.1121 + }
1.1122 + }
1.1123 +
1.1124 +void CMMFMidiTestController::InsertInterfaceNameInChunk(const TDesC8& aInterfaceName)
1.1125 + {
1.1126 + TFindChunk findChunk(KMidiClntChunk);
1.1127 + TFullName chunkName;
1.1128 + TInt err = findChunk.Next(chunkName);
1.1129 +
1.1130 + if(err == KErrNone)
1.1131 + {
1.1132 + RChunk chunk;
1.1133 + chunk.OpenGlobal(KMidiClntChunk,EFalse);
1.1134 + TUint8* base = chunk.Base();
1.1135 + for(TInt i=0; i<40 ; i++)
1.1136 + {
1.1137 + *base = 0x0;
1.1138 + base++;
1.1139 + }
1.1140 + TBuf8<40> buf(aInterfaceName);
1.1141 + TPtr8 ptr(chunk.Base(),chunk.Size());
1.1142 + ptr = buf;
1.1143 + chunk.Close();
1.1144 + RSemaphore sem;
1.1145 + sem.OpenGlobal(KMidiClntSemaphore);
1.1146 + sem.Signal();
1.1147 + sem.Close();
1.1148 + }
1.1149 + }
1.1150 +
1.1151 +TInt CMMFMidiTestController::MdcEvaluateIntent(ContentAccess::TIntent aIntent)
1.1152 + {
1.1153 + if (iDataSource == NULL)
1.1154 + {
1.1155 + return KErrNotReady;
1.1156 + }
1.1157 + if (iDataSource && iDataSource->DataSourceType()==KUidMmfFileSource)
1.1158 + {
1.1159 + CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
1.1160 + TInt err = file->EvaluateIntent(aIntent);
1.1161 + return err;
1.1162 + }
1.1163 + else
1.1164 + {
1.1165 + // Evaluating intent will always succeed on sinks that
1.1166 + // don't support DRM
1.1167 + return KErrNone;
1.1168 + }
1.1169 +
1.1170 + }
1.1171 +
1.1172 +TInt CMMFMidiTestController::MdcExecuteIntent(ContentAccess::TIntent aIntent)
1.1173 + {
1.1174 + if (iDataSource == NULL)
1.1175 + {
1.1176 + return KErrNotReady;
1.1177 + }
1.1178 + if (iDataSource->DataSourceType()==KUidMmfFileSource)
1.1179 + {
1.1180 + CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
1.1181 + TInt err = file->ExecuteIntent(aIntent);
1.1182 + return err;
1.1183 + }
1.1184 + else
1.1185 + {
1.1186 + // Executing intent will always succeed on sinks that
1.1187 + // don't support DRM
1.1188 + return KErrNone;
1.1189 + }
1.1190 + }
1.1191 +
1.1192 +TInt CMMFMidiTestController::MdcDisableAutomaticIntent(TBool aDisableAutoIntent)
1.1193 + {
1.1194 + iDisableAutoIntent = aDisableAutoIntent;
1.1195 + return KErrNone;
1.1196 + }
1.1197 +
1.1198 +
1.1199 +TInt CMMFMidiTestController::MdcSetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue)
1.1200 + {
1.1201 + if (iDataSource == NULL)
1.1202 + {
1.1203 + return KErrNotReady;
1.1204 + }
1.1205 +
1.1206 + if (iDataSource->DataSourceType()==KUidMmfFileSource)
1.1207 + {
1.1208 + CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
1.1209 + TInt err = file->SetAgentProperty(aProperty, aValue);
1.1210 + return err;
1.1211 + }
1.1212 + else
1.1213 + {
1.1214 + return KErrNone;
1.1215 + }
1.1216 + }
1.1217 +
1.1218 +// __________________________________________________________________________
1.1219 +// Exported proxy for instantiation method resolution
1.1220 +// Define the interface UIDs
1.1221 +
1.1222 +
1.1223 +const TImplementationProxy ImplementationTable[] =
1.1224 + {
1.1225 + IMPLEMENTATION_PROXY_ENTRY(KMmfMidiTestControllerUid, CMMFMidiTestController::NewL)
1.1226 + };
1.1227 +
1.1228 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1.1229 + {
1.1230 + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1.1231 +
1.1232 + return ImplementationTable;
1.1233 + }
1.1234 +