Use ERROR_LOG for error messages instead.
Free loaded data in Ringbuffer only while

ffmpeg is requiring more data. Clean up some codes.