The answer is very simple, you are not supposed to pass the same frame again to the libfaac, so even if the frame_finished is not 1 you should still go to the next frame.
it should be as follows:
frames[n]
i = 0 ;
while (there are frames)
{
cur_frame = frames[i];
av_encode_audio(frame, ...., &frame_finished);
i++;
}