os/mm/mmlibs/mmfw/tsrc/mmfunittest/MidiClnt/MidiTestCntrl/Ts_cmmfmiditestcontroller.cpp
Update contrib.
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 //const TInt KOpenDelay =500000;; // EABI warning removal
19 //const TInt KPrepareDelay = 500000;; // EABI warning removal
20 //const TInt KFrameReadyDelay = 500000;; // EABI warning removal
21 //const TInt KDuration = 1000000; // EABI warning removal
22 //const TInt KFrameLength = 100000; // EABI warning removal
24 //const TInt KMaxVolume = 100; // EABI warning removal
25 //const TInt KFrameWidth = 100; // EABI warning removal
26 //const TInt KFrameHeight = 50; // EABI warning removal
28 //const TInt KBufMimeTypeGranularity = 4; // EABI warning removal
30 const TUint8 KMaxChannelNumber = 15;
32 #include <mmf/server/mmffile.h>
33 #include "Ts_cmmfmiditestcontroller.h"
35 #include <mmf/common/mmfmidi.h>
40 _LIT(KMmfTestControllerCategory, "CMMFTestController");
41 GLDEF_C void Panic(TMmfTestControllerPanic aReason)
43 User::Panic(KMmfTestControllerCategory, aReason);
46 _LIT(KMidiClntChunk, "MidiClntChunk");
47 _LIT(KMidiClntSemaphore, "MidiClntSemaphore");
50 CMMFMidiTestController* CMMFMidiTestController::NewL()
52 CMMFMidiTestController* self = CMMFMidiTestController::NewLC();
57 CMMFMidiTestController* CMMFMidiTestController::NewLC(void)
59 CMMFMidiTestController* self = new (ELeave) CMMFMidiTestController();
60 CleanupStack::PushL(self);
65 CMMFMidiTestController::CMMFMidiTestController()
70 iTempoMicroBeatsPerMinute = 1004;
71 iPitchTranspositionCents= 1005;
73 iDurationMicroSeconds = 1007;
74 iDurationMicroBeats = 1008;
76 iPositionMicroSeconds = 1010;
77 iPositionMicroBeats = 1011;
79 iNumInstruments = 1013;
86 iRepeatNumberOfTimes = 0;
87 iTrailingSilence = TTimeIntervalMicroSeconds(0);
88 iCurrentMidiTestControllerState = EMidiStateClosedDisengaged;
91 CMMFMidiTestController::~CMMFMidiTestController(void)
94 delete iMidiEventGenerator;
95 delete iChanVolumeValues;
98 void CMMFMidiTestController::ConstructL (void)
100 iDelayEvent = CControllerTimer::NewL(this);
101 CActiveScheduler::Add(iDelayEvent);
103 iMidiEventGenerator = CMidiEventGenerator::NewL(this);
104 CActiveScheduler::Add(iMidiEventGenerator);
106 //TUid uid = {0x101F945C};
107 CMidiCustomCommandParser* midiParser = CMidiCustomCommandParser::NewL(*this);
108 iMidiEventHandler = midiParser;
109 CleanupStack::PushL(midiParser);
110 AddCustomCommandParserL(*midiParser);
113 CMMFDRMCustomCommandParser* drmParser = CMMFDRMCustomCommandParser::NewL(*this);
114 CleanupStack::PushL(drmParser);
115 AddCustomCommandParserL(*drmParser);
118 iChanVolumeValues = new(ELeave)CArrayFixFlat<TReal32>(KMaxChannelNumber);
119 if (iChanVolumeValues)
121 for (TInt i=0; i<=KMaxChannelNumber; i++)
122 iChanVolumeValues->AppendL(0);
126 // The method below need to be filled in with the correct responses
128 void CMMFMidiTestController::AddDataSourceL(MDataSource& aDataSource)
130 iDataSource = &aDataSource;
131 iDelayEvent->DelayOpen(TTimeIntervalMicroSeconds(1000000));//1sec
134 void CMMFMidiTestController::AddDataSinkL(MDataSink& /*aDataSink*/)
138 void CMMFMidiTestController::RemoveDataSourceL(MDataSource& /*aDataSource*/)
143 void CMMFMidiTestController::RemoveDataSinkL(MDataSink& /*aDataSink*/)
147 void CMMFMidiTestController::RemoveSourceSinkL()
152 void CMMFMidiTestController::ResetL() //XXX - replacement for RemoveSourceSink()
156 /*No leave happens when there is no iDataSource here because a
157 user suppose to perform Midi Live Event even when there
158 is no resource (file) opened.*/
159 void CMMFMidiTestController::PrimeL()
163 iDataSource->SourcePrimeL();
167 void CMMFMidiTestController::PlayL()
171 if (!iDisableAutoIntent)
173 User::LeaveIfError( MdcExecuteIntent(ContentAccess::EPlay) );
176 iDelayEvent->DelayPlayStarted(TTimeIntervalMicroSeconds(100000));//1 sec
179 void CMMFMidiTestController::PauseL()
183 iDataSource->SourcePauseL();
187 User::Leave(KErrNotReady);
191 void CMMFMidiTestController::StopL()
193 if(iDelayEvent->IsActive())
195 iDelayEvent->Cancel();
197 iDelayEvent->DelayStop(TTimeIntervalMicroSeconds(0));
200 iDataSource->SourceStopL();
204 TTimeIntervalMicroSeconds CMMFMidiTestController::PositionL() const
208 User::Leave(KErrNotReady);
210 return iPositionMicroSeconds;
214 void CMMFMidiTestController::SetPositionL(const TTimeIntervalMicroSeconds& /*aPosition*/)
218 TTimeIntervalMicroSeconds CMMFMidiTestController::DurationL() const
220 return iDurationMicroSeconds;
223 void CMMFMidiTestController::CustomCommand(TMMFMessage& aMessage)
225 if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFDRMControl)
227 aMessage.Complete(KErrNotSupported);
231 aMessage.Complete(KErrNone);
235 void CMMFMidiTestController::SetPrioritySettings(const TMMFPrioritySettings& /*aPrioritySettings*/)
239 void CMMFMidiTestController::GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries)
241 aNumberOfEntries = 10;
244 CMMFMetaDataEntry* CMMFMidiTestController::GetMetaDataEntryL(TInt /*aIndex*/)
246 CMMFMetaDataEntry* metaDataEntry = NULL;
247 return metaDataEntry;
250 TInt CMMFMidiTestController::SendEventToClient(const TMMFEvent& aEvent)
252 //send event to client...
253 TInt result = DoSendEventToClient(aEvent);
257 TInt CMMFMidiTestController::OpenComplete()
259 CMMFMidiEvent* opencomplete = new CMMFMidiEvent(KMMFEventCategoryMidiOpenDataSourceComplete, KErrNone);
262 switch (iCurrentMidiTestControllerState)
264 case EMidiStateClosedDisengaged:
265 opencomplete->iOldState = EMidiStateClosedDisengaged;
266 opencomplete->iNewState = EMidiStateOpenDisengaged;
267 iCurrentMidiTestControllerState = EMidiStateOpenDisengaged;
269 case EMidiStateOpenPlaying:
270 opencomplete->iOldState = EMidiStateOpenPlaying;
271 opencomplete->iNewState = EMidiStateOpenEngaged;
272 iCurrentMidiTestControllerState = EMidiStateOpenEngaged;
275 opencomplete->iOldState = iCurrentMidiTestControllerState;
276 opencomplete->iNewState = iCurrentMidiTestControllerState;
277 opencomplete->iEventType = KMMFErrorCategoryControllerGeneralError;
280 opencomplete->iMicroSeconds = iDurationMicroSeconds;
281 iMidiEventHandler->SendMidiEventToClient(*opencomplete);
286 TInt CMMFMidiTestController::PlayStarted()
288 CMMFMidiEvent* playStarted = new CMMFMidiEvent(KMMFEventCategoryMidiPlaying, KErrNone);
291 // decide which is the state the MIDI controller can go into when Play is called
292 switch (iCurrentMidiTestControllerState)
294 case EMidiStateClosedDisengaged:
295 playStarted->iOldState = EMidiStateClosedDisengaged;
296 playStarted->iNewState = EMidiStateClosedEngaged;
297 iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
298 playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
299 iMidiEventHandler->SendMidiEventToClient(*playStarted);
301 iDelayEvent->PlayFinished(TTimeIntervalMicroSeconds(20000000));//20 sec
302 iMidiEventGenerator->MidiEventTrigger();
305 case EMidiStateOpenDisengaged:
306 playStarted->iOldState = EMidiStateOpenDisengaged;
307 playStarted->iNewState = EMidiStateOpenPlaying;
308 iCurrentMidiTestControllerState = EMidiStateOpenPlaying;
309 playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
310 iMidiEventHandler->SendMidiEventToClient(*playStarted);
312 iDelayEvent->PlayFinished(TTimeIntervalMicroSeconds(20000000));//20 sec
313 iMidiEventGenerator->MidiEventTrigger();
316 case EMidiStateOpenEngaged:
317 playStarted->iOldState = EMidiStateOpenEngaged;
318 playStarted->iNewState = EMidiStateOpenPlaying;
319 iCurrentMidiTestControllerState = EMidiStateOpenPlaying;
320 playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
321 iMidiEventHandler->SendMidiEventToClient(*playStarted);
323 iDelayEvent->PlayFinished(TTimeIntervalMicroSeconds(20000000));//20 sec
324 iMidiEventGenerator->MidiEventTrigger();
328 playStarted->iOldState = iCurrentMidiTestControllerState;
329 playStarted->iNewState = iCurrentMidiTestControllerState;
330 playStarted->iEventType = KMMFErrorCategoryControllerGeneralError;
331 playStarted->iMicroSeconds = TTimeIntervalMicroSeconds(0);
332 iMidiEventHandler->SendMidiEventToClient(*playStarted);
339 TInt CMMFMidiTestController::PlayFinished()
343 CMMFMidiEvent* playFinished = new CMMFMidiEvent(tmp, KErrNone);
346 switch (iCurrentMidiTestControllerState)
348 case EMidiStateClosedEngaged:
349 playFinished->iOldState = EMidiStateClosedEngaged;
350 playFinished->iNewState = EMidiStateClosedEngaged;
351 iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
354 case EMidiStateOpenPlaying:
355 playFinished->iOldState = EMidiStateOpenPlaying;
356 playFinished->iNewState = EMidiStateOpenEngaged;
357 iCurrentMidiTestControllerState = EMidiStateOpenEngaged;
361 playFinished->iOldState = iCurrentMidiTestControllerState;
362 playFinished->iNewState = iCurrentMidiTestControllerState;
363 playFinished->iEventType = KMMFErrorCategoryControllerGeneralError;
367 playFinished->iMicroSeconds = iDurationMicroSeconds;
368 iMidiEventHandler->SendMidiEventToClient(*playFinished);
373 TInt CMMFMidiTestController::Stop()
375 CMMFMidiEvent* playStop = new CMMFMidiEvent(KMMFEventCategoryMidiPlayingComplete, KErrNone);
379 switch (iCurrentMidiTestControllerState)
381 case EMidiStateOpenPlaying:
382 playStop->iOldState = EMidiStateOpenPlaying;
383 playStop->iNewState = EMidiStateOpenDisengaged;
384 iCurrentMidiTestControllerState = EMidiStateOpenDisengaged;
387 case EMidiStateClosedEngaged:
388 playStop->iOldState = EMidiStateClosedEngaged;
389 playStop->iNewState = EMidiStateClosedDisengaged;
390 iCurrentMidiTestControllerState = EMidiStateClosedDisengaged;
393 case EMidiStateOpenEngaged:
394 playStop->iOldState = EMidiStateOpenEngaged;
395 playStop->iNewState = EMidiStateOpenDisengaged;
396 iCurrentMidiTestControllerState = EMidiStateOpenDisengaged;
400 playStop->iOldState = iCurrentMidiTestControllerState;
401 playStop->iNewState = iCurrentMidiTestControllerState;
402 playStop->iEventType = KMMFErrorCategoryControllerGeneralError;
406 playStop->iMicroSeconds = iPositionMicroSeconds;
407 iMidiEventHandler->SendMidiEventToClient(*playStop);
412 TInt CMMFMidiTestController::Close()
414 CMMFMidiEvent* close = new CMMFMidiEvent(KMMFEventCategoryMidiClose, KErrNone);
418 switch (iCurrentMidiTestControllerState)
420 case EMidiStateOpenDisengaged:
421 close->iOldState = EMidiStateOpenDisengaged;
422 close->iNewState = EMidiStateClosedDisengaged;
423 iCurrentMidiTestControllerState = EMidiStateClosedDisengaged;
426 case EMidiStateOpenPlaying:
427 close->iOldState = EMidiStateOpenPlaying;
428 close->iNewState = EMidiStateClosedDisengaged;
429 iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
432 case EMidiStateOpenEngaged:
433 close->iOldState = EMidiStateOpenEngaged;
434 close->iNewState = EMidiStateClosedEngaged;
435 iCurrentMidiTestControllerState = EMidiStateClosedEngaged;
439 close->iOldState = iCurrentMidiTestControllerState;
440 close->iNewState = iCurrentMidiTestControllerState;
441 close->iEventType = KMMFErrorCategoryControllerGeneralError;
444 close->iMicroSeconds = TTimeIntervalMicroSeconds(0);
445 iMidiEventHandler->SendMidiEventToClient(*close);
450 TInt CMMFMidiTestController::SyncUpdate()
452 CMMFMidiEvent* syncUpd = new CMMFMidiEvent(KMMFEventCategoryMidiSyncUpdate, KErrNone);
455 iMidiEventHandler->SendMidiEventToClient(*syncUpd);
460 TInt CMMFMidiTestController::TempoChanged()
462 CMMFMidiEvent* tempoChanged = new CMMFMidiEvent(KMMFEventCategoryTempoChanged, KErrNone);
465 tempoChanged->iTempoMicroBeats = 60; //Adagio
466 iMidiEventHandler->SendMidiEventToClient(*tempoChanged);
468 iMidiEventGenerator->MidiEventTrigger();
472 TInt CMMFMidiTestController::VolumeChanged()
474 CMMFMidiEvent* volumeChanged = new CMMFMidiEvent(KMMFEventCategoryVolumeChanged, KErrNone);
477 volumeChanged->iVolumeInDecibels = 50000;
478 volumeChanged->iChannel = 14;
479 iMidiEventHandler->SendMidiEventToClient(*volumeChanged);
480 delete volumeChanged;
481 iMidiEventGenerator->MidiEventTrigger();
485 TInt CMMFMidiTestController::MuteChanged()
487 CMMFMidiEvent* muteChanged = new CMMFMidiEvent(KMMFEventCategoryMuteChanged, KErrNone);
490 muteChanged->iChannel = 15;
491 muteChanged->iMute = ETrue;
492 iMidiEventHandler->SendMidiEventToClient(*muteChanged);
494 iMidiEventGenerator->MidiEventTrigger();
498 TInt CMMFMidiTestController::PolyphonyChanged()
500 CMMFMidiEvent* polyphonyChanged = new CMMFMidiEvent(KMMFEventCategoryPolyphonyChanged, KErrNone);
501 if(!polyphonyChanged)
503 polyphonyChanged->iPolyphony = 10;
504 iMidiEventHandler->SendMidiEventToClient(*polyphonyChanged);
505 delete polyphonyChanged;
506 iMidiEventGenerator->MidiEventTrigger();
510 TInt CMMFMidiTestController::InstrumentChanged()
512 CMMFMidiEvent* instrumentChanged = new CMMFMidiEvent(KMMFEventCategoryInstrumentChanged, KErrNone);
513 if(!instrumentChanged )
515 instrumentChanged->iChannel = 3;
516 instrumentChanged->iBankId = 4;
517 instrumentChanged->iInstrumentId = 5;
518 iMidiEventHandler->SendMidiEventToClient(*instrumentChanged);
519 delete instrumentChanged ;
520 iMidiEventGenerator->MidiEventTrigger();
524 TInt CMMFMidiTestController::SmfMetaDataEntryFound()
526 TTimeIntervalMicroSeconds position(200000);
527 CMMFMidiEvent* smfMetaDataEntryFound = new CMMFMidiEvent(KMMFEventCategoryMetaDataEntryFound, KErrNone);
528 if(!smfMetaDataEntryFound )
530 smfMetaDataEntryFound->iMetaDataEntryId = 15;//Not supported in this test controller
531 smfMetaDataEntryFound->iMicroSeconds = position;
532 iMidiEventHandler->SendMidiEventToClient(*smfMetaDataEntryFound);
533 delete smfMetaDataEntryFound;
534 iMidiEventGenerator->MidiEventTrigger();
538 TInt CMMFMidiTestController::MipMessageReceived()
540 TMipMessageEntry mipMessageEntry;
541 mipMessageEntry.iChannel = 11;
542 mipMessageEntry.iMIPValue = 21;
544 TMipMessageEntry mipMessageEntry2;
545 mipMessageEntry2.iChannel = 1;
546 mipMessageEntry2.iMIPValue = 2;
548 CMMFMidiEvent* mipMessageReceived = new CMMFMidiEvent(KMMFEventCategoryMipMessageReceived, KErrNone);
549 if(!mipMessageReceived )
551 mipMessageReceived->iMipMessage.Append(mipMessageEntry);
553 CMMFMidiEvent* mipMessageReceived2 = new CMMFMidiEvent(KMMFEventCategoryMipMessageReceived, KErrNone);
554 if(!mipMessageReceived2 )
556 mipMessageReceived2->iMipMessage.Append(mipMessageEntry2);
559 iMidiEventHandler->SendMidiEventToClient(*mipMessageReceived);
560 iMidiEventHandler->SendMidiEventToClient(*mipMessageReceived2);
561 delete mipMessageReceived;
562 delete mipMessageReceived2;
566 void CMMFMidiTestController::MmcSetPositionMicroBeatsL(TInt64 /*aMicroBeats*/)
568 InsertInterfaceNameInChunk(_L8("SetPositionMicroBeatsL"));
571 void CMMFMidiTestController::MmcPositionMicroBeatsL(TInt64& aMicroBeats)
573 aMicroBeats = iPositionMicroBeats;
574 InsertInterfaceNameInChunk(_L8("PositionMicroBeatsL"));
577 void CMMFMidiTestController::MmcPlayNoteL(TInt /*aChannel*/,TInt /*aNote*/,const TTimeIntervalMicroSeconds& /*aDuration*/,TInt /*aNoteOnVelocity*/,TInt /*aNoteOffVelocity*/)
579 InsertInterfaceNameInChunk(_L8("PlayNoteL"));
582 void CMMFMidiTestController::MmcPlayNoteL(TInt /*aChannel*/,TInt /*aNote*/,const TTimeIntervalMicroSeconds& /*aStartTime*/, const TTimeIntervalMicroSeconds& /*aDuration*/,TInt /*aNoteOnVelocity*/,TInt /*aNoteOffVelocity*/)
584 InsertInterfaceNameInChunk(_L8("PlayNoteWithStartTime"));
587 void CMMFMidiTestController::MmcStopNotesL(TInt /*aChannel*/)
589 InsertInterfaceNameInChunk(_L8("StopNotes"));
592 void CMMFMidiTestController::MmcNoteOnL(TInt /*aChannel*/,TInt /*aNote*/,TInt /*aVelocity*/)
594 InsertInterfaceNameInChunk(_L8("NoteOnL"));
597 void CMMFMidiTestController::MmcNoteOffL(TInt /*aChannel*/,TInt /*aNote*/,TInt /*aVelocity*/)
599 InsertInterfaceNameInChunk(_L8("NoteOffL"));
602 void CMMFMidiTestController::MmcPlaybackRateL(TInt& aPlayBackRate)
604 aPlayBackRate = iPlayBackRate;
605 InsertInterfaceNameInChunk(_L8("PlaybackRateL"));
608 void CMMFMidiTestController::MmcSetPlaybackRateL(TInt /*aPlayBackRate*/)
610 InsertInterfaceNameInChunk(_L8("SetPlaybackRateL"));
613 void CMMFMidiTestController::MmcMaxPlaybackRateL(TInt& aMaxRate)
616 InsertInterfaceNameInChunk(_L8("MaxPlaybackRateL"));
619 void CMMFMidiTestController::MmcMinPlaybackRateL(TInt& aMinRate)
622 InsertInterfaceNameInChunk(_L8("MinPlaybackRateL"));
625 void CMMFMidiTestController::MmcTempoMicroBeatsPerMinuteL(TInt& aMicroBeatsPerMinute)
627 aMicroBeatsPerMinute = iTempoMicroBeatsPerMinute;
628 InsertInterfaceNameInChunk(_L8("TempoMicroBeatsPerMinuteL"));
631 void CMMFMidiTestController::MmcSetTempoL(TInt /*aMicroBeatsPerMinute*/)
633 InsertInterfaceNameInChunk(_L8("SetTempoL"));
636 void CMMFMidiTestController::MmcPitchTranspositionCentsL(TInt& aPitch)
638 aPitch = iPitchTranspositionCents;
639 InsertInterfaceNameInChunk(_L8("PitchTranspositionCentsL"));
642 void CMMFMidiTestController::MmcSetPitchTranspositionL(TInt /*aCents*/, TInt& aCentsApplied)
644 aCentsApplied = iCentsApplied;
645 InsertInterfaceNameInChunk(_L8("SetPitchTranspositionL"));
648 void CMMFMidiTestController::MmcDurationMicroBeatsL(TInt64& aDuration)
650 aDuration = iDurationMicroBeats;
651 InsertInterfaceNameInChunk(_L8("DurationMicroBeatsL"));
654 void CMMFMidiTestController::MmcNumTracksL(TInt& aTracks)
656 aTracks = iNumTracks;
657 InsertInterfaceNameInChunk(_L8("NumTracksL"));
660 void CMMFMidiTestController::MmcSetTrackMuteL(TInt /*aTrack*/, TBool /*aMuted*/)
662 InsertInterfaceNameInChunk(_L8("SetTrackMuteL"));
665 void CMMFMidiTestController::MmcMimeTypeL(TDes8& aMimeType)
669 InsertInterfaceNameInChunk(_L8("MimeTypeL"));
672 void CMMFMidiTestController::MmcSetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 /*aMicroBeats*/)
674 InsertInterfaceNameInChunk(_L8("SetSyncUpdateCallbackIntervalL"));
675 iDelayEvent->DelaySyncUpdate(aMicroSeconds);
678 void CMMFMidiTestController::MmcSendMessageL(const TDesC8& aMidiMessage, TInt& aBytes)
680 aBytes = aMidiMessage.Length();
681 InsertInterfaceNameInChunk(_L8("SendMessageL"));
684 void CMMFMidiTestController::MmcSendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& /*aTime*/, TInt& aBytes)
686 aBytes = aMidiMessage.Length();
687 InsertInterfaceNameInChunk(_L8("SendMessageWithTimeStamp"));
690 void CMMFMidiTestController::MmcSendMipMessageL(const TArray<TMipMessageEntry>& aEntry)
692 for(TInt i=0; i< aEntry.Count(); i++)
694 TMipMessageEntry tmp = aEntry[i];
695 tmp.iChannel++;//to remove the warning
697 InsertInterfaceNameInChunk(_L8("SendMipMessageL"));
700 void CMMFMidiTestController::MmcNumberOfBanksL(TBool /*aCustom*/, TInt& aNumBanks)
702 aNumBanks = iNumBanks;
703 InsertInterfaceNameInChunk(_L8("NumberOfBanksL"));
706 void CMMFMidiTestController::MmcGetBankIdL(TBool /*aCustom*/, TInt aBankIndex, TInt& aBankId)
708 aBankId = ++aBankIndex;
709 InsertInterfaceNameInChunk(_L8("GetBankIdL"));
712 void CMMFMidiTestController::MmcLoadCustomBankL(const TDesC& /*aFileName*/,TInt& aBankId)
715 InsertInterfaceNameInChunk(_L8("LoadCustomBankL"));
718 void CMMFMidiTestController::MmcUnloadCustomBankL(TInt /*aBankId*/)
720 InsertInterfaceNameInChunk(_L8("UnloadCustomBankL"));
723 void CMMFMidiTestController::MmcCustomBankLoadedL(TInt /*aBankId*/, TBool& aBankLoaded)
726 InsertInterfaceNameInChunk(_L8("CustomBankLoadedL"));
729 void CMMFMidiTestController::MmcUnloadAllCustomBanksL()
731 InsertInterfaceNameInChunk(_L8("UnloadAllCustomBanksL"));
734 void CMMFMidiTestController::MmcNumberOfInstrumentsL(TInt /*aBankId*/, TBool /*aCustom*/, TInt& aNumInstruments)
736 aNumInstruments = iNumInstruments;
737 InsertInterfaceNameInChunk(_L8("NumberOfInstrumentsL"));
740 void CMMFMidiTestController::MmcGetInstrumentIdL(TInt /*aBankId*/,TBool /*aCustom*/,TInt /*aInstrumentIndex*/, TInt& aInstrumentId)
743 InsertInterfaceNameInChunk(_L8("GetInstrumentIdL"));
746 const TDesC& CMMFMidiTestController::MmcInstrumentNameL(TInt /*aBankId*/, TBool /*aCustom*/, TInt /*aInstrumentId*/)
748 _LIT(KInstrumentName, "Guitar");
749 InsertInterfaceNameInChunk(_L8("InstrumentNameL"));
750 return KInstrumentName;
753 void CMMFMidiTestController::MmcSetInstrumentL(TInt /*aChannel*/,TInt /*aBankId*/,TInt /*aInstrumentId*/)
755 InsertInterfaceNameInChunk(_L8("SetInstrumentL"));
758 void CMMFMidiTestController::MmcLoadCustomInstrumentL(const TDesC& /*aFileName*/, TInt /*aFileBankId*/, TInt /*aFileInstrumentId*/, TInt /*aMemoryBankId*/, TInt /*aMemoryInstrumentId*/)
760 InsertInterfaceNameInChunk(_L8("LoadCustomInstrumentL"));
763 void CMMFMidiTestController::MmcUnloadCustomInstrumentL(TInt /*aCustomBankId*/,TInt /*aInstrumentId*/)
765 InsertInterfaceNameInChunk(_L8("UnloadCustomInstrumentL"));
768 const TDesC& CMMFMidiTestController::MmcPercussionKeyNameL(TInt /*aNote*/, TInt /*aBankId*/, TBool /*aCustom*/, TInt /*aInstrumentId*/)
770 _LIT(KPercussionKeyName, "Do");
771 InsertInterfaceNameInChunk(_L8("PercussionKeyNameL"));
772 return KPercussionKeyName;
775 void CMMFMidiTestController::MmcStopTimeL(TTimeIntervalMicroSeconds& aStopTime)
777 aStopTime = iStopTime;
778 InsertInterfaceNameInChunk(_L8("StopTimeL"));
781 void CMMFMidiTestController::MmcSetStopTimeL(const TTimeIntervalMicroSeconds& /*aStopTime*/)
783 InsertInterfaceNameInChunk(_L8("SetStopTimeL"));
786 void CMMFMidiTestController::MmcPolyphonyL(TInt& aNumNotes)
788 aNumNotes = iNumNotes;
789 InsertInterfaceNameInChunk(_L8("PolyphonyL"));
792 void CMMFMidiTestController::MmcMaxPolyphonyL(TInt& aMaxNotes)
794 aMaxNotes = iMaxNotes;
795 InsertInterfaceNameInChunk(_L8("MaxPolyphonyL"));
799 void CMMFMidiTestController::MmcChannelsSupportedL(TInt& aChannels)
801 aChannels = iChannels;
802 InsertInterfaceNameInChunk(_L8("ChannelsSupportedL"));
805 void CMMFMidiTestController::MmcChannelVolumeL(TInt aChannel, TReal32& aChannelVol)
807 aChannelVol = iChanVolumeValues->At(aChannel);
808 InsertInterfaceNameInChunk(_L8("ChannelVolumeL"));
811 void CMMFMidiTestController::MmcMaxChannelVolumeL(TReal32& aMaxVol)
814 InsertInterfaceNameInChunk(_L8("MaxChannelVolumeL"));
817 void CMMFMidiTestController::MmcSetChannelVolumeL(TInt aChannel,TReal32 aVolume)
819 iChanVolumeValues->InsertL(aChannel, aVolume);
820 InsertInterfaceNameInChunk(_L8("SetChannelVolumeL"));
823 void CMMFMidiTestController::MmcSetChannelMuteL(TInt /*aChannel*/,TBool /*aMuted*/)
825 InsertInterfaceNameInChunk(_L8("SetChannelMuteL"));
828 void CMMFMidiTestController::MmcVolumeL(TInt& aVolume)
831 InsertInterfaceNameInChunk(_L8("VolumeL"));
834 void CMMFMidiTestController::MmcMaxVolumeL(TInt& aMaxVolume)
836 aMaxVolume = iMaxVolume;
837 InsertInterfaceNameInChunk(_L8("MaxVolumeL"));
840 void CMMFMidiTestController::MmcSetVolumeL(TInt /*aVolume*/)
842 InsertInterfaceNameInChunk(_L8("SetVolumeL"));
845 void CMMFMidiTestController::MmcSetVolumeRampL(const TTimeIntervalMicroSeconds& /*aRampDuration*/)
847 InsertInterfaceNameInChunk(_L8("SetVolumeRampL"));
850 void CMMFMidiTestController::MmcGetBalanceL(TInt& aBalance)
853 InsertInterfaceNameInChunk(_L8("GetBalanceL"));
856 void CMMFMidiTestController::MmcSetBalanceL(TInt /*aBalance*/)
858 InsertInterfaceNameInChunk(_L8("SetBalanceL"));
861 void CMMFMidiTestController::MmcLoadCustomBankDataL(const TDesC8& /*aBankData*/,TInt& aBankId)
864 InsertInterfaceNameInChunk(_L8("LoadCustomBankDataL"));
867 void CMMFMidiTestController::MmcLoadCustomInstrumentDataL(const TDesC8& /*aInstrumentData*/, TInt /*aBankDataId*/, TInt /*aInstrumentDataId*/, TInt /*aMemoryBankId*/, TInt /*aMemoryInstrumentId*/)
869 InsertInterfaceNameInChunk(_L8("LoadCustomInstrumentDataL"));
872 void CMMFMidiTestController::MmcSetMaxPolyphonyL(TInt aMaxNotes)
874 iMaxNotes = aMaxNotes;
875 InsertInterfaceNameInChunk(_L8("SetMaxPolyphonyL"));
878 void CMMFMidiTestController::MmcGetRepeatsL(TInt& aNumRepeats)
880 aNumRepeats = iRepeatNumberOfTimes;
881 InsertInterfaceNameInChunk(_L8("GetRepeats"));
884 void CMMFMidiTestController::MmcSetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
886 iRepeatNumberOfTimes = aRepeatNumberOfTimes;
887 iTrailingSilence = aTrailingSilence;
888 InsertInterfaceNameInChunk(_L8("SetRepeatsL"));
891 void CMMFMidiTestController::MmcSetBankL(TBool /*aCustom*/)
893 InsertInterfaceNameInChunk(_L8("SetBankL"));
896 void CMMFMidiTestController::MmcIsTrackMuteL(TInt /*aTrack*/, TBool& aTrackMute)
899 InsertInterfaceNameInChunk(_L8("IsTrackMuteL"));
902 void CMMFMidiTestController::MmcIsChannelMuteL(TInt /*aChannel*/, TBool& aChannelMute)
904 aChannelMute = ETrue;
905 InsertInterfaceNameInChunk(_L8("IsChannelMuteL"));
908 void CMMFMidiTestController::MmcGetInstrumentL(TInt /*aChannel*/, TInt& aInstrumentId, TInt& aBankId)
912 InsertInterfaceNameInChunk(_L8("GetInstrumentL"));
915 void CMMFMidiTestController::MmcCloseL()
917 iDelayEvent->DelayClose(TTimeIntervalMicroSeconds(0));
920 void CMMFMidiTestController::MmcStopL(const TTimeIntervalMicroSeconds& /*aFadeOutDuration*/)
922 if(iDelayEvent->IsActive())
923 iDelayEvent->Cancel();
924 if(iMidiEventGenerator->IsActive())
925 iMidiEventGenerator->Cancel();
927 iDelayEvent->DelayStop(TTimeIntervalMicroSeconds(0));
935 CMMFMidiTestController::CControllerTimer* CMMFMidiTestController::CControllerTimer::NewL(CMMFMidiTestController* aController)
937 CControllerTimer* self = new (ELeave) CControllerTimer(aController);
938 CleanupStack::PushL(self);
940 CleanupStack::Pop(self);
944 CMMFMidiTestController::CControllerTimer::CControllerTimer(CMMFMidiTestController* aController)
945 :CTimer(EPriorityStandard)
947 iController = aController;
950 void CMMFMidiTestController::CControllerTimer::DelayOpen(TTimeIntervalMicroSeconds aDelay)
953 iType = ETmrOpenComplete;
954 After(I64INT(aDelay.Int64()));
957 void CMMFMidiTestController::CControllerTimer::DelayPlayStarted(TTimeIntervalMicroSeconds aDelay)
960 iType = ETmrDelayPlayStarted;
961 After(I64INT(aDelay.Int64()));
964 void CMMFMidiTestController::CControllerTimer::PlayFinished(TTimeIntervalMicroSeconds aDelay)
967 iType = ETmrPlayFinished;
968 After(I64INT(aDelay.Int64()));
971 void CMMFMidiTestController::CControllerTimer::DelaySyncUpdate(TTimeIntervalMicroSeconds aDelay)
974 iType = ETmrSyncUpdate;
975 After(I64INT(aDelay.Int64()));
978 void CMMFMidiTestController::CControllerTimer::DelayStop(TTimeIntervalMicroSeconds aDelay)
981 iType = ETmrDelayStop;
982 After(I64INT(aDelay.Int64()));
985 void CMMFMidiTestController::CControllerTimer::DelayClose(TTimeIntervalMicroSeconds aDelay)
988 iType = ETmrDelayClose;
989 After(I64INT(aDelay.Int64()));
992 void CMMFMidiTestController::CControllerTimer::RunL()
997 case ETmrOpenComplete :
998 User::LeaveIfError(iController->OpenComplete());
1000 case ETmrSyncUpdate :
1001 User::LeaveIfError(iController->SyncUpdate());
1003 case ETmrDelayPlayStarted :
1004 User::LeaveIfError(iController->PlayStarted());
1006 case ETmrPlayFinished :
1007 User::LeaveIfError(iController->PlayFinished());
1009 case ETmrDelayStop :
1010 User::LeaveIfError(iController->Stop());
1012 case ETmrDelayClose :
1013 User::LeaveIfError(iController->Close());
1020 CMMFMidiTestController::CMidiEventGenerator* CMMFMidiTestController::CMidiEventGenerator::NewL(CMMFMidiTestController* aController)
1022 CMidiEventGenerator* self = new (ELeave) CMidiEventGenerator(aController);
1023 CleanupStack::PushL(self);
1025 CleanupStack::Pop(self);
1029 CMMFMidiTestController::CMidiEventGenerator::CMidiEventGenerator(CMMFMidiTestController* aController)
1030 :CTimer(EPriorityStandard)
1032 iController = aController;
1033 iDelay = TTimeIntervalMicroSeconds(0);//2 secs
1037 void CMMFMidiTestController::CMidiEventGenerator::MidiEventTrigger()
1039 switch(iTriggerCount)
1042 iType = EEventTempoChanged;
1045 iType = EEventVolumeChanged;
1048 iType = EEventMuteChanged;
1051 iType = EEventPolyphonyChanged;
1054 iType = EEventInstrumentChanged;
1057 iType = EEventSmfMetaDataEntryFound;
1060 iType = EEventVolumeChanged;
1063 iType = EEventMuteChanged;
1066 iType = EEventPolyphonyChanged;
1069 iType = EEventInstrumentChanged;
1072 iType = EEventSmfMetaDataEntryFound;
1075 iType = EEventMipMessageReceived;
1079 After(I64INT(iDelay.Int64()));
1083 void CMMFMidiTestController::CMidiEventGenerator::DelaySyncUpdate(TTimeIntervalMicroSeconds aDelay)
1085 ASSERT(iController);
1086 iType = ETmrSyncUpdate;
1087 After(I64INT(aDelay.Int64()));
1091 void CMMFMidiTestController::CMidiEventGenerator::RunL()
1093 ASSERT(iController);
1097 case EEventTempoChanged:
1098 User::LeaveIfError(iController->TempoChanged());
1100 case EEventVolumeChanged:
1101 User::LeaveIfError(iController->VolumeChanged());
1103 case EEventMuteChanged:
1104 User::LeaveIfError(iController->MuteChanged());
1106 case EEventPolyphonyChanged:
1107 User::LeaveIfError(iController->PolyphonyChanged());
1109 case EEventInstrumentChanged:
1110 User::LeaveIfError(iController->InstrumentChanged());
1112 case EEventSmfMetaDataEntryFound:
1113 User::LeaveIfError(iController->SmfMetaDataEntryFound());
1115 case EEventMipMessageReceived:
1116 User::LeaveIfError(iController->MipMessageReceived());
1121 void CMMFMidiTestController::InsertInterfaceNameInChunk(const TDesC8& aInterfaceName)
1123 TFindChunk findChunk(KMidiClntChunk);
1124 TFullName chunkName;
1125 TInt err = findChunk.Next(chunkName);
1130 chunk.OpenGlobal(KMidiClntChunk,EFalse);
1131 TUint8* base = chunk.Base();
1132 for(TInt i=0; i<40 ; i++)
1137 TBuf8<40> buf(aInterfaceName);
1138 TPtr8 ptr(chunk.Base(),chunk.Size());
1142 sem.OpenGlobal(KMidiClntSemaphore);
1148 TInt CMMFMidiTestController::MdcEvaluateIntent(ContentAccess::TIntent aIntent)
1150 if (iDataSource == NULL)
1152 return KErrNotReady;
1154 if (iDataSource && iDataSource->DataSourceType()==KUidMmfFileSource)
1156 CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
1157 TInt err = file->EvaluateIntent(aIntent);
1162 // Evaluating intent will always succeed on sinks that
1163 // don't support DRM
1169 TInt CMMFMidiTestController::MdcExecuteIntent(ContentAccess::TIntent aIntent)
1171 if (iDataSource == NULL)
1173 return KErrNotReady;
1175 if (iDataSource->DataSourceType()==KUidMmfFileSource)
1177 CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
1178 TInt err = file->ExecuteIntent(aIntent);
1183 // Executing intent will always succeed on sinks that
1184 // don't support DRM
1189 TInt CMMFMidiTestController::MdcDisableAutomaticIntent(TBool aDisableAutoIntent)
1191 iDisableAutoIntent = aDisableAutoIntent;
1196 TInt CMMFMidiTestController::MdcSetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue)
1198 if (iDataSource == NULL)
1200 return KErrNotReady;
1203 if (iDataSource->DataSourceType()==KUidMmfFileSource)
1205 CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
1206 TInt err = file->SetAgentProperty(aProperty, aValue);
1215 // __________________________________________________________________________
1216 // Exported proxy for instantiation method resolution
1217 // Define the interface UIDs
1220 const TImplementationProxy ImplementationTable[] =
1222 IMPLEMENTATION_PROXY_ENTRY(KMmfMidiTestControllerUid, CMMFMidiTestController::NewL)
1225 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1227 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1229 return ImplementationTable;