From fd32ad620234832d674875d2c65128cf7bc021a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mesquita?= Date: Wed, 6 Jan 2010 03:45:00 +0000 Subject: [PATCH] A couple of more changes to the portaudio configuration. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16168 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- fscomm/prefdialog.ui | 92 +++++++++++++++++++++++++++++++++++----- fscomm/prefportaudio.cpp | 75 +++++++++++++++++++++----------- fscomm/prefportaudio.h | 6 +++ 3 files changed, 138 insertions(+), 35 deletions(-) diff --git a/fscomm/prefdialog.ui b/fscomm/prefdialog.ui index 9ffe34bded..1f228692c0 100644 --- a/fscomm/prefdialog.ui +++ b/fscomm/prefdialog.ui @@ -6,7 +6,7 @@ 0 0 - 661 + 711 437 @@ -197,7 +197,27 @@ - + + + + + + + + false + + + + 86 + 27 + + + + Test + + + + @@ -207,7 +227,27 @@ - + + + + + + + + false + + + + 86 + 27 + + + + Test + + + + @@ -217,7 +257,7 @@ Files - + @@ -226,11 +266,22 @@ - - - tone_stream://%(2000,4000,440.0,480.0);loops=20 - - + + + + + tone_stream://%(2000,4000,440.0,480.0);loops=20 + + + + + + + Open + + + + @@ -240,7 +291,11 @@ - + + + 5 + + @@ -250,7 +305,22 @@ - + + + + + true + + + + + + + Open + + + + diff --git a/fscomm/prefportaudio.cpp b/fscomm/prefportaudio.cpp index 36de76f06c..ecd1c603b9 100644 --- a/fscomm/prefportaudio.cpp +++ b/fscomm/prefportaudio.cpp @@ -7,6 +7,55 @@ PrefPortaudio::PrefPortaudio(Ui::PrefDialog *ui, QObject *parent) : _ui(ui) { _settings = new QSettings(); + connect(_ui->PaRingFileBtn, SIGNAL(clicked()), this, SLOT(ringFileChoose())); + connect(_ui->PaHoldFileBtn, SIGNAL(clicked()), this, SLOT(holdFileChoose())); + connect(_ui->PaOutdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(outdevChangeDev(int))); + connect(_ui->PaRingdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(ringdevChangeDev(int))); +} + +void PrefPortaudio::ringdevChangeDev(int dev) +{ + QString result; + if (g_FSHost.sendCmd("pa", QString("ringdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS) + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev to #%d on mod_portaudio!\n", dev); + QMessageBox::critical(0, tr("Unable to change device."), + tr("There was an error changing the ringdev.\nPlease report this bug."), + QMessageBox::Ok); + + } +} + +void PrefPortaudio::outdevChangeDev(int dev) +{ + QString result; + if (g_FSHost.sendCmd("pa", QString("outdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS) + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting outdev to #%d on mod_portaudio!\n", dev); + QMessageBox::critical(0, tr("Unable to change device."), + tr("There was an error changing the outdev.\nPlease report this bug."), + QMessageBox::Ok); + } +} + +void PrefPortaudio::holdFileChoose() +{ + QString fileName = QFileDialog::getOpenFileName(0, + tr("Select file"), + QDir::homePath(), + NULL); + if (!fileName.isNull()) + _ui->PaHoldFileEdit->setText(fileName); +} + +void PrefPortaudio::ringFileChoose() +{ + QString fileName = QFileDialog::getOpenFileName(0, + tr("Select file"), + QDir::homePath(), + NULL); + if (!fileName.isNull()) + _ui->PaRingFileEdit->setText(fileName); } void PrefPortaudio::writeConfig() @@ -79,33 +128,11 @@ void PrefPortaudio::writeConfig() if (noutdev!= outdev) { - if (g_FSHost.sendCmd("pa", QString("outdev #%1").arg(noutdev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS) - { - _settings->setValue("outdev", noutdev); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting outdev from #%d to #%d on mod_portaudio!\n", - outdev, noutdev); - QMessageBox::critical(0, tr("Unable to save settings"), - tr("There was an error changing the outdev.\nPlease report this bug."), - QMessageBox::Ok); - } + _settings->setValue("outdev", noutdev); } if (nringdev != ringdev) { - if (g_FSHost.sendCmd("pa", QString("ringdev #%1").arg(nringdev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS) - { - _settings->setValue("ringdev", nringdev); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev from #%d to #%d on mod_portaudio!\n", - nringdev, nringdev); - QMessageBox::critical(0, tr("Unable to save settings"), - tr("There was an error changing the ringdev.\nPlease report this bug."), - QMessageBox::Ok); - } + _settings->setValue("ringdev", nringdev); } _settings->endGroup(); diff --git a/fscomm/prefportaudio.h b/fscomm/prefportaudio.h index 84b8a29079..d427121629 100644 --- a/fscomm/prefportaudio.h +++ b/fscomm/prefportaudio.h @@ -15,6 +15,12 @@ public: void writeConfig(); void readConfig(); +private slots: + void ringFileChoose(); + void holdFileChoose(); + void outdevChangeDev(int); + void ringdevChangeDev(int); + private: void getPaDevlist(void); QSettings *_settings;