[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdereview/phonon/gstreamer
From:       Matthias Kretz <kretz () kde ! org>
Date:       2008-04-10 11:37:57
Message-ID: 1207827477.016348.9839.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 795460 by mkretz:

use QByteArray instead of QString. converting from (const) char * -> QString -> const \
char * doesn't add value :-)


 M  +2 -2      audiooutput.cpp  
 M  +15 -15    devicemanager.cpp  
 M  +7 -7      devicemanager.h  
 M  +17 -17    gsthelper.cpp  
 M  +7 -6      gsthelper.h  


--- trunk/kdereview/phonon/gstreamer/audiooutput.cpp #795459:795460
@@ -139,8 +139,8 @@
     if (m_audioSink &&  newDevice >= 0 && newDevice < deviceList.size()) {
         // Save previous state
         GstState oldState = GST_STATE(m_audioSink);
-        QString oldDeviceValue = GstHelper::property(m_audioSink, "device");
-        QString deviceId = deviceList.at(newDevice).gstId;
+        const QByteArray oldDeviceValue = GstHelper::property(m_audioSink, \
"device"); +        const QByteArray deviceId = deviceList.at(newDevice).gstId;
         m_device = newDevice;
 
         // We test if the device can be opened by checking if it can go from NULL to \
                READY state
--- trunk/kdereview/phonon/gstreamer/devicemanager.cpp #795459:795460
@@ -37,7 +37,7 @@
 namespace Gstreamer
 {
 
-AudioDevice::AudioDevice(DeviceManager *manager, const QString &gstId)
+AudioDevice::AudioDevice(DeviceManager *manager, const QByteArray &gstId)
         : gstId(gstId)
 {
     //get an id
@@ -53,9 +53,9 @@
             gchar *deviceDescription = NULL;
 
             if (GST_IS_PROPERTY_PROBE(aSink) && gst_property_probe_get_property( \
                GST_PROPERTY_PROBE(aSink), "device" ) ) {
-                g_object_set (G_OBJECT(aSink), "device", \
gstId.toLatin1().constData(), NULL); +                g_object_set (G_OBJECT(aSink), \
                "device", gstId.constData(), NULL);
                 g_object_get (G_OBJECT(aSink), "device-name", &deviceDescription, \
                NULL);
-                description = QString(deviceDescription);
+                description = QByteArray(deviceDescription);
                 g_free (deviceDescription);
                 gst_element_set_state(aSink, GST_STATE_NULL);
                 gst_object_unref (aSink);
@@ -73,12 +73,12 @@
 
     m_audioSink = qgetenv("PHONON_GST_AUDIOSINK");
     if (m_audioSink.isEmpty()) {
-        m_audioSink = settings.value(QLatin1String("audiosink"), \
"Auto").toString().toLower(); +        m_audioSink = \
settings.value(QLatin1String("audiosink"), "Auto").toByteArray().toLower();  }
 
     m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE");
     if (m_videoSinkWidget.isEmpty()) {
-        m_videoSinkWidget = settings.value(QLatin1String("videomode"), \
"Auto").toString().toLower(); +        m_videoSinkWidget = \
settings.value(QLatin1String("videomode"), "Auto").toByteArray().toLower();  }
 
     if (m_backend->isValid())
@@ -195,9 +195,9 @@
         } else if (m_audioSink == "artssink") {
             sink = GST_ELEMENT(g_object_new(arts_sink_get_type(), NULL));
         } else if (!m_audioSink.isEmpty()) { //Use a custom sink
-            sink = gst_element_factory_make (qPrintable(m_audioSink), NULL);
+            sink = gst_element_factory_make (m_audioSink, NULL);
             if (canOpenDevice(sink))
-                m_backend->logMessage(QString("AudioOutput using \
%0").arg(m_audioSink)); +                m_backend->logMessage(QString("AudioOutput \
using %0").arg(QString::fromUtf8(m_audioSink)));  else if (sink) {
                 gst_object_unref(sink);
                 sink = 0;
@@ -246,7 +246,7 @@
  *
  * The gstId is typically in the format hw:1,0
  */
-int DeviceManager::deviceId(const QString &gstId) const
+int DeviceManager::deviceId(const QByteArray &gstId) const
 {
     for (int i = 0 ; i < m_audioDeviceList.size() ; ++i) {
         if (m_audioDeviceList[i].gstId == gstId) {
@@ -259,14 +259,14 @@
 /**
  * Get a human-readable description from a device id
  */
-QString DeviceManager::deviceDescription(int id) const
+QByteArray DeviceManager::deviceDescription(int id) const
 {
     for (int i = 0 ; i < m_audioDeviceList.size() ; ++i) {
         if (m_audioDeviceList[i].id == id) {
             return m_audioDeviceList[i].description;
         }
     }
-    return QString();
+    return QByteArray();
 }
 
 /**
@@ -277,26 +277,26 @@
     //fetch list of current devices
     GstElement *audioSink= createAudioSink();
 
-    QStringList list;
+    QList<QByteArray> list;
 
     if (audioSink) {
         list = GstHelper::extractProperties(audioSink, "device");
         list.prepend("default");
 
         for (int i = 0 ; i < list.size() ; ++i) {
-            QString gstId = list.at(i);
+            QByteArray gstId = list.at(i);
             if (deviceId(gstId) == -1) {
                 // This is a new device, add it
                 m_audioDeviceList.append(AudioDevice(this, gstId));
                 emit deviceAdded(deviceId(gstId));
-                m_backend->logMessage(QString("Found new audio device \
%0").arg(gstId), Backend::Debug, this); +                \
m_backend->logMessage(QString("Found new audio device \
%0").arg(QString::fromUtf8(gstId)), Backend::Debug, this);  }
         }
 
         if (list.size() < m_audioDeviceList.size()) {
             //a device was removed
             for (int i = m_audioDeviceList.size() -1 ; i >= 0 ; --i) {
-                QString currId = m_audioDeviceList[i].gstId;
+                QByteArray currId = m_audioDeviceList[i].gstId;
                 bool found = false;
                 for (int k = list.size() -1  ; k >= 0 ; --k) {
                     if (currId == list[k]) {
@@ -305,7 +305,7 @@
                     }
                 }
                 if (!found) {
-                    m_backend->logMessage(QString("Audio device lost \
%0").arg(currId), Backend::Debug, this); +                    \
m_backend->logMessage(QString("Audio device lost %0").arg(QString::fromUtf8(currId)), \
Backend::Debug, this);  emit deviceRemoved(deviceId(currId));
                     m_audioDeviceList.removeAt(i);
                 }
--- trunk/kdereview/phonon/gstreamer/devicemanager.h #795459:795460
@@ -38,10 +38,10 @@
 
 class AudioDevice {
 public :
-    AudioDevice(DeviceManager *s, const QString &deviceId);
+    AudioDevice(DeviceManager *s, const QByteArray &deviceId);
     int id;
-    QString gstId;
-    QString description;
+    QByteArray gstId;
+    QByteArray description;
 };
 
 class DeviceManager : public QObject {
@@ -51,8 +51,8 @@
     virtual ~DeviceManager();
     const QList<AudioDevice> audioOutputDevices() const;
     GstPad *requestPad(int device) const;
-    int deviceId(const QString &gstId) const;
-    QString deviceDescription(int id) const;
+    int deviceId(const QByteArray &gstId) const;
+    QByteArray deviceDescription(int id) const;
     GstElement *createGNOMEAudioSink(Category category);
     GstElement *createAudioSink(Category category = NoCategory);
     AbstractRenderer *createVideoRenderer(VideoWidget *parent);
@@ -69,8 +69,8 @@
     Backend *m_backend;
     QList <AudioDevice> m_audioDeviceList;
     QTimer m_devicePollTimer;
-    QString m_audioSink;
-    QString m_videoSinkWidget;
+    QByteArray m_audioSink;
+    QByteArray m_videoSinkWidget;
 };
 }
 } // namespace Phonon::Gstreamer
--- trunk/kdereview/phonon/gstreamer/gsthelper.cpp #795459:795460
@@ -20,7 +20,7 @@
 #include "common.h"
 #include "gsthelper.h"
 
-#include <QtCore/QStringList>
+#include <QtCore/QList>
 
 QT_BEGIN_NAMESPACE
 
@@ -35,17 +35,17 @@
  * @return a QStringList containing a list of allwed string values for the given
  *           element
  */
-QStringList GstHelper::extractProperties(GstElement *elem, const QString &value)
+QList<QByteArray> GstHelper::extractProperties(GstElement *elem, const QByteArray \
&value)  {
     Q_ASSERT(elem);
-    QStringList list;
+    QList<QByteArray> list;
 
     if (GST_IS_PROPERTY_PROBE(elem)) {
         GstPropertyProbe *probe = GST_PROPERTY_PROBE(elem);
         const GParamSpec *devspec = 0;
         GValueArray *array = NULL;
 
-        if ((devspec = gst_property_probe_get_property (probe, qPrintable(value)))) \
{ +        if ((devspec = gst_property_probe_get_property (probe, value))) {
             if ((array = gst_property_probe_probe_and_get_values (probe, devspec))) \
                {
                 for (unsigned int device = 0; device < array->n_values; device++) {
                     GValue *deviceId = g_value_array_get_nth (array, device);
@@ -64,13 +64,13 @@
  *
  * @return false if the value could not be set.
  */
-bool GstHelper::setProperty(GstElement *elem, const QString &propertyName, const \
QString &propertyValue) +bool GstHelper::setProperty(GstElement *elem, const char \
*propertyName, const QByteArray &propertyValue)  {
     Q_ASSERT(elem);
-    Q_ASSERT(!propertyName.isEmpty());
+    Q_ASSERT(propertyName && strlen(propertyName));
 
-    if (GST_IS_PROPERTY_PROBE(elem) && gst_property_probe_get_property( \
                GST_PROPERTY_PROBE( elem), qPrintable(propertyName) ) ) {
-        g_object_set(G_OBJECT(elem), qPrintable(propertyName), \
qPrintable(propertyValue), NULL); +    if (GST_IS_PROPERTY_PROBE(elem) && \
gst_property_probe_get_property( GST_PROPERTY_PROBE( elem), propertyName ) ) { +      \
g_object_set(G_OBJECT(elem), propertyName, propertyValue.constData(), NULL);  return \
true;  }
     return false;
@@ -79,16 +79,16 @@
 /**
  * Queries an element for the value of an object property
  */
-QString GstHelper::property(GstElement *elem, const QString &propertyName)
+QByteArray GstHelper::property(GstElement *elem, const char *propertyName)
 {
     Q_ASSERT(elem);
-    Q_ASSERT(!propertyName.isEmpty());
-    QString retVal;
+    Q_ASSERT(propertyName && strlen(propertyName));
+    QByteArray retVal;
 
-    if (GST_IS_PROPERTY_PROBE(elem) && gst_property_probe_get_property( \
GST_PROPERTY_PROBE(elem), qPrintable(propertyName))) { +    if \
(GST_IS_PROPERTY_PROBE(elem) && gst_property_probe_get_property( \
GST_PROPERTY_PROBE(elem), propertyName)) {  gchar *value = NULL;
-        g_object_get (G_OBJECT(elem), qPrintable(propertyName), &value, NULL);
-        retVal = QString(value);
+        g_object_get (G_OBJECT(elem), propertyName, &value, NULL);
+        retVal = QByteArray(value);
         g_free (value);
     }
     return retVal;
@@ -97,13 +97,13 @@
 /**
  * Queries a GstObject for it's name
  */
-QString GstHelper::name(GstObject *obj)
+QByteArray GstHelper::name(GstObject *obj)
 {
     Q_ASSERT(obj);
-    QString retVal;
+    QByteArray retVal;
     gchar *value = NULL;
     if ((value = gst_object_get_name (obj))) {
-        retVal = QString(value);
+        retVal = QByteArray(value);
         g_free (value);
     }
     return retVal;
--- trunk/kdereview/phonon/gstreamer/gsthelper.h #795459:795460
@@ -20,12 +20,13 @@
 
 #include "common.h"
 
-#include <QtCore/QStringList>
-
 #include <gst/gst.h>
 
 QT_BEGIN_NAMESPACE
 
+template<class T> class QList;
+class QByteArray;
+
 namespace Phonon
 {
 namespace Gstreamer
@@ -33,10 +34,10 @@
 class GstHelper
 {
 public:
-    static QStringList extractProperties(GstElement *elem, const QString &value);
-    static bool setProperty(GstElement *elem, const QString &propertyName, const \
                QString &propertyValue);
-    static QString property(GstElement *elem, const QString &propertyName);
-    static QString name(GstObject *elem);
+    static QList<QByteArray> extractProperties(GstElement *elem, const QByteArray \
&value); +    static bool setProperty(GstElement *elem, const char *propertyName, \
const QByteArray &propertyValue); +    static QByteArray property(GstElement *elem, \
const char *propertyName); +    static QByteArray name(GstObject *elem);
     static GstElement* createPluggablePlaybin();
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic