stop AVThread as soon as possible. reduce lock scope

split long time operations and check stop condition