Commit Graph

10 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
Paul Licameli 64c50e57da
Sample block cleanups (#657)
* Revert "[Bug 2533] New: Extreme space inefficiency importing silence from an AUP file"...

... It did not fix the symptoms.  Using a zero blob only gives temporary
in-memory space efficiency when adding a row to the database, not space savings
in the file.

This reverts commit d9047dfd25.

* Remove unused SampleBlockFactory::Get

* Eliminate some repetition and magic numbers

* Lower some common steps into GetSummary(); removed unused argument

* mSummary256Bytes and mSummary64kBytes not needed after initialization

* Satisfy sample and summary requests for silent blocks without using db
2020-09-02 13:11:30 -05:00
Paul Licameli a3fcd611b5
Dependency cleanup (#627)
* DBConnection doesn't use ProjectFileIO or need friendship...

... Instead, it is given its own weak_ptr to the project

* Demote the bypass flag into DBConnection...

... So SqliteSampleBlock needs ProjectFileIO only to get the DBConnection

* Accessor functions for the connection objects for SqliteSampleBlock

* Another level of indirection to get to the DBConnection object...

... The document holds the unique_ptr to DBConnection in an attached object;
later we want the SqliteSampleBlockFactory to locate the same pointer without
using ProjectFileIO

* SqliteSampleBlock and its factory don't use class ProjectFileIO...

... Instead they share a pointer to the pointer to the current DBConnection.

This means they no longer know how to invoke the lazy opening of that
connection.

So just require that this be done before any operations on blocks happen.  If
it hasn't, throw and let the application recover.

* ProjectFileIO no longer needs weak_ptr to Project for safety...

... so eliminate much ugliness from 127696879d

* Move DBConnection to new files...

... And SqliteSampleBlock does not depend on ProjectFileIO.

* SampleBlock.h doesn't need ClientData.h

* Function ProjectFileIO::Conn() isn't needed
2020-07-23 01:04:46 -05: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 8ea07572c1 AUP3: Several fixes
These mainly address the bugs that Steve reported and a couple
more I found along the way.

Corrected ProjectFileIO::GetMinMaxRMS() - It was still using the
original method of keep all block data in memory.  I missed it
when I redid everything.  Fixes his Amplify crash.

Temporary filenames should no longer be shown to the user.

Resaves will no longer present a Save As dialog.

Cleaned up duplicate pathname handling in ProjectFileIO.

Returned proper errors when loading a project
2020-07-01 13:26:20 -05:00
James Crook 299710f0a9 Add comments to document the SQL. 2020-07-01 14:55:06 +01: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