Maybe nicer fix for restoring the play range. Use recursive mutex in audio source.
This commit is contained in:
parent
1d283c419c
commit
552c165628
@ -36,6 +36,8 @@ inline double ramp(int64_t pos, int64_t totallen, int64_t rampinlen, int64_t ram
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using LockGuard = std::lock_guard<std::recursive_mutex>;
|
||||||
|
|
||||||
class AInputS final : public InputS
|
class AInputS final : public InputS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -51,7 +53,7 @@ public:
|
|||||||
|
|
||||||
void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len)
|
void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
LockGuard locker(m_mutex);
|
||||||
m_afreader = nullptr;
|
m_afreader = nullptr;
|
||||||
m_using_memory_buffer = true;
|
m_using_memory_buffer = true;
|
||||||
m_readbuf = *buf;
|
m_readbuf = *buf;
|
||||||
@ -77,7 +79,7 @@ public:
|
|||||||
AudioFormatReader* reader = m_manager->createReaderFor(file);
|
AudioFormatReader* reader = m_manager->createReaderFor(file);
|
||||||
if (reader)
|
if (reader)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
LockGuard locker(m_mutex);
|
||||||
m_using_memory_buffer = false;
|
m_using_memory_buffer = false;
|
||||||
m_afreader = std::unique_ptr<AudioFormatReader>(reader);
|
m_afreader = std::unique_ptr<AudioFormatReader>(reader);
|
||||||
if (m_activerange.isEmpty())
|
if (m_activerange.isEmpty())
|
||||||
@ -107,7 +109,7 @@ public:
|
|||||||
}
|
}
|
||||||
int readNextBlock(AudioBuffer<float>& abuf, int nsmps, int numchans) override
|
int readNextBlock(AudioBuffer<float>& abuf, int nsmps, int numchans) override
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
LockGuard locker(m_mutex);
|
||||||
if (m_afreader == nullptr && m_using_memory_buffer == false)
|
if (m_afreader == nullptr && m_using_memory_buffer == false)
|
||||||
{
|
{
|
||||||
jassert(false);
|
jassert(false);
|
||||||
@ -281,9 +283,9 @@ public:
|
|||||||
}
|
}
|
||||||
void seek(double pos) override //0=start,1.0=end
|
void seek(double pos) override //0=start,1.0=end
|
||||||
{
|
{
|
||||||
seekImpl(pos);
|
//seekImpl(pos);
|
||||||
/*
|
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
LockGuard locker(m_mutex);
|
||||||
if (m_seekfade.state == 0)
|
if (m_seekfade.state == 0)
|
||||||
{
|
{
|
||||||
m_seekfade.state = 1;
|
m_seekfade.state = 1;
|
||||||
@ -291,7 +293,7 @@ public:
|
|||||||
}
|
}
|
||||||
m_seekfade.length = 16384;
|
m_seekfade.length = 16384;
|
||||||
m_seekfade.requestedpos = pos;
|
m_seekfade.requestedpos = pos;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Range<double>,Range<double>> getCachedRangesNormalized()
|
std::pair<Range<double>,Range<double>> getCachedRangesNormalized()
|
||||||
@ -330,7 +332,7 @@ public:
|
|||||||
}
|
}
|
||||||
void setActiveRange(Range<double> rng) override
|
void setActiveRange(Range<double> rng) override
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
LockGuard locker(m_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (rng.contains(getCurrentPositionPercent()))
|
if (rng.contains(getCurrentPositionPercent()))
|
||||||
@ -393,7 +395,7 @@ private:
|
|||||||
int64_t m_loopcount = 0;
|
int64_t m_loopcount = 0;
|
||||||
bool m_using_memory_buffer = true;
|
bool m_using_memory_buffer = true;
|
||||||
AudioFormatManager* m_manager = nullptr;
|
AudioFormatManager* m_manager = nullptr;
|
||||||
std::mutex m_mutex;
|
std::recursive_mutex m_mutex;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int state = 0; // 0 inactive, 1 seek requested, 2 fade out, 3 fade in
|
int state = 0; // 0 inactive, 1 seek requested, 2 fade out, 3 fade in
|
||||||
|
@ -727,7 +727,7 @@ void StretchAudioSource::setOnsetDetection(double x)
|
|||||||
|
|
||||||
void StretchAudioSource::setPlayRange(Range<double> playrange)
|
void StretchAudioSource::setPlayRange(Range<double> playrange)
|
||||||
{
|
{
|
||||||
if (m_playrange.isEmpty() == false && playrange == m_playrange)
|
if ((m_playrange.isEmpty() == false && playrange == m_playrange) || playrange==m_inputfile->getActiveRange())
|
||||||
return;
|
return;
|
||||||
if (m_cs.tryEnter())
|
if (m_cs.tryEnter())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user