Fix crash due to concurrent sndfile access
Peak files are built int background which can happen concurrently to estimating tempo. Notably when importing large .flac files this can cause a crash because libsndfile API does not allow for concurrent use of the same SNDFILE object.
This commit is contained in:
@@ -135,7 +135,10 @@ AudioSource::~AudioSource ()
|
||||
void
|
||||
AudioSource::estimate_tempo ()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
/* CALLER MUST HOLD WRITER LOCK */
|
||||
assert (!_lock.writer_trylock());
|
||||
#endif
|
||||
|
||||
const samplecnt_t ten_seconds = _session.sample_rate() * 10;
|
||||
|
||||
|
||||
@@ -259,7 +259,10 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
||||
throw failed_constructor ();
|
||||
}
|
||||
ret->check_for_analysis_data_on_disk ();
|
||||
src->estimate_tempo ();
|
||||
{
|
||||
Source::WriterLock lm (src->mutex ());
|
||||
src->estimate_tempo ();
|
||||
}
|
||||
if (announce) {
|
||||
SourceCreated (ret);
|
||||
}
|
||||
@@ -276,7 +279,10 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
||||
throw failed_constructor ();
|
||||
}
|
||||
ret->check_for_analysis_data_on_disk ();
|
||||
src->estimate_tempo ();
|
||||
{
|
||||
Source::WriterLock lm (src->mutex ());
|
||||
src->estimate_tempo ();
|
||||
}
|
||||
if (announce) {
|
||||
SourceCreated (ret);
|
||||
}
|
||||
@@ -425,7 +431,10 @@ SourceFactory::createFromPlaylist (DataType type, Session& s, std::shared_ptr<Pl
|
||||
}
|
||||
|
||||
ret->check_for_analysis_data_on_disk ();
|
||||
src->estimate_tempo ();
|
||||
{
|
||||
Source::WriterLock lm (src->mutex ());
|
||||
src->estimate_tempo ();
|
||||
}
|
||||
SourceCreated (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user