59 } |
59 } |
60 |
60 |
61 void CMMFBackendEngine::ConstructL() |
61 void CMMFBackendEngine::ConstructL() |
62 { |
62 { |
63 iAPIBeingUsed = ENoUtility; |
63 iAPIBeingUsed = ENoUtility; |
64 iBaseAudioRecorder = CMdaAudioRecorderUtility::NewL(*this); |
|
65 iAudioRecorder = (CMdaAudioRecorderUtility*)iBaseAudioRecorder; |
|
66 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
64 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
|
65 } |
|
66 |
|
67 void CMMFBackendEngine::InitAudioRecorderUtilityL() |
|
68 { |
|
69 if (!iAudioRecorder) |
|
70 { |
|
71 iBaseAudioRecorder = CMdaAudioRecorderUtility::NewL(*this); |
|
72 iAudioRecorder = (CMdaAudioRecorderUtility*)iBaseAudioRecorder; |
|
73 } |
67 } |
74 } |
68 |
75 |
69 void CMMFBackendEngine::InitAudioPlayerUtilityL() |
76 void CMMFBackendEngine::InitAudioPlayerUtilityL() |
70 { |
77 { |
71 if (!iAudioPlayer) |
78 if (!iAudioPlayer) |
111 if (func == ERecord) |
118 if (func == ERecord) |
112 { |
119 { |
113 if (iRecordState == ERecorderNotReady) |
120 if (iRecordState == ERecorderNotReady) |
114 { |
121 { |
115 iFileFormat = format; |
122 iFileFormat = format; |
116 iAPIBeingUsed = EAudioRecorderUtility; |
123 iAPIBeingUsed = DetermineAPIToUse(uri, EPlay); |
117 TPtr8 fileuri(((TUint8*)uri), strlen(uri) ,strlen(uri)); |
124 err = XA_RESULT_INTERNAL_ERROR; |
118 TPtr8 filepath = fileuri.RightTPtr(strlen(uri)-fileslashlen); |
125 if (iAPIBeingUsed == EAudioRecorderUtility) |
119 TInt pos = filepath.LocateReverse(':'); |
126 { |
120 if(pos != KErrNotFound) |
127 /* Initialize URI as needed by MMF utilities */ |
121 { |
128 err = InitializeURIForMMFUtil(uri); |
122 fileuri.Delete(fileslashlen+pos,1); |
129 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
123 } |
130 /* Initalize Recorder related objects */ |
124 |
131 TRAP(err, InitAudioRecorderUtilityL()); |
125 TUriParser8 localfileUri; |
132 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
126 TInt ret = localfileUri.Parse(fileuri); |
133 |
127 HBufC* file = NULL; |
134 TRAP(err, iAudioRecorder->OpenFileL(iFileName)); |
128 TRAP(err,file = localfileUri.GetFileNameL()); |
135 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
129 TPtr des = file->Des(); |
136 /* Wait until we receive moscostatechanged callback */ |
130 iFileName = des; |
|
131 delete file; |
|
132 file = NULL; |
|
133 TRAP(err, iAudioRecorder->OpenFileL(iFileName)); |
|
134 if (!err) |
|
135 { /* Wait until we receive moscostatechanged callback */ |
|
136 if(!iActiveSchedulerWait->IsStarted()) |
137 if(!iActiveSchedulerWait->IsStarted()) |
137 { |
138 { |
138 iActiveSchedulerWait->Start(); |
139 iActiveSchedulerWait->Start(); |
139 } |
140 } |
140 err = iErrorCode; |
141 RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR); |
141 } |
142 } |
142 } |
143 } |
143 } |
144 } |
144 else |
145 else |
145 { |
146 { |
146 /* The second one is needed for dynamic source interface */ |
147 /* The second one is needed for dynamic source interface */ |
147 if ((iMediaPlayerState == XA_PLAYSTATE_PLAYERUNINITIALIZED) || |
148 if ((iMediaPlayerState == XA_PLAYSTATE_PLAYERUNINITIALIZED) || |
503 } |
504 } |
504 |
505 |
505 TInt CMMFBackendEngine::SetRecorderState(TRecorderState state, XAboolean stopCalled) |
506 TInt CMMFBackendEngine::SetRecorderState(TRecorderState state, XAboolean stopCalled) |
506 { |
507 { |
507 TInt err(KErrNone); |
508 TInt err(KErrNone); |
|
509 |
|
510 if (iAPIBeingUsed != EAudioRecorderUtility) |
|
511 { |
|
512 return XA_RESULT_INTERNAL_ERROR; |
|
513 } |
|
514 |
508 switch(state) |
515 switch(state) |
509 { |
516 { |
510 case ERecorderNotReady: |
517 case ERecorderNotReady: |
511 iAudioRecorder->Close(); |
518 iAudioRecorder->Close(); |
512 iRecordState = ERecorderNotReady; |
519 iRecordState = ERecorderNotReady; |
572 if(iPositionUpdateTimer) |
579 if(iPositionUpdateTimer) |
573 { |
580 { |
574 iPositionUpdateTimer->Stop(); |
581 iPositionUpdateTimer->Stop(); |
575 } |
582 } |
576 |
583 |
577 if(iActiveSchedulerWait) |
584 if (iActiveSchedulerWait && iActiveSchedulerWait->IsStarted()) |
578 { |
585 { |
579 if(iActiveSchedulerWait->IsStarted()) |
586 iActiveSchedulerWait->AsyncStop(); |
580 { |
|
581 iActiveSchedulerWait->AsyncStop(); |
|
582 } |
|
583 } |
587 } |
584 } |
588 } |
585 |
589 |
586 void CMMFBackendEngine::Destroy() |
590 void CMMFBackendEngine::Destroy() |
587 { |
591 { |
588 |
|
589 if (iBaseAudioRecorder) |
|
590 { |
|
591 iAudioRecorder->Close(); |
|
592 } |
|
593 |
|
594 if (iActiveSchedulerWait && iActiveSchedulerWait->IsStarted()) |
|
595 { |
|
596 iActiveSchedulerWait->AsyncStop(); |
|
597 } |
|
598 |
|
599 delete iPositionUpdateTimer; |
592 delete iPositionUpdateTimer; |
600 iPositionUpdateTimer = NULL; |
593 iPositionUpdateTimer = NULL; |
601 delete iUri; |
594 delete iUri; |
602 iUri = NULL; |
595 iUri = NULL; |
603 delete iMarkerPositionTimer; |
596 delete iMarkerPositionTimer; |
605 delete iPlayItfPositionUpdateTimer; |
598 delete iPlayItfPositionUpdateTimer; |
606 iPlayItfPositionUpdateTimer = NULL; |
599 iPlayItfPositionUpdateTimer = NULL; |
607 delete iBaseVideoPlayer; |
600 delete iBaseVideoPlayer; |
608 iBaseVideoPlayer = NULL; |
601 iBaseVideoPlayer = NULL; |
609 iVideoPlayer = NULL; |
602 iVideoPlayer = NULL; |
610 if (iaudioInputRecord) |
603 delete iaudioInputRecord; |
611 { |
604 iaudioInputRecord = NULL; |
612 delete iaudioInputRecord; |
|
613 iaudioInputRecord = NULL; |
|
614 } |
|
615 |
|
616 delete iBaseAudioPlayer; |
605 delete iBaseAudioPlayer; |
617 iBaseAudioPlayer = NULL; |
606 iBaseAudioPlayer = NULL; |
618 iAudioPlayer = NULL; |
607 iAudioPlayer = NULL; |
619 delete iBaseAudioRecorder; |
608 delete iBaseAudioRecorder; |
620 iBaseAudioRecorder = NULL; |
609 iBaseAudioRecorder = NULL; |