diff --git a/TestHost/TestCases.cpp b/TestHost/TestCases.cpp index 524fe18..c06e3f6 100644 --- a/TestHost/TestCases.cpp +++ b/TestHost/TestCases.cpp @@ -352,7 +352,7 @@ void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles) bool supportsARA2Persistency { false }; // will be properly set after creating document controller - auto archive = new MemoryArchive { plugInEntry->getARAFactory ()->documentArchiveID }; + MemoryArchive archive { plugInEntry->getARAFactory ()->documentArchiveID }; // create and archive the document, // caching the audio source / modification persistent IDs @@ -364,11 +364,17 @@ void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles) auto araDocumentController { createHostAndBasicDocument (plugInEntry, testHost, "testArchiving", true, audioFiles) }; supportsARA2Persistency = araDocumentController->supportsPartialPersistency (); - // read the audio source content + // log the audio source and modification content as reference for (const auto& audioSource : araDocumentController->getDocument ()->getAudioSources ()) { - ARA_LOG ("Audio source %p (ARAAudioSourceRef %p) has persistent ID \"%s\"", audioSource.get (), araDocumentController->getRef (audioSource.get ()), audioSource->getPersistentID ().c_str ()); + ARA_LOG ("Audio source %p (ARAAudioSourceRef %p) will be stored with persistent ID \"%s\"", audioSource.get (), araDocumentController->getRef (audioSource.get ()), audioSource->getPersistentID ().c_str ()); araDocumentController->logAvailableContent (audioSource.get ()); + + for (const auto& audioModification : audioSource->getAudioModifications ()) + { + ARA_LOG ("Audio modification %p (ARAAudioModificationRef %p) be stored with persistent ID \"%s\"", audioModification.get (), araDocumentController->getRef (audioModification.get ()), audioModification->getPersistentID ().c_str ()); + araDocumentController->logAvailableContent (audioModification.get ()); + } } // cache the audio source and modification persistent IDs @@ -382,9 +388,9 @@ void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles) // store our analysis results bool archivingSuccess { false }; if (supportsARA2Persistency) - archivingSuccess = araDocumentController->storeObjectsToArchive (archive); + archivingSuccess = araDocumentController->storeObjectsToArchive (&archive); else - archivingSuccess = araDocumentController->storeDocumentToArchive (archive); + archivingSuccess = araDocumentController->storeDocumentToArchive (&archive); ARA_VALIDATE_API_STATE (archivingSuccess); // our archive writer implementation never returns false, so this must always succeed } @@ -403,7 +409,7 @@ void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles) if (supportsARA2Persistency) araDocumentController->beginEditing (); else - unarchivingSuccess = araDocumentController->beginRestoringDocumentFromArchive (archive); + unarchivingSuccess = araDocumentController->beginRestoringDocumentFromArchive (&archive); // add a musical context and describe our timeline auto musicalContext { testHost->addMusicalContext (documentName, "ARA Test Musical Context", { 1.0f, 0.0f, 0.0f }) }; @@ -431,21 +437,27 @@ void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles) // inject state and end the document edit cycle if (supportsARA2Persistency) { - unarchivingSuccess = araDocumentController->restoreObjectsFromArchive (archive); + unarchivingSuccess = araDocumentController->restoreObjectsFromArchive (&archive); araDocumentController->endEditing (); } else { - unarchivingSuccess = araDocumentController->endRestoringDocumentFromArchive (archive) && unarchivingSuccess; + unarchivingSuccess = araDocumentController->endRestoringDocumentFromArchive (&archive) && unarchivingSuccess; } ARA_VALIDATE_API_STATE (unarchivingSuccess); // our archive reader implementation never returns false, and the archive // was created on the same machine, so this call must always succeed - // verify the restored content + // log the restored audio source and modification content to verify proper restoration for (const auto& audioSource : araDocumentController->getDocument ()->getAudioSources ()) { ARA_LOG ("Audio source %p (ARAAudioSourceRef %p) with persistent ID \"%s\" has been restored", audioSource.get (), araDocumentController->getRef (audioSource.get ()), audioSource->getPersistentID ().c_str ()); araDocumentController->logAvailableContent (audioSource.get ()); + + for (const auto& audioModification : audioSource->getAudioModifications ()) + { + ARA_LOG ("Audio modification %p (ARAAudioModificationRef %p) with persistent ID \"%s\" has been restored", audioModification.get (), araDocumentController->getRef (audioModification.get ()), audioModification->getPersistentID ().c_str ()); + araDocumentController->logAvailableContent (audioModification.get ()); + } } // plug-ins must deal with archives containing more data than actually being restored. @@ -460,19 +472,25 @@ void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles) testHost->removeAudioModification (araDocumentController->getDocument ()->getName (), modificationToRemove); testHost->removeAudioSource (araDocumentController->getDocument ()->getName (), sourceToRemove); - unarchivingSuccess = araDocumentController->restoreObjectsFromArchive (archive); + unarchivingSuccess = araDocumentController->restoreObjectsFromArchive (&archive); ARA_VALIDATE_API_STATE (unarchivingSuccess); araDocumentController->endEditing (); + // log the restored audio source and modification content to verify proper restoration for (const auto& audioSource : araDocumentController->getDocument ()->getAudioSources ()) { ARA_LOG ("Audio source %p (ARAAudioSourceRef %p) with persistent ID \"%s\" has been restored", audioSource.get (), araDocumentController->getRef (audioSource.get ()), audioSource->getPersistentID ().c_str ()); araDocumentController->logAvailableContent (audioSource.get ()); + + for (const auto& audioModification : audioSource->getAudioModifications ()) + { + ARA_LOG ("Audio modification %p (ARAAudioModificationRef %p) with persistent ID \"%s\" has been restored", audioModification.get (), araDocumentController->getRef (audioModification.get ()), audioModification->getPersistentID ().c_str ()); + araDocumentController->logAvailableContent (audioModification.get ()); + } } } } - delete archive; } /*******************************************************************************/ diff --git a/TestPlugIn/ARATestDocumentController.cpp b/TestPlugIn/ARATestDocumentController.cpp index 5f56d65..e72c9c8 100644 --- a/TestPlugIn/ARATestDocumentController.cpp +++ b/TestPlugIn/ARATestDocumentController.cpp @@ -434,6 +434,8 @@ void ARATestDocumentController::didEndEditing () noexcept bool ARATestDocumentController::doRestoreObjectsFromArchive (ARA::PlugIn::HostArchiveReader* archiveReader, const ARA::PlugIn::RestoreObjectsFilter* filter) noexcept { + archiveReader->notifyDocumentUnarchivingProgress (0.0f); + TestUnarchiver unarchiver { [archiveReader] (size_t position, size_t length, uint8_t buffer[]) noexcept -> bool { return archiveReader->readBytesFromArchive (position, length, buffer); @@ -447,7 +449,8 @@ bool ARATestDocumentController::doRestoreObjectsFromArchive (ARA::PlugIn::HostAr for (size_t i = 0; i < numAudioSources; ++i) { const float progressVal { static_cast (i) / static_cast (numAudioSources) }; - archiveReader->notifyDocumentUnarchivingProgress (progressVal); + if (i != 0) + archiveReader->notifyDocumentUnarchivingProgress (progressVal); // read audio source persistent ID const auto persistentID { unarchiver.readString () }; @@ -488,6 +491,8 @@ bool ARATestDocumentController::doRestoreObjectsFromArchive (ARA::PlugIn::HostAr bool ARATestDocumentController::doStoreObjectsToArchive (ARA::PlugIn::HostArchiveWriter* archiveWriter, const ARA::PlugIn::StoreObjectsFilter* filter) noexcept { + archiveWriter->notifyDocumentArchivingProgress (0.0f); + // make sure to capture any pending analysis result processCompletedAnalysisTasks (); @@ -508,7 +513,8 @@ bool ARATestDocumentController::doStoreObjectsToArchive (ARA::PlugIn::HostArchiv for (size_t i { 0 }; i < numAudioSources; ++i) { const float progressVal { static_cast (i) / static_cast (numAudioSources) }; - archiveWriter->notifyDocumentArchivingProgress (progressVal); + if (i != 0) + archiveWriter->notifyDocumentArchivingProgress (progressVal); // write persistent ID archiver.writeString (audioSourcesToPersist[i]->getPersistentID ());