Skip to content

Commit c81e20a

Browse files
committed
Add ARAModelUpdateControllerInterface::notifyDocumentDataChanged() and related code
1 parent fd91000 commit c81e20a

File tree

9 files changed

+48
-2
lines changed

9 files changed

+48
-2
lines changed

ChangeLog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Changes since previous releases:
99
a channel count too and copies the channel arrangement data instead of referencing it
1010
As a result, DocumentController::doUpdateChannelArrangement() has been removed since
1111
the arrangement is now always available, just like sample rate etc.
12+
- added API to notify the host when the private, opaque document state changes (to trigger saving it)
1213
- added ARA_VALIDATE_API_THREAD to enable conveniently raising kARAAssertInvalidThread
1314
- added optional document controller thread validation to ARAPlug
1415
- required minimum CMake version increased from 3.4 to 3.19 (same as VST3)

Dispatch/ARAHostDispatch.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,20 @@ namespace ModelUpdateControllerDispatcher
213213
fromHostRef (controllerHostRef)->notifyPlaybackRegionContentChanged (playbackRegionHostRef, range, flags);
214214
}
215215

216+
static void ARA_CALL notifyDocumentDataChanged (ARAModelUpdateControllerHostRef controllerHostRef) noexcept
217+
{
218+
fromHostRef (controllerHostRef)->notifyDocumentDataChanged ();
219+
}
220+
216221
static const ARAModelUpdateControllerInterface* getInterface () noexcept
217222
{
218-
static const SizedStruct<ARA_STRUCT_MEMBER (ARAModelUpdateControllerInterface, notifyPlaybackRegionContentChanged)> ifc =
223+
static const SizedStruct<ARA_STRUCT_MEMBER (ARAModelUpdateControllerInterface, notifyDocumentDataChanged)> ifc =
219224
{
220225
ModelUpdateControllerDispatcher::notifyAudioSourceAnalysisProgress,
221226
ModelUpdateControllerDispatcher::notifyAudioSourceContentChanged,
222227
ModelUpdateControllerDispatcher::notifyAudioModificationContentChanged,
223-
ModelUpdateControllerDispatcher::notifyPlaybackRegionContentChanged
228+
ModelUpdateControllerDispatcher::notifyPlaybackRegionContentChanged,
229+
ModelUpdateControllerDispatcher::notifyDocumentDataChanged
224230
};
225231
return &ifc;
226232
}

