... To append files during recording or import, it doesn't depend on the
subclasses of BlockFile, instead taking a factory function to which it gives
the filename; and the choice of factory function is also lifted up through the
level of class Sequence which is just above DirManager.
This frees four files from dependency cycles, including DirManager.cpp but not
yet Sequence.cpp
... Unnecessary because transitively included.
But each .cpp file still includes its own .h file near the top to ensure
that it compiles indenendently, even if it is reincluded transitively later.
... for wxString and wxArrayStringEx, holding file paths (absolute or relative,
directory or plain file); to be replaced later with different types
(not yet using std::vector, becase of some uses of wxArrayString::Index with
two arguments)
... which will make it easier to change the types of those containers to
std::vectors of other string-like classes
for wxString,
IsEmpty => empty
Clear => clear
Alloc => reserve
for wxArrayString,
Count => size
GetCount => size
IsEmpty => empty
Add => push_back
Clear => clear
Empty => clear
Sort => std::sort (only with default comparator)
SetCount => resize
Last => back
Item => operator []
Alloc => reserve
... Assuming that large unsigned magnitudes with high order bit set are not
the problem, but signed negatives of small magnitude may be:
1) Always cast the unsigned to signed in comparisons, not the other way.
Also:
2) Cast unsigned TERM to signed by itself, before subtracting. Don't cast
the result.
3) Rewrite some comparisons by moving subtracted term to other side.
See commits
d2fe7b1757d77d93d82d53685a118517a4d2e996
f463eda36c059236ecc168919c745eb687170c95
... and similar wx "variadics," which all treat wxString smartly enough that
you don't need this.
Don't need c_str either to convert wxString to const wxChar * because
wxString has a conversion operator that does the same.
- Dead code from experiments in SelectionBar removed.
- Many warnings about unused parameters fixed with WXUNUSED()
- Many warnings about signed / unsigned comparisons cleaned up.
- Several 'local variable declared but not used' warnings fixed.
... Such projects as described in
http://forum.audacityteam.org/viewtopic.php?f=47&t=97787
(That thread did not describe the crashes, but I came across them, debugging,
or deduced the possibility of them)
In which all the shared_ptrs to BlockFile objects ended up pointing at one
common file; but the size of this file was sometimes larger than the
Sequence's maximum block size, or not the same as the difference between one
block's start offset and the next one's.
... That for SetSamples was too strict, making needless errors in case of
harmless zero-length clips.
The one for Get was analogous to SetSamples.
That for Delete was too lax. But reexamination shows the stricter condition
to be satisfied in all calls. Sequence::Delete() can be reached only from
WaveClip::Clear and WaveClip::ClearAndAddCutLine(), and all calls to those
are in WaveTrack.cpp.
... There are two in AboutDialog.cpp, but these strings aren't actually used.
There are two in InconsistencyException.cpp, which ought never to be seen by
users, but should be treated as high priority bugs if they are.
There is a very old one in Sequence.cpp, which was never internationalized and
was only written to the log and likewise ought to be eliminated from happening
in pre-release testing.
Therefore, though this is a minor breach of string freeze, it's only the second
one above that users might ever see, and then only if a serious bug escaped.
... I didn't figure out why reproducibility seemed to vary after startup
or on Linux or in Release build, but I am satisfied a real mistake is fixed
here.
... Though in the only place where these summaries are used, which is
Sequence::GetWaveDisplay, we ignore the correctly reported error code anyway.
Also RAII in management of relevant memory buffers and mutexes.
... 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.
... whenever they really describe the size of a buffer that fits in memory, or
of a block file (which is never now more than a megabyte and so could be fit in
memory all at once), or a part thereof.
... with run-time assertions.
I examined each place and reasoned that the narrowing was safe, and commented
why so.
Again, there are places where the sampleCount variable will later be changed
to have a different type, and they are not changed here.
... A non-narrowing conversion out to long long is a necessity, but the
conversions to float and double are simply conveniences.
Conversion from floating is explicit, to avoid unintended consequences with
arithmetic operators, when later sampleCount ceases to be an alias for an
integral type.
Some conversions are not made explicit, where I expect to change the type of
the variable later to have mere size_t width.
... Define lots of operators for disambiguation, but they will go away after
all conversions from sampleCount to built-in numerical types are forced
to be explicit.