summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mixxx.cpp8
-rw-r--r--src/preferences/dialog/dlgprefsound.cpp4
-rw-r--r--src/soundio/sounddevice.h13
-rw-r--r--src/soundio/sounddeviceerror.h13
-rw-r--r--src/soundio/sounddevicenetwork.cpp8
-rw-r--r--src/soundio/sounddevicenetwork.h4
-rw-r--r--src/soundio/sounddeviceportaudio.cpp22
-rw-r--r--src/soundio/sounddeviceportaudio.h4
-rw-r--r--src/soundio/soundmanager.cpp39
-rw-r--r--src/soundio/soundmanager.h8
10 files changed, 63 insertions, 60 deletions
diff --git a/src/mixxx.cpp b/src/mixxx.cpp
index d7511d7d47..10238ef295 100644
--- a/src/mixxx.cpp
+++ b/src/mixxx.cpp
@@ -397,14 +397,14 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
}
// Try open player device If that fails, the preference panel is opened.
- int setupDevices = m_pSoundManager->setupDevices();
+ SoundDeviceError result = m_pSoundManager->setupDevices();
unsigned int numDevices = m_pSoundManager->getConfig().getOutputs().count();
// test for at least one out device, if none, display another dlg that
// says "mixxx will barely work with no outs"
- while (setupDevices != OK || numDevices == 0) {
+ while (result != SOUNDDEVICE_ERROR_OK || numDevices == 0) {
// Exit when we press the Exit button in the noSoundDlg dialog
- // only call it if setupDevices != OK
- if (setupDevices != OK) {
+ // only call it if result != OK
+ if (result != SOUNDDEVICE_ERROR_OK) {
if (noSoundDlg() != 0) {
exit(0);
}
diff --git a/src/preferences/dialog/dlgprefsound.cpp b/src/preferences/dialog/dlgprefsound.cpp
index efb03edf5c..e0c0607278 100644
--- a/src/preferences/dialog/dlgprefsound.cpp
+++ b/src/preferences/dialog/dlgprefsound.cpp
@@ -192,7 +192,7 @@ void DlgPrefSound::slotApply() {
return;
}
- int err = OK;
+ SoundDeviceError err = SOUNDDEVICE_ERROR_OK;
{
ScopedWaitCursor cursor;
m_pKeylockEngine->set(keylockComboBox->currentIndex());
@@ -204,7 +204,7 @@ void DlgPrefSound::slotApply() {
emit(writePaths(&m_config));
err = m_pSoundManager->setConfig(m_config);
}
- if (err != OK) {
+ if (err != SOUNDDEVICE_ERROR_OK) {
QString error;
QString deviceName(tr("a device"));
QString detailedError(tr("An unknown error occurred"));
diff --git a/src/soundio/sounddevice.h b/src/soundio/sounddevice.h
index c499779ffe..4084d2ffbb 100644
--- a/src/soundio/sounddevice.h
+++ b/src/soundio/sounddevice.h
@@ -22,7 +22,7 @@
#include <QList>
#include "soundio/soundmanager.h"
-#include "util/result.h"
+#include "soundio/sounddeviceerror.h"
//Forward declarations
class SoundDevice;
@@ -30,13 +30,6 @@ class SoundManager;
class AudioOutput;
class AudioInput;
-enum SoundDeviceError {
- SOUNDDEVICE_ERROR_OK = OK,
- SOUNDDEVICE_ERROR_DUPLICATE_OUTPUT_CHANNEL,
- SOUNDDEVICE_ERROR_EXCESSIVE_OUTPUT_CHANNEL,
- SOUNDDEVICE_ERROR_EXCESSIVE_INPUT_CHANNEL,
-};
-
const QString kNetworkDeviceInternalName = "Network stream";
class SoundDevice {
@@ -55,9 +48,9 @@ class SoundDevice {
}
void setSampleRate(double sampleRate);
void setFramesPerBuffer(unsigned int framesPerBuffer);
- virtual Result open(bool isClkRefDevice, int syncBuffers) = 0;
+ virtual SoundDeviceError open(bool isClkRefDevice, int syncBuffers) = 0;
virtual bool isOpen() const = 0;
- virtual Result close() = 0;
+ virtual SoundDeviceError close() = 0;
virtual void readProcess() = 0;
virtual void writeProcess() = 0;
virtual QString getError() const = 0;
diff --git a/src/soundio/sounddeviceerror.h b/src/soundio/sounddeviceerror.h
new file mode 100644
index 0000000000..1157ebd5fb
--- /dev/null
+++ b/src/soundio/sounddeviceerror.h
@@ -0,0 +1,13 @@
+#ifndef SOUNDDEVICEERROR_H
+#define SOUNDDEVICEERROR_H
+
+// Used for returning errors from sounddevice functions.
+enum SoundDeviceError {
+ SOUNDDEVICE_ERROR_ERR = -1,
+ SOUNDDEVICE_ERROR_OK = 0,
+ SOUNDDEVICE_ERROR_DUPLICATE_OUTPUT_CHANNEL,
+ SOUNDDEVICE_ERROR_EXCESSIVE_OUTPUT_CHANNEL,
+ SOUNDDEVICE_ERROR_EXCESSIVE_INPUT_CHANNEL,
+};
+
+#endif /* SOUNDDEVICEERROR_H */
diff --git a/src/soundio/sounddevicenetwork.cpp b/src/soundio/sounddevicenetwork.cpp
index 2bb50b3880..ad0631ec6b 100644
--- a/src/soundio/sounddevicenetwork.cpp
+++ b/src/soundio/sounddevicenetwork.cpp
@@ -32,7 +32,7 @@ SoundDeviceNetwork::SoundDeviceNetwork(UserSettingsPointer config,
SoundDeviceNetwork::~SoundDeviceNetwork() {
}
-Result SoundDeviceNetwork::open(bool isClkRefDevice, int syncBuffers) {
+SoundDeviceError SoundDeviceNetwork::open(bool isClkRefDevice, int syncBuffers) {
Q_UNUSED(syncBuffers);
qDebug() << "SoundDeviceNetwork::open()" << getInternalName();
@@ -68,14 +68,14 @@ Result SoundDeviceNetwork::open(bool isClkRefDevice, int syncBuffers) {
m_pNetworkStream->startStream(m_dSampleRate);
- return OK;
+ return SOUNDDEVICE_ERROR_OK;
}
bool SoundDeviceNetwork::isOpen() const {
return (m_inputFifo != NULL || m_outputFifo != NULL);
}
-Result SoundDeviceNetwork::close() {
+SoundDeviceError SoundDeviceNetwork::close() {
//qDebug() << "SoundDeviceNetwork::close()" << getInternalName();
m_pNetworkStream->stopStream();
if (m_outputFifo) {
@@ -86,7 +86,7 @@ Result SoundDeviceNetwork::close() {
delete m_inputFifo;
m_inputFifo = NULL;
}
- return OK;
+ return SOUNDDEVICE_ERROR_OK;
}
QString SoundDeviceNetwork::getError() const {
diff --git a/src/soundio/sounddevicenetwork.h b/src/soundio/sounddevicenetwork.h
index 21224dae8b..2bc315ed2d 100644
--- a/src/soundio/sounddevicenetwork.h
+++ b/src/soundio/sounddevicenetwork.h
@@ -18,9 +18,9 @@ class SoundDeviceNetwork : public SoundDevice {
QSharedPointer<EngineNetworkStream> pNetworkStream);
virtual ~SoundDeviceNetwork();
- virtual Result open(bool isClkRefDevice, int syncBuffers);
+ virtual SoundDeviceError open(bool isClkRefDevice, int syncBuffers);
virtual bool isOpen() const;
- virtual Result close();
+ virtual SoundDeviceError close();
virtual void readProcess();
virtual void writeProcess();
virtual QString getError() const;
diff --git a/src/soundio/sounddeviceportaudio.cpp b/src/soundio/sounddeviceportaudio.cpp
index 566c441524..4e2a1ff07f 100644
--- a/src/soundio/sounddeviceportaudio.cpp
+++ b/src/soundio/sounddeviceportaudio.cpp
@@ -142,7 +142,7 @@ SoundDevicePortAudio::~SoundDevicePortAudio() {
delete m_pMasterAudioLatencyOverload;
}
-Result SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers) {
+SoundDeviceError SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers) {
qDebug() << "SoundDevicePortAudio::open()" << getInternalName();
PaError err;
@@ -150,7 +150,7 @@ Result SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers) {
m_lastError = QString::fromAscii(
"No inputs or outputs in SDPA::open() "
"(THIS IS A BUG, this should be filtered by SM::setupDevices)");
- return ERR;
+ return SOUNDDEVICE_ERROR_ERR;
}
memset(&m_outputParams, 0, sizeof(m_outputParams));
@@ -318,7 +318,7 @@ Result SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers) {
if (err != paNoError) {
qWarning() << "Error opening stream:" << Pa_GetErrorText(err);
m_lastError = QString::fromUtf8(Pa_GetErrorText(err));
- return ERR;
+ return SOUNDDEVICE_ERROR_ERR;
} else {
qDebug() << "Opened PortAudio stream successfully... starting";
}
@@ -351,7 +351,7 @@ Result SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers) {
qWarning() << "PortAudio: Close stream error:"
<< Pa_GetErrorText(err) << getInternalName();
}
- return ERR;
+ return SOUNDDEVICE_ERROR_ERR;
} else {
qDebug() << "PortAudio: Started stream successfully";
}
@@ -377,14 +377,14 @@ Result SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers) {
m_invalidTimeInfoCount = 0;
}
m_pStream = pStream;
- return OK;
+ return SOUNDDEVICE_ERROR_OK;
}
bool SoundDevicePortAudio::isOpen() const {
return m_pStream != NULL;
}
-Result SoundDevicePortAudio::close() {
+SoundDeviceError SoundDevicePortAudio::close() {
//qDebug() << "SoundDevicePortAudio::close()" << getInternalName();
PaStream* pStream = m_pStream;
m_pStream = NULL;
@@ -394,13 +394,13 @@ Result SoundDevicePortAudio::close() {
// 1 means the stream is stopped. 0 means active.
if (err == 1) {
//qDebug() << "PortAudio: Stream already stopped, but no error.";
- return OK;
+ return SOUNDDEVICE_ERROR_OK;
}
// Real PaErrors are always negative.
if (err < 0) {
qWarning() << "PortAudio: Stream already stopped:"
<< Pa_GetErrorText(err) << getInternalName();
- return ERR;
+ return SOUNDDEVICE_ERROR_ERR;
}
//Stop the stream.
@@ -416,7 +416,7 @@ Result SoundDevicePortAudio::close() {
if (err != paNoError) {
qWarning() << "PortAudio: Stop stream error:"
<< Pa_GetErrorText(err) << getInternalName();
- return ERR;
+ return SOUNDDEVICE_ERROR_ERR;
}
// Close stream
@@ -424,7 +424,7 @@ Result SoundDevicePortAudio::close() {
if (err != paNoError) {
qWarning() << "PortAudio: Close stream error:"
<< Pa_GetErrorText(err) << getInternalName();
- return ERR;
+ return SOUNDDEVICE_ERROR_ERR;
}
if (m_outputFifo) {
@@ -439,7 +439,7 @@ Result SoundDevicePortAudio::close() {
m_inputFifo = NULL;
m_bSetThreadPriority = false;
- return OK;
+ return SOUNDDEVICE_ERROR_OK;
}
QString SoundDevicePortAudio::getError() const {
diff --git a/src/soundio/sounddeviceportaudio.h b/src/soundio/sounddeviceportaudio.h
index e644218ea8..de753d846b 100644
--- a/src/soundio/sounddeviceportaudio.h
+++ b/src/soundio/sounddeviceportaudio.h
@@ -45,9 +45,9 @@ class SoundDevicePortAudio : public SoundDevice {
unsigned int devIndex);
virtual ~SoundDevicePortAudio();
- virtual Result open(bool isClkRefDevice, int syncBuffers);
+ virtual SoundDeviceError open(bool isClkRefDevice, int syncBuffers);
virtual bool isOpen() const;
- virtual Result close();
+ virtual SoundDeviceError close();
virtual void readProcess();
virtual void writeProcess();
virtual QString getError() const;
diff --git a/src/soundio/soundmanager.cpp b/src/soundio/soundmanager.cpp
index 98863b850c..e99ca4f71c 100644
--- a/src/soundio/soundmanager.cpp
+++ b/src/soundio/soundmanager.cpp
@@ -313,13 +313,13 @@ void SoundManager::queryDevicesMixxx() {
m_devices.push_back(currentDevice);
}
-Result SoundManager::setupDevices() {
+SoundDeviceError SoundManager::setupDevices() {
// NOTE(rryan): Big warning: This function is concurrent with calls to
// pushBuffer and onDeviceOutputCallback until closeDevices() below.
qDebug() << "SoundManager::setupDevices()";
m_pControlObjectSoundStatusCO->set(SOUNDMANAGER_CONNECTING);
- Result err = OK;
+ SoundDeviceError err = SOUNDDEVICE_ERROR_OK;
// NOTE(rryan): Do not clear m_pClkRefDevice here. If we didn't touch the
// SoundDevice that is the clock reference, then it is safe to leave it as
// it was. Clearing it causes the engine to stop being processed which
@@ -367,8 +367,8 @@ Result SoundManager::setupDevices() {
// TODO(bkgood) look into allocating this with the frames per
// buffer value from SMConfig
AudioInputBuffer aib(in, SampleUtil::alloc(MAX_BUFFER_LEN));
- err = device->addInput(aib) != SOUNDDEVICE_ERROR_OK ? ERR : OK;
- if (err != OK) {
+ err = device->addInput(aib);
+ if (err != SOUNDDEVICE_ERROR_OK) {
delete [] aib.getBuffer();
goto closeAndError;
}
@@ -406,8 +406,8 @@ Result SoundManager::setupDevices() {
}
AudioOutputBuffer aob(out, pBuffer);
- err = device->addOutput(aob) != SOUNDDEVICE_ERROR_OK ? ERR : OK;
- if (err != OK) goto closeAndError;
+ err = device->addOutput(aob);
+ if (err != SOUNDDEVICE_ERROR_OK) goto closeAndError;
if (out.getType() == AudioOutput::MASTER) {
pNewMasterClockRef = device;
} else if ((out.getType() == AudioOutput::DECK ||
@@ -453,16 +453,13 @@ Result SoundManager::setupDevices() {
syncBuffers = 2;
}
err = device->open(pNewMasterClockRef == device, syncBuffers);
- if (err != OK) {
- goto closeAndError;
- } else {
- ++devicesOpened;
- if (mode.isOutput) {
- ++outputDevicesOpened;
- }
- if (mode.isInput) {
- ++inputDevicesOpened;
- }
+ if (err != SOUNDDEVICE_ERROR_OK) goto closeAndError;
+ ++devicesOpened;
+ if (mode.isOutput) {
+ ++outputDevicesOpened;
+ }
+ if (mode.isInput) {
+ ++inputDevicesOpened;
}
}
@@ -483,10 +480,10 @@ Result SoundManager::setupDevices() {
// returns OK if we were able to open all the devices the user wanted
if (devicesAttempted == devicesOpened) {
emit(devicesSetup());
- return OK;
+ return SOUNDDEVICE_ERROR_OK;
}
m_pErrorDevice = NULL;
- return ERR;
+ return SOUNDDEVICE_ERROR_ERR;
closeAndError:
const bool sleepAfterClosing = false;
@@ -502,8 +499,8 @@ SoundManagerConfig SoundManager::getConfig() const {
return m_config;
}
-Result SoundManager::setConfig(SoundManagerConfig config) {
- Result err = OK;
+SoundDeviceError SoundManager::setConfig(SoundManagerConfig config) {
+ SoundDeviceError err = SOUNDDEVICE_ERROR_OK;
m_config = config;
checkConfig();
@@ -519,7 +516,7 @@ Result SoundManager::setConfig(SoundManagerConfig config) {
m_pConfig->set(ConfigKey("[Soundcard]","Samplerate"), ConfigValue(m_config.getSampleRate()));
err = setupDevices();
- if (err == OK) {
+ if (err == SOUNDDEVICE_ERROR_OK) {
m_config.writeToDisk();
}
return err;
diff --git a/src/soundio/soundmanager.h b/src/soundio/soundmanager.h
index 653678ddb7..c4ca24d2d0 100644
--- a/src/soundio/soundmanager.h
+++ b/src/soundio/soundmanager.h
@@ -25,10 +25,10 @@
#include "preferences/usersettings.h"
#include "engine/sidechain/enginenetworkstream.h"
#include "soundio/soundmanagerconfig.h"
-#include "util/result.h"
+#include "soundio/sounddevice.h"
+#include "soundio/sounddeviceerror.h"
#include "util/types.h"
-class SoundDevice;
class EngineMaster;
class AudioOutput;
class AudioInput;
@@ -66,7 +66,7 @@ class SoundManager : public QObject {
// Opens all the devices chosen by the user in the preferences dialog, and
// establishes the proper connections between them and the mixing engine.
- Result setupDevices();
+ SoundDeviceError setupDevices();
// Playermanager will notify us when the number of decks changes.
void setConfiguredDeckCount(int count);
@@ -83,7 +83,7 @@ class SoundManager : public QObject {
// Get a list of host APIs supported by PortAudio.
QList<QString> getHostAPIList() const;
SoundManagerConfig getConfig() const;
- Result setConfig(SoundManagerConfig config);
+ SoundDeviceError setConfig(SoundManagerConfig config);
void checkConfig();
void onDeviceOutputCallback(const unsigned int iFramesPerBuffer);