diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | appveyor.yml | 2 | ||||
-rwxr-xr-x | plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp | 122 | ||||
-rw-r--r-- | res/skins/Tango/button_hotcue_sam_pre.xml | 4 | ||||
-rw-r--r-- | src/dialog/dlgabout.cpp | 7 | ||||
-rw-r--r-- | src/library/browse/browsetablemodel.cpp | 12 | ||||
-rw-r--r-- | src/preferences/dialog/dlgprefsound.cpp | 9 | ||||
-rw-r--r-- | src/preferences/dialog/dlgprefsound.h | 9 | ||||
-rw-r--r-- | src/preferences/dialog/dlgprefsounditem.cpp | 55 | ||||
-rw-r--r-- | src/preferences/dialog/dlgprefsounditem.h | 16 | ||||
-rw-r--r-- | src/soundio/sounddevice.h | 9 | ||||
-rw-r--r-- | src/soundio/sounddevicenetwork.h | 19 | ||||
-rw-r--r-- | src/soundio/sounddeviceportaudio.cpp | 4 | ||||
-rw-r--r-- | src/soundio/sounddeviceportaudio.h | 19 | ||||
-rw-r--r-- | src/soundio/soundmanager.cpp | 143 | ||||
-rw-r--r-- | src/soundio/soundmanager.h | 18 | ||||
-rw-r--r-- | src/soundio/soundmanagerconfig.cpp | 10 | ||||
-rw-r--r-- | src/util/compatibility.h | 13 | ||||
-rw-r--r-- | src/widget/wtracktableview.cpp | 49 |
19 files changed, 286 insertions, 237 deletions
@@ -66,11 +66,11 @@ Help to spread Mixxx with translations into more languages, as well as to update Mixxx is a vibrant community of hackers, DJs and artists. To keep track of development and community news: +- Chat with us on [Zulip][zulip]. - Follow us on [Twitter], [Facebook], and [G+]. - Subscribe to the [Mixxx Development Blog][blog]. - Join the developer [mailing list]. - Post on the [Mixxx forums][forums]. -- Join our [#mixxx on Freenode IRC][irc channel] to chat with us. ## License @@ -105,3 +105,4 @@ license. [Mixxx localization forum]: http://mixxx.org/forums/viewforum.php?f=10 [Mixxx glossary]: https://www.transifex.com/projects/p/mixxxdj/glossary/l/en/ [hardware compatibility]: http://mixxx.org/wiki/doku.php/hardware_compatibility +[zulip]: https://mixxx.zulipchat.com/ diff --git a/appveyor.yml b/appveyor.yml index 4879ec24a4..9f8934646e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -83,4 +83,4 @@ notifications: on_build_success: true on_build_failure: true on_build_status_changed: true - body: "type=stream&to=appveyor&subject={{projectName}} Build {{buildVersion}} {{status}}&content=Build {{buildVersion}} {{status}}{{#isPullRequest}} (PR #{{pullRequestId}}) {{/isPullRequest}}{{#failed}} :x:{{/failed}}{{#passed}} :y:{{/passed}} {{buildUrl}}" + body: "type=stream&to=appveyor&subject={{projectName}} Build {{buildVersion}} {{status}}&content=Build {{buildVersion}} {{status}}{{#isPullRequest}} (PR #{{pullRequestId}}) {{/isPullRequest}}{{#failed}} :cross_mark:{{/failed}}{{#passed}} :heavy_check_mark:{{/passed}} {{buildUrl}}" diff --git a/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp b/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp index ed39904cf6..3ed0d3b5e8 100755 --- a/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp +++ b/plugins/soundsourcemediafoundation/soundsourcemediafoundation.cpp @@ -484,43 +484,19 @@ ReadableSampleFrames SoundSourceMediaFoundation::readSampleFramesClamped( std::min(writableSampleFrames.writableLength(), frames2samples(numberOfFrames)))); } -//------------------------------------------------------------------- -// configureAudioStream -// -// Selects an audio stream from the source file, and configures the -// stream to deliver decoded PCM audio. -//------------------------------------------------------------------- - -/** Cobbled together from: - http://msdn.microsoft.com/en-us/library/dd757929(v=vs.85).aspx - and http://msdn.microsoft.com/en-us/library/dd317928(VS.85).aspx - -- Albert - If anything in here fails, just bail. I'm not going to decode HRESULTS. - -- Bill - */ -bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) { - HRESULT hr; +namespace { - // deselect all streams, we only want the first - hr = m_pSourceReader->SetStreamSelection( - MF_SOURCE_READER_ALL_STREAMS, false); - if (FAILED(hr)) { - kLogger.warning() << hr - << "failed to deselect all streams"; - return false; - } +bool configureMediaType( + IMFSourceReader* pSourceReader, + SINT *pBitrate, + const AudioSource::OpenParams& params = AudioSource::OpenParams()) { + DEBUG_ASSERT(pSourceReader); + DEBUG_ASSERT(pBitrate); - hr = m_pSourceReader->SetStreamSelection( - kStreamIndex, true); - if (FAILED(hr)) { - kLogger.warning() << hr - << "failed to select first audio stream"; - return false; - } + HRESULT hr; IMFMediaType* pAudioType = nullptr; - - hr = m_pSourceReader->GetCurrentMediaType( + hr = pSourceReader->GetCurrentMediaType( kStreamIndex, &pAudioType); if (FAILED(hr)) { kLogger.warning() << hr @@ -530,16 +506,14 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) //------ Get bitrate from the file, before we change it to get uncompressed audio UINT32 avgBytesPerSecond; - hr = pAudioType->GetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &avgBytesPerSecond); if (FAILED(hr)) { kLogger.warning() << hr << "error getting MF_MT_AUDIO_AVG_BYTES_PER_SECOND"; + safeRelease(&pAudioType); return false; } - - initBitrateOnce( (avgBytesPerSecond * 8) / 1000); - //------ + *pBitrate = (avgBytesPerSecond * 8) / 1000; hr = pAudioType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio); if (FAILED(hr)) { @@ -600,10 +574,10 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) if (FAILED(hr)) { kLogger.warning() << hr << "failed to get actual number of channels"; + safeRelease(&pAudioType); return false; - } else { - qDebug() << "Number of channels in input stream" << numChannels; } + kLogger.debug() << "Number of channels in input stream" << numChannels; if (params.channelCount().valid()) { numChannels = params.channelCount(); hr = pAudioType->SetUINT32( @@ -615,7 +589,7 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) safeRelease(&pAudioType); return false; } - qDebug() << "Requested number of channels" << numChannels; + kLogger.debug() << "Requested number of channels" << numChannels; } UINT32 samplesPerSecond; @@ -624,10 +598,10 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) if (FAILED(hr)) { kLogger.warning() << hr << "failed to get samples per second"; + safeRelease(&pAudioType); return false; - } else { - qDebug() << "Samples per second in input stream" << samplesPerSecond; } + kLogger.debug() << "Samples per second in input stream" << samplesPerSecond; if (params.sampleRate().valid()) { samplesPerSecond = params.sampleRate(); hr = pAudioType->SetUINT32( @@ -639,12 +613,12 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) safeRelease(&pAudioType); return false; } - qDebug() << "Requested samples per second" << samplesPerSecond; + kLogger.debug() << "Requested samples per second" << samplesPerSecond; } // Set this type on the source reader. The source reader will // load the necessary decoder. - hr = m_pSourceReader->SetCurrentMediaType( + hr = pSourceReader->SetCurrentMediaType( kStreamIndex, nullptr, pAudioType); if (FAILED(hr)) { kLogger.warning() << hr @@ -653,15 +627,64 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) return false; } - // Finally release the reference before reusing the pointer safeRelease(&pAudioType); + return true; +} + +} // anonymous namespace + +//------------------------------------------------------------------- +// configureAudioStream +// +// Selects an audio stream from the source file, and configures the +// stream to deliver decoded PCM audio. +//------------------------------------------------------------------- + +/** Cobbled together from: + http://msdn.microsoft.com/en-us/library/dd757929(v=vs.85).aspx + and http://msdn.microsoft.com/en-us/library/dd317928(VS.85).aspx + -- Albert + If anything in here fails, just bail. I'm not going to decode HRESULTS. + -- Bill + */ +bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& openParams) { + HRESULT hr; + + // deselect all streams, we only want the first + hr = m_pSourceReader->SetStreamSelection( + MF_SOURCE_READER_ALL_STREAMS, false); + if (FAILED(hr)) { + kLogger.warning() << hr + << "failed to deselect all streams"; + return false; + } + + hr = m_pSourceReader->SetStreamSelection( + kStreamIndex, true); + if (FAILED(hr)) { + kLogger.warning() << hr + << "failed to select first audio stream"; + return false; + } + + SINT bitrate; + if (!configureMediaType(m_pSourceReader, &bitrate, openParams)) { + // Fallback: Ignore custom params + if (!configureMediaType(m_pSourceReader, &bitrate)) { + kLogger.warning() << "Unsupported media type"; + return false; + } + } + initBitrateOnce(bitrate); // Get the resulting output format. + IMFMediaType* pAudioType = nullptr; hr = m_pSourceReader->GetCurrentMediaType( kStreamIndex, &pAudioType); if (FAILED(hr)) { kLogger.warning() << hr << "failed to retrieve completed media type"; + safeRelease(&pAudioType); return false; } @@ -671,23 +694,28 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) if (FAILED(hr)) { kLogger.warning() << hr << "failed to select first audio stream (again)"; + safeRelease(&pAudioType); return false; } + UINT32 numChannels; hr = pAudioType->GetUINT32( MF_MT_AUDIO_NUM_CHANNELS, &numChannels); if (FAILED(hr)) { kLogger.warning() << hr << "failed to get actual number of channels"; + safeRelease(&pAudioType); return false; } setChannelCount(numChannels); + UINT32 samplesPerSecond; hr = pAudioType->GetUINT32( MF_MT_AUDIO_SAMPLES_PER_SECOND, &samplesPerSecond); if (FAILED(hr)) { kLogger.warning() << hr << "failed to get the actual sample rate"; + safeRelease(&pAudioType); return false; } setSampleRate(samplesPerSecond); @@ -697,6 +725,7 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) if (FAILED(hr)) { kLogger.warning() << hr << "failed to get sample buffer size (in bytes)"; + safeRelease(&pAudioType); return false; } DEBUG_ASSERT((leftoverBufferSizeInBytes % kBytesPerSample) == 0); @@ -709,11 +738,8 @@ bool SoundSourceMediaFoundation::configureAudioStream(const OpenParams& params) kLogger.debug() << "Sample buffer capacity" << m_sampleBuffer.capacity(); - - // Finally release the reference safeRelease(&pAudioType); - return true; } diff --git a/res/skins/Tango/button_hotcue_sam_pre.xml b/res/skins/Tango/button_hotcue_sam_pre.xml index 0848d25deb..8a2787c27a 100644 --- a/res/skins/Tango/button_hotcue_sam_pre.xml +++ b/res/skins/Tango/button_hotcue_sam_pre.xml @@ -31,6 +31,10 @@ Variables: <ButtonState>LeftButton</ButtonState> </Connection> <Connection> + <ConfigKey><Variable name="group"/>,hotcue_<Variable name="HotCue"/>_clear</ConfigKey> + <ButtonState>RightButton</ButtonState> + </Connection> + <Connection> <ConfigKey><Variable name="group"/>,hotcue_<Variable name="HotCue"/>_enabled</ConfigKey> <ConnectValueFromWidget>false</ConnectValueFromWidget> </Connection> diff --git a/src/dialog/dlgabout.cpp b/src/dialog/dlgabout.cpp index b12dc6a00a..1a1a2295c7 100644 --- a/src/dialog/dlgabout.cpp +++ b/src/dialog/dlgabout.cpp @@ -42,7 +42,8 @@ DlgAbout::DlgAbout(QWidget* parent) : QDialog(parent), Ui::DlgAboutDlg() { << "Marcos Cardinot" << "Nicu Badescu" << "Uwe Klotz" - << "Be"; + << "Be" + << "Sébastien Blaisot"; QStringList thisReleaseContributors; thisReleaseContributors @@ -91,7 +92,6 @@ DlgAbout::DlgAbout(QWidget* parent) : QDialog(parent), Ui::DlgAboutDlg() { << "Marco Angerer" << "Ferran Pujol Camins" << "Markus Klösges" - << "Sébastien Blaisot" << "Vladimír Dudr" << "Thorsten Munsch" << "Emile Vrijdags" @@ -126,7 +126,8 @@ DlgAbout::DlgAbout(QWidget* parent) : QDialog(parent), Ui::DlgAboutDlg() { << "Daniel Poelzleithner" << "Artyom Lyan" << "Johan Lasperas" - << "Olaf Hering"; + << "Olaf Hering" + << "Stefan Weber"; QStringList specialThanks; specialThanks diff --git a/src/library/browse/browsetablemodel.cpp b/src/library/browse/browsetablemodel.cpp index 14d9212a65..eab36226f5 100644 --- a/src/library/browse/browsetablemodel.cpp +++ b/src/library/browse/browsetablemodel.cpp @@ -130,9 +130,15 @@ QString BrowseTableModel::getTrackLocation(const QModelIndex& index) const { } TrackId BrowseTableModel::getTrackId(const QModelIndex& index) const { - Q_UNUSED(index); - // We can't implement this as it stands. - return TrackId(); + TrackPointer pTrack = getTrack(index); + if (pTrack) { + return pTrack->getId(); + } else { + qWarning() + << "Track is not available in library" + << getTrackLocation(index); + return TrackId(); + } } const QLinkedList<int> BrowseTableModel::getTrackRows(TrackId trackId) const { diff --git a/src/preferences/dialog/dlgprefsound.cpp b/src/preferences/dialog/dlgprefsound.cpp index 527541ef75..24a371ef22 100644 --- a/src/preferences/dialog/dlgprefsound.cpp +++ b/src/preferences/dialog/dlgprefsound.cpp @@ -21,7 +21,6 @@ #include "engine/enginemaster.h" #include "mixer/playermanager.h" #include "soundio/soundmanager.h" -#include "soundio/sounddevice.h" #include "util/rlimit.h" #include "util/scopedoverridecursor.h" #include "control/controlproxy.h" @@ -290,8 +289,8 @@ void DlgPrefSound::addPath(AudioOutput output) { toInsert = new DlgPrefSoundItem(outputTab, type, m_outputDevices, false); } - connect(this, SIGNAL(refreshOutputDevices(const QList<SoundDevice*>&)), - toInsert, SLOT(refreshDevices(const QList<SoundDevice*>&))); + connect(this, SIGNAL(refreshOutputDevices(const QList<SoundDevicePointer>&)), + toInsert, SLOT(refreshDevices(const QList<SoundDevicePointer>&))); insertItem(toInsert, outputVLayout); connectSoundItem(toInsert); } @@ -321,8 +320,8 @@ void DlgPrefSound::addPath(AudioInput input) { toInsert = new DlgPrefSoundItem(inputTab, type, m_inputDevices, true); } - connect(this, SIGNAL(refreshInputDevices(const QList<SoundDevice*>&)), - toInsert, SLOT(refreshDevices(const QList<SoundDevice*>&))); + connect(this, SIGNAL(refreshInputDevices(const QList<SoundDevicePointer>&)), + toInsert, SLOT(refreshDevices(const QList<SoundDevicePointer>&))); insertItem(toInsert, inputVLayout); connectSoundItem(toInsert); } diff --git a/src/preferences/dialog/dlgprefsound.h b/src/preferences/dialog/dlgprefsound.h index c4cf218f66..a2fb180a24 100644 --- a/src/preferences/dialog/dlgprefsound.h +++ b/src/preferences/dialog/dlgprefsound.h @@ -21,6 +21,7 @@ #include "soundio/soundmanagerconfig.h" #include "soundio/sounddeviceerror.h" #include "preferences/dlgpreferencepage.h" +#include "soundio/sounddevice.h" class SoundManager; class PlayerManager; @@ -49,8 +50,8 @@ class DlgPrefSound : public DlgPreferencePage, public Ui::DlgPrefSoundDlg { signals: void loadPaths(const SoundManagerConfig &config); void writePaths(SoundManagerConfig *config); - void refreshOutputDevices(const QList<SoundDevice*> &devices); - void refreshInputDevices(const QList<SoundDevice*> &devices); + void refreshOutputDevices(const QList<SoundDevicePointer>& devices); + void refreshInputDevices(const QList<SoundDevicePointer>& devices); void updatingAPI(); void updatedAPI(); @@ -106,8 +107,8 @@ class DlgPrefSound : public DlgPreferencePage, public Ui::DlgPrefSoundDlg { ControlProxy* m_pMasterEnabled; ControlProxy* m_pMasterMonoMixdown; ControlProxy* m_pMicMonitorMode; - QList<SoundDevice*> m_inputDevices; - QList<SoundDevice*> m_outputDevices; + QList<SoundDevicePointer> m_inputDevices; + QList<SoundDevicePointer> m_outputDevices; bool m_settingsModified; bool m_bLatencyChanged; bool m_bSkipConfigClear; diff --git a/src/preferences/dialog/dlgprefsounditem.cpp b/src/preferences/dialog/dlgprefsounditem.cpp index 058c40b6e7..cf782731ae 100644 --- a/src/preferences/dialog/dlgprefsounditem.cpp +++ b/src/preferences/dialog/dlgprefsounditem.cpp @@ -18,6 +18,7 @@ #include "preferences/dialog/dlgprefsounditem.h" #include "soundio/sounddevice.h" #include "soundio/soundmanagerconfig.h" +#include "util/compatibility.h" /** * Constructs a new preferences sound item, representing an AudioPath and SoundDevice @@ -28,13 +29,12 @@ * @param isInput true if this is representing an AudioInput, false otherwise * @param index the index of the represented AudioPath, if applicable */ -DlgPrefSoundItem::DlgPrefSoundItem(QWidget *parent, AudioPathType type, - QList<SoundDevice*> &devices, bool isInput, +DlgPrefSoundItem::DlgPrefSoundItem(QWidget* parent, AudioPathType type, + const QList<SoundDevicePointer>& devices, bool isInput, unsigned int index) : QWidget(parent), m_type(type), m_index(index), - m_devices(devices), m_isInput(isInput), m_inhibitSettingChanged(false) { setupUi(this); @@ -45,7 +45,7 @@ DlgPrefSoundItem::DlgPrefSoundItem(QWidget *parent, AudioPathType type, this, SLOT(deviceChanged(int))); connect(channelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(channelChanged())); - refreshDevices(m_devices); + refreshDevices(devices); } DlgPrefSoundItem::~DlgPrefSoundItem() { @@ -56,7 +56,7 @@ DlgPrefSoundItem::~DlgPrefSoundItem() { * Slot called when the parent preferences pane updates its list of sound * devices, to update the item widget's list of devices to display. */ -void DlgPrefSoundItem::refreshDevices(const QList<SoundDevice*> &devices) { +void DlgPrefSoundItem::refreshDevices(const QList<SoundDevicePointer>& devices) { m_devices = devices; QString oldDev = deviceComboBox->itemData(deviceComboBox->currentIndex()).toString(); deviceComboBox->setCurrentIndex(0); @@ -65,9 +65,9 @@ void DlgPrefSoundItem::refreshDevices(const QList<SoundDevice*> &devices) { while (deviceComboBox->count() > 1) { deviceComboBox->removeItem(deviceComboBox->count() - 1); } - foreach (SoundDevice *device, m_devices) { - if (!hasSufficientChannels(device)) continue; - deviceComboBox->addItem(device->getDisplayName(), device->getInternalName()); + for (const auto& pDevice: qAsConst(m_devices)) { + if (!hasSufficientChannels(*pDevice)) continue; + deviceComboBox->addItem(pDevice->getDisplayName(), pDevice->getInternalName()); } int newIndex = deviceComboBox->findData(oldDev); if (newIndex != -1) { @@ -86,12 +86,12 @@ void DlgPrefSoundItem::deviceChanged(int index) { if (selection == "None") { goto emitAndReturn; } else { - foreach (SoundDevice *device, m_devices) { - if (device->getInternalName() == selection) { + for (const auto& pDevice: qAsConst(m_devices)) { + if (pDevice->getInternalName() == selection) { if (m_isInput) { - numChannels = device->getNumInputChannels(); + numChannels = pDevice->getNumInputChannels(); } else { - numChannels = device->getNumOutputChannels(); + numChannels = pDevice->getNumOutputChannels(); } } } @@ -184,9 +184,9 @@ void DlgPrefSoundItem::loadPath(const SoundManagerConfig &config) { * record its respective path with the SoundManagerConfig instance at * config. */ -void DlgPrefSoundItem::writePath(SoundManagerConfig *config) const { - SoundDevice *device = getDevice(); - if (device == NULL) { +void DlgPrefSoundItem::writePath(SoundManagerConfig* config) const { + SoundDevicePointer pDevice = getDevice(); + if (!pDevice) { return; } // otherwise, this will have a valid audiopath @@ -201,11 +201,11 @@ void DlgPrefSoundItem::writePath(SoundManagerConfig *config) const { if (m_isInput) { config->addInput( - device->getInternalName(), + pDevice->getInternalName(), AudioInput(m_type, channelBase, channelCount, m_index)); } else { config->addOutput( - device->getInternalName(), + pDevice->getInternalName(), AudioOutput(m_type, channelBase, channelCount, m_index)); } } @@ -236,19 +236,21 @@ void DlgPrefSoundItem::reload() { * Gets the currently selected SoundDevice * @returns pointer to SoundDevice, or NULL if the "None" option is selected. */ -SoundDevice* DlgPrefSoundItem::getDevice() const { +SoundDevicePointer DlgPrefSoundItem::getDevice() const { QString selection = deviceComboBox->itemData(deviceComboBox->currentIndex()).toString(); if (selection == "None") { - return NULL; + return SoundDevicePointer(); } - foreach (SoundDevice *device, m_devices) { - if (selection == device->getInternalName()) { - return device; + for (const auto& pDevice: qAsConst(m_devices)) { + qDebug() << "1" << pDevice->getDisplayName(); + qDebug() << "2" << pDevice->getInternalName(); + if (selection == pDevice->getInternalName()) { + return pDevice; } } // looks like something became invalid ??? deviceComboBox->setCurrentIndex(0); // set it to none - return NULL; + return SoundDevicePointer(); } /** @@ -290,13 +292,12 @@ void DlgPrefSoundItem::setChannel(unsigned int channelBase, /** * Checks that a given device can act as a source/input for our type. */ -int DlgPrefSoundItem::hasSufficientChannels(const SoundDevice *device) const -{ +int DlgPrefSoundItem::hasSufficientChannels(const SoundDevice& device) const { unsigned char needed(AudioPath::minChannelsForType(m_type)); if (m_isInput) { - return device->getNumInputChannels() >= needed; + return device.getNumInputChannels() >= needed; } else { - return device->getNumOutputChannels() >= needed; + return device.getNumOutputChannels() >= needed; } } diff --git a/src/preferences/dialog/dlgprefsounditem.h b/src/preferences/dialog/dlgprefsounditem.h index 0cbe00dd7f..85e0197952 100644 --- a/src/preferences/dialog/dlgprefsounditem.h +++ b/src/preferences/dialog/dlgprefsounditem.h @@ -18,6 +18,7 @@ #include "preferences/dialog/ui_dlgprefsounditem.h" #include "soundio/soundmanagerutil.h" +#include "soundio/sounddevice.h" class SoundDevice; class SoundManagerConfig; @@ -31,8 +32,9 @@ class SoundManagerConfig; class DlgPrefSoundItem : public QWidget, public Ui::DlgPrefSoundItem { Q_OBJECT public: - DlgPrefSoundItem(QWidget *parent, AudioPathType type, - QList<SoundDevice*> &devices, bool isInput, unsigned int index = 0); + DlgPrefSoundItem(QWidget* parent, AudioPathType type, + const QList<SoundDevicePointer>& devices, + bool isInput, unsigned int index = 0); virtual ~DlgPrefSoundItem(); AudioPathType type() const { return m_type; }; @@ -42,23 +44,23 @@ class DlgPrefSoundItem : public QWidget, public Ui::DlgPrefSoundItem { void settingChanged(); public slots: - void refreshDevices(const QList<SoundDevice*> &devices); + void refreshDevices(const QList<SoundDevicePointer>& devices); void deviceChanged(int index); void channelChanged(); - void loadPath(const SoundManagerConfig &config); + void loadPath(const SoundManagerConfig& config); void writePath(SoundManagerConfig *config) const; void save(); void reload(); private: - SoundDevice* getDevice() const; // if this returns NULL, we don't have a valid AudioPath + SoundDevicePointer getDevice() const; // if this returns NULL, we don't have a valid AudioPath void setDevice(const QString &deviceName); void setChannel(unsigned int channelBase, unsigned int channels); - int hasSufficientChannels(const SoundDevice *device) const; + int hasSufficientChannels(const SoundDevice& device) const; AudioPathType m_type; unsigned int m_index; - QList<SoundDevice*> m_devices; + QList<SoundDevicePointer> m_devices; bool m_isInput; QString m_savedDevice; // Because QVariant supports QPoint natively we use a QPoint to store the diff --git a/src/soundio/sounddevice.h b/src/soundio/sounddevice.h index 7c3c719332..4db9a349ca 100644 --- a/src/soundio/sounddevice.h +++ b/src/soundio/sounddevice.h @@ -21,14 +21,17 @@ #include <QString> #include <QList> -#include "soundio/soundmanager.h" +#include "util/types.h" +#include "preferences/usersettings.h" #include "soundio/sounddeviceerror.h" +#include "soundio/sounddevice.h" -//Forward declarations class SoundDevice; class SoundManager; class AudioOutput; class AudioInput; +class AudioOutputBuffer; +class AudioInputBuffer; const QString kNetworkDeviceInternalName = "Network stream"; @@ -105,4 +108,6 @@ class SoundDevice { QList<AudioInputBuffer> m_audioInputs; }; +typedef QSharedPointer<SoundDevice> SoundDevicePointer; + #endif diff --git a/src/soundio/sounddevicenetwork.h b/src/soundio/sounddevicenetwork.h index 7c69a1be0f..8f4d5dad02 100644 --- a/src/soundio/sounddevicenetwork.h +++ b/src/soundio/sounddevicenetwork.h @@ -12,6 +12,7 @@ #include "util/performancetimer.h" #include "util/memory.h" #include "soundio/sounddevice.h" +#include "engine/sidechain/networkoutputstreamworker.h" #define CPU_USAGE_UPDATE_RATE 30 // in 1/s, fits to display frame rate #define CPU_OVERLOAD_DURATION 500 // in ms @@ -25,18 +26,18 @@ class SoundDeviceNetworkThread; class SoundDeviceNetwork : public SoundDevice { public: SoundDeviceNetwork(UserSettingsPointer config, - SoundManager *sm, + SoundManager* sm, QSharedPointer<EngineNetworkStream> pNetworkStream); - virtual ~SoundDeviceNetwork(); + ~SoundDeviceNetwork() override; - virtual SoundDeviceError open(bool isClkRefDevice, int syncBuffers); - virtual bool isOpen() const; - virtual SoundDeviceError close(); - virtual void readProcess(); - virtual void writeProcess(); - virtual QString getError() const; + SoundDeviceError open(bool isClkRefDevice, int syncBuffers) override; + bool isOpen() const override; + SoundDeviceError close() override; + void readProcess() override; + void writeProcess() override; + QString getError() const override; - virtual unsigned int getDefaultSampleRate() const { + unsigned int getDefaultSampleRate() const override { return 44100; } diff --git a/src/soundio/sounddeviceportaudio.cpp b/src/soundio/sounddeviceportaudio.cpp index 6b8b916194..d189d1416b 100644 --- a/src/soundio/sounddeviceportaudio.cpp +++ b/src/soundio/sounddeviceportaudio.cpp @@ -88,8 +88,8 @@ int paV19CallbackClkRef(const void *inputBuffer, void *outputBuffer, SoundDevicePortAudio::SoundDevicePortAudio(UserSettingsPointer config, - SoundManager *sm, - const PaDeviceInfo *deviceInfo, + SoundManager* sm, + const PaDeviceInfo* deviceInfo, unsigned int devIndex) : SoundDevice(config, sm), m_pStream(NULL), diff --git a/src/soundio/sounddeviceportaudio.h b/src/soundio/sounddeviceportaudio.h index 70190b2d10..169c724923 100644 --- a/src/soundio/sounddeviceportaudio.h +++ b/src/soundio/sounddeviceportaudio.h @@ -25,6 +25,7 @@ #include "soundio/sounddevice.h" #include "util/duration.h" +#include "util/fifo.h" #define CPU_USAGE_UPDATE_RATE 30 // in 1/s, fits to display frame rate @@ -39,16 +40,16 @@ typedef int (*EnableAlsaRT)(PaStream* s, int enable); class SoundDevicePortAudio : public SoundDevice { public: SoundDevicePortAudio(UserSettingsPointer config, - SoundManager *sm, const PaDeviceInfo *deviceInfo, + SoundManager* sm, const PaDeviceInfo* deviceInfo, unsigned int devIndex); - virtual ~SoundDevicePortAudio(); + ~SoundDevicePortAudio() override; - virtual SoundDeviceError open(bool isClkRefDevice, int syncBuffers); - virtual bool isOpen() const; - virtual SoundDeviceError close(); - virtual void readProcess(); - virtual void writeProcess(); - virtual QString getError() const; + SoundDeviceError open(bool isClkRefDevice, int syncBuffers) override; + bool isOpen() const override; + SoundDeviceError close() override; + void readProcess() override; + void writeProcess() override; + QString getError() const override; // This callback function gets called everytime the sound device runs out of // samples (ie. when it needs more sound to play) @@ -67,7 +68,7 @@ class SoundDevicePortAudio : public SoundDevice { const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags); - virtual unsigned int getDefaultSampleRate() const { + unsigned int getDefaultSampleRate() const override { return m_deviceInfo ? static_cast<unsigned int>( m_deviceInfo->defaultSampleRate) : 44100; } diff --git a/src/soundio/soundmanager.cpp b/src/soundio/soundmanager.cpp index 1bf64ae2a5..ce2cb5dd1f 100644 --- a/src/soundio/soundmanager.cpp +++ b/src/soundio/soundmanager.cpp @@ -51,7 +51,7 @@ namespace { #define CPU_OVERLOAD_DURATION 500 // in ms struct DeviceMode { - SoundDevice* device; + SoundDevicePointer pDevice; bool isInput; bool isOutput; }; @@ -123,29 +123,28 @@ SoundManager::~SoundManager() { delete m_pMasterAudioLatencyOverload; } -QList<SoundDevice*> SoundManager::getDeviceList( - QString filterAPI, bool bOutputDevices, bool bInputDevices) { +QList<SoundDevicePointer> SoundManager::getDeviceList( + QString filterAPI, bool bOutputDevices, bool bInputDevices) const { //qDebug() << "SoundManager::getDeviceList"; if (filterAPI == "None") { - QList<SoundDevice*> emptyList; - |