AudacityException is an abstract base class for exceptions generated by
Audacity.
GuardedCall wraps any function (usually a lambda) in an appropriate catch
block.
It can also accept a second function that defines a catch block action, which
can rethrow or return a value for the GuardedCall.
It can also accept a third function, that defines another, delayed action that
executes in the main thread at idle time if the second function intercepts an
AudacityException and completes without rethrow.
Defaults for the second function simply return void or false. Default for the
third function invokes a virtual method of AudacityException, which for
subclass MessageBoxException, displays a message box.
... also replace explicit mutex locking with RAII and atomics.
This is a part of the big project that handles failure to write block files, as
from disk exhaustion. ODDecodeBlockFile::WriteODDecodeBlockFile is the one
place calling WriteSimpleBlockFile but not (as in SimpleBlockFile constructor)
throwing an exception.
It is called only when attempting to recover files at open time, or in worker
threads in an EXPERIMENTAL code branch.
... Eliminate CreateFromCopy, add new one-step constructor instead.
It was wasteful to create a copy only to re-create the Sequence at once.
Sequence::Copy is a factory returning a unique_ptr.
Some error checks are removed, but there will be exceptions instead later.
... This means unneeded block files can be reclaimed sooner.
This also eliminates the checks of use_count, which might vary in a
multithreaded context; though that didn't really matter (because once it
was below 2, the function had the only remaining shared_ptr to the block file,
so it could not have increased again to 2).
... Time warping functions should be nondecreasing, but let's not assume so.
If not, the insertion sort just takes linear time to check that there are no
disorders.