I have been trying to solve this problem for several weeks now and it is getting very frustrating. I have seen several useful posts on how to play back AMR-encoded audio, but I haven't been able to get AMR recording to work correctly when mixed with playback. My app. has to work with the Nokia 3650, so I can't rely on any of the new 2.0 API's.
I'm trying to do basically a clone of the Voice Recorder app as part of a larger application. My first approach was to use the CMdaAudioRecorderUtility (with TMdaRawAmrClipFormat and TMdaRawAmrAudioCodec), using a temp. file for the location. Bug #1 was that the last 0.6 seconds of the audio file were getting cut off, so I had to set a timer callback to wait 0.6 seconds before stopping the recording.
Bug #2 is where I'm stuck. When the user saves the audio, I want to Close() the recorder, copy the file, then re-open the recorder. I only got this to work reliably by using another callback with a delay of 0.5 sec before closing. The problem is that, if the user plays back their recording before saving, about half the time I get a MdaAudioSampleEditor panic 1 (NotReady). Adding additional delays didn't help. Is there some magic trick to closing and reopening this beast?
The alternate approach I tried was to record in PCM format to a descriptor (since I only got crashes when trying to use the AMR encoder with a descriptor), and manually convert the audio on load/save. For loading, I can use the CMdaAudioConvertUtility, but it is too slow (6.7 seconds for a 60 second clip). I could only get saving to work by using the low level CPcmToAmrEncoder class, and it is really slow (25 sec. for a 60 sec. clip).
My current attempt is to try to encode the audio to AMR while it's recording to the PCM descriptor, and try to avoid any race conditions (I noticed there's a thread ID field in TMdaDesClipLocation..). For playback, I can try playing directly from the file.
So, guys and gals, what's the magic secret to using these buggy, poorly documented, audio API classes for both recording and playback? Anyone experiencing these sorts of difficulties? I'm nearly at my wit's end...
Thanks in advance!