Revision
16229
Author
seven
Date
2010-01-10 10:52:35 -0600 (Sun, 10 Jan 2010)

Log Message

add pa looptest; tweak debug msg; reload devlist on devchange, say a USB mic pluged/unpluged; Fix dev settings bug where currentIndex does not match device id
I know I should commit multi times for each fixes/features, but hard to separate them, commit at one time for now

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/seven/fscomm/conf/portaudio.conf.xml (16228 => 16229)


--- freeswitch/trunk/contrib/seven/fscomm/conf/portaudio.conf.xml	2010-01-10 16:45:13 UTC (rev 16228)
+++ freeswitch/trunk/contrib/seven/fscomm/conf/portaudio.conf.xml	2010-01-10 16:52:35 UTC (rev 16229)
@@ -14,8 +14,8 @@
                 <param name="dialplan" value="XML"/>
                 <param name="cid-name" value="${cid-name}"/>
                 <param name="cid-num" value="${cid-num}"/>
-                <param name="sample-rate" value="48000"/>
-                <param name="codec-ms" value="10"/>
+                <param name="sample-rate" value="${sample-rate}"/>
+                <param name="codec-ms" value="${codec-ms}"/>
             </settings>
         </configuration>
     </section>

Modified: freeswitch/trunk/contrib/seven/fscomm/fshost.cpp (16228 => 16229)


--- freeswitch/trunk/contrib/seven/fscomm/fshost.cpp	2010-01-10 16:45:13 UTC (rev 16228)
+++ freeswitch/trunk/contrib/seven/fscomm/fshost.cpp	2010-01-10 16:52:35 UTC (rev 16229)
@@ -39,7 +39,7 @@
     QThread(parent)
 {
     /* Initialize libs & globals */
-    printf("Initializing globals...\n");
+    qDebug() << "Initializing globals..." << endl;
     switch_core_setrlimits();
     switch_core_set_globals();
 
@@ -112,14 +112,14 @@
     }
 
     /* If you need to override configuration directories, you need to change them in the SWITCH_GLOBAL_dirs global structure */
-    printf("Initializing core...\n");
+    qDebug() << "Initializing core..." << endl;
     /* Initialize the core and load modules, that will startup FS completely */
     if (switch_core_init(flags, console, &err) != SWITCH_STATUS_SUCCESS) {
         fprintf(stderr, "Failed to initialize FreeSWITCH's core: %s\n", err);
         emit coreLoadingError(err);
     }
 
-    printf("Everything OK, Entering runtime loop.\n");
+    qDebug() << "Everything OK, Entering runtime loop ..." << endl;
 
     if (switch_event_bind("FSHost", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, eventHandlerCallback, NULL) != SWITCH_STATUS_SUCCESS) {
             switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
@@ -149,7 +149,7 @@
     destroy_status = switch_core_destroy();
     if (destroy_status == SWITCH_STATUS_SUCCESS)
     {
-        printf("We have properly shutdown the core.\n");
+        qDebug() << "We have properly shutdown the core." << endl;
     }
 }
 
@@ -341,6 +341,7 @@
     switch_status_t status = SWITCH_STATUS_FALSE;
     switch_stream_handle_t stream = { 0 };
     SWITCH_STANDARD_STREAM(stream);
+    qDebug() << "Sending command: " << cmd << args << endl;
     status = switch_api_execute(cmd, args, NULL, &stream);
     *res = switch_str_nil((char *) stream.data);
 

Modified: freeswitch/trunk/contrib/seven/fscomm/mod_qsettings/mod_qsettings.cpp (16228 => 16229)


--- freeswitch/trunk/contrib/seven/fscomm/mod_qsettings/mod_qsettings.cpp	2010-01-10 16:45:13 UTC (rev 16228)
+++ freeswitch/trunk/contrib/seven/fscomm/mod_qsettings/mod_qsettings.cpp	2010-01-10 16:52:35 UTC (rev 16229)
@@ -43,7 +43,7 @@
 
     if (QFile::exists(QString("%1/.fscomm/templates/%2.xml").arg(QDir::homePath(),tmpl))) {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
-                          "Using template %s.xml on .fscomm/.\n",
+                          "Using template .fscomm/templates/%s.xml\n",
                           tmpl.toAscii().constData());
     }
     else if(QFile::exists(QString(":/confs/%1.xml").arg(tmpl)))

Modified: freeswitch/trunk/contrib/seven/fscomm/preferences/prefdialog.ui (16228 => 16229)


--- freeswitch/trunk/contrib/seven/fscomm/preferences/prefdialog.ui	2010-01-10 16:45:13 UTC (rev 16228)
+++ freeswitch/trunk/contrib/seven/fscomm/preferences/prefdialog.ui	2010-01-10 16:52:35 UTC (rev 16229)
@@ -867,6 +867,48 @@
             </item>
            </layout>
           </item>
