sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "midiclientutilitybody.h" sl@0: sl@0: const TInt KMimeLength = 256; sl@0: const TInt KMinChannel = 0; sl@0: const TInt KMaxChannel = 15; sl@0: const TInt KMinNote = 0; sl@0: const TInt KMaxNote = 127; sl@0: const TInt KMinNoteOnVelocity = 0; sl@0: const TInt KMaxNoteOnVelocity = 127; sl@0: const TInt KMinNoteOffVelocity = 0; sl@0: const TInt KMaxNoteOffVelocity = 127; sl@0: const TInt KMinInstrumentId = 0; sl@0: const TInt KMaxInstrumentId = 127; sl@0: sl@0: sl@0: CMidiClientUtility::CBody* CMidiClientUtility::CBody::NewL(CMidiClientUtility* aParent, sl@0: MMidiClientUtilityObserver& aObserver, sl@0: TInt aPriority, sl@0: TInt aPref, sl@0: TBool aUseSharedHeap) sl@0: { sl@0: CBody* self = new(ELeave) CBody(aParent, aObserver, aPriority, aPref); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aUseSharedHeap); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CMidiClientUtility::CBody::CBody(CMidiClientUtility* aParent, sl@0: MMidiClientUtilityObserver& aObserver, sl@0: TInt aPriority, sl@0: TInt aPref) : sl@0: iObserver(aObserver), sl@0: iMidiControllerCommands(iController), sl@0: iDRMCustomCommands(iController) sl@0: sl@0: { sl@0: iParent = aParent; sl@0: iState = EMidiStateClosedDisengaged; sl@0: iPrioritySettings.iPriority = aPriority; sl@0: iPrioritySettings.iPref = aPref; sl@0: iIntervalSec = ETrue; sl@0: iStopPosition = TTimeIntervalMicroSeconds(0); sl@0: } sl@0: sl@0: CMidiClientUtility::CBody::~CBody() sl@0: { sl@0: delete iAddDataSourceSinkAsync; sl@0: if (iMidiControllerEventMonitor) sl@0: iMidiControllerEventMonitor->Cancel(); sl@0: sl@0: iController.Close(); sl@0: delete iMidiControllerEventMonitor; sl@0: delete iMimeType; sl@0: delete iRepeatTrailingSilenceTimer; sl@0: delete iSource; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::ConstructL(TBool aUseSharedHeap) sl@0: { sl@0: iMidiControllerEventMonitor = CMidiControllerEventMonitor::NewL(*this, iMidiControllerCommands, *iParent); sl@0: iMimeType = HBufC8::NewL(KMimeLength); sl@0: sl@0: RMMFControllerImplInfoArray controllers; sl@0: CleanupResetAndDestroyPushL(controllers); sl@0: CMMFControllerPluginSelectionParameters* cSelect = CMMFControllerPluginSelectionParameters::NewLC(); sl@0: sl@0: // Select the media IDs to allow sl@0: RArray mediaIds; sl@0: CleanupClosePushL(mediaIds); sl@0: User::LeaveIfError(mediaIds.Append(KUidMediaTypeMidi)); sl@0: cSelect->SetMediaIdsL(mediaIds,CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds); sl@0: CleanupStack::PopAndDestroy();//mediaIds sl@0: cSelect->ListImplementationsL(controllers); sl@0: // Open and configure a controller sl@0: User::LeaveIfError(DoOpen(controllers, KUidMmfAudioOutput, KNullDesC8, aUseSharedHeap)); sl@0: CleanupStack::PopAndDestroy(2);//controllers, cSelect sl@0: iRepeatTrailingSilenceTimer = CRepeatTrailingSilenceTimer::NewL(*this); sl@0: iAddDataSourceSinkAsync = CMMFAddDataSourceSinkAsync::NewL(*this); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::MadssaoAddDataSourceSinkAsyncComplete(TInt aError, const TMMFMessageDestination& aHandle) sl@0: { sl@0: if (aError == KErrNone) sl@0: { sl@0: iSourceHandle = aHandle; sl@0: } sl@0: else sl@0: { sl@0: iMidiControllerEventMonitor->SelfComplete(aError); sl@0: } sl@0: } sl@0: void CMidiClientUtility::CBody::OpenFile(const TDesC& aFileName) sl@0: { sl@0: TMMFFileConfig sourceCfg; sl@0: sourceCfg().iPath = aFileName; sl@0: // Add the data source to the controller. MmcuoStateChanged will be call on completition. sl@0: iAddDataSourceSinkAsync->AddDataSource(iController, KUidMmfFileSource, sourceCfg); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::OpenFile(RFile& aFile) sl@0: { sl@0: // Add the data source to the controller. MmcuoStateChanged will be call on completition. sl@0: iAddDataSourceSinkAsync->AddFileHandleDataSource(iController, aFile); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::OpenFile(const TMMSource& aSource) sl@0: { sl@0: TRAPD(err, DoOpenFileL(aSource)); sl@0: if (err != KErrNone) sl@0: { sl@0: iMidiControllerEventMonitor->SelfComplete(err); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CMidiClientUtility::CBody::DoOpenFileL(const TMMSource& aSource) sl@0: { sl@0: delete iSource; sl@0: iSource = NULL; sl@0: iSource = CMMFileSourceSink::NewL(KUidMmfFileSource, aSource); sl@0: static_cast(iSource)->EvaluateIntentL( aSource.Intent() ); sl@0: iAddDataSourceSinkAsync->AddDataSource(iController, sl@0: iSource->SourceSinkUid(), sl@0: iSource->SourceSinkData()); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::OpenDes(const TDesC8& aDescriptor) sl@0: { sl@0: TMMFDescriptorConfig sourceCfg; sl@0: sourceCfg().iDes = (TAny*)&aDescriptor; sl@0: sourceCfg().iDesThreadId = RThread().Id(); sl@0: // Add the data source to the controller. MmcuoStateChanged will be call on completition. sl@0: iAddDataSourceSinkAsync->AddDataSource(iController, KUidMmfDescriptorSource, sourceCfg); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::OpenUrl(const TDesC& aUrl,TInt aIapId,const TDesC8& /*aMimeType*/) sl@0: { sl@0: TRAPD(err, DoOpenUrlL(aUrl, aIapId)); sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: iMidiControllerEventMonitor->SelfComplete(err); sl@0: } sl@0: sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::DoOpenUrlL(const TDesC& aUrl,TInt aIapId) sl@0: { sl@0: CMMFUrlParams* sourceCfg = CMMFUrlParams::NewLC(aUrl, aIapId); sl@0: CBufFlat* sourceCfgBuffer = sourceCfg->ExternalizeToCBufFlatLC(); sl@0: // Add the data source to the controller. MmcuoStateChanged will be call on completition. sl@0: iAddDataSourceSinkAsync->AddDataSource(iController, KUidMmfUrlSource, sourceCfgBuffer->Ptr(0)); sl@0: CleanupStack::PopAndDestroy(2, sourceCfg);//sourceCfgBuffer, sourceCfg sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::Close() sl@0: { sl@0: iMidiControllerCommands.Close(); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::Play() sl@0: { sl@0: TInt err = iController.Prime(); sl@0: if (err==KErrNone) sl@0: { sl@0: err=iController.Play(); sl@0: } sl@0: if (err!=KErrNone) sl@0: { sl@0: iMidiControllerEventMonitor->SelfComplete(err); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration) sl@0: { sl@0: iMidiControllerCommands.Stop(aFadeOutDuration); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Returns the current state of the MIDI client utility sl@0: * with regard to MIDI resources. sl@0: * sl@0: * @return "TMidiState" The current state of the utility sl@0: * sl@0: * @since 7.0s sl@0: */ sl@0: sl@0: TMidiState CMidiClientUtility::CBody::State() const sl@0: { sl@0: return iState; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::PlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity) sl@0: { sl@0: if((aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: && (aNote >= KMinNote && aNote <= KMaxNote) sl@0: && (aNoteOnVelocity >= KMinNoteOnVelocity && aNoteOnVelocity <= KMaxNoteOnVelocity) sl@0: && (aNoteOffVelocity >= KMinNoteOffVelocity && aNoteOffVelocity <= KMaxNoteOffVelocity)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.PlayNote(aChannel, aNote, aDuration, aNoteOnVelocity, aNoteOffVelocity)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::PlayNoteL(TInt aChannel,TInt aNote, const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration, TInt aNoteOnVelocity, TInt aNoteOffVelocity) sl@0: { sl@0: if((aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: && (aNote >= KMinNote && aNote <= KMaxNote) sl@0: && (aNoteOnVelocity >= KMinNoteOnVelocity && aNoteOnVelocity <= KMaxNoteOnVelocity) sl@0: && (aNoteOffVelocity >= KMinNoteOffVelocity && aNoteOffVelocity <= KMaxNoteOffVelocity)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.PlayNote(aChannel, aNote, aStartTime, aDuration, aNoteOnVelocity, aNoteOffVelocity)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::StopNotes(TInt aChannel) sl@0: { sl@0: if(aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: { sl@0: iMidiControllerCommands.StopNotes(aChannel); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::NoteOnL(TInt aChannel,TInt aNote,TInt aVelocity) sl@0: { sl@0: if((aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: && (aNote >= KMinNote && aNote <= KMaxNote) sl@0: && (aVelocity >= KMinNoteOnVelocity && aVelocity <= KMaxNoteOnVelocity)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.NoteOn(aChannel, aNote, aVelocity)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::NoteOffL(TInt aChannel,TInt aNote,TInt aVelocity) sl@0: { sl@0: if((aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: && (aNote >= KMinNote && aNote <= KMaxNote) sl@0: && (aVelocity >= KMinNoteOffVelocity && aVelocity <= KMaxNoteOffVelocity)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.NoteOff(aChannel, aNote, aVelocity)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::PlaybackRateL() const sl@0: { sl@0: TInt rate; sl@0: User::LeaveIfError(iMidiControllerCommands.PlaybackRate(rate)); sl@0: return rate; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetPlaybackRateL(TInt aRate) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetPlaybackRate(aRate)); sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::MaxPlaybackRateL() const sl@0: { sl@0: TInt maxRate; sl@0: User::LeaveIfError(iMidiControllerCommands.MaxPlaybackRate(maxRate)); sl@0: return maxRate; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::MinPlaybackRateL() const sl@0: { sl@0: TInt minRate; sl@0: User::LeaveIfError(iMidiControllerCommands.MinPlaybackRate(minRate)); sl@0: return minRate; sl@0: } sl@0: sl@0: sl@0: TInt CMidiClientUtility::CBody::TempoMicroBeatsPerMinuteL() const sl@0: { sl@0: TInt microBeatsPerMinute; sl@0: User::LeaveIfError(iMidiControllerCommands.TempoMicroBeatsPerMinute(microBeatsPerMinute)); sl@0: return microBeatsPerMinute; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetTempoL(TInt aMicroBeatsPerMinute) sl@0: { sl@0: if(aMicroBeatsPerMinute > 0) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetTempo(aMicroBeatsPerMinute)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::PitchTranspositionCentsL() const sl@0: { sl@0: TInt cents; sl@0: User::LeaveIfError(iMidiControllerCommands.PitchTranspositionCents(cents)); sl@0: return cents; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::SetPitchTranspositionL(TInt aCents) sl@0: { sl@0: TInt pitchApplied = 0; sl@0: //we do not check aCents value - it is expected the controller will report KErrArgument sl@0: //if the pitch level is not supported. sl@0: User::LeaveIfError(iMidiControllerCommands.SetPitchTransposition(aCents, pitchApplied)); sl@0: sl@0: return pitchApplied; sl@0: } sl@0: sl@0: TTimeIntervalMicroSeconds CMidiClientUtility::CBody::DurationMicroSecondsL() const sl@0: { sl@0: TTimeIntervalMicroSeconds duration; sl@0: User::LeaveIfError(iController.GetDuration(duration)); sl@0: return duration; sl@0: } sl@0: sl@0: TInt64 CMidiClientUtility::CBody::DurationMicroBeatsL() const sl@0: { sl@0: TInt64 duration; sl@0: User::LeaveIfError(iMidiControllerCommands.DurationMicroBeats(duration)); sl@0: return duration; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::NumTracksL() const sl@0: { sl@0: TInt tracks; sl@0: User::LeaveIfError(iMidiControllerCommands.NumTracks(tracks)); sl@0: return tracks; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetTrackMuteL(TInt aTrack, TBool aMuted) const sl@0: { sl@0: TInt numTracks = NumTracksL(); sl@0: if((aTrack >= 0) && (aTrack < numTracks)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetTrackMute(aTrack, aMuted)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: const TDesC8& CMidiClientUtility::CBody::MimeTypeL() sl@0: { sl@0: TPtr8 des = iMimeType->Des(); sl@0: User::LeaveIfError(iMidiControllerCommands.MimeType(des)); sl@0: return *iMimeType; sl@0: } sl@0: sl@0: TTimeIntervalMicroSeconds CMidiClientUtility::CBody::PositionMicroSecondsL() const sl@0: { sl@0: TTimeIntervalMicroSeconds position; sl@0: User::LeaveIfError(iController.GetPosition(position)); sl@0: return position; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetPositionMicroSecondsL(const TTimeIntervalMicroSeconds& aPosition) sl@0: { sl@0: TTimeIntervalMicroSeconds maxPosition = DurationMicroSecondsL(); sl@0: TTimeIntervalMicroSeconds minPosition(0); sl@0: sl@0: TTimeIntervalMicroSeconds position = aPosition; sl@0: if (aPosition > maxPosition) sl@0: { sl@0: position = maxPosition; sl@0: } sl@0: if (aPosition < minPosition) sl@0: { sl@0: position = minPosition; sl@0: } sl@0: User::LeaveIfError(iController.SetPosition(position)); sl@0: } sl@0: sl@0: TInt64 CMidiClientUtility::CBody::PositionMicroBeatsL() const sl@0: { sl@0: TInt64 position; sl@0: User::LeaveIfError(iMidiControllerCommands.PositionMicroBeats(position)); sl@0: return position; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetPositionMicroBeatsL(TInt64 aMicroBeats) sl@0: { sl@0: TInt64 maxPosition = DurationMicroBeatsL(); sl@0: TInt64 minPosition(0); sl@0: sl@0: TInt64 position = aMicroBeats; sl@0: if (aMicroBeats > maxPosition) sl@0: { sl@0: position = maxPosition; sl@0: } sl@0: if (aMicroBeats < minPosition) sl@0: { sl@0: position = minPosition; sl@0: } sl@0: User::LeaveIfError(iMidiControllerCommands.SetPositionMicroBeats(position)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds, TInt64 aMicroBeats) sl@0: { sl@0: sl@0: if((aMicroSeconds > TTimeIntervalMicroSeconds(0)) || (aMicroSeconds == TTimeIntervalMicroSeconds(0) && aMicroBeats == 0)) sl@0: { sl@0: iIntervalSec = ETrue; sl@0: } sl@0: else sl@0: { sl@0: if (aMicroBeats > 0) sl@0: { sl@0: iIntervalSec = EFalse; sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: User::LeaveIfError(iMidiControllerCommands.SetSyncUpdateCallbackInterval(aMicroSeconds, aMicroBeats)); sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::SendMessageL(const TDesC8& aMidiMessage) sl@0: { sl@0: TInt numByteProc; sl@0: User::LeaveIfError(iMidiControllerCommands.SendMessage(aMidiMessage, numByteProc)); sl@0: return numByteProc; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::SendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime) sl@0: { sl@0: TInt numByteProc; sl@0: User::LeaveIfError(iMidiControllerCommands.SendMessage(aMidiMessage, aTime, numByteProc)); sl@0: return numByteProc; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SendMipMessageL(const RArray& aEntry) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SendMipMessage(aEntry)); sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::NumberOfBanksL(TBool aCustom) const sl@0: { sl@0: TInt numBanks; sl@0: User::LeaveIfError(iMidiControllerCommands.NumberOfBanks(aCustom, numBanks)); sl@0: return numBanks; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::GetBankIdL(TBool aCustom,TInt aBankIndex) const sl@0: { sl@0: TInt numBanks = NumberOfBanksL(aCustom); sl@0: TInt bankId = 0; sl@0: if(aBankIndex >= 0 && aBankIndex < numBanks) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.GetBankId(aCustom, aBankIndex, bankId)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: return bankId; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::LoadCustomBankL(const TDesC& aFileName,TInt& aBankCollectionIndex) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.LoadCustomBank(aFileName, aBankCollectionIndex)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::UnloadCustomBankL(TInt aBankCollectionIndex) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.UnloadCustomBank(aBankCollectionIndex)); sl@0: } sl@0: sl@0: TBool CMidiClientUtility::CBody::CustomBankLoadedL(TInt aBankCollectionIndex) const sl@0: { sl@0: TBool bankLoaded; sl@0: User::LeaveIfError(iMidiControllerCommands.CustomBankLoaded(aBankCollectionIndex, bankLoaded)); sl@0: return bankLoaded; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::UnloadAllCustomBanksL() sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.UnloadAllCustomBanks()); sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::NumberOfInstrumentsL(TInt aBankId,TBool aCustom) const sl@0: { sl@0: TInt numInstruments; sl@0: User::LeaveIfError(iMidiControllerCommands.NumberOfInstruments(aBankId, aCustom, numInstruments)); sl@0: return numInstruments; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::GetInstrumentIdL(TInt aBankId,TBool aCustom,TInt aInstrumentIndex) const sl@0: { sl@0: TInt numInstruments = NumberOfInstrumentsL(aBankId, aCustom); sl@0: TInt instrumentId = 0; sl@0: if(aInstrumentIndex >=0 && aInstrumentIndex < numInstruments) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.GetInstrumentId(aBankId, aCustom, aInstrumentIndex, instrumentId)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: return instrumentId; sl@0: } sl@0: sl@0: HBufC* CMidiClientUtility::CBody::InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const sl@0: { sl@0: HBufC* instrumentName = NULL; sl@0: sl@0: if(aInstrumentId >= KMinInstrumentId && aInstrumentId <= KMaxInstrumentId) sl@0: { sl@0: instrumentName = iMidiControllerCommands.InstrumentNameL(aBankId, aCustom, aInstrumentId); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: return instrumentName; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetInstrumentL(TInt aChannel,TInt aBankId,TInt aInstrumentId) sl@0: { sl@0: if((aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: && (aInstrumentId >= KMinInstrumentId && aInstrumentId <= KMaxInstrumentId)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetInstrument(aChannel, aBankId, aInstrumentId)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::LoadCustomInstrumentL(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId) sl@0: { sl@0: if((aFileInstrumentId >= KMinInstrumentId && aFileInstrumentId <= KMaxInstrumentId) sl@0: && (aMemoryInstrumentId >= KMinInstrumentId && aMemoryInstrumentId <= KMaxInstrumentId)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.LoadCustomInstrument(aFileName, aFileBankId, aFileInstrumentId, aMemoryBankId, aMemoryInstrumentId)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::UnloadCustomInstrumentL(TInt aCustomBankId,TInt aInstrumentId) sl@0: { sl@0: if(aInstrumentId >= KMinInstrumentId && aInstrumentId <= KMaxInstrumentId) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.UnloadCustomInstrument(aCustomBankId, aInstrumentId)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: HBufC* CMidiClientUtility::CBody::PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const sl@0: { sl@0: HBufC* pKeyName = NULL; sl@0: sl@0: if((aNote >= KMinNote && aNote <= KMaxNote) sl@0: && (aInstrumentId >= KMinInstrumentId && aInstrumentId <= KMaxInstrumentId)) sl@0: { sl@0: pKeyName = iMidiControllerCommands.PercussionKeyNameL(aNote, aBankId, aCustom, aInstrumentId); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: return pKeyName; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::StopTimeL(TTimeIntervalMicroSeconds& aStopTime) const sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.StopTime(aStopTime)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetStopTimeL(const TTimeIntervalMicroSeconds& aStopTime) sl@0: { sl@0: TTimeIntervalMicroSeconds duration = DurationMicroSecondsL(); sl@0: if(aStopTime >= TTimeIntervalMicroSeconds(0) && aStopTime <= duration) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetStopTime(aStopTime)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence) sl@0: { sl@0: if((aRepeatNumberOfTimes >= 0) && (aTrailingSilence >= TTimeIntervalMicroSeconds(0))) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetRepeats(aRepeatNumberOfTimes, aTrailingSilence)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::PolyphonyL() const sl@0: { sl@0: TInt numNotes; sl@0: TInt maxPoly = MaxPolyphonyL(); sl@0: User::LeaveIfError(iMidiControllerCommands.Polyphony(numNotes)); sl@0: if(maxPoly <= numNotes) sl@0: { sl@0: return maxPoly; sl@0: } sl@0: else sl@0: { sl@0: return numNotes; sl@0: } sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::MaxPolyphonyL() const sl@0: { sl@0: TInt maxNotes; sl@0: User::LeaveIfError(iMidiControllerCommands.MaxPolyphony(maxNotes)); sl@0: return maxNotes; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::ChannelsSupportedL() const sl@0: { sl@0: TInt channels; sl@0: User::LeaveIfError(iMidiControllerCommands.ChannelsSupported(channels)); sl@0: return channels; sl@0: } sl@0: sl@0: TReal32 CMidiClientUtility::CBody::ChannelVolumeL(TInt aChannel) const sl@0: { sl@0: TReal32 channelVol; sl@0: if(aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.ChannelVolume(aChannel, channelVol)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: return channelVol; sl@0: } sl@0: sl@0: TReal32 CMidiClientUtility::CBody::MaxChannelVolumeL() const sl@0: { sl@0: TReal32 maxChanVol; sl@0: User::LeaveIfError(iMidiControllerCommands.MaxChannelVolume(maxChanVol)); sl@0: return maxChanVol; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetChannelVolumeL(TInt aChannel,TReal32 aVolume) sl@0: { sl@0: TReal32 maxChanVol = MaxChannelVolumeL(); sl@0: if((aChannel >= KMinChannel && aChannel <= KMaxChannel) && aVolume <= maxChanVol) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetChannelVolume(aChannel, aVolume)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetChannelMuteL(TInt aChannel,TBool aMuted) sl@0: { sl@0: if(aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetChannelMute(aChannel, aMuted)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::VolumeL() const sl@0: { sl@0: TInt vol; sl@0: User::LeaveIfError(iMidiControllerCommands.Volume(vol)); sl@0: return vol; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::MaxVolumeL() const sl@0: { sl@0: TInt maxVol; sl@0: User::LeaveIfError(iMidiControllerCommands.MaxVolume(maxVol)); sl@0: return maxVol; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetVolumeL(TInt aVolume) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetVolume(aVolume)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetVolumeRamp(aRampDuration)); sl@0: } sl@0: sl@0: sl@0: TInt CMidiClientUtility::CBody::GetBalanceL() const sl@0: { sl@0: TInt balance; sl@0: User::LeaveIfError(iMidiControllerCommands.GetBalance(balance)); sl@0: return balance; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetBalanceL(TInt aBalance) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetBalance(aBalance)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetPriorityL(TInt aPriority, TInt aPref) sl@0: { sl@0: TMMFPrioritySettings priority; sl@0: priority.iPriority = aPriority; sl@0: priority.iPref = aPref; sl@0: sl@0: User::LeaveIfError(iController.SetPrioritySettings(priority)); sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::NumberOfMetaDataEntriesL() const sl@0: { sl@0: TInt numMetaData; sl@0: User::LeaveIfError(iController.GetNumberOfMetaDataEntries(numMetaData)); sl@0: return numMetaData; sl@0: } sl@0: sl@0: CMMFMetaDataEntry* CMidiClientUtility::CBody::GetMetaDataEntryL(TInt aMetaDataIndex) const sl@0: { sl@0: CMMFMetaDataEntry* metaDataEntry = iController.GetMetaDataEntryL(aMetaDataIndex); sl@0: return metaDataEntry; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom) sl@0: { sl@0: User::LeaveIfError(iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2) sl@0: { sl@0: User::LeaveIfError(iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus) sl@0: { sl@0: iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus) sl@0: { sl@0: iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aStatus); sl@0: } sl@0: sl@0: MMMFDRMCustomCommand* CMidiClientUtility::CBody::GetDRMCustomCommand() sl@0: { sl@0: if (iDRMCustomCommands.IsSupported()) sl@0: { sl@0: return static_cast(&iDRMCustomCommands); sl@0: } sl@0: return NULL; sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::DoOpen(const RMMFControllerImplInfoArray& aControllers, TUid aSinkUid, const TDesC8& aSinkData, TBool aUseSharedHeap) sl@0: { sl@0: // Make sure any existing controller is closed. sl@0: iMidiControllerEventMonitor->Cancel(); sl@0: iController.Close(); sl@0: sl@0: // Try opening and configuring each controller in turn sl@0: TInt error = KErrNotSupported; sl@0: TInt index = 0; sl@0: while (error) sl@0: { sl@0: // Break if we're at the end of the array of controllers sl@0: if (index >= aControllers.Count()) sl@0: break; sl@0: sl@0: // Open the controller sl@0: error = iController.Open(aControllers[index]->Uid(), iPrioritySettings, aUseSharedHeap); sl@0: sl@0: // If the controller was opened without error, start receiving events from it. sl@0: if (error==KErrNone) sl@0: { sl@0: iMidiControllerEventMonitor->Start(); sl@0: } sl@0: sl@0: // Add the data sink sl@0: if (error==KErrNone) sl@0: error = iController.AddDataSink(aSinkUid, aSinkData, iSinkHandle); sl@0: sl@0: // If an error occurred in any of the above, close the controller. sl@0: if (error!=KErrNone) sl@0: { sl@0: iMidiControllerEventMonitor->Cancel(); sl@0: iController.Close(); sl@0: } sl@0: sl@0: // increment index sl@0: index++; sl@0: } sl@0: sl@0: return error; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::HandleMidiEvent(const CMMFMidiEvent& aEvent) sl@0: { sl@0: if(aEvent.iEventType == KMMFEventCategoryMidiOpenDataSourceComplete || sl@0: aEvent.iEventType == KMMFEventCategoryMidiClose || sl@0: aEvent.iEventType == KMMFEventCategoryMidiPrime || sl@0: aEvent.iEventType == KMMFEventCategoryMidiPlaying || sl@0: aEvent.iEventType == KMMFEventCategoryMidiPlaybackIncompatible || sl@0: aEvent.iEventType == KMMFEventCategoryMidiPlaybackSilent) sl@0: { sl@0: iState = aEvent.iNewState; sl@0: iObserver.MmcuoStateChanged(aEvent.iOldState, aEvent.iNewState, aEvent.iMicroSeconds, aEvent.iErrorCode); sl@0: sl@0: if (aEvent.iEventType == KMMFEventCategoryMidiClose) sl@0: { sl@0: if (iSourceHandle.DestinationHandle()) sl@0: { sl@0: iController.RemoveDataSource(iSourceHandle); sl@0: } sl@0: } sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryMidiPlayingComplete) sl@0: { sl@0: iState = aEvent.iNewState; sl@0: iObserver.MmcuoStateChanged(aEvent.iOldState, aEvent.iNewState, aEvent.iMicroSeconds, aEvent.iErrorCode); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryMidiSyncUpdate) sl@0: { sl@0: iObserver.MmcuoSyncUpdate(aEvent.iMicroSeconds, aEvent.iMicroBeats); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryTempoChanged) sl@0: { sl@0: iObserver.MmcuoTempoChanged(aEvent.iTempoMicroBeats); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryVolumeChanged) sl@0: { sl@0: iObserver.MmcuoVolumeChanged(aEvent.iChannel, aEvent.iVolumeInDecibels); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryMuteChanged) sl@0: { sl@0: iObserver.MmcuoMuteChanged(aEvent.iChannel, aEvent.iMute); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryMetaDataEntryFound) sl@0: { sl@0: iObserver.MmcuoMetaDataEntryFound(aEvent.iMetaDataEntryId, aEvent.iMicroSeconds); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryMipMessageReceived) sl@0: { sl@0: iObserver.MmcuoMipMessageReceived(aEvent.iMipMessage); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryPolyphonyChanged) sl@0: { sl@0: iObserver.MmcuoPolyphonyChanged(aEvent.iPolyphony); sl@0: } sl@0: else if(aEvent.iEventType == KMMFEventCategoryInstrumentChanged) sl@0: { sl@0: iObserver.MmcuoInstrumentChanged(aEvent.iChannel,aEvent.iBankId,aEvent.iInstrumentId); sl@0: } sl@0: else if((iState == EMidiStateOpenPlaying) || (iState == EMidiStatePlaybackIncompatible) || sl@0: (iState == EMidiStatePlaybackSilent) || (iState == EMidiStateClosedEngaged) || sl@0: (iState == EMidiStateOpenEngaged)) sl@0: { sl@0: iState = aEvent.iNewState; sl@0: iObserver.MmcuoStateChanged(aEvent.iOldState, aEvent.iNewState, aEvent.iMicroSeconds, aEvent.iErrorCode); sl@0: sl@0: } sl@0: else if (aEvent.iEventType == KMMFErrorCategoryControllerGeneralError) sl@0: { sl@0: iObserver.MmcuoStateChanged(iState, iState, TTimeIntervalMicroSeconds(0), aEvent.iErrorCode); sl@0: } sl@0: else sl@0: { sl@0: // xxx - what do we do when we don't understand the error type? sl@0: } sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Used to change the value of MaxPolyphonyL() sl@0: */ sl@0: void CMidiClientUtility::CBody::SetMaxPolyphonyL(TInt aMaxNotes) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetMaxPolyphony(aMaxNotes)); sl@0: } sl@0: sl@0: TInt CMidiClientUtility::CBody::GetRepeats() sl@0: { sl@0: TInt numRepeats = 0; sl@0: iMidiControllerCommands.GetRepeats(numRepeats); sl@0: return numRepeats; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::LoadCustomBankDataL(const TDesC8& aBankData,TInt& aBankId) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.LoadCustomBankData(aBankData, aBankId)); sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::LoadCustomInstrumentDataL(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId) sl@0: { sl@0: if((aInstrumentDataId >= KMinInstrumentId && aInstrumentDataId <= KMaxInstrumentId) sl@0: && (aMemoryInstrumentId >= KMinInstrumentId && aMemoryInstrumentId <= KMaxInstrumentId)) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.LoadCustomInstrumentData(aInstrumentData, aBankDataId, aInstrumentDataId, aMemoryBankId, aMemoryInstrumentId)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::SetBankL(TBool aCustom) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.SetBank(aCustom)); sl@0: } sl@0: sl@0: TBool CMidiClientUtility::CBody::IsTrackMuteL(TInt aTrack) const sl@0: { sl@0: TBool mute; sl@0: User::LeaveIfError(iMidiControllerCommands.IsTrackMute(aTrack, mute)); sl@0: return mute; sl@0: } sl@0: sl@0: TBool CMidiClientUtility::CBody::IsChannelMuteL(TInt aChannel) const sl@0: { sl@0: TBool mute; sl@0: if (aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.IsChannelMute(aChannel, mute)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: return mute; sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::GetInstrumentL(TInt aChannel, TInt& aInstrumentId, TInt& aBankId) sl@0: { sl@0: if (aChannel >= KMinChannel && aChannel <= KMaxChannel) sl@0: { sl@0: User::LeaveIfError(iMidiControllerCommands.GetInstrument(aChannel, aInstrumentId, aBankId)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: } sl@0: sl@0: void CMidiClientUtility::CBody::RepeatTrailingSilenceTimerComplete() sl@0: { sl@0: Play(); sl@0: } sl@0: sl@0: CRepeatTrailingSilenceTimer* CRepeatTrailingSilenceTimer::NewL(MRepeatTrailingSilenceTimerObs& aObs) sl@0: { sl@0: CRepeatTrailingSilenceTimer* s = new(ELeave) CRepeatTrailingSilenceTimer(aObs); sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return s; sl@0: } sl@0: sl@0: void CRepeatTrailingSilenceTimer::RunL() sl@0: { sl@0: iObs.RepeatTrailingSilenceTimerComplete(); sl@0: } sl@0: sl@0: CRepeatTrailingSilenceTimer::CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs) : sl@0: CTimer(EPriorityHigh), sl@0: iObs(aObs) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: // sl@0: // sl@0: // sl@0: // sl@0: sl@0: CMidiControllerEventMonitor* CMidiControllerEventMonitor::NewL(MMidiControllerEventMonitorObserver& aMidiObserver, sl@0: RMidiControllerCustomCommands& aMidiControllerCustomCommands, const CMidiClientUtility& aParent) sl@0: { sl@0: CMidiControllerEventMonitor* self = new(ELeave) CMidiControllerEventMonitor(aMidiObserver, aMidiControllerCustomCommands, aParent); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CMidiControllerEventMonitor::ConstructL() sl@0: { sl@0: iMidiEvent = new (ELeave) CMMFMidiEvent(); sl@0: } sl@0: sl@0: CMidiControllerEventMonitor::CMidiControllerEventMonitor(MMidiControllerEventMonitorObserver& aMidiObserver, sl@0: RMidiControllerCustomCommands& aMidiControllerCustomCommands, const CMidiClientUtility& aParent) : sl@0: CActive(EPriorityStandard), sl@0: iMidiObserver(aMidiObserver), sl@0: iMidiControllerCustomCommands(aMidiControllerCustomCommands), sl@0: iParent(aParent) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: CMidiControllerEventMonitor::~CMidiControllerEventMonitor() sl@0: { sl@0: Cancel(); sl@0: delete iMidiEvent; sl@0: } sl@0: sl@0: /** sl@0: Start receiving events from the controller. sl@0: sl@0: This can only be called once the controller is open. sl@0: */ sl@0: void CMidiControllerEventMonitor::Start() sl@0: { sl@0: iMidiControllerCustomCommands.ReceiveEvents(iSizeOfEvent, iStatus); sl@0: SetActive(); sl@0: } sl@0: sl@0: void CMidiControllerEventMonitor::RunL() sl@0: { sl@0: User::LeaveIfError(iStatus.Int()); sl@0: sl@0: // Create a buffer big enough to hold the event, then retrieve it from the server sl@0: HBufC8* buf = HBufC8::NewLC(iSizeOfEvent()); sl@0: TPtr8 bufPtr = buf->Des(); sl@0: User::LeaveIfError(iMidiControllerCustomCommands.RetrieveEvent(bufPtr)); sl@0: sl@0: // Now internalize a CMMFMidiEvent with the info in the buffer sl@0: RDesReadStream stream(bufPtr); sl@0: CleanupClosePushL(stream); sl@0: sl@0: CMMFMidiEvent* theEvent = new (ELeave) CMMFMidiEvent(); sl@0: sl@0: CleanupStack::PushL(theEvent); sl@0: theEvent->InternalizeL(stream); sl@0: sl@0: iMidiObserver.HandleMidiEvent(*theEvent); sl@0: Start(); sl@0: sl@0: CleanupStack::PopAndDestroy(3);//buf, stream, theEvent sl@0: } sl@0: sl@0: void CMidiControllerEventMonitor::SelfComplete(TInt aError) sl@0: { sl@0: Cancel(); sl@0: TRequestStatus *status = &iStatus; sl@0: if(!IsActive()) sl@0: SetActive(); sl@0: User::RequestComplete(status, aError); sl@0: } sl@0: sl@0: void CMidiControllerEventMonitor::DoCancel() sl@0: { sl@0: iMidiControllerCustomCommands.CancelReceiveEvents(); sl@0: } sl@0: sl@0: TInt CMidiControllerEventMonitor::RunError(TInt aError) sl@0: { sl@0: iMidiEvent->iEventType = KMMFErrorCategoryControllerGeneralError; sl@0: iMidiEvent->iErrorCode = aError; sl@0: iMidiEvent->iOldState = iParent.State(); sl@0: iMidiEvent->iNewState = iMidiEvent->iOldState; sl@0: sl@0: iMidiObserver.HandleMidiEvent(*iMidiEvent); sl@0: Start(); sl@0: return KErrNone; sl@0: }