Synchronize between Thread of recording and Main Thread

All your problems with Audio, Video and Images.

Synchronize between Thread of recording and Main Thread

Postby luanbt » Tue Feb 22, 2011 10:38 am

While I'm developing VoiceRecorder using MediaRecorder, I saw issue as follow :

STEP:
+ using MediaRecorder to record.
+ using System.currentTimeMillis() to measure the time recording.
+ use timer (Handler.postDelayed) to update the time once 1 second.
+ recording a long time (I try to record more than 2 hours).
= 2 hours --> stop recording automatically and save file.

RESULT:
+ when timer = 2 hours, stop recording. But, when I get actual file, the DURATION is less than 2 hours (about 1:59:52)

I think that, it's non-synchronized between Recording Thread and Main Thread. I haven't solution at the moment, do any body have a solution to help me solve this isue?
thank you very much.
---------------------------------------

//source Recording:
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(outputfileformat);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(mSampleFile.getAbsolutePath());
mRecorder.setMaxDuration( MAX_DURATION ); //MAX_DURATION = 2hours

...

//source update timer:
if(nTime >= MAX_DURATION){
//stop recording and save file here
}else{
handle.postDelayed(handle, 1000);
}
luanbt
Freshman
Freshman
 
Posts: 7
Joined: Tue Feb 22, 2011 8:00 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 13 guests