+          <item row="4" column="1">
+           <widget class="QPushButton" name="PaRefreshDevListBtn">
+            <property name="text">
+             <string>Refresh DevList</string>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="0">
+           <widget class="QPushButton" name="PaLoopTestBtn">
+            <property name="text">
+             <string>Loop Test</string>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="1">
+           <widget class="QLineEdit" name="PaSampleRateEdit">
+            <property name="text">
+             <string>16000</string>
+            </property>
+           </widget>
+          </item>
+          <item row="6" column="1">
+           <widget class="QLineEdit" name="PaCodecMSEdit">
+            <property name="text">
+             <string>10</string>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="0">
+           <widget class="QLabel" name="label_40">
+            <property name="text">
+             <string>Sample Rate</string>
+            </property>
+           </widget>
+          </item>
+          <item row="6" column="0">
+           <widget class="QLabel" name="label_41">
+            <property name="text">
+             <string>Codec MS</string>
+            </property>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>

Modified: freeswitch/trunk/contrib/seven/fscomm/preferences/prefportaudio.cpp (16228 => 16229)


--- freeswitch/trunk/contrib/seven/fscomm/preferences/prefportaudio.cpp	2010-01-10 16:45:13 UTC (rev 16228)
+++ freeswitch/trunk/contrib/seven/fscomm/preferences/prefportaudio.cpp	2010-01-10 16:52:35 UTC (rev 16229)
@@ -9,9 +9,12 @@
     _settings = new QSettings();
     connect(_ui->PaRingFileBtn, SIGNAL(clicked()), this, SLOT(ringFileChoose()));
     connect(_ui->PaHoldFileBtn, SIGNAL(clicked()), this, SLOT(holdFileChoose()));
+    connect(_ui->PaIndevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(indevChangeDev(int)));
     connect(_ui->PaOutdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(outdevChangeDev(int)));
     connect(_ui->PaRingdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(ringdevChangeDev(int)));
     connect(_ui->PaRingdevTestBtn, SIGNAL(clicked()), this, SLOT(ringdevTest()));
+    connect(_ui->PaLoopTestBtn, SIGNAL(clicked()), this, SLOT(loopTest()));
+    connect(_ui->PaRefreshDevListBtn, SIGNAL(clicked()), this, SLOT(refreshDevList()));
 }
 
 void PrefPortaudio::ringdevTest()
@@ -24,9 +27,51 @@
     }
 }
 
