Make sure buffer is unmapped if codec can't be flushed.
Use "g_malloc" / "g_free".
Fix warnings about format string.
Make number of threads configurable.