Ensure sampleRateIndex is uint8_t and cast channelCount to uint8_t
Clean up error handling in encoder