-void PrefPortaudio::ringdevChangeDev(int dev)
+void PrefPortaudio::loopTest()
 {
     QString result;
+    _ui->PaLoopTestBtn->setEnabled(false);
+    if (g_FSHost.sendCmd("pa", "looptest", &result) != SWITCH_STATUS_SUCCESS)
+    {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error running looptest on mod_portaudio! %s\n",
+                          result.toAscii().constData());
+    }
+    _ui->PaLoopTestBtn->setEnabled(true);
+}
+
+void PrefPortaudio::refreshDevList()
+{
+    QString result;
+    if (g_FSHost.sendCmd("pa", "rescan", &result) != SWITCH_STATUS_SUCCESS)
+    {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error rescaning sound device on mod_portaudio! %s\n",
+                          result.toAscii().constData());
+    }
+    //clear combox
+    _ui->PaIndevCombo->clear();
+    _ui->PaOutdevCombo->clear();
+    _ui->PaRingdevCombo->clear();
+    getPaDevlist();
+}
+
+void PrefPortaudio::indevChangeDev(int index)
+{
+    QString result;
+    int dev = _ui->PaIndevCombo->itemData(index, Qt::UserRole).toInt();
+    if (g_FSHost.sendCmd("pa", QString("indev #%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::ringdevChangeDev(int index)
+{
+    QString result;
+    int dev = _ui->PaRingdevCombo->itemData(index, Qt::UserRole).toInt();
     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);
@@ -37,9 +82,10 @@
     }
 }
 
-void PrefPortaudio::outdevChangeDev(int dev)
+void PrefPortaudio::outdevChangeDev(int index)
 {
     QString result;
+    int dev = _ui->PaRingdevCombo->itemData(index, Qt::UserRole).toInt();
     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);
@@ -89,13 +135,21 @@
     int ring_interval = _settings->value("ring-interval").toInt();
     int nring_interval = _ui->PaRingIntervalSpin->value();
 
+    QString sample_rate = _settings->value("sample-rate").toString();
+    QString nsample_rate = _ui->PaSampleRateEdit->text();
+
+    QString codec_ms = _settings->value("codec-ms").toString();
+    QString ncodec_ms = _ui->PaCodecMSEdit->text();
+
     QString result;
 
     if (cid_name != ncid_name ||
         cid_num != ncid_num ||
         hold_file != nhold_file ||
         ring_file != nring_file ||
-        ring_interval != nring_interval)
+        ring_interval != nring_interval ||
+        sample_rate != nsample_rate||
+        codec_ms != ncodec_ms)
     {
         if (g_FSHost.sendCmd("reload", "mod_portaudio", &result) == SWITCH_STATUS_SUCCESS)
         {
@@ -104,6 +158,8 @@
             _settings->setValue("ring-file", nring_file);
             _settings->setValue("ring-interval", nring_interval);
             _settings->setValue("hold-file", nhold_file);
+            _settings->setValue("sample-rate", nsample_rate);
+            _settings->setValue("codec-ms", ncodec_ms);
         }
         else
         {
@@ -114,11 +170,11 @@
         }
     }
 
-    int nindev = _ui->PaIndevCombo->currentIndex();
+    int nindev = _ui->PaIndevCombo->itemData(_ui->PaIndevCombo->currentIndex(), Qt::UserRole).toInt();
     int indev = _settings->value("indev").toInt();
-    int noutdev = _ui->PaOutdevCombo->currentIndex();
+    int noutdev = _ui->PaOutdevCombo->itemData(_ui->PaOutdevCombo->currentIndex(), Qt::UserRole).toInt();
     int outdev = _settings->value("outdev").toInt();
-    int nringdev = _ui->PaRingdevCombo->currentIndex();
+    int nringdev = _ui->PaRingdevCombo->itemData(_ui->PaRingdevCombo->currentIndex(), Qt::UserRole).toInt();
     int ringdev = _settings->value("ringdev").toInt();
 
     if (nindev != indev)
@@ -161,6 +217,8 @@
     _ui->PaHoldFileEdit->setText(_settings->value("hold-file").toString());
     _ui->PaRingFileEdit->setText(_settings->value("ring-file").toString());
     _ui->PaRingIntervalSpin->setValue(_settings->value("ring-interval").toInt());
+    _ui->PaSampleRateEdit->setText(_settings->value("sample-rate").toString());
+    _ui->PaCodecMSEdit->setText(_settings->value("codec-ms").toString());
     _settings->endGroup();
 
     _settings->endGroup();
@@ -260,19 +318,29 @@
         {
             for(int itemId=0; itemId<_ui->PaRingdevCombo->count(); itemId++)
             {
-                if (itemId == _ui->PaRingdevCombo->itemData(itemId,Qt::UserRole).toInt())
+                if (id == _ui->PaRingdevCombo->itemData(itemId,Qt::UserRole))
                 {
+                    //setCurrentIndex triggers currentIndexChanged signal, hmmm...
                     _ui->PaRingdevCombo->setCurrentIndex(itemId);
                     break;
                 }
             }
         }
         else if (child.tagName() == "input")
-            _ui->PaIndevCombo->setCurrentIndex(id.toInt());
+        {
+            for(int itemId=0; itemId<_ui->PaRingdevCombo->count(); itemId++)
+            {
+                if (id == _ui->PaIndevCombo->itemData(itemId,Qt::UserRole))
+                {
+                    _ui->PaIndevCombo->setCurrentIndex(itemId);
+                    break;
+                }
+            }
+        }
         else if (child.tagName() == "output")
             for(int itemId=0; itemId<_ui->PaOutdevCombo->count(); itemId++)
             {
-                if (itemId == _ui->PaOutdevCombo->itemData(itemId,Qt::UserRole).toInt())
+                if (id == _ui->PaOutdevCombo->itemData(itemId,Qt::UserRole))
                 {
                     _ui->PaOutdevCombo->setCurrentIndex(itemId);
                     break;

Modified: freeswitch/trunk/contrib/seven/fscomm/preferences/prefportaudio.h (16228 => 16229)


--- freeswitch/trunk/contrib/seven/fscomm/preferences/prefportaudio.h	2010-01-10 16:45:13 UTC (rev 16228)
+++ freeswitch/trunk/contrib/seven/fscomm/preferences/prefportaudio.h	2010-01-10 16:52:35 UTC (rev 16229)
@@ -18,10 +18,12 @@
 private slots:
     void ringFileChoose();
     void holdFileChoose();
+    void indevChangeDev(int);
     void outdevChangeDev(int);
     void ringdevChangeDev(int);
     void ringdevTest();
-
+    void loopTest();
+    void refreshDevList();
 private:
     void getPaDevlist(void);
     QSettings *_settings;