View Issue Details

IDProjectCategoryView StatusLast Update
0001264OpenMPTGeneralpublic2020-05-24 12:53
ReporterSaga Musix Assigned To 
PrioritynormalSeverityminorReproducibilityN/A
Status newResolutionopen 
Summary0001264: Turn CriticalSection into shared mutex
Description

We should consider turning the CriticalSection lock used to serialize access to CSoundFile from different threads into a shared_mutex. Right now the differences are negligible, but in the future there are several ways we can take advantage of this feature:

  • Scripting API: Script access to CSoundFile doesn't have to block audio thread if it's just reading
  • Autosave: Can safely run in another thread without blocking GUI and audio thread, but would still block edits made at the same time, obviously.

Read access to const CSoundFile would go through shared_lock, write access to CSoundFile would go through unique_lock.

TagsNo tags attached.
Has the bug occurred in previous versions?
Tested code revision (in case you know it)

Activities

manx

manx

2020-05-24 12:48

administrator   ~0004343

It probably makes sense to split out a separate mutex for the PlayState at the same time. The PlayState is written-to by the audio thread, while the rest of CSoundFile is not.

Saga Musix

Saga Musix

2020-05-24 12:53

administrator   ~0004344

I thought the same initially but it isn't 100% true: The "invert loop" MOD command modifies sample data, so if we do that, an extra lock would have to be acquired when that command is encountered.

The Paula resampler and OPL emulator states (which are not part of PlayState) are also written to in the mixer but there are no heap allocations in those apart from the initial mixer initialization.

Issue History

Date Modified Username Field Change
2019-09-22 18:07 Saga Musix New Issue
2020-05-24 12:48 manx Note Added: 0004343
2020-05-24 12:53 Saga Musix Note Added: 0004344