1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

70 Commits

Author SHA1 Message Date
Paul Licameli
aa0b33dc8f Detect failure to reconnect to temp project when first saving it 2020-12-06 23:20:44 -05:00
Paul Licameli
41eb66fccf Where CurConn() is used, don't assume it is non-null 2020-12-06 21:31:06 -05:00
Paul Licameli
6944ba564c Use events to break dependency cycle introduced at 3978e8c 2020-11-25 12:24:21 -05:00
Paul Licameli
7e1e339f72 Bug2599: -wal and -shm of discarded temp projects should clean up 2020-11-24 14:38:58 -05:00
Paul Licameli
5ebfe4670c Bug2596: Error dialogs opening unreadable project should not be blank 2020-11-24 12:43:00 -05:00
Paul Licameli
3e0120be05 Bug2550 residual: also move -shm file if present...
... Also much other extra care in the handling of -shm and -wal files
2020-11-22 14:32:42 -05:00
Paul Licameli
14c300c672 Bug2542: Discard button of auto recovery should work with UP 2020-11-19 15:18:01 -05:00
Paul Licameli
a9cbd953f0 Define InvisibleTemporaryProject 2020-11-18 23:51:01 -05:00
Paul Licameli
16b249ab9f ProjectFileIO fns now take multiple pointers to const TrackLists 2020-11-18 17:30:55 -05:00
Paul Licameli
e7b3c2b99f Cut and paste TransactionScope into DBConnection.* files 2020-09-05 14:44:34 -04:00
Paul Licameli
ddc2593282 TransactionScope only requires DBConnection not ProjectFileIO 2020-09-05 14:35:24 -04:00
Paul Licameli
eb7e67623e Demote error message storage from ProjectFileIO into DBConnection 2020-09-05 14:32:39 -04:00
Paul Licameli
c9dec8f5a9 Factor ProjectFileIO::GetConnection (returning reference not pointer) 2020-09-05 14:30:34 -04:00
Paul Licameli
c17b804750
Dont delete sample blocks prematurely (#648)
* Revert "AUP3: Don't delete sample blocks prematurely"

This reverts commit c1884349d595a2fb889c90f209ea4af3d1c70e1d.

* "Don't delete sample blocks prematurely" fixed otherwise...

... and very simply.

Problem was that, only for an interactive effect (like Bass and Treble), the
save point was created, rolled back, created again, then committed.

But (unlike with the non-savepoint commands, even if savepoint is outermost),
rolling back a savepoint really just rewinds it without removing it -- therefore
the second savepoint was inner, but the first (outer) was never committed, so
some changes failed to persist.

Solution:  add a commit after rollback of savepoint to implement destructor
of AutoCommitTransaction.

The reversion of c188434 also leaves AutoCommitTransaction as a better RAII
style operation.  Rollback changes by default -- keep changes only if
success is explicitly indicated.

* Rename AutoCommitTransaction as TransactionScope...

... More appropriately, since it's now the rollback that is automatic but
the commit that must be explicit
2020-08-28 15:38:38 -05:00
Paul Licameli
1bb34e703e
Bug2529: don't lose data when closing without saving on small drive (#650) 2020-08-28 13:03:35 -05:00
Leland Lucius
0bbf1792fa AUP3: Don't molest project file when applying macros
Cliff reported that if you apply a macro to "Files" and you had
a "saved project" open at the time, you would get the "not saved
properly" dialog when you next open that "saved project".

This should correct it...
2020-08-26 00:06:19 -05:00
Leland Lucius
913c41e6e8 AUP3: Minor code cleanup and addition of comments
Probably over commented for some, but I want a good refresher
a year from now when I've completely forgotten how it works.
2020-08-01 15:52:31 -05:00
Leland Lucius
8943494f8a AUP3: Better space usage calculations
Several improvements in determining how much actual disk space a
sampleblock uses. This allows us to provide how much space will
be recovered when using File -> Compact Project.

In addition, the History window now provides better space estimates.
2020-08-01 04:25:42 -05:00
Leland Lucius
d4627f0daf AUP3: Reduce crash exposure when compacting
There's still the possibility if a crash happens at just the
right time that the project will be named "<project>_compact_back"
so we should probably look for it during startup.

This also changes all "Vacuum" references to "compact".
2020-07-28 23:25:50 -05:00
Leland Lucius
09f7aaad5b AUP3: UP-35 Dirty Project-2 bloat retention
Add compaction to SaveProject for the original file.
2020-07-27 23:16:27 -05:00
Leland Lucius
a4554d3631 AUP3: Make sure original file gets closed
When doing a Save As, make sure autosave doc is removed
from the original project and the original project is
properly closed.  (The original project does NOT get
compacted.)
2020-07-27 19:39:26 -05:00
Leland Lucius
6fef14dd08 AUP3: Rework Compact Project menu item and AutoRecoverDialog
Plus a couple of fixes that prevent leaving temporary files
after a project is loaded.
2020-07-26 02:01:37 -05:00
Leland Lucius
c1884349d5 AUP3: Don't delete sample blocks prematurely
The wrong sample blocks would be deleted at close in step 6:

1) New Project
2) Save and name
3) Import one stereo MP3 (about 6 minutes)
4) Save, close and re-open
5) Apply Bass and Treble to the track using real-time preview
6) Save, close and re-open
7) Message Failed to retrieve sample block
2020-07-25 20:03:23 -05:00
Leland Lucius
03762d0ca3 AUP3: Fix unopened project file 2020-07-25 18:47:30 -05:00
Paul Licameli
a8fd6c6ce8
Preliminaries for grouped block deletion (#628)
* Change usage of AutoCommitTransaction::Rollback...

... It is the more useful pattern (as in many finally blocks) for the failure
path in the destructor (which rolls back) to be the default, but an explicit
call must inform it of success.

This corrects the early return paths in Effect::DoEffect().

Throw inconsistency exception if Commit() is called again after having been
called once, successfully

Also remove a friend declaration

* UndoManager's interface uses consistent 0-based indexing of states...

... Returned by GetCurrentState() and used by SetStateTo(),
GetLongDescription(), GetShortDescription()

* SampleBlock::GetBlockID is const

* Generalized function to visit sample blocks used in a TrackList...

... Eliminating some duplication; put it in WaveTrack, not Track, to avoid
a dependency cycle.

* Eliminate more repetition with BlockSpaceUsageAccumulator

* Function to delete all blocks of/not-of a given set in one command
2020-07-23 11:17:29 -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 127696879dcc5ca687ec50a4ccef7acbed563926

* 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
Leland Lucius
38e830edf0 AUP3: Remove unused methods 2020-07-22 20:34:49 -05:00
Leland Lucius
6f771d1783 AUP3: Fix previous commit and rework db handling
This moves direct handling of the sqlite3 DB handle into it's own
class, along with the checkpointing thread and prepared statement
cache.
2020-07-22 11:41:03 -05:00
Leland Lucius
5fe26bc738 AUP3: Fix build 2020-07-21 11:34:26 -05:00
Leland Lucius
6c70cb86ee AUP3: Use persistent prepared statements
SqliteSampleBlock now uses already prepared SQL statements for
all DB usage. This means that the statements  won't have to be
compiled each time they are used.
2020-07-21 09:04:50 -05:00
Paul Licameli
17a4958173
Unitary thread review (#623)
* Fix uninitialized members of ProjectFileIO...

... which fixes this problem I observed:

Opening a previously saved project, saving-as to another path, then exiting
Audacity, gives a progress dialog waiting for checkpoints to end, which doesn't
go away

* Remove two mutexes...

... One wasn't used at all, and another was only ever used by one thread, and
then not correctly unlocked for each locking on all possible paths.

* Values that the worker thread writes and main reads should be atomic

* Remember to close db connections even after failure to open
2020-07-20 20:17:45 -05:00
Paul Licameli
9ffd169aa7
Various unitary fixes (#622)
* some comments

* No intermediate arrays (of arrays) of strings for query results...

... instead, let any query pass its own lambda to collect row data directly
however it needs to, for a bit of efficiency.  Also the precautions of a new
GuardedCall
2020-07-20 17:11:43 -05:00
Leland Lucius
84f363ee07 AUP3: Simplify checkpoing and add checkpoint progress dialog
Also move the project file closure out of the ProjectFileIO
destructor and does it before the project file window is
destroyed.
2020-07-20 11:10:31 -05:00
Leland Lucius
d2b4a0e488 AUP3: Put checkpointing in a separate thread
This is highly experimental.  It's defers most checkpointing
to a separate thread to see if we get better throughput and
less choppiness when applying effects.
2020-07-19 03:28:02 -05:00
Leland Lucius
1f87d4f716 AUP3: Fix build 2020-07-17 17:23:23 -05:00
Leland Lucius
93d9303c3d AUP3: Many corrections and (safe) speed ups
This reenables synchronous mode by default.  However, for processing
where a power cut or crash can be tolerated, synchronous and journaling
are disabled.  Once the processing is complete, they are reenabled.

Types of processing that are like this are "Save As", "Backup Project",
and "Vacuuming". They all write to a separate project file while
running, so the real project file is safe.

Unfortunately, effects are back to be slow and sluggish.

I believe I've address all of the weird file corruption issues and
I'll continue to continue testing for these.
2020-07-17 16:17:42 -05:00
Leland Lucius
6ffced4881 AUP3: Adds connection configuration and ...
Optimizes a couple of sample block copy loops by only preparing
the statement once outside the loop.

The connection configuration ensure that all connections use the same
settings...assuming you remember to configure it after opening. :-)

The possibly controversial setting is the "PRAGMA synchronous = off"
2020-07-16 01:10:54 -05:00
Leland Lucius
5bc3ae659c AUP3: Added AUP3 importer and improved progress dialogs 2020-07-15 01:32:48 -05:00
Leland Lucius
6f233cbff5 AUP3: Fix build issues 2020-07-13 09:48:37 -05:00
Leland Lucius
e75ab6eaad AUP3: Fix last commit
I hate conflicts...I ALWAYS get them wrong.
2020-07-13 00:45:14 -05:00
Leland Lucius
0815344e5d AUP3: Reworked CopyTo() yet again
This time it has the potential to produce much smaller
output files since it ONLY copies the active blocks and
not all of the blocks related to undo history.  This is
done for "Save As" and "Backup Project".  Normal save
can't take advantage of this, but then it really doesn't
need it as it has to depend on vacuuming.

The vacuuming at close has been adjusted to utilize CopyTo()
so it should produce similarly small files as long as the
vacuuming happens when the project is definitely closing.
2020-07-13 00:04:54 -05:00
Leland Lucius
a0008831e0 Revert "AUP3: Reworked CopyTo() yet again"
A bit more thought needs to do into this.
2020-07-12 10:55:54 -05:00
Leland Lucius
e3c5563d35 AUP3: Reworked CopyTo() yet again
This time it has the potential to produce much smaller
output files since it ONLY copies the active blocks and
not all of the blocks related to undo history.
2020-07-12 10:39:37 -05:00
Paul Licameli
cea658d9eb
Fix the reading of autosave files... (#610)
* Fix the reading of autosave files...

... problem was in recreating strings from buffers, but copying too many because
null terminators were lacking.

* Autosave during recording backs up all tracks correctly...

... whether to new track, or appending; and it doesn't lose the other tracks
besides the recording.

It is also unnecessary when just starting to record, so remove one call.
2020-07-11 00:49:37 -05:00
Leland Lucius
5b41115bd0 AUP3: Mostly rework of CopyTo()
It now uses VACUUM INTO instead of the SQLite backup API
in hopes that the copies will be smaller. And VACUUM INTO
is "supposed" to be faster, but time will tell.  It's easy
to put the backup API usage back in.

This also fixes a bit I missed with redoing the orphan block
handling that was reported by Paul.

And finally, it renames the AutoRecovery.cpp/.h files and AutoSaveFile
class to ProjectSerializer since the AutoSaveFile class is being
used for regular project documents now and it doesn't write to a
file anymore.

If anyone has a better idea for a name other than ProjectSerializer
feel free to change it.  I hate naming things.
2020-07-10 00:50:52 -05:00
Paul Licameli
7ad8849d32 When saving new project, put correct file name into MRU submenu...
... bug was introduced at 590d8c6d09fa2989f1e35ad3125965c801ece506
2020-07-09 19:17:23 -04:00
Leland Lucius
2ec3adf555 AUP3: Fix build failures 2020-07-09 13:46:38 -05:00
Leland Lucius
632ad6efcf AUP3: Better orphan block handling
This replaces my previous attempt since it didn't account
for all the situations where orphans blocks could occur.
2020-07-09 13:14:12 -05:00
Leland Lucius
af6a23696b AUP3: Detect and delete orphan blocks at startup 2020-07-08 00:18:05 -05:00
Paul Licameli
590d8c6d09
Fail safe save as (#606)
* ProjectFileIO::SaveProject() won't close original db until done...

... So on the failure path, don't risk closing the original too early, failing
with the new database, and then failing to reopen the original.

Just keep the original open and a new connection open too, until it is
certain that the initial population of the new database is successful.

* Check return value from AutoSaveDelete when saving-as

* Fix the remaining unchecked sqlite3_bind* calls, which are in Autosave...

...similarly to checks in 8b3f9fa

* When saving-as or -copy, open the new database only once

* Check return value from sqlite_initialize
2020-07-07 15:41:33 -05:00