Merge pull request #557 from diizy/loops

SampleBuffer, AFP: implement ping-pong loop mode
Fix close on crash patch which was  posted on the mailing list by Filipe Coelho
Merge pull request #558 from diizy/fixclosecrash

Fix close on crash patch which was  posted on the mailing list by Filipe...
SampleBuffer: fix a segfault when moving a loop point while playing a note, also do some sptring cleanup (some unused/redundant variables removed)
Also, some codepath optimization: add a method to SampleBuffer for setting all loop/start/endpoints at once, so we don't have to wait for mutex unlocks 4 times in a row. Then make AFP utilize this method.