-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
reduce memory usage for Echo effect #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,21 @@ class SoundManager : public QObject { | |
| SoundManager(UserSettingsPointer pConfig, EngineMaster *_master); | ||
| virtual ~SoundManager(); | ||
|
|
||
| // PortAudio sample rate enumeration is very slow on Linux | ||
| // (ALSA dmix sucks, so we can't blame PortAudio), so use this static | ||
| // list of supported sample rates. | ||
|
|
||
| // There is no reason Mixxx should support higher sample rates for playback, | ||
| // even if a user's sound card does. It provides no benefit and is likely to | ||
| // introduce introduce intermodulation distortion when playing ultrasonic | ||
| // frequencies. Refer to http://xiph.org/~xiphmont/demo/neil-young.html | ||
| // for details. | ||
| constexpr static const unsigned int s_iSupportedSampleRates[3] = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be private. Do you explicitly need to state the size here? |
||
| 44100, | ||
| 48000, | ||
| 96000 | ||
| }; | ||
|
|
||
| // Returns a list of all devices we've enumerated that match the provided | ||
| // filterApi, and have at least one output or input channel if the | ||
| // bOutputDevices or bInputDevices are set, respectively. | ||
|
|
@@ -82,12 +97,6 @@ class SoundManager : public QObject { | |
| QString getErrorDeviceName() const; | ||
| QString getLastErrorMessage(SoundDeviceError err) const; | ||
|
|
||
| // Returns a list of samplerates we will attempt to support for a given API. | ||
| QList<unsigned int> getSampleRates(QString api) const; | ||
|
|
||
| // Convenience overload for SoundManager::getSampleRates(QString) | ||
| QList<unsigned int> getSampleRates() const; | ||
|
|
||
| // Get a list of host APIs supported by PortAudio. | ||
| QList<QString> getHostAPIList() const; | ||
| SoundManagerConfig getConfig() const; | ||
|
|
@@ -150,7 +159,6 @@ class SoundManager : public QObject { | |
| unsigned int m_jackSampleRate; | ||
| #endif | ||
| QList<SoundDevice*> m_devices; | ||
| QList<unsigned int> m_samplerates; | ||
| QList<CSAMPLE*> m_inputBuffers; | ||
|
|
||
| SoundManagerConfig m_config; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,11 +216,13 @@ void SoundManagerConfig::setForceNetworkClock(bool force) { | |
| * @returns false if the sample rate is not found in SoundManager's list, | ||
| * otherwise true | ||
| */ | ||
| bool SoundManagerConfig::checkSampleRate(const SoundManager &soundManager) { | ||
| if (!soundManager.getSampleRates(m_api).contains(m_sampleRate)) { | ||
| return false; | ||
| bool SoundManagerConfig::checkSampleRate() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced by: |
||
| for (const unsigned int& rate : SoundManager::s_iSupportedSampleRates) { | ||
| if (rate == m_sampleRate) { | ||
| return true; | ||
| } | ||
| } | ||
| return true; | ||
| return false; | ||
| } | ||
|
|
||
| unsigned int SoundManagerConfig::getDeckCount() const { | ||
|
|
@@ -398,15 +400,15 @@ void SoundManagerConfig::loadDefaults(SoundManager *soundManager, unsigned int f | |
| } | ||
| } | ||
| if (flags & SoundManagerConfig::OTHER) { | ||
| QList<unsigned int> sampleRates = soundManager->getSampleRates(m_api); | ||
| if (sampleRates.contains(defaultSampleRate)) { | ||
| m_sampleRate = defaultSampleRate; | ||
| } else if (sampleRates.contains(kFallbackSampleRate)) { | ||
| m_sampleRate = kFallbackSampleRate; | ||
| } else if (!sampleRates.isEmpty()) { | ||
| m_sampleRate = sampleRates.first(); | ||
| } else { | ||
| qWarning() << "got empty sample rate list from SoundManager, this is a bug"; | ||
| m_sampleRate = defaultSampleRate; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| bool bDefaultSampleRateIsSupported = false; | ||
| for (const unsigned int& rate : SoundManager::s_iSupportedSampleRates) { | ||
| if (rate == defaultSampleRate) { | ||
| bDefaultSampleRateIsSupported = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!bDefaultSampleRateIsSupported) { | ||
| m_sampleRate = kFallbackSampleRate; | ||
| } | ||
| m_audioBufferSizeIndex = kDefaultAudioBufferSizeIndex; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some static functions to SoundManager to avoid leaking internal storage and ordering and to make the code more readable:
static constexpr SINT minSupportedSampleRate()
static constexpr SINT maxSupportedSampleRate()
static bool isSupportedSampleRate(SINT sampleRate)