Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into revamp-buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Oct 31, 2024
2 parents 3d53aa8 + 9912fd8 commit acfbfc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
19 changes: 16 additions & 3 deletions include/AudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <memory>
#include <vector>

#include "AudioDevice.h"
#include "lmms_basics.h"
#include "SampleFrame.h"
#include "LocklessList.h"
Expand Down Expand Up @@ -230,9 +231,20 @@ class LMMS_EXPORT AudioEngine : public QObject
}


sample_rate_t baseSampleRate() const;
sample_rate_t outputSampleRate() const;
sample_rate_t inputSampleRate() const;
sample_rate_t baseSampleRate() const { return m_baseSampleRate; }


sample_rate_t outputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() : m_baseSampleRate;
}


sample_rate_t inputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() : m_baseSampleRate;
}


inline float masterGain() const
{
Expand Down Expand Up @@ -325,6 +337,7 @@ class LMMS_EXPORT AudioEngine : public QObject
SampleFrame* m_inputBuffer[2];
f_cnt_t m_inputBufferFrames[2];
f_cnt_t m_inputBufferSize[2];
sample_rate_t m_baseSampleRate;
int m_inputBufferRead;
int m_inputBufferWrite;

Expand Down
29 changes: 1 addition & 28 deletions src/core/AudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ AudioEngine::AudioEngine( bool renderOnly ) :
m_framesPerPeriod(std::clamp(ConfigManager::inst()
->value("audioengine", "framesperaudiobuffer", QString::number(AudioEngine::DefaultBufferSize))
.toInt(), AudioEngine::MinimumBufferSize, AudioEngine::MaximumBufferSize)),
m_baseSampleRate(std::max(ConfigManager::inst()->value("audioengine", "samplerate").toInt(), 44100)),
m_inputBufferRead( 0 ),
m_inputBufferWrite( 1 ),
m_outputBufferRead(nullptr),
Expand Down Expand Up @@ -180,34 +181,6 @@ void AudioEngine::stopProcessing()



sample_rate_t AudioEngine::baseSampleRate() const
{
sample_rate_t sr = ConfigManager::inst()->value( "audioengine", "samplerate" ).toInt();
if( sr < 44100 )
{
sr = 44100;
}
return sr;
}




sample_rate_t AudioEngine::outputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() :
baseSampleRate();
}




sample_rate_t AudioEngine::inputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() :
baseSampleRate();
}

bool AudioEngine::criticalXRuns() const
{
return cpuLoad() >= 99 && Engine::getSong()->isExporting() == false;
Expand Down

0 comments on commit acfbfc4

Please sign in to comment.