Allocate/deallocate the encoder in `open()`/`close()` and its buffers in `start()` / `stop()`. Also fail correctly if configuring the encoder fails.
Allocate/deallocate the encoder in `open()`/`close()` and its buffers in `start()` / `stop()`. Also fail correctly if configuring the encoder fails.