just for testing purposes i want to stop the recording
1. after a while (fixed length)
2. when stopped by the user

i use this function for trying out :

void CAudioStreamEngine::Stop()
    // if input or output streams are active, close them
    if (iInputStatus!=ENotReady) 
        //ShowMessage(_L("\nRecording stopped!"), ETrue);
        iBufferOK = ETrue;
        iInputStatus = ENotReady;
        TInt Err;
        TRAP( Err, SaveAudioFileL() );
        if( Err == KErrNone )
        	//do something!
    if (iOutputStatus!=ENotReady) 
        iOutputStatus = ENotReady;
        ShowMessage(_L("\nPlayback stopped!"), ETrue);

if i run the code and let the program run the overall length( fixed ) it writes the file and responses:
"Recording complete!" in "MaiscBufferCopied".
But when i stop the recording by stop menu i get an error : recording error : -39 from "MaiscBufferCopied".
The file seems to be written...

So where is the best location to put " SaveAudioFileL()"