Fix memory leaks related to sndfile and sample data

* free sndfile after reading it
* free sample data array when fixing rate
* free list of output ports before reusing variable
  (only if INPUT is defined)