Commit Graph

159 Commits

Author SHA1 Message Date
Paul Licameli c5ebc396eb Audacity.h has shrunk to nothing, now remove it! 2021-05-10 00:05:23 -05:00
Paul Licameli 9d6dd45973 More use of constSamplePtr instead of samplePtr 2020-11-29 19:45:18 -05:00
binarywisdom a10a1b81aa fixed bug/enh 266 2020-09-04 11:39:11 -04:00
Paul Licameli 7294f7a8e0
Bug2532: should preserve sharing of sample blocks when importing AUP (#651) 2020-08-30 17:18:18 -05:00
Paul Licameli 372393f49e Rewrite comments about exception safety guarantees with Doxygen...
... Defining a new macro, which generates a special paragraph with links to a
new page describing the principles.
2020-08-22 23:07:28 -04:00
Paul Licameli bd6536f3c4 Remove obsolete mentions of blockfiles in comments & incomplete types 2020-07-20 19:03:31 -04:00
Paul Licameli 875e8e0984
Cross project copy data loss (#604)
* Need only CloseLock now, not old Lock and Unlock...

... which were for cross-project cut and paste, but they no longer work and we
need another solution.  So delete much old code.

* Fix dangling reference to AudacityProject completely! ...

... in SqliteSampleBlockFactory: retain ONLY the shared pointer to
ProjectFileIO, then pass that, not project, to constructors of blocks.

completing the work of 127696879d

* Restore part of the Bug2436 fix...

... which needs the non-default arguments to WaveTrack::EmptyCopy that got lost
at d39590cf41

So that pasted WaveTracks refer to the correct SampleBlockFactory and database
for their project

But this is not yet a sufficient re-fix for the bug

* Complete the fix for cross-project copies and 2436...

... by duplicating sample blocks, in Sequence.cpp, when it is wrong just to
share them.

And to determine which case it is, see whether source and destination Sequences
have the same sample block factories when doing Copy or Paste.  Duplicate
when the factories are different.  Otherwise sharing is safe and more space
efficient.

This does the analogous to what DirManager::CopyBlockFile did before commit
d39590c.
2020-07-07 15:41:50 -05:00
Paul Licameli fff9e6a2e4 Fix another long long format argument 2020-07-07 02:03:51 -04:00
Paul Licameli 8b3f9fae58
Sqlite errors (#601)
* Null checks on return from std::make_shared are unnecessary...

... instead std::bad_alloc would be thrown in case of memory exhaustion, which
we don't try to recover from.

* Restore uses of the mayThrow arguments in Sequence...

... that became unused at commit d39590cf41.

It's important to ignore exceptions from SampleBlocks when only displaying, not
editing or playing, and just treat missing data as silence.

Pass the boolean into the SampleBlock routines.  But the throwing of exceptions
is not yet implemented.

* SampleBlockFactory functions guaranteed to return non-null or throw...

... which corrects Sequence.cpp, which was assuming non-null results.

This supplies the throw statements that the previous commit comment says were
still lacking.

This corrects the absence of checks of returns from sql_bind_... function calls
in SqliteSampleBlock.cpp.  (Other calls remain to be checked elsewhere.)

User visible error messages, carried by the exceptions, might be improved.

* Restore the try/catch in AutoSaveFile::Decode...

... which was introduced at 2ba17c78d6

but removed at d39590cf41, yet without removing
the throw statement

which left the program vulnerable to abrupt termination instead of graceful
failure, when uninterpretable auto save contents are detected.
2020-07-05 14:13:30 -05:00
Paul Licameli 127696879d
Unitary changes (#599)
* Define SampleBlockFactory replacing static members of SampleBlock...

... This will become an abstract base class

* Sequence and WaveTrack only store SampleBlockFactory not Project...

... This adds a dependency from Track to SampleBlock which temporarily enlarges
a cycle in the dependency graph

* Register a global factory of SampleBlockFactory...

... so that later we can make an abstract SampleBlockFactory, separate from the
concrete implementation in terms of sqlite, and inject the dependency at startup
avoiding static dependency

* New concrete classes SqliteSampleBlock, SqliteSampleBlockFactory...

... separated from abstract base classes and put into a new source file,
breaking dependency cycles, and perhaps allowing easy reimplementation for other
databases in the future.

Note that the new file is a header-less plug-in!  Nothing depends on it.  It
uses static initialization to influence the program's behavior.

* Compile dependency on sqlite3.h limited to just two .cpp files...

... these are ProjectFileIO.cpp and SqliteSampleBlock.cpp.

But there is still close cooperation of ProjectFileIO and SqliteSampleBlock.cpp.
This suggests that these files ought to be merged, and perhaps ProjectFileIO
also needs to be split into abstract and concrete classes, and there should be
another injection of a factory function at startup.  That will make the choice
of database implementation even more modular.

Also removed one unnecessary inclusion of ProjectFileIO.h

* Fix crashes cutting and pasting cross-project...

... in case the source project is closed before the paste happens.

This caused destruction of the ProjectFileIO object and a closing of the sqlite
database with the sample data in it, leaving dangling references in the
SqliteSampleBlock objects.

The fix is that the SqliteSampleBlockFactory object holds a shared_ptr to the
ProjectFileIO object.  So the clipboard may own WaveTracks, which own WaveClips,
which own Sequences, which own SqliteSampleBlockFactories, which keep the
ProjectFileIO and the database connection alive until the clipboard is cleared.

The consequence of the fix is delayed closing of the entire database associated
with the source project.

If the source project is reopened before the clipboard is cleared, will there
be correct concurrent access to the same persistent store?  My preliminary
trials suggest this is so (reopening a saved project, deleting from it, closing
it again -- the clipboard contents are still unchanged and available).
2020-07-02 18:11:38 -05:00
Paul Licameli 1fcb77ebce
Unitary fixes (#598)
* Eliminate unneeded back-pointer to project from non-wave Tracks...

... now that DirManager is gone

* Remove unused declarations

* SampleData::mProject was not used

* Correct ProjectFileIO::GetLibraryError

* Remove unnecessary #include directives
2020-07-02 11:42:25 -05:00
Leland Lucius d39590cf41 AUP3: First round of updates
!!! THERE WILL NO DOUBT BE BUGS !!!

This is a big one and there's still several things to
complete. Just want to get this in the wild to start
receiving feedback.

One big thing right now is that it will NOT load pre-aup3
files.  An importer is on the way for that.
2020-07-01 02:30:18 -05:00
Leland Lucius b1beb20ae9 AUP3: Remove obsolete audio file cache 2020-07-01 01:14:10 -05:00
Leland Lucius cbf1bb558e AUP3: Removes OD code related to project file handling
This removes all of the OnDemand code embedded throughout
    the main codebase. Individual files related specifically
    to OD have been left in place, but removed from the build.
2020-07-01 01:14:05 -05:00
Paul Licameli 4a56af43aa Bug2442 residual: Review AudacityException classes...
... Have copy constructors only (no moves); disallow all assignments
2020-06-05 13:48:53 -04:00
Paul Licameli dc39f22442 AudacityMessageBox takes TranslatableString message and caption 2019-12-20 21:32:50 -05:00
Paul Licameli 4eb220e7b9 TranslatableString for undo history short and long descriptions 2019-12-16 14:19:23 -05:00
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
d2fe7b1757
f463eda36c
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