Tsmf clean shutdown and resource deallocation fixes

This fix is inteded to resolve issues #1399, #1398. It removes the ```/tmp/tsmf.tid``` hack killing the thread playing video and audio replacing it with a proper thread shutdown.
Proper resource sync and deallocation in ```tsmf_stream_free``` and ```xf_thread``` clears up thread and mutex handles after they are no longer used.

It was necessary to rewrite certain parts of ```tsmf_sample_queue_ack``` and ```tsmf_stream_playback_func``` so please point out any mistake that could break the ```tsmf``` module.