1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 16:40:07 +02:00

142 Commits

Author SHA1 Message Date
Paul Licameli
f86403378b Move AudacityMessageBox to its own files...
... breaking cycles among low-level files introduced by 273ba9f
2019-05-20 14:48:36 -04:00
Paul Licameli
7b51653b36 Sequence.cpp does not depend on ODDecodeBlockFile.cpp...
... This frees Sequence.cpp from dependency cycles
2019-05-18 20:32:19 -04:00
Paul Licameli
0832bccc7b DirManager.cpp has fewer dependencies...
... 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
2019-05-18 20:32:19 -04:00
Paul Licameli
d46bb29e3a DirManager.cpp does not depend on Sequence.cpp...
... This does not yet break any dependency cycles
2019-05-18 20:32:19 -04:00
Paul Licameli
6c57948d8f Remove unnecessary #include-s from .cpp files...
... 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.
2019-05-16 17:21:00 -04:00
Paul Licameli
a30000cf74 Use type aliases FilePath, FilePaths...
... 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)
2019-03-15 15:18:11 -04:00
Paul Licameli
2db49dc1f0 Use standard library style members of wxArrayString (and wxString) ...
... 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
2019-03-10 14:43:57 -04:00
Steve Daulton
0ac3ed8453
Update Sequence.cpp
Fix crash on Linux when recovering project where samples read do not match expected number of samples.
2018-06-05 18:14:36 +01:00
Paul Licameli
2ea5741e2e Redo format setting choices in Quality preferences 2018-03-25 14:46:53 -04:00
andheh
d0960b2c57 fixed a "signed vs. unsigned" warning 2018-03-06 21:30:34 +00:00
Paul Licameli
080dd34e61 Get rid of wx object arrays, use std::vector 2018-02-21 19:33:27 -05:00
Paul Licameli
52a7f2320d Re-fix some warnings about mixing signed and unsigned better...
... 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
2018-01-23 18:51:53 -05:00
James Crook
d2fe7b1757 Clean up most remaining MSVC warnings. 2018-01-06 13:03:48 +00:00
Paul Licameli
7fd78183d2 Remove needless uses of wxString::c_str() in wxString::Format...
... 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.
2018-01-01 20:34:33 -05:00
Paul Licameli
ccb4bbac33 Translate "Message" as default title of message box...
... This required a sweeping change of all calls to wxMessageBox!  But it seems
safe to me, despite the great number of touched files.
2018-01-01 17:50:02 -05:00
James Crook
f463eda36c Clean up some dead code and MSVC warnings.
- 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.
2017-12-08 15:20:39 +00:00
Paul Licameli
9c028c0761 Certain sanity checks against crash or bad behavior on corrupt projects...
... 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.
2017-11-22 22:27:01 -05:00
Paul Licameli
92691d8485 Bug1784: Changed conditions for exceptions from Sequence...
... 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.
2017-11-20 21:42:32 -05:00
Paul Licameli
6e72aed6a5 Sequence consistency check will not throw in 2.2.1 2017-11-20 20:28:04 -05:00
Paul Licameli
2068662954 Replaced one THROW_INCONSISTENCY_EXCEPTION with othe precautions 2017-11-20 19:01:48 -05:00
Paul Licameli
74e3a6fdba Replace mentions of feedback@audacityteam.org with url of forum...
... 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.
2017-08-31 17:01:45 -04:00
Paul Licameli
6adc9f9062 Fix silly out of bounds mistake in Sequence consistency check 2017-08-22 08:40:01 -04:00
Paul Licameli
b521fb8422 Earlier detection and abort editing in case of overlong block file...
... Bill has reported that the truncation in WriteXML happened, but a
reproducible case is not known yet.
2017-07-23 12:41:46 -04:00
Paul Licameli
a0a6d33b4b Bug1655: Sequence inconsistency in cut or copy...
... 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.
2017-06-24 12:34:36 -04:00
Paul Licameli
55439247ad All the catches are in place for BlockFile and other errors, now throw. 2017-04-03 23:32:40 -04:00
David Bailes
0e3f4ce50c Fix for windows build
Trivial fix.
2017-04-03 09:29:39 +01:00
Paul Licameli
fc0f093db7 Sequence::Append* give strong guarantee 2017-04-02 21:33:23 -04:00
Paul Licameli
63cf80d244 Sequence::Delete gives strong guarantee 2017-04-02 21:33:23 -04:00
Paul Licameli
06f6953c91 Sequence::SetSamples, ::SetSilence give strong guarantee 2017-04-02 21:33:23 -04:00
Paul Licameli
73e61592aa Sequence::ConvertToSampleFormat gives strong guarantee 2017-04-02 21:33:23 -04:00
Paul Licameli
3c65731f38 Sequence::InsertSilence gives strong guarantee 2017-04-02 21:33:22 -04:00
Paul Licameli
160d846643 Sequence::Paste gives strong guarantee 2017-04-02 21:33:22 -04:00
Paul Licameli
2ba6065961 Sequence consistency check throws; new unused commit functions use it 2017-04-02 21:33:22 -04:00
Paul Licameli
6b84dc1c1d Factory methods will return non-NULL or throw 2017-03-31 18:14:29 -04:00
Paul Licameli
d1cbac4181 more finally, more const, remove unused, fix warnings 2017-03-31 17:47:18 -04:00
Paul Licameli
23dc35a18c Bug1614: fix crash duplicating a clip 2017-03-30 16:48:52 -04:00
Paul Licameli
39b8d99a56 WaveTrack::Get, WaveClip::GetSamples take a mayThrow=true argument...
... and pass non-default in all needed places.

Don't throw, don't put up error dialogs, in drawing or hit-test code.
2017-03-21 17:23:34 -04:00
Paul Licameli
70d9e4bdc7 GetMinMax, GetRMS functions take a mayThrow argument, return numbers 2017-03-21 14:19:02 -04:00
Paul Licameli
52fd607b42 Sequence::AppendBlock and Sequence::Blockify are static 2017-03-20 17:49:03 -04:00
Paul Licameli
2677796b0c Zero and return false for all failures to read block file summary...
... 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.
2017-03-20 17:49:03 -04:00
Paul Licameli
7b7ad75a49 Remove Sequence::CopyWrite and needless file reads in Sequence::Set 2017-03-20 17:49:03 -04:00
Paul Licameli
b81cdee7e3 Comment where xml writing functions may throw 2017-03-18 11:45:05 -04:00
Paul Licameli
692a033968 Remove naked new[] in: various 2017-03-17 17:52:47 -04:00
Paul Licameli
934a505e1a Changes in WaveClip construction...
... 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.
2017-03-17 17:52:39 -04:00
Paul Licameli
81285ee0c1 More const and override 2017-03-17 17:52:20 -04:00
Paul Licameli
8f28382525 Fix inability to convert sample format from 16 to 32 bits 2016-12-11 01:34:09 -05:00
Paul Licameli
ad04187a41 Change sampleCount arguments, variables, return values to size_t...
... 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.
2016-09-15 21:03:17 -04:00
Paul Licameli
078ff056e2 Make many conversions sampleCount->size_t are explicit and checked...
... 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.
2016-09-15 21:02:32 -04:00
Paul Licameli
78be459fa1 Convert sampleCount <-> floating or -> long long explicitly ...
... 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.
2016-09-15 21:02:31 -04:00
Paul Licameli
26b5e77050 Define sampleCount as a class, not a type alias...
... 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.
2016-09-15 21:02:31 -04:00