]> git.sesse.net Git - kdenlive/commitdiff
sdl audio driver detection fails sometimes (pulseaudio being the only one confirmed...
authorAlberto Villa <avilla@FreeBSD.org>
Thu, 11 Jun 2009 22:55:59 +0000 (22:55 +0000)
committerAlberto Villa <avilla@FreeBSD.org>
Thu, 11 Jun 2009 22:55:59 +0000 (22:55 +0000)
svn path=/trunk/kdenlive/; revision=3519

src/kdenlivesettings.kcfg
src/mainwindow.cpp
src/mainwindow.h
src/renderer.cpp

index bfa9c37f22673b3a71fe1e7f316f4521341689e9..693a449d8dc05432172daef641606fd6bfba13e9 100644 (file)
       <default>true</default>
     </entry>
 
+    <entry name="autoaudiodrivername" type="String">
+      <label>Audio driver selected automatically.</label>
+      <default></default>
+    </entry>
+
     <entry name="audiocodecs" type="StringList">
       <label>Available avformat audio codecs.</label>
       <default></default>
index 18974fda3e6cbeaf4816b9bf5094564ae8330dd4..bec755b3cb9237dfd610f03b9b18063035aa8ff1 100644 (file)
@@ -70,6 +70,7 @@
 #include <kstandarddirs.h>
 #include <KUrlRequesterDialog>
 #include <KTemporaryFile>
+#include <KProcess>
 #include <KActionMenu>
 #include <KMenu>
 #include <locale.h>
@@ -173,6 +174,8 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
                        actionCollection());
     readOptions();
 
+    slotDetectAudioDriver();
+
     m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
     m_clipMonitorDock->setObjectName("clip_monitor");
     m_clipMonitor = new Monitor("clip", m_monitorManager, this);
@@ -1521,6 +1524,31 @@ void MainWindow::slotEditProfiles()
     delete w;
 }
 
+void MainWindow::slotDetectAudioDriver()
+{
+    //decide which audio driver is really best, in some cases SDL is wrong
+    if(KdenliveSettings::audiodrivername().isEmpty()) {
+        QString driver;
+        KProcess readProcess;
+        //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
+        if (!KStandardDirs::findExe("pactl").isEmpty()) {
+            readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
+            readProcess.setProgram("pactl", QStringList() << "stat");
+            readProcess.execute(2000); // Kill it after 2 seconds
+
+            QString result = QString(readProcess.readAllStandardOutput());
+            kDebug() << "// / / / / / READING PACTL: ";
+            kDebug() << result;
+            if(!result.isEmpty()) {
+                driver = "pulse";
+                kDebug() << "// / / / / PULSEAUDIO DETECTED";
+            }
+        }
+        //put others here
+        KdenliveSettings::setAutoaudiodrivername(driver);
+    }
+}
+
 void MainWindow::slotEditProjectSettings()
 {
     QPoint p = m_activeDocument->getTracksCount();
@@ -1922,6 +1950,7 @@ void MainWindow::slotPreferences(int page, int option)
     // create it :
     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
+    connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
     connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
     connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
index 1e5ebc25b1c7ba6b788a05f9cfa40ff5ef5047c7..393e5056ba0c4c19bd874980fc1f3982c4e565e9 100644 (file)
@@ -218,6 +218,7 @@ private slots:
     void slotUpdateMousePosition(int pos);
     void slotAddEffect(QDomElement effect, GenTime pos = GenTime(), int track = -1);
     void slotEditProfiles();
+    void slotDetectAudioDriver();
     void slotEditProjectSettings();
     void slotDisplayActionMessage(QAction *a);
     void slotSwitchVideoThumbs();
index 7689a11d2762b76522b6934cd8e0da258e9688f8..28c803ec169058fc2119ae15bbfc50d267755201 100644 (file)
@@ -148,6 +148,8 @@ void Render::buildConsumer()
     }
 
     QString audioDriver = KdenliveSettings::audiodrivername();
+    if (audioDriver.isEmpty())
+        audioDriver = KdenliveSettings::autoaudiodrivername();
     if (!audioDriver.isEmpty()) {
         tmp = decodedString(audioDriver);
         m_mltConsumer->set("audio_driver", tmp);