Dispatch/ARAHostDispatch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ class ModelUpdateControllerInterface
183183
virtual void notifyAudioModificationContentChanged (ARAAudioModificationHostRef audioModificationHostRef, const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept = 0;
184184
//! \copydoc ARAModelUpdateControllerInterface::notifyPlaybackRegionContentChanged
185185
virtual void notifyPlaybackRegionContentChanged (ARAPlaybackRegionHostRef playbackRegionHostRef, const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept = 0;
186+
//! \copydoc ARAModelUpdateControllerInterface::notifyDocumentDataChanged
187+
virtual void notifyDocumentDataChanged () noexcept = 0;
186188
};
187189
ARA_MAP_HOST_REF (ModelUpdateControllerInterface, ARAModelUpdateControllerHostRef)
188190

Dispatch/ARAPlugInDispatch.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,13 @@ void HostModelUpdateController::notifyPlaybackRegionContentChanged (ARAPlaybackR
717717
getInterface ()->notifyPlaybackRegionContentChanged (getRef (), playbackRegionHostRef, range, scopeFlags);
718718
}
719719

720+
void HostModelUpdateController::notifyDocumentDataChanged () noexcept
721+
{
722+
// notifyDocumentDataChanged was added in ARA 2.3 draft, so check its presence here
723+
if (getInterface ().implements<ARA_STRUCT_MEMBER (ARAModelUpdateControllerInterface, notifyDocumentDataChanged)> ())
724+
getInterface ()->notifyDocumentDataChanged (getRef ());
725+
}
726+
720727
/*******************************************************************************/
721728
// PlaybackController
722729
/*******************************************************************************/

Dispatch/ARAPlugInDispatch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ class HostModelUpdateController : public InterfaceInstance<ARAModelUpdateControl
464464
//! \copydoc ARAModelUpdateControllerInterface::notifyPlaybackRegionContentChanged
465465
void notifyPlaybackRegionContentChanged (ARAPlaybackRegionHostRef playbackRegionHostRef,
466466
const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept;
467+
//! \copydoc ARAModelUpdateControllerInterface::notifyDocumentDataChanged
468+
void notifyDocumentDataChanged () noexcept;
467469
};
468470

469471
/*******************************************************************************/

IPC/ARAIPCProxyHost.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ class ModelUpdateController : public Host::ModelUpdateControllerInterface, prote
463463
void notifyAudioSourceContentChanged (ARAAudioSourceHostRef audioSourceHostRef, const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept override;
464464
void notifyAudioModificationContentChanged (ARAAudioModificationHostRef audioModificationHostRef, const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept override;
465465
void notifyPlaybackRegionContentChanged (ARAPlaybackRegionHostRef playbackRegionHostRef, const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept override;
466+
void notifyDocumentDataChanged () noexcept override;
466467

467468
private:
468469
ARAModelUpdateControllerHostRef _remoteHostRef;
@@ -494,6 +495,12 @@ void ModelUpdateController::notifyPlaybackRegionContentChanged (ARAPlaybackRegio
494495
_remoteHostRef, playbackRegionHostRef, range, scopeFlags);
495496
}
496497

498+
void ModelUpdateController::notifyDocumentDataChanged () noexcept
499+
{
500+
remoteCall (ARA_IPC_HOST_METHOD_ID (ARAModelUpdateControllerInterface, notifyDocumentDataChanged),
501+
_remoteHostRef);
502+
}
503+
497504

498505
/*******************************************************************************/
499506
//! Implementation of PlaybackControllerInterface that channels all calls through IPC

IPC/ARAIPCProxyPlugIn.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,16 @@ void ProxyPlugIn::handleReceivedMessage (const MessageID messageID, const Messag
17091709

17101710
documentController->getHostModelUpdateController ()->notifyPlaybackRegionContentChanged (playbackRegionHostRef, (range.second) ? &range.first : nullptr, scopeFlags);
17111711
}
1712+
else if (messageID == ARA_IPC_HOST_METHOD_ID (ARAModelUpdateControllerInterface, notifyDocumentDataChanged))
1713+
{
1714+
ARAModelUpdateControllerHostRef controllerHostRef;
1715+
decodeArguments (decoder, controllerHostRef);
1716+
1717+
auto documentController { fromHostRef (controllerHostRef) };
1718+
ARA_VALIDATE_API_ARGUMENT (controllerHostRef, isValidInstance (documentController));
1719+
1720+
documentController->getHostModelUpdateController ()->notifyDocumentDataChanged ();
1721+
}
17121722

17131723
// ARAPlaybackControllerInterface
17141724
else if (messageID == ARA_IPC_HOST_METHOD_ID (ARAPlaybackControllerInterface, requestStartPlayback))

PlugIn/ARAPlug.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,10 @@ void DocumentController::notifyModelUpdates () noexcept
11171117
hostModelUpdateController->notifyPlaybackRegionContentChanged (playbackRegionUpdate.first->getHostRef (), nullptr, playbackRegionUpdate.second);
11181118
_playbackRegionContentUpdates.clear ();
11191119

1120+
if (_documentDataChanged)
1121+
hostModelUpdateController->notifyDocumentDataChanged ();
1122+
_documentDataChanged = false;
1123+
11201124
didNotifyModelUpdates ();
11211125
}
11221126

@@ -2312,6 +2316,11 @@ void DocumentController::notifyPlaybackRegionContentChanged (PlaybackRegion* pla
23122316
_playbackRegionContentUpdates[playbackRegion] += scopeFlags;
23132317
}
23142318

2319+
void DocumentController::notifyDocumentDataChanged () noexcept
2320+
{
2321+
_documentDataChanged = true;
2322+
}
2323+
23152324
/*******************************************************************************/
23162325

23172326
HostAudioReader::HostAudioReader (const AudioSource* audioSource, bool use64BitSamples) noexcept

PlugIn/ARAPlug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ class DocumentController : public DocumentControllerInterface,
12741274
void notifyAudioSourceContentChanged (AudioSource* audioSource, ContentUpdateScopes scopeFlags) noexcept;
12751275
void notifyAudioModificationContentChanged (AudioModification* audioModification, ContentUpdateScopes scopeFlags) noexcept;
12761276
void notifyPlaybackRegionContentChanged (PlaybackRegion* playbackRegion, ContentUpdateScopes scopeFlags) noexcept;
1277+
void notifyDocumentDataChanged () noexcept;
12771278
//@}
12781279

12791280
// Helper for analysis requests.
@@ -1348,6 +1349,7 @@ class DocumentController : public DocumentControllerInterface,
13481349
std::map<AudioSource*, ContentUpdateScopes> _audioSourceContentUpdates;
13491350
std::map<AudioModification*, ContentUpdateScopes> _audioModificationContentUpdates;
13501351
std::map<PlaybackRegion*, ContentUpdateScopes> _playbackRegionContentUpdates;
1352+
bool _documentDataChanged { false };
13511353
std::atomic_flag _analysisProgressIsSynced {}; // { true } would be better but C++ standard only allows for default-init to false
13521354

13531355
bool _isHostEditingDocument { false };

0 commit comments

Comments
 (0)