Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/phonon/gstreamer/devicemanager.cpp

    r561 r846  
    2525#include "x11renderer.h"
    2626#include "artssink.h"
     27#include "pulsesupport.h"
    2728
    2829#ifdef USE_ALSASINK2
     
    4546        : gstId(gstId)
    4647{
    47     //get an id
    48     static int counter = 0;
    49     id = counter++;
     48    // This should never be called when PulseAudio is active.
     49    Q_ASSERT(!PulseSupport::getInstance()->isActive());
     50
     51    id = manager->allocateDeviceId();
     52    icon = "audio-card";
     53
    5054    //get name from device
    5155    if (gstId == "default") {
     
    7276        : QObject(backend)
    7377        , m_backend(backend)
    74 {
    75     m_audioSink = qgetenv("PHONON_GST_AUDIOSINK");
    76     m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE");
    77 
    78 #ifndef QT_NO_SETTINGS
     78        , m_audioDeviceCounter(0)
     79{
    7980    QSettings settings(QLatin1String("Trolltech"));
    8081    settings.beginGroup(QLatin1String("Qt"));
    8182
     83    PulseSupport *pulse = PulseSupport::getInstance();
     84    m_audioSink = qgetenv("PHONON_GST_AUDIOSINK");
    8285    if (m_audioSink.isEmpty()) {
    8386        m_audioSink = settings.value(QLatin1String("audiosink"), "Auto").toByteArray().toLower();
    84     }
    85 
     87        if (m_audioSink == "auto" && pulse->isActive())
     88            m_audioSink = "pulsesink";
     89    }
     90    if ("pulsesink" != m_audioSink)
     91        pulse->enable(false);
     92
     93    m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE");
    8694    if (m_videoSinkWidget.isEmpty()) {
    8795        m_videoSinkWidget = settings.value(QLatin1String("videomode"), "Auto").toByteArray().toLower();
    8896    }
    89 #endif //QT_NO_SETTINGS
    9097
    9198    if (m_backend->isValid())
     
    272279#endif //QT_NO_PHONON_VIDEO
    273280
    274 /*
    275  * Returns a positive device id or -1 if device
    276  * does not exist
     281/**
     282 * Allocate a device id for a new audio device
     283 */
     284int DeviceManager::allocateDeviceId()
     285{
     286    return m_audioDeviceCounter++;
     287}
     288
     289
     290/**
     291 * Returns a positive device id or -1 if device does not exist
    277292 *
    278293 * The gstId is typically in the format hw:1,0
     
    289304
    290305/**
    291  * Get a human-readable description from a device id
    292  */
    293 QByteArray DeviceManager::deviceDescription(int id) const
     306 * Returns a gstId or "default" if device does not exist
     307 *
     308 * The gstId is typically in the format hw:1,0
     309 */
     310const QByteArray DeviceManager::gstId(int deviceId)
     311{
     312    if (!PulseSupport::getInstance()->isActive()) {
     313        AudioDevice *ad = audioDevice(deviceId);
     314        if (ad)
     315            return QByteArray(ad->gstId);
     316    }
     317    return QByteArray("default");
     318}
     319
     320/**
     321* Get the AudioDevice for a given device id
     322*/
     323AudioDevice* DeviceManager::audioDevice(int id)
    294324{
    295325    for (int i = 0 ; i < m_audioDeviceList.size() ; ++i) {
    296         if (m_audioDeviceList[i].id == id) {
    297             return m_audioDeviceList[i].description;
    298         }
    299     }
    300     return QByteArray();
     326        if (m_audioDeviceList[i].id == id)
     327            return &m_audioDeviceList[i];
     328    }
     329    return NULL;
    301330}
    302331
     
    312341
    313342    if (audioSink) {
    314         list = GstHelper::extractProperties(audioSink, "device");
    315         list.prepend("default");
     343        if (!PulseSupport::getInstance()->isActive()) {
     344            // If we're using pulse, the PulseSupport class takes care of things for us.
     345            list = GstHelper::extractProperties(audioSink, "device");
     346            list.prepend("default");
     347        }
    316348
    317349        for (int i = 0 ; i < list.size() ; ++i) {
Note: See TracChangeset for help on using the changeset viewer.