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:
89 edited
18 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/phonon/CMakeLists.txt

    r561 r846  
    7171   endif (MINGW)
    7272
     73   if (QT_USE_FRAMEWORKS)
     74     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -F${QT_LIBRARY_DIR}")
     75   endif (QT_USE_FRAMEWORKS)
     76
    7377   check_cxx_compiler_flag(-fPIE HAVE_FPIE_SUPPORT)
    7478   if(KDE4_ENABLE_FPIE)
     
    9195
    9296   # get the gcc version
    93    exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
     97   exec_program(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_COMPILER_ARG1} --version OUTPUT_VARIABLE _gcc_version_info)
    9498
    9599   string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
     
    149153
    150154set(PHONON_LIB_MAJOR_VERSION "4")
    151 set(PHONON_LIB_MINOR_VERSION "3")
    152 set(PHONON_LIB_PATCH_VERSION "50")
     155set(PHONON_LIB_MINOR_VERSION "4")
     156set(PHONON_LIB_PATCH_VERSION "0")
    153157set(PHONON_LIB_VERSION "${PHONON_LIB_MAJOR_VERSION}.4.0")
    154158set(PHONON_LIB_SOVERSION ${PHONON_LIB_MAJOR_VERSION})
  • trunk/src/3rdparty/phonon/ds9/backendnode.cpp

    r561 r846  
    6868                    HRESULT hr = info.pGraph->RemoveFilter(filter);
    6969
    70                     if (hr == VFW_E_NOT_STOPPED && m_mediaObject) {
     70                    if (FAILED(hr) && m_mediaObject) {
    7171                        m_mediaObject->ensureStopped();
    7272
  • trunk/src/3rdparty/phonon/ds9/iodevicereader.cpp

    r561 r846  
    129129                  while (m_buffer.size() < int(length)) {
    130130                      needData();
    131                       if (m_mediaGraph->isStopping()) {
    132                           return VFW_E_WRONG_STATE;
    133                       }
    134131
    135132                      if (oldSize == m_buffer.size()) {
  • trunk/src/3rdparty/phonon/ds9/mediagraph.cpp

    r561 r846  
    380380            filter->QueryFilterInfo(&info);
    381381#ifdef GRAPH_DEBUG
    382             qDebug() << "removeFilter" << QString::fromUtf16(info.achName);
     382            qDebug() << "removeFilter" << QString((const QChar *)info.achName);
    383383#endif
    384384            if (info.pGraph) {
     
    876876                FILTER_INFO info;
    877877                filter->QueryFilterInfo(&info);
    878                 qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
     878                qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
    879879                if (info.pGraph) {
    880880                    info.pGraph->Release();
     
    922922                FILTER_INFO info;
    923923                filter->QueryFilterInfo(&info);
    924                 qDebug() << "found a decoder filter" << QString::fromUtf16(info.achName);
     924                qDebug() << "found a decoder filter" << QString((const QChar *)info.achName);
    925925                if (info.pGraph) {
    926926                    info.pGraph->Release();
     
    938938                FILTER_INFO info;
    939939                filter->QueryFilterInfo(&info);
    940                 qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
     940                qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
    941941                if (info.pGraph) {
    942942                    info.pGraph->Release();
     
    957957                FILTER_INFO info;
    958958                filter->QueryFilterInfo(&info);
    959                 qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
     959                qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
    960960                if (info.pGraph) {
    961961                    info.pGraph->Release();
     
    991991                FILTER_INFO info;
    992992                filter->QueryFilterInfo(&info);
    993                 qDebug() << "found a demuxer filter" << QString::fromUtf16(info.achName);
     993                qDebug() << "found a demuxer filter" << QString((const QChar *)info.achName);
    994994                if (info.pGraph) {
    995995                    info.pGraph->Release();
  • trunk/src/3rdparty/phonon/ds9/mediaobject.cpp

    r561 r846  
    2828#include <initguid.h>
    2929#include <qnetwork.h>
     30#ifdef Q_CC_MSVC
     31# include <comdef.h>
     32#endif
    3033#include <evcode.h>
    3134
  • trunk/src/3rdparty/phonon/ds9/videorenderer_soft.cpp

    r561 r846  
    4646
    4747#ifndef QT_NO_OPENGL
    48 #include <gl/gl.h>
     48#include <GL/gl.h>
    4949#ifndef GL_FRAGMENT_PROGRAM_ARB
    5050#define GL_FRAGMENT_PROGRAM_ARB           0x8804
  • trunk/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp

    r561 r846  
    2323#include <QtGui/QWidget>
    2424#include <QtGui/QPainter>
    25 #include <QtCore/QTimerEvent>
    26 
    27 #ifndef Q_OS_WINCE
     25
    2826#include <d3d9.h>
    2927#include <vmr9.h>
    30 #else
    31 #include <uuids.h>
    32 #endif
    3328
    3429QT_BEGIN_NAMESPACE
     
    4944
    5045
    51 #ifdef Q_OS_WINCE
    52         VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target)
    53         {
    54             m_target->setAttribute(Qt::WA_PaintOnScreen, true);
    55             m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter);
    56         }
    57 
    58         QSize VideoRendererVMR9::videoSize() const
    59         {
    60             LONG w = 0,
    61                 h = 0;
    62             ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
    63             if (basic) {
    64                 basic->GetVideoSize( &w, &h);
    65             }
    66             return QSize(w, h);
    67         }
    68 
    69         void VideoRendererVMR9::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/)
    70         {
    71             //nothing to do here: the renderer paints everything
    72         }
    73 
    74         void VideoRendererVMR9::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio,
    75             Phonon::VideoWidget::ScaleMode scaleMode)
    76         {
    77             if (!isActive()) {
    78                 ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
    79                 if (basic) {
    80                     basic->SetDestinationPosition(0, 0, 0, 0);
    81                 }
    82                 return;
    83             }
    84 
    85             ComPointer<IVideoWindow> video(m_filter, IID_IVideoWindow);
    86 
    87             OAHWND owner;
    88             HRESULT hr = video->get_Owner(&owner);
    89             if (FAILED(hr)) {
    90                 return;
    91             }
    92 
    93             const OAHWND newOwner = reinterpret_cast<OAHWND>(m_target->winId());
    94             if (owner != newOwner) {
    95                 video->put_Owner(newOwner);
    96                 video->put_MessageDrain(newOwner);
    97                 video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
    98             }
    99 
    100             //make sure the widget takes the whole size of the parent
    101             video->SetWindowPosition(0, 0, size.width(), size.height());
    102 
    103             const QSize vsize = videoSize();
    104             internalNotifyResize(size, vsize, aspectRatio, scaleMode);
    105 
    106             ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
    107             if (basic) {
    108                 basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight);
    109             }
    110         }
    111 
    112         void VideoRendererVMR9::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/)
    113         {
    114             //this can't be supported for WinCE
    115         }
    116 
    117         QImage VideoRendererVMR9::snapshot() const
    118         {
    119             ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
    120             if (basic) {
    121                 LONG bufferSize = 0;
    122                 //1st we get the buffer size
    123                 basic->GetCurrentImage(&bufferSize, 0);
    124 
    125                 QByteArray buffer;
    126                 buffer.resize(bufferSize);
    127                 HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast<long*>(buffer.data()));
    128 
    129                 if (SUCCEEDED(hr)) {
    130 
    131                     const BITMAPINFOHEADER  *bmi = reinterpret_cast<const BITMAPINFOHEADER*>(buffer.constData());
    132 
    133                     const int w = qAbs(bmi->biWidth),
    134                         h = qAbs(bmi->biHeight);
    135 
    136                     // Create image and copy data into image.
    137                     QImage ret(w, h, QImage::Format_RGB32);
    138 
    139                     if (!ret.isNull()) {
    140                         const char *data = buffer.constData() + bmi->biSize;
    141                         const int bytes_per_line = w * sizeof(QRgb);
    142                         for (int y = h - 1; y >= 0; --y) {
    143                             qMemCopy(ret.scanLine(y), //destination
    144                                 data,     //source
    145                                 bytes_per_line);
    146                             data += bytes_per_line;
    147                         }
    148                     }
    149                     return ret;
    150                 }
    151             }
    152             return QImage();
    153         }
    154 
    155 #else
    15646        VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target)
    15747        {
    15848            m_filter = Filter(CLSID_VideoMixingRenderer9, IID_IBaseFilter);
    15949            if (!m_filter) {
    160                 qWarning("the video widget could not be initialized correctly");
    16150                return;
    16251            }
     
    326215            mixer->SetProcAmpControl(0, &ctrl);
    327216        }
    328 #endif
    329217    }
    330218}
  • trunk/src/3rdparty/phonon/ds9/videorenderer_vmr9.h

    r2 r846  
    2020
    2121#include "abstractvideorenderer.h"
    22 #include "compointer.h"
    2322
    2423QT_BEGIN_NAMESPACE
  • trunk/src/3rdparty/phonon/ds9/videowidget.cpp

    r769 r846  
    2525#include "mediaobject.h"
    2626
     27#ifndef Q_OS_WINCE
     28#include "videorenderer_evr.h"
    2729#include "videorenderer_vmr9.h"
     30#else
     31#include "videorenderer_default.h"
     32#endif
    2833#include "videorenderer_soft.h"
    2934
     
    353358            if (m_renderers[index] == 0 && autoCreate) {
    354359                AbstractVideoRenderer *renderer = 0;
    355                                 if (type == Native) {
    356                     renderer = new VideoRendererVMR9(m_widget);
     360                if (type == Native) {
     361#ifndef Q_OS_WINCE
     362                    renderer = new VideoRendererEVR(m_widget);
    357363                    if (renderer->getFilter() == 0) {
    358                         //instanciating the renderer might fail with error VFW_E_DDRAW_CAPS_NOT_SUITABLE (0x80040273)
     364                        delete renderer;
     365                        //EVR not present, let's try VMR
     366                        renderer = new VideoRendererVMR9(m_widget);
     367                        if (renderer->getFilter() == 0) {
     368                            //instanciating the renderer might fail
     369                            m_noNativeRendererSupported = true;
     370                            delete renderer;
     371                            renderer = 0;
     372                        }
     373                    }
     374#else
     375                    renderer = new VideoRendererDefault(m_widget);
     376                    if (renderer->getFilter() == 0) {
     377                        //instanciating the renderer might fail
    359378                        m_noNativeRendererSupported = true;
    360379                        delete renderer;
    361380                        renderer = 0;
    362381                    }
     382#endif
    363383                }
    364384
  • trunk/src/3rdparty/phonon/gstreamer/CMakeLists.txt

    r561 r846  
    2020   include_directories(
    2121          ${CMAKE_CURRENT_BINARY_DIR}
    22           ${GSTREAMER_INCLUDE_DIR} 
     22          ${GSTREAMER_INCLUDE_DIR}
    2323          ${GLIB2_INCLUDE_DIR}
    2424      ${LIBXML2_INCLUDE_DIR}
     
    3535   set(phonon_gstreamer_SRCS
    3636      audiooutput.cpp
    37       artssink.cpp
    3837      backend.cpp
    3938      devicemanager.cpp
     
    5150      audioeffect.cpp
    5251      abstractrenderer.cpp
    53       x11renderer.cpp
    5452      widgetrenderer.cpp
    5553      glrenderer.cpp
    5654      volumefadereffect.cpp
     55      audiodataoutput.cpp
    5756      )
    5857
    59    find_package(Alsa)
    60    macro_ensure_version("0.10.22" ${GSTREAMER_VERSION} GSTREAMER_HAS_NONBLOCKING_ALSASINK)
     58   if(NOT WIN32)
     59      set(phonon_gstreamer_SRCS
     60          ${phonon_gstreamer_SRCS}
     61          artssink.cpp
     62          x11renderer.cpp)
     63      macro_optional_find_package(Alsa)
     64      macro_ensure_version("0.10.22" ${GSTREAMER_VERSION} GSTREAMER_HAS_NONBLOCKING_ALSASINK)
     65   endif(NOT WIN32)
    6166   if(ALSA_FOUND AND NOT GSTREAMER_HAS_NONBLOCKING_ALSASINK)
    6267      add_definitions(-DUSE_ALSASINK2)
     
    7984      target_link_libraries(phonon_gstreamer ${ASOUND_LIBRARY})
    8085   endif(ALSA_FOUND)
     86   if(USE_INSTALL_PLUGIN)
     87       target_link_libraries(phonon_gstreamer ${GSTREAMER_PLUGIN_PBUTILS_LIBRARIES})
     88   endif(USE_INSTALL_PLUGIN)
    8189
    8290   install(TARGETS phonon_gstreamer DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/phonon_backend)
  • trunk/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake

    r2 r846  
    1818macro_optional_find_package(GStreamerPlugins)
    1919macro_log_feature(GSTREAMER_PLUGIN_VIDEO_LIBRARIES "GStreamer video plugin" "The gstreamer video plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
     20macro_log_feature(GSTREAMER_PLUGIN_AUDIO_LIBRARIES "GStreamer audio plugin" "The gstreamer audio plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
    2021
    2122macro_optional_find_package(GLIB2)
     
    3132macro_log_feature(OPENGL_FOUND "OpenGL" "OpenGL support is required to compile the gstreamer backend for Phonon" "" FALSE)
    3233
    33 if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
     34if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
    3435   set(BUILD_PHONON_GSTREAMER TRUE)
    35 else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
     36else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
    3637   set(BUILD_PHONON_GSTREAMER FALSE)
    37 endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
     38endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
  • trunk/src/3rdparty/phonon/gstreamer/audiooutput.cpp

    r561 r846  
    126126{
    127127    m_backend->logMessage(Q_FUNC_INFO + QString::number(newDevice), Backend::Info, this);
     128
    128129    if (newDevice == m_device)
    129130        return true;
     
    136137
    137138    bool success = false;
    138     const QList<AudioDevice> deviceList = m_backend->deviceManager()->audioOutputDevices();
    139     int deviceIdx = -1;
    140     for (int i=0; i<deviceList.size(); i++) {
    141         if (deviceList.at(i).id == newDevice) {
    142             deviceIdx = i;
    143             break;
    144         }
    145     }
    146 
    147     if (m_audioSink && deviceIdx >= 0) {
     139    if (m_audioSink &&  newDevice >= 0) {
    148140        // Save previous state
    149141        GstState oldState = GST_STATE(m_audioSink);
    150142        const QByteArray oldDeviceValue = GstHelper::property(m_audioSink, "device");
    151         const QByteArray deviceId = deviceList.at(deviceIdx).gstId;
     143        const QByteArray deviceId = m_backend->deviceManager()->gstId(newDevice);
    152144        m_device = newDevice;
    153145
     
    171163        }
    172164
    173         // Note the stopped state should not really be neccessary, but seems to be required to
     165        // Note the stopped state should not really be necessary, but seems to be required to
    174166        // properly reset after changing the audio state
    175167        if (root()) {
  • trunk/src/3rdparty/phonon/gstreamer/backend.cpp

    r561 r846  
    1919#include "backend.h"
    2020#include "audiooutput.h"
     21#include "audiodataoutput.h"
    2122#include "audioeffect.h"
    2223#include "mediaobject.h"
     
    2728#include "volumefadereffect.h"
    2829#include <gst/interfaces/propertyprobe.h>
     30#include <phonon/pulsesupport.h>
    2931
    3032#include <QtCore/QSet>
     
    5052        , m_isValid(false)
    5153{
     54    // Initialise PulseAudio support
     55    PulseSupport *pulse = PulseSupport::getInstance();
     56    pulse->enable();
     57    connect(pulse, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), SIGNAL(objectDescriptionChanged(ObjectDescriptionType)));
     58
    5259    // In order to support reloading, we only set the app name once...
    5360    static bool first = true;
     
    5663        g_set_application_name(qApp->applicationName().toUtf8());
    5764    }
    58 
    5965    GError *err = 0;
    6066    bool wasInit = gst_init_check(0, 0, &err);  //init gstreamer: must be called before any gst-related functions
     
    9399Backend::~Backend()
    94100{
     101    delete m_effectManager;
     102    delete m_deviceManager;
     103    PulseSupport::shutdown();
    95104}
    96105
     
    120129        return new MediaObject(this, parent);
    121130
    122     case AudioOutputClass: {
    123             AudioOutput *ao = new AudioOutput(this, parent);
    124             m_audioOutputs.append(ao);
    125             return ao;
    126         }
     131    case AudioOutputClass:
     132        return new AudioOutput(this, parent);
     133
    127134#ifndef QT_NO_PHONON_EFFECT
    128135    case EffectClass:
     
    130137#endif //QT_NO_PHONON_EFFECT
    131138    case AudioDataOutputClass:
    132         logMessage("createObject() : AudioDataOutput not implemented");
    133         break;
     139        return new AudioDataOutput(this, parent);
    134140
    135141#ifndef QT_NO_PHONON_VIDEO
     
    215221        QString klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature));
    216222
    217         if (klass == QLatin1String("Codec/Decoder") ||
    218             klass == QLatin1String("Codec/Decoder/Audio") ||
    219             klass == QLatin1String("Codec/Decoder/Video") ||
    220             klass == QLatin1String("Codec/Demuxer") ||
    221             klass == QLatin1String("Codec/Demuxer/Audio") ||
    222             klass == QLatin1String("Codec/Demuxer/Video") ||
    223             klass == QLatin1String("Codec/Parser") ||
    224             klass == QLatin1String("Codec/Parser/Audio") ||
     223        if (klass == QLatin1String("Codec/Decoder") || 
     224            klass == QLatin1String("Codec/Decoder/Audio") || 
     225            klass == QLatin1String("Codec/Decoder/Video") || 
     226            klass == QLatin1String("Codec/Demuxer") || 
     227            klass == QLatin1String("Codec/Demuxer/Audio") || 
     228            klass == QLatin1String("Codec/Demuxer/Video") || 
     229            klass == QLatin1String("Codec/Parser") || 
     230            klass == QLatin1String("Codec/Parser/Audio") || 
    225231            klass == QLatin1String("Codec/Parser/Video")) {
    226232
     
    235241
    236242                    if (caps) {
    237                         const GstStructure* capsStruct = gst_caps_get_structure (caps, 0);
    238                         QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
    239                         if (!availableMimeTypes.contains(mime))
    240                               availableMimeTypes.append(mime);
     243                        for (unsigned int struct_idx = 0; struct_idx < gst_caps_get_size (caps); struct_idx++) {
     244
     245                            const GstStructure* capsStruct = gst_caps_get_structure (caps, struct_idx);
     246                            QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
     247                            if (!availableMimeTypes.contains(mime))
     248                                availableMimeTypes.append(mime);
     249                        }
    241250                    }
    242251                }
     
    245254    }
    246255    g_list_free(factoryList);
     256    if (availableMimeTypes.contains("audio/x-vorbis")
     257        && availableMimeTypes.contains("application/x-ogm-audio")) {
     258        if (!availableMimeTypes.contains("audio/x-vorbis+ogg"))
     259            availableMimeTypes.append("audio/x-vorbis+ogg");
     260        if (!availableMimeTypes.contains("application/ogg"))  /* *.ogg */
     261            availableMimeTypes.append("application/ogg");
     262        if (!availableMimeTypes.contains("audio/ogg")) /* *.oga */
     263            availableMimeTypes.append("audio/ogg");
     264    }
    247265    availableMimeTypes.sort();
    248266    return availableMimeTypes;
     
    294312    switch (type) {
    295313    case Phonon::AudioOutputDeviceType: {
    296             QList<AudioDevice> audioDevices = deviceManager()->audioOutputDevices();
    297             foreach(const AudioDevice &device, audioDevices) {
    298                 if (device.id == index) {
    299                     ret.insert("name", device.gstId);
    300                     ret.insert("description", device.description);
    301                     ret.insert("icon", QLatin1String("audio-card"));
    302                     break;
    303                 }
     314            AudioDevice* ad;
     315            if ((ad = deviceManager()->audioDevice(index))) {
     316                ret.insert("name", ad->gstId);
     317                ret.insert("description", ad->description);
     318                ret.insert("icon", ad->icon);
    304319            }
    305320        }
     
    430445/**
    431446 * Returns a debuglevel that is determined by the
    432  * PHONON_GSTREAMER_DEBUG environment variable.
     447 * PHONON_GST_DEBUG environment variable.
    433448 *
    434449 *  Warning - important warnings
  • trunk/src/3rdparty/phonon/gstreamer/backend.h

    r2 r846  
    8787private:
    8888    static gboolean busCall(GstBus *bus, GstMessage *msg, gpointer data);
    89     QList<QPointer<AudioOutput> > m_audioOutputs;
    9089
    9190    DeviceManager *m_deviceManager;
  • 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) {
  • trunk/src/3rdparty/phonon/gstreamer/devicemanager.h

    r2 r846  
    4343    QByteArray gstId;
    4444    QByteArray description;
     45    QString icon;
    4546};
    4647
     
    5253    const QList<AudioDevice> audioOutputDevices() const;
    5354    GstPad *requestPad(int device) const;
     55    int allocateDeviceId();
    5456    int deviceId(const QByteArray &gstId) const;
    55     QByteArray deviceDescription(int id) const;
     57    const QByteArray gstId(int id);
     58    AudioDevice* audioDevice(int id);
    5659    GstElement *createGNOMEAudioSink(Category category);
    5760    GstElement *createAudioSink(Category category = NoCategory);
     
    6972    Backend *m_backend;
    7073    QList <AudioDevice> m_audioDeviceList;
     74    int m_audioDeviceCounter;
    7175    QTimer m_devicePollTimer;
    7276    QByteArray m_audioSink;
  • trunk/src/3rdparty/phonon/gstreamer/effectmanager.cpp

    r2 r846  
    5555            // "equalizer-nbands" not really useful at the moment
    5656
    57             // These plugins simply dont work or have major stability issues:
     57            // These plugins simply don't work or have major stability issues:
    5858            // "iir" Does not seem to do much at the moment
    5959            // "audioinvert" Only works for some streams, should be invesigated
  • trunk/src/3rdparty/phonon/gstreamer/glrenderer.cpp

    r2 r846  
    267267    setPalette(palette);
    268268    setAutoFillBackground(true);
    269     // Videowidget allways have this property to allow hiding the mouse cursor
     269    // Videowidget always have this property to allow hiding the mouse cursor
    270270    setMouseTracking(true);
    271271}
     
    305305        const QRectF r = drawFrameRect();
    306306
    307         const float v_array[] = { r.left(), r.top(), r.right(), r.top(), r.right(), r.bottom(), r.left(), r.bottom() };
     307        const float v_array[] = { float(r.left()), float(r.top()), float(r.right()), float(r.top()), float(r.right()), float(r.bottom()), float(r.left()), float(r.bottom()) };
    308308
    309309        glActiveTexture(GL_TEXTURE0);
  • trunk/src/3rdparty/phonon/gstreamer/gsthelper.cpp

    r2 r846  
    122122    GstElement *playbin = 0;
    123123    //init playbin and add to our pipeline
    124     playbin = gst_element_factory_make("playbin", NULL);
     124    playbin = gst_element_factory_make("playbin2", NULL);
    125125
    126126    //Create an identity element to redirect sound
  • trunk/src/3rdparty/phonon/gstreamer/gstreamer.desktop

    r2 r846  
    1111
    1212Name=GStreamer
     13Name[bg]=GStreamer
     14Name[ca]=GStreamer
     15Name[ca@valencia]=GStreamer
     16Name[cs]=GStreamer
     17Name[da]=GStreamer
     18Name[de]=GStreamer
     19Name[el]=GStreamer
     20Name[en_GB]=GStreamer
     21Name[es]=GStreamer
     22Name[et]=GStreamer
     23Name[eu]=GStreamer
     24Name[fi]=GStreamer
     25Name[fr]=GStreamer
     26Name[ga]=GStreamer
     27Name[gl]=GStreamer
     28Name[hsb]=GStreamer
     29Name[hu]=GStreamer
     30Name[id]=GStreamer
     31Name[is]=GStreamer
     32Name[it]=GStreamer
     33Name[ja]=GStreamer
     34Name[ko]=GStreamer
     35Name[ku]=GStreamer
     36Name[lt]=GStreamer
     37Name[lv]=GStreamer
     38Name[nb]=GStreamer
     39Name[nds]=GStreamer
     40Name[nl]=GStreamer
     41Name[nn]=GStreamer
    1342Name[pa]=àšœà©€àšžàšŸà©€àš°àš®àš°
     43Name[pl]=GStreamer
     44Name[pt]=GStreamer
     45Name[pt_BR]=GStreamer
     46Name[ru]=GStreamer
     47Name[se]=GStreamer
     48Name[sk]=GStreamer
     49Name[sl]=GStreamer
    1450Name[sr]=ГстрОЌер
     51Name[sr@ijekavian]=ГстрОЌер
     52Name[sr@ijekavianlatin]=GStreamer
     53Name[sr@latin]=GStreamer
    1554Name[sv]=Gstreamer
     55Name[tr]=GStreamer
     56Name[uk]=GStreamer
    1657Name[x-test]=xxGStreamerxx
     58Name[zh_CN]=GStreamer
     59Name[zh_TW]=GStreamer
    1760
    1861Comment=Phonon GStreamer backend
    1962Comment[bg]=Phonon GStreamer
    2063Comment[ca]=Dorsal GStreamer del Phonon
     64Comment[ca@valencia]=Dorsal GStreamer del Phonon
     65Comment[cs]=Phonon GStreamer backend
    2166Comment[da]=GStreamer-backend til Phonon
    2267Comment[de]=Phonon-Treiber fÃŒr GStreamer
     
    2469ποστήριΟης GStreamer τοÏ
    2570 Phonon
     71Comment[en_GB]=Phonon GStreamer backend
    2672Comment[es]=Motor GStreamer para Phonon
    2773Comment[et]=Phononi GStreameri taustaprogramm
     74Comment[eu]=Phonon GStreamer backend
     75Comment[fi]=Phonon GStreamer-taustaohjelma
    2876Comment[fr]=SystÚme de gestion GStreamer pour Phonon
    2977Comment[ga]=Inneall GStreamer le haghaidh Phonon
    3078Comment[gl]=Infraestrutura de GStreamer para Phonon
     79Comment[hsb]=Phonon GStreamer backend
     80Comment[hu]=Phonon GStreamer modul
     81Comment[id]=Phonon GStreamer backend
    3182Comment[is]=Phonon GStreamer bakendi
    3283Comment[it]=Motore Gstreamer di Phonon
     
    3485Comment[ko]=Phonon GStreamer 백엔드
    3586Comment[ku]=Binesaza Phonon GStreamer
     87Comment[lt]=Phonon GStreamer galinė sÄ
     88saja
    3689Comment[lv]=Phonon GStreamer aizmugure
     90Comment[nb]=Phonon-motor for GStreamer
    3791Comment[nds]=Phonon-HÃŒlpprogramm GStreamer
    3892Comment[nl]=GStreamer-backend (Phonon)
     
    4296Comment[pt]=Infra-estrutura do GStreamer para o Phonon
    4397Comment[pt_BR]=Infraestrutura Phonon GStreamer
     98Comment[ru]=МеÑ
     99аМОзЌ GStreamer Ўля Phonon
     100Comment[se]=Phonon GStreamer duogášmohtor
    44101Comment[sk]=GStreamer podsystém
    45102Comment[sl]=Phononova hrbtenica GStreamer
    46103Comment[sr]=ГстрОЌер каП пПзаЎОМа ЀПМПМа
     104Comment[sr@ijekavian]=ГстрОЌер каП пПзаЎОМа ЀПМПМа
     105Comment[sr@ijekavianlatin]=GStreamer kao pozadina Phonona
    47106Comment[sr@latin]=GStreamer kao pozadina Phonona
    48107Comment[sv]=Phonon Gstreamer-grÀnssnitt
  • trunk/src/3rdparty/phonon/gstreamer/medianode.cpp

    r2 r846  
    199199        // potential deadlock. Hence we force the pipeline into ready state
    200200        // before any nodes are disconnected.
    201         gst_element_set_state(root()->pipeline(), GST_STATE_READY);   
    202 
    203         Q_ASSERT(sink->root()); //sink has to have a root since it is onnected
     201        gst_element_set_state(root()->pipeline(), GST_STATE_READY);
     202
     203        Q_ASSERT(sink->root()); //sink has to have a root since it is connected
    204204
    205205        if (sink->description() & (AudioSink)) {
  • trunk/src/3rdparty/phonon/gstreamer/mediaobject.cpp

    r561 r846  
    1717#include <cmath>
    1818#include <gst/interfaces/propertyprobe.h>
     19#include <gst/pbutils/install-plugins.h>
    1920#include "common.h"
    2021#include "mediaobject.h"
     
    5455        , m_prefinishMark(0)
    5556        , m_transitionTime(0)
     57        , m_isStream(false)
    5658        , m_posAtSeek(-1)
    5759        , m_prefinishMarkReachedNotEmitted(true)
     
    8082        , m_availableTitles(0)
    8183        , m_currentTitle(1)
     84        , m_pendingTitle(1)
    8285{
    8386    qRegisterMetaType<GstCaps*>("GstCaps*");
     
    9699        connect(m_tickTimer, SIGNAL(timeout()), SLOT(emitTick()));
    97100    }
    98     connect(this, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
    99             this, SLOT(notifyStateChange(Phonon::State,Phonon::State)));
     101    connect(this, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
     102            this, SLOT(notifyStateChange(Phonon::State, Phonon::State)));
    100103
    101104}
     
    137140}
    138141
     142void
     143pluginInstallationDone( GstInstallPluginsReturn res, gpointer userData )
     144{
     145    // Nothing inside yet
     146    Q_UNUSED(res);
     147    Q_UNUSED(userData);
     148}
     149
    139150void MediaObject::saveState()
    140151{
     
    196207        bool canPlay = (m_hasAudio || m_videoStreamFound);
    197208        Phonon::ErrorType error = canPlay ? Phonon::NormalError : Phonon::FatalError;
     209#ifdef PLUGIN_INSTALL_API
     210        GstInstallPluginsContext *ctx = gst_install_plugins_context_new ();
     211        gchar *details[2];
     212        details[0] = m_missingCodecs[0].toLocal8Bit().data();
     213        details[1] = NULL;
     214        GstInstallPluginsReturn status;
     215
     216        status = gst_install_plugins_async( details, ctx, pluginInstallationDone, NULL );
     217        gst_install_plugins_context_free ( ctx );
     218
     219        if ( status != GST_INSTALL_PLUGINS_STARTED_OK )
     220        {
     221            if( status == GST_INSTALL_PLUGINS_HELPER_MISSING )
     222                setError(tr("Missing codec helper script assistant."), Phonon::FatalError );
     223            else
     224                setError(tr("Plugin codec installation failed for codec: %0")
     225                        .arg(m_missingCodecs[0].split("|")[3]), error);
     226        }
     227        m_missingCodecs.clear();
     228#else
     229        QString codecs = m_missingCodecs.join(", ");
     230
    198231        if (error == Phonon::NormalError && m_hasVideo && !m_videoStreamFound) {
    199232            m_hasVideo = false;
    200233            emit hasVideoChanged(false);
    201234        }
    202         QString codecs = m_missingCodecs.join(", ");
    203         setError(QString(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0")).arg(codecs), error);
     235        setError(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0").arg(codecs), error);
    204236        m_missingCodecs.clear();
     237#endif
    205238    }
    206239}
     
    249282
    250283    }
    251     media->addMissingCodecName(value);
     284
     285#ifdef PLUGIN_INSTALL_API
     286    QString plugins = QString("gstreamer|0.10|%0|%1|decoder-%2")
     287        .arg( qApp->applicationName() )
     288        .arg( value )
     289        .arg( QString::fromUtf8(gst_caps_to_string (caps) ) );
     290    media->addMissingCodecName( plugins );
     291#else
     292    media->addMissingCodecName( value );
     293#endif
    252294}
    253295
     
    310352            // Note that the notify::caps _must_ be installed after linking to work with Dapper
    311353            m_capsHandler = g_signal_connect(pad, "notify::caps", G_CALLBACK(notifyVideoCaps), this);
    312  
     354
    313355            if (!m_loading && !m_hasVideo) {
    314356                m_hasVideo = m_videoStreamFound;
     
    369411
    370412    // Create a new datasource based on the input URL
    371     QByteArray encoded_cstr_url = url.toEncoded();
     413    // add the 'file' scheme if it's missing; the double '/' is needed!
     414    QByteArray encoded_cstr_url = (url.scheme() == QLatin1String("") ?
     415                    "file://" + url.toEncoded() :
     416                    url.toEncoded());
    372417    m_datasource = gst_element_make_from_uri(GST_URI_SRC, encoded_cstr_url.constData(), (const char*)NULL);
    373418    if (!m_datasource)
     
    389434            m_backend->logMessage(QString("new device speed : 2X"), Backend::Info, this);
    390435        }
     436  }
     437
     438    /* make HTTP sources send extra headers so we get icecast
     439     * metadata in case the stream is an icecast stream */
     440    if (encoded_cstr_url.startsWith("http://")
     441        && g_object_class_find_property (G_OBJECT_GET_CLASS (m_datasource), "iradio-mode")) {
     442        g_object_set (m_datasource, "iradio-mode", TRUE, NULL);
     443        m_isStream = true;
    391444    }
    392445
     
    443496    gst_object_sink (GST_OBJECT (m_pipeline));
    444497
    445     m_decodebin = gst_element_factory_make ("decodebin", NULL);
     498    m_decodebin = gst_element_factory_make ("decodebin2", NULL);
    446499    g_signal_connect (m_decodebin, "new-decoded-pad", G_CALLBACK (&cb_newpad), this);
    447500    g_signal_connect (m_decodebin, "unknown-type", G_CALLBACK (&cb_unknown_type), this);
     
    647700        } else if (currentState == GST_STATE_PLAYING) {
    648701            changeState(Phonon::PlayingState);
    649         } else if (!m_atEndOfStream && gst_element_set_state(m_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE) {
     702        } else if (gst_element_set_state(m_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE) {
    650703            m_pendingState = Phonon::PlayingState;
    651704        } else {
     
    677730
    678731    Phonon::State oldState = m_state;
    679     m_state = newstate; // m_state must be set before emitting, since 
     732    m_state = newstate; // m_state must be set before emitting, since
    680733                        // Error state requires that state() will return the new value
    681734    m_pendingState = newstate;
     
    697750    case Phonon::StoppedState:
    698751        m_backend->logMessage("phonon state changed: Stopped", Backend::Info, this);
     752        // We must reset the pipeline when playing again
     753        m_resetNeeded = true;
    699754        m_tickTimer->stop();
    700755        break;
     
    862917    GstState state;
    863918    gst_element_set_state(m_pipeline, GST_STATE_NULL);
    864     gst_element_get_state (m_pipeline, &state, NULL, 2000);
     919    gst_element_get_state(m_pipeline, &state, NULL, 2000);
    865920
    866921    m_source = source;
     
    872927    changeState(Phonon::LoadingState);
    873928    m_loading = true;
    874     m_resetNeeded = false;
     929    // IMPORTANT: Honor the m_resetNeeded flag as it currently stands.
     930    // See https://qa.mandriva.com/show_bug.cgi?id=56807
     931    //m_resetNeeded = false;
    875932    m_resumeState = false;
    876933    m_pendingState = Phonon::StoppedState;
     
    885942    m_aboutToFinishEmitted = false;
    886943    m_error = NoError;
    887     m_errorString = QString();
    888    
     944    m_errorString.clear();
     945
    889946    m_bufferPercent = 0;
    890947    m_prefinishMarkReachedNotEmitted = true;
     
    895952    m_atEndOfStream = false;
    896953
    897     // Clear exising meta tags
     954    m_availableTitles = 0;
     955    m_pendingTitle = 1;
     956    m_currentTitle = 1;
     957
     958    // Clear existing meta tags
    898959    m_metaData.clear();
     960    m_isStream = false;
    899961
    900962    switch (source.type()) {
    901     case MediaSource::Url: {           
    902             if (createPipefromURL(source.url()))
    903                 m_loading = true;
    904             else
     963    case MediaSource::Url: {
     964            if (!createPipefromURL(source.url()))
    905965                setError(tr("Could not open media source."));
    906966        }
     
    908968
    909969    case MediaSource::LocalFile: {
    910             if (createPipefromURL(QUrl::fromLocalFile(source.fileName())))
    911                 m_loading = true;
    912             else
     970            if (!createPipefromURL(QUrl::fromLocalFile(source.fileName())))
    913971                setError(tr("Could not open media source."));
    914972        }
     
    923981
    924982    case MediaSource::Stream:
    925         if (createPipefromStream(source))
    926             m_loading = true;
    927         else
     983        if (!createPipefromStream(source))
    928984            setError(tr("Could not open media source."));
    929985        break;
     
    931987    case MediaSource::Disc:
    932988        {
    933             QString mediaUrl;
    934             switch (source.discType()) {
    935             case Phonon::NoDisc:
     989       QString mediaUrl;
     990       switch (source.discType()) {
     991       case Phonon::NoDisc:
    936992                qWarning() << "I should never get to see a MediaSource that is a disc but doesn't specify which one";
    937993                return;
     
    9491005                return;
    9501006            }
    951             if (!mediaUrl.isEmpty() && createPipefromURL(QUrl(mediaUrl)))
    952                 m_loading = true;
    953             else
     1007            if (mediaUrl.isEmpty() || !createPipefromURL(QUrl(mediaUrl)))
    9541008                setError(tr("Could not open media source."));
    9551009        }
     
    9671021    // We need to link this node to ensure that fake sinks are connected
    9681022    // before loading, otherwise the stream will be blocked
    969     if (m_loading)
    970         link();
     1023    link();
    9711024    beginLoad();
    9721025}
     
    10051058    }
    10061059
    1007     m_availableTitles = 1;
    1008     gint64 titleCount;
    1009     GstFormat format = gst_format_get_by_nick("track");
    1010     if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
     1060    if (m_source.discType() == Phonon::Cd) {
     1061        gint64 titleCount;
     1062        GstFormat format = gst_format_get_by_nick("track");
     1063        if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
    10111064        //check if returned format is still "track",
    10121065        //gstreamer sometimes returns the total time, if tracks information is not available.
    1013         if (qstrcmp(gst_format_get_name(format), "track") == 0)  {
    1014             int oldAvailableTitles = m_availableTitles;
    1015             m_availableTitles = (int)titleCount;
    1016             if (m_availableTitles != oldAvailableTitles) {
    1017                 emit availableTitlesChanged(m_availableTitles);
    1018                 m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
     1066            if (qstrcmp(gst_format_get_name(format), "track") == 0)  {
     1067                int oldAvailableTitles = m_availableTitles;
     1068                m_availableTitles = (int)titleCount;
     1069                if (m_availableTitles != oldAvailableTitles) {
     1070                    emit availableTitlesChanged(m_availableTitles);
     1071                    m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
     1072                }
    10191073            }
    10201074        }
    10211075    }
    1022 
    10231076}
    10241077
     
    10781131
    10791132        quint64 current = currentTime();
    1080         quint64 total = totalTime(); 
     1133        quint64 total = totalTime();
    10811134
    10821135        if (current < total - m_prefinishMark)
     
    10991152    if (m_tickInterval > 0 && currentTime != m_previousTickTime) {
    11001153        emit tick(currentTime);
    1101         m_previousTickTime = currentTime;       
     1154        m_previousTickTime = currentTime;
    11021155    }
    11031156    if (m_state == Phonon::PlayingState) {
     
    11101163        // Prepare load of next source
    11111164        if (currentTime >= totalTime - ABOUT_TO_FINNISH_TIME) {
    1112             if (!m_aboutToFinishEmitted) {
     1165            if (m_source.type() == MediaSource::Disc &&
     1166                m_autoplayTitles &&
     1167                m_availableTitles > 1 &&
     1168                m_currentTitle < m_availableTitles) {
     1169                m_aboutToFinishEmitted = false;
     1170            } else if (!m_aboutToFinishEmitted) {
    11131171                m_aboutToFinishEmitted = true; // track is about to finish
    11141172                emit aboutToFinish();
     
    12141272    switch (GST_MESSAGE_TYPE (gstMessage)) {
    12151273
    1216     case GST_MESSAGE_EOS: 
    1217         m_backend->logMessage("EOS recieved", Backend::Info, this);
     1274    case GST_MESSAGE_EOS:
     1275        m_backend->logMessage("EOS received", Backend::Info, this);
    12181276        handleEndOfStream();
    12191277        break;
     
    12231281            gst_message_parse_tag(gstMessage, &tag_list);
    12241282            if (tag_list) {
     1283                TagMap newTags;
     1284                gst_tag_list_foreach (tag_list, &foreach_tag_function, &newTags);
     1285                gst_tag_list_free(tag_list);
     1286
     1287                // Determine if we should no fake the album/artist tags.
     1288                // This is a little confusing as we want to fake it on initial
     1289                // connection where title, album and artist are all missing.
     1290                // There are however times when we get just other information,
     1291                // e.g. codec, and so we want to only do clever stuff if we
     1292                // have a commonly available tag (ORGANIZATION) or we have a
     1293                // change in title
     1294                bool fake_it =
     1295                   (m_isStream
     1296                    && ((!newTags.contains("TITLE")
     1297                         && newTags.contains("ORGANIZATION"))
     1298                        || (newTags.contains("TITLE")
     1299                            && m_metaData.value("TITLE") != newTags.value("TITLE")))
     1300                    && !newTags.contains("ALBUM")
     1301                    && !newTags.contains("ARTIST"));
     1302
    12251303                TagMap oldMap = m_metaData; // Keep a copy of the old one for reference
    1226                 // Append any new meta tags to the existing tag list
    1227                 gst_tag_list_foreach (tag_list, &foreach_tag_function, &m_metaData);
     1304
     1305                // Now we've checked the new data, append any new meta tags to the existing tag list
     1306                // We cannot use TagMap::iterator as this is a multimap and when streaming data
     1307                // could in theory be lost.
     1308                QList<QString> keys = newTags.keys();
     1309                for (QList<QString>::iterator i = keys.begin(); i != keys.end(); ++i) {
     1310                    QString key = *i;
     1311                    if (m_isStream) {
     1312                        // If we're streaming, we need to remove data in m_metaData
     1313                        // in order to stop it filling up indefinitely (as it's a multimap)
     1314                        m_metaData.remove(key);
     1315                    }
     1316                    QList<QString> values = newTags.values(key);
     1317                    for (QList<QString>::iterator j = values.begin(); j != values.end(); ++j) {
     1318                        QString value = *j;
     1319                        QString currVal = m_metaData.value(key);
     1320                        if (!m_metaData.contains(key) || currVal != value) {
     1321                            m_metaData.insert(key, value);
     1322                        }
     1323                    }
     1324                }
     1325
    12281326                m_backend->logMessage("Meta tags found", Backend::Info, this);
    1229                 if (oldMap != m_metaData && !m_loading)
    1230                     emit metaDataChanged(m_metaData);
    1231                 gst_tag_list_free(tag_list);
    1232             }
     1327                if (oldMap != m_metaData) {
     1328                    // This is a bit of a hack to ensure that stream metadata is
     1329                    // returned. We get as much as we can from the Shoutcast server's
     1330                    // StreamTitle= header. If further info is decoded from the stream
     1331                    // itself later, then it will overwrite this info.
     1332                    if (m_isStream && fake_it) {
     1333                        m_metaData.remove("ALBUM");
     1334                        m_metaData.remove("ARTIST");
     1335
     1336                        // Detect whether we want to "fill in the blanks"
     1337                        QString str;
     1338                        if (m_metaData.contains("TITLE"))
     1339                        {
     1340                            str = m_metaData.value("TITLE");
     1341                            int splitpoint;
     1342                            // Check to see if our title matches "%s - %s"
     1343                            // Where neither %s are empty...
     1344                            if ((splitpoint = str.indexOf(" - ")) > 0
     1345                                && str.size() > (splitpoint+3)) {
     1346                                m_metaData.insert("ARTIST", str.left(splitpoint));
     1347                                m_metaData.replace("TITLE", str.mid(splitpoint+3));
     1348                            }
     1349                        } else {
     1350                            str = m_metaData.value("GENRE");
     1351                            if (!str.isEmpty())
     1352                                m_metaData.insert("TITLE", str);
     1353                            else
     1354                                m_metaData.insert("TITLE", "Streaming Data");
     1355                        }
     1356                        if (!m_metaData.contains("ARTIST")) {
     1357                            str = m_metaData.value("LOCATION");
     1358                            if (!str.isEmpty())
     1359                                m_metaData.insert("ARTIST", str);
     1360                            else
     1361                                m_metaData.insert("ARTIST", "Streaming Data");
     1362                        }
     1363                        str = m_metaData.value("ORGANIZATION");
     1364                        if (!str.isEmpty())
     1365                            m_metaData.insert("ALBUM", str);
     1366                        else
     1367                            m_metaData.insert("ALBUM", "Streaming Data");
     1368                    }
     1369                    // As we manipulate the title, we need to recompare
     1370                    // oldMap and m_metaData here...
     1371                    if (oldMap != m_metaData && !m_loading)
     1372                        emit metaDataChanged(m_metaData);
     1373                }
     1374                        }
    12331375        }
    12341376        break;
     
    12561398                m_tickTimer->start();
    12571399                changeState(Phonon::PlayingState);
     1400                if ((m_source.type() == MediaSource::Disc) && (m_currentTitle != m_pendingTitle)) {
     1401                    setTrack(m_pendingTitle);
     1402                }
    12581403                if (m_resumeState && m_oldState == Phonon::PlayingState) {
    12591404                    seek(m_oldPos);
     
    12911436                m_backend->logMessage("gstreamer: pipeline state set to ready", Backend::Debug, this);
    12921437                m_tickTimer->stop();
     1438                if ((m_source.type() == MediaSource::Disc) && (m_currentTitle != m_pendingTitle)) {
     1439                    setTrack(m_pendingTitle);
     1440                }
    12931441                break;
    12941442
     
    13291477                        gst_caps_unref (caps);
    13301478                        gst_object_unref (sinkPad);
    1331                    } 
     1479                   }
    13321480               } else {
    13331481                    setError(QString(err->message), Phonon::FatalError);
     
    14011549        //case GST_MESSAGE_LATENCY: only from 0.10.12
    14021550        //case GST_MESSAGE_ASYNC_DONE: only from 0.10.13
    1403     default: 
    1404         break; 
     1551    default:
     1552        break;
    14051553    }
    14061554}
     
    14181566        m_atEndOfStream = true;
    14191567
    1420     if (m_autoplayTitles &&
     1568    if (m_source.type() == MediaSource::Disc &&
     1569        m_autoplayTitles &&
    14211570        m_availableTitles > 1 &&
    14221571        m_currentTitle < m_availableTitles) {
     
    14421591                setState(m_pendingState);
    14431592        }
     1593    }
     1594}
     1595
     1596void MediaObject::invalidateGraph()
     1597{
     1598    m_resetNeeded = true;
     1599    if (m_state == Phonon::PlayingState || m_state == Phonon::PausedState) {
     1600        changeState(Phonon::StoppedState);
    14441601    }
    14451602}
     
    15031660void MediaObject::_iface_setCurrentTitle(int title)
    15041661{
     1662    m_backend->logMessage(QString("setCurrentTitle %0").arg(title), Backend::Info, this);
     1663    if ((title == m_currentTitle) || (title == m_pendingTitle))
     1664        return;
     1665
     1666    m_pendingTitle = title;
     1667
     1668    if (m_state == Phonon::PlayingState || m_state == Phonon::StoppedState) {
     1669        setTrack(m_pendingTitle);
     1670    } else {
     1671        setState(Phonon::StoppedState);
     1672    }
     1673}
     1674
     1675void MediaObject::setTrack(int title)
     1676{
     1677    if (((m_state != Phonon::PlayingState) && (m_state != Phonon::StoppedState)) || (title < 1) || (title > m_availableTitles))
     1678        return;
     1679
     1680
     1681    //let's seek to the beginning of the song
    15051682    GstFormat trackFormat = gst_format_get_by_nick("track");
    1506     m_backend->logMessage(QString("setCurrentTitle %0").arg(title), Backend::Info, this);
    1507     if ((title == m_currentTitle) || (title < 1) || (title > m_availableTitles))
    1508         return;
    1509 
    1510     m_currentTitle = title;
    1511 
    1512     //let's seek to the beginning of the song
    1513     if (gst_element_seek_simple(m_pipeline, trackFormat, GST_SEEK_FLAG_FLUSH, m_currentTitle - 1)) {
     1683    m_backend->logMessage(QString("setTrack %0").arg(title), Backend::Info, this);
     1684    if (gst_element_seek_simple(m_pipeline, trackFormat, GST_SEEK_FLAG_FLUSH, title - 1)) {
     1685        m_currentTitle = title;
    15141686        updateTotalTime();
    15151687        m_atEndOfStream = false;
  • trunk/src/3rdparty/phonon/gstreamer/mediaobject.h

    r2 r846  
    5656{
    5757    friend class Stream;
     58    friend class AudioDataOutput;
    5859    Q_OBJECT
    5960    Q_INTERFACES(Phonon::MediaObjectInterface
     
    145146    void handleEndOfStream();
    146147    void addMissingCodecName(const QString &codec) { m_missingCodecs.append(codec); }
    147     void invalidateGraph() {
    148         m_resetNeeded = true;
    149         if (m_state == Phonon::PlayingState || m_state == Phonon::PausedState) {
    150             changeState(Phonon::StoppedState);
    151         }
    152     }
     148    void invalidateGraph();
     149
    153150    static void cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data);
    154151    static void cb_pad_added (GstElement *decodebin, GstPad *pad, gpointer data);
     
    237234    int _iface_currentTitle() const;
    238235    void _iface_setCurrentTitle(int title);
     236    void setTrack(int title);
    239237
    240238    bool m_resumeState;
     
    251249    qint32 m_prefinishMark;
    252250    qint32 m_transitionTime;
     251        bool m_isStream;
    253252
    254253    qint64 m_posAtSeek;
     
    286285    int m_availableTitles;
    287286    int m_currentTitle;
     287    int m_pendingTitle;
    288288};
    289289}
  • trunk/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h

    r2 r846  
    2020
    2121#include "common.h"
     22#include "qwidgetvideosink.h"
    2223
    2324#include <QtCore/QByteArray>
  • trunk/src/3rdparty/phonon/gstreamer/videowidget.h

    r561 r846  
    2626#include "medianode.h"
    2727#include "abstractrenderer.h"
     28#include "videowidget.h"
    2829
    2930#include <gst/gst.h>
  • trunk/src/3rdparty/phonon/gstreamer/x11renderer.cpp

    r2 r846  
    9191            videoSink = 0;
    9292        } else {
    93             // Note that this should not really be neccessary as these are
     93            // Note that this should not really be necessary as these are
    9494            // default values, though under certain conditions values are retained
    9595            // even between application instances. (reproducible on 0.10.16/Gutsy)
     
    139139{
    140140    Q_UNUSED(movieSize);
     141
    141142    if (m_renderWidget) {
    142143        m_renderWidget->setGeometry(m_videoWidget->calculateDrawFrameRect());
  • trunk/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp

    r769 r846  
    185185{
    186186    // Default implementation
     187    Q_UNUSED(param)
     188    Q_UNUSED(value)
    187189    Q_ASSERT_X(false, Q_FUNC_INFO, "Effect has no parameters");
    188190    return 0;
  • trunk/src/3rdparty/phonon/mmf/abstractaudioeffect.h

    r769 r846  
    119119// in the implementations of the backend effect nodes.
    120120
     121#ifdef Q_CC_NOKIAX86
     122#   pragma warn_illtokenpasting off
     123#endif
     124
    121125#define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect)                      \
    122126                                                                        \
  • trunk/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp

    r769 r846  
    1717*/
    1818
     19#include <QResource>
    1920#include <QUrl>
    2021
     
    2324#include "mediaobject.h"
    2425#include "utils.h"
     26#include <cdbcols.h>
     27#include <cdblen.h>
     28#include <commdb.h>
    2529
    2630QT_BEGIN_NAMESPACE
     
    5155        ,   m_pending(NothingPending)
    5256        ,   m_positionTimer(new QTimer(this))
     57        ,   m_position(0)
    5358        ,   m_bufferStatusTimer(new QTimer(this))
    5459        ,   m_mmfMaxVolume(NullMaxVolume)
    5560        ,   m_prefinishMarkSent(false)
    5661        ,   m_aboutToFinishSent(false)
     62#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     63        ,   m_download(0)
     64        ,   m_downloadStalled(false)
     65#endif
    5766{
    5867    connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick()));
     
    183192
    184193        doSeek(ms);
     194        m_position = ms;
    185195        resetMarksIfRewound();
    186196
     
    207217}
    208218
     219qint64 MMF::AbstractMediaPlayer::currentTime() const
     220{
     221    return m_position;
     222}
     223
    209224void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval)
    210225{
     
    217232}
    218233
    219 void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file)
    220 {
    221     TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi);
     234void MMF::AbstractMediaPlayer::open()
     235{
     236    TRACE_CONTEXT(AbstractMediaPlayer::open, EAudioApi);
     237    const MediaSource source = m_parent->source();
    222238    TRACE_ENTRY("state %d source.type %d", privateState(), source.type());
    223239
     
    230246    switch (source.type()) {
    231247    case MediaSource::LocalFile: {
    232         symbianErr = openFile(file);
     248        RFile *const file = m_parent->file();
     249        Q_ASSERT(file);
     250        symbianErr = openFile(*file);
    233251        if (KErrNone != symbianErr)
    234252            errorMessage = tr("Error opening file");
     
    238256    case MediaSource::Url: {
    239257        const QUrl url(source.url());
    240 
    241258        if (url.scheme() == QLatin1String("file")) {
    242             symbianErr = openFile(file);
     259            RFile *const file = m_parent->file();
     260            Q_ASSERT(file);
     261            symbianErr = openFile(*file);
    243262            if (KErrNone != symbianErr)
    244263                errorMessage = tr("Error opening file");
    245         } else {
    246             symbianErr = openUrl(url.toString());
     264        }
     265#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     266        else if (url.scheme() == QLatin1String("http")) {
     267            Q_ASSERT(!m_download);
     268            m_download = new Download(url, this);
     269            connect(m_download, SIGNAL(lengthChanged(qint64)),
     270                    this, SLOT(downloadLengthChanged(qint64)));
     271            connect(m_download, SIGNAL(stateChanged(Download::State)),
     272                    this, SLOT(downloadStateChanged(Download::State)));
     273            int iap = m_parent->currentIAP();
     274            TRACE("HTTP Url: Using IAP %d", iap);
     275            m_download->start(iap);
     276        }
     277#endif
     278        else {
     279            int iap = m_parent->currentIAP();
     280            TRACE("Using IAP %d", iap);
     281            symbianErr = openUrl(url.toString(), iap);
    247282            if (KErrNone != symbianErr)
    248283                errorMessage = tr("Error opening URL");
    249284        }
    250285
     286        break;
     287    }
     288
     289    case MediaSource::Stream: {
     290        QResource *const resource = m_parent->resource();
     291        if (resource) {
     292            m_buffer.Set(resource->data(), resource->size());
     293            symbianErr = openDescriptor(m_buffer);
     294            if (KErrNone != symbianErr)
     295                errorMessage = tr("Error opening resource");
     296        } else {
     297            errorMessage = tr("Error opening source: resource not opened");
     298        }
    251299        break;
    252300    }
     
    271319}
    272320
     321void MMF::AbstractMediaPlayer::close()
     322{
     323    doClose();
     324#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     325    delete m_download;
     326    m_download = 0;
     327#endif
     328    m_position = 0;
     329}
     330
    273331void MMF::AbstractMediaPlayer::volumeChanged(qreal volume)
    274332{
     
    357415    stopBufferStatusTimer();
    358416    emit MMF::AbstractPlayer::bufferStatus(100);
    359     changeState(m_stateBeforeBuffering);
     417    if (!progressiveDownloadStalled())
     418        changeState(m_stateBeforeBuffering);
    360419}
    361420
     
    368427void MMF::AbstractMediaPlayer::loadingComplete(int error)
    369428{
    370     Q_ASSERT(Phonon::LoadingState == state());
    371 
    372     if (KErrNone == error) {
    373         updateMetaData();
    374         changeState(StoppedState);
     429    TRACE_CONTEXT(AbstractMediaPlayer::loadingComplete, EAudioApi);
     430    TRACE_ENTRY("state %d error %d", state(), error);
     431    if (progressiveDownloadStalled()) {
     432        Q_ASSERT(Phonon::BufferingState == state());
     433        if (KErrNone == error) {
     434            bufferingComplete();
     435            doSeek(m_position);
     436            startPlayback();
     437#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     438            m_downloadStalled = false;
     439#endif
     440        }
    375441    } else {
    376         setError(tr("Loading clip failed"), error);
     442        Q_ASSERT(Phonon::LoadingState == state());
     443        if (KErrNone == error) {
     444            updateMetaData();
     445            changeState(StoppedState);
     446        } else {
     447            if (isProgressiveDownload() && KErrCorrupt == error) {
     448                setProgressiveDownloadStalled();
     449            } else {
     450                setError(tr("Loading clip failed"), error);
     451            }
     452        }
    377453    }
    378454}
     
    398474    }
    399475    else {
    400         setError(tr("Playback complete"), error);
    401         emit finished();
     476        if (isProgressiveDownload() && KErrCorrupt == error) {
     477            setProgressiveDownloadStalled();
     478        } else {
     479            setError(tr("Playback complete"), error);
     480            emit finished();
     481        }
    402482    }
    403483}
     
    408488}
    409489
     490bool MMF::AbstractMediaPlayer::isProgressiveDownload() const
     491{
     492#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     493    return (0 != m_download);
     494#else
     495    return false;
     496#endif
     497}
     498
     499bool MMF::AbstractMediaPlayer::progressiveDownloadStalled() const
     500{
     501#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     502    return m_downloadStalled;
     503#else
     504    return false;
     505#endif
     506}
     507
    410508//-----------------------------------------------------------------------------
    411509// Slots
     
    414512void MMF::AbstractMediaPlayer::positionTick()
    415513{
    416     const qint64 current = currentTime();
    417     emitMarksIfReached(current);
    418     emit MMF::AbstractPlayer::tick(current);
     514    const qint64 pos = getCurrentTime();
     515    if (pos > m_position) {
     516        m_position = pos;
     517        emitMarksIfReached(m_position);
     518        emit MMF::AbstractPlayer::tick(m_position);
     519    }
    419520}
    420521
     
    441542void MMF::AbstractMediaPlayer::resetMarksIfRewound()
    442543{
    443     const qint64 current = currentTime();
     544    const qint64 current = getCurrentTime();
    444545    const qint64 total = totalTime();
    445546    const qint64 remaining = total - current;
     
    470571}
    471572
     573void MMF::AbstractMediaPlayer::setProgressiveDownloadStalled()
     574{
     575#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     576    TRACE_CONTEXT(AbstractMediaPlayer::setProgressiveDownloadStalled, EAudioApi);
     577    TRACE_ENTRY("state %d", state());
     578    Q_ASSERT(isProgressiveDownload());
     579    m_downloadStalled = true;
     580    doClose();
     581    bufferingStarted();
     582    // Video player loses window handle when closed - need to reapply it here
     583    videoOutputChanged();
     584    m_download->resume();
     585#endif
     586}
     587
    472588void MMF::AbstractMediaPlayer::bufferStatusTick()
    473589{
    474     emit MMF::AbstractPlayer::bufferStatus(bufferStatus());
    475 }
     590    // During progressive download, there is no way to detect the buffering status.
     591    // Phonon does not support a "buffering; amount unknown" signal, therefore we
     592    // return a buffering status of zero.
     593    const int status = progressiveDownloadStalled() ? 0 : bufferStatus();
     594    emit MMF::AbstractPlayer::bufferStatus(status);
     595}
     596
     597#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     598void MMF::AbstractMediaPlayer::downloadLengthChanged(qint64 length)
     599{
     600    TRACE_CONTEXT(AbstractMediaPlayer::downloadLengthChanged, EAudioApi);
     601    TRACE_ENTRY("length %Ld", length);
     602    Q_UNUSED(length)
     603    if (m_downloadStalled) {
     604        bufferingComplete();
     605        int err = m_parent->openFileHandle(m_download->targetFileName());
     606        if (KErrNone == err)
     607            err = openFile(*m_parent->file());
     608        if (KErrNone != err)
     609            setError(tr("Error opening file"));
     610    }
     611}
     612
     613void MMF::AbstractMediaPlayer::downloadStateChanged(Download::State state)
     614{
     615    TRACE_CONTEXT(AbstractMediaPlayer::downloadStateChanged, EAudioApi);
     616    TRACE_ENTRY("state %d", state);
     617    switch (state) {
     618    case Download::Idle:
     619    case Download::Initializing:
     620        break;
     621    case Download::Downloading:
     622        {
     623        int err = m_parent->openFileHandle(m_download->targetFileName());
     624        if (KErrNone == err)
     625            err = openFile(*m_parent->file());
     626        else if (KErrCorrupt == err)
     627            // Insufficient data downloaded - enter Buffering state
     628            setProgressiveDownloadStalled();
     629        if (KErrNone != err)
     630            setError(tr("Error opening file"));
     631        }
     632        break;
     633    case Download::Complete:
     634        break;
     635    case Download::Error:
     636        setError(tr("Download error"));
     637        break;
     638    }
     639}
     640#endif // PHONON_MMF_PROGRESSIVE_DOWNLOAD
    476641
    477642Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) const
  • trunk/src/3rdparty/phonon/mmf/abstractmediaplayer.h

    r769 r846  
    2424#include <e32std.h>
    2525#include "abstractplayer.h"
     26#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     27#   include "download.h"
     28#endif
    2629
    2730class RFile;
     
    4851
    4952public:
    50     virtual void open(const Phonon::MediaSource&, RFile&);
     53    virtual void open();
     54    virtual void close();
    5155
    5256    // MediaObjectInterface
     
    5660    virtual void seek(qint64 milliseconds);
    5761    virtual bool isSeekable() const;
     62    virtual qint64 currentTime() const;
    5863    virtual void volumeChanged(qreal volume);
    5964
     
    6974    virtual void doSeek(qint64 pos) = 0;
    7075    virtual int setDeviceVolume(int mmfVolume) = 0;
     76    virtual int openFile(const QString &fileName) = 0;
    7177    virtual int openFile(RFile& file) = 0;
    72     virtual int openUrl(const QString& url) = 0;
     78    virtual int openUrl(const QString& url, int iap) = 0;
     79    virtual int openDescriptor(const TDesC8 &des) = 0;
    7380    virtual int bufferStatus() const = 0;
    74     virtual void close() = 0;
     81    virtual void doClose() = 0;
    7582
    7683    void updateMetaData();
     84    virtual qint64 getCurrentTime() const = 0;
    7785    virtual int numberOfMetaDataEntries() const = 0;
    7886    virtual QPair<QString, QString> metaDataEntry(int index) const = 0;
     
    8795    static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
    8896
     97    bool isProgressiveDownload() const;
     98    bool progressiveDownloadStalled() const;
     99
    89100private:
    90101    void startPositionTimer();
     
    97108    void resetMarksIfRewound();
    98109    void startPlayback();
     110    void setProgressiveDownloadStalled();
    99111
    100112    enum Pending {
     
    109121    void positionTick();
    110122    void bufferStatusTick();
     123#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     124    void downloadLengthChanged(qint64);
     125    void downloadStateChanged(Download::State);
     126#endif
    111127
    112128private:
     
    116132
    117133    QScopedPointer<QTimer>      m_positionTimer;
     134    qint64                      m_position;
    118135
    119136    QScopedPointer<QTimer>      m_bufferStatusTimer;
     
    124141    bool                        m_prefinishMarkSent;
    125142    bool                        m_aboutToFinishSent;
     143
     144    // Used for playback of resource files
     145    TPtrC8                      m_buffer;
     146
     147#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
     148    Download                    *m_download;
     149    bool                        m_downloadStalled;
     150#endif
    126151
    127152    QMultiMap<QString, QString> m_metaData;
  • trunk/src/3rdparty/phonon/mmf/abstractplayer.h

    r769 r846  
    2727#include "abstractvideooutput.h"
    2828
    29 class RFile;
    30 
    3129QT_BEGIN_NAMESPACE
    3230
     
    5553    AbstractPlayer(const AbstractPlayer *player);
    5654
    57     virtual void open(const Phonon::MediaSource&, RFile&) = 0;
     55    virtual void open() = 0;
     56    virtual void close() = 0;
    5857
    5958    // MediaObjectInterface (implemented)
  • trunk/src/3rdparty/phonon/mmf/abstractvideooutput.cpp

    r769 r846  
    6161    ,   m_scaleMode(DefaultScaleMode)
    6262{
    63 
     63    // Ensure that this widget has a native window handle
     64    winId();
    6465}
    6566
     
    161162#ifndef QT_NO_DEBUG
    162163    TRACE_CONTEXT(AbstractVideoOutput::dump, EVideoInternal);
    163 
    164164    QScopedPointer<ObjectDump::QVisitor> visitor(new ObjectDump::QVisitor);
    165165    visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs
    166166    ObjectDump::addDefaultAnnotators(*visitor);
    167 
    168     if (QWidget *window = QApplication::activeWindow()) {
    169         TRACE("Dumping from root window 0x%08x:", window);
    170         ObjectDump::dumpTreeFromLeaf(*window, *visitor);
    171     }
    172 
    173     TRACE("Dumping tree from leaf 0x%08x:", this);
    174167    ObjectDump::dumpTreeFromLeaf(*this, *visitor);
    175 
    176     QScopedPointer<ObjectDump::QDumper> dumper(new ObjectDump::QDumper);
    177     dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs
    178     ObjectDump::addDefaultAnnotators(*dumper);
    179     TRACE_0("Dumping AbstractVideoOutput:");
    180     dumper->dumpObject(*this);
    181168#endif
    182169}
  • trunk/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp

    r769 r846  
    1717*/
    1818
     19#include <QDir>
    1920#include <QUrl>
    2021#include <QTimer>
     
    6768    createPlayer();
    6869
     70    m_player->RegisterForVideoLoadingNotification(*this);
     71
    6972    TRACE_EXIT_0();
    7073}
     
    131134}
    132135
     136int MMF::AbstractVideoPlayer::openFile(const QString &fileName)
     137{
     138    const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
     139    TRAPD(err, m_player->OpenFileL(*nativeFileName));
     140    return err;
     141}
     142
    133143int MMF::AbstractVideoPlayer::openFile(RFile &file)
    134144{
     
    137147}
    138148
    139 int MMF::AbstractVideoPlayer::openUrl(const QString &url)
    140 {
    141     TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url)));
     149int MMF::AbstractVideoPlayer::openUrl(const QString &url, int iap)
     150{
     151    TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url), iap));
     152    return err;
     153}
     154
     155int MMF::AbstractVideoPlayer::openDescriptor(const TDesC8 &des)
     156{
     157    TRAPD(err, m_player->OpenDesL(des));
    142158    return err;
    143159}
     
    150166}
    151167
    152 void MMF::AbstractVideoPlayer::close()
     168void MMF::AbstractVideoPlayer::doClose()
    153169{
    154170    m_player->Close();
     
    160176}
    161177
    162 qint64 MMF::AbstractVideoPlayer::currentTime() const
    163 {
    164     TRACE_CONTEXT(AbstractVideoPlayer::currentTime, EVideoApi);
     178qint64 MMF::AbstractVideoPlayer::getCurrentTime() const
     179{
     180    TRACE_CONTEXT(AbstractVideoPlayer::getCurrentTime, EVideoApi);
    165181
    166182    TTimeIntervalMicroSeconds us;
     
    212228    TRACE_ENTRY("state %d aspectRatio %d", state());
    213229
    214     updateScaleFactors(m_videoOutput->videoWindowSize());
     230    if (m_videoOutput)
     231        updateScaleFactors(m_videoOutput->videoWindowSize());
    215232
    216233    TRACE_EXIT_0();
     
    222239    TRACE_ENTRY("state %d", state());
    223240
    224     updateScaleFactors(m_videoOutput->videoWindowSize());
     241    if (m_videoOutput)
     242        updateScaleFactors(m_videoOutput->videoWindowSize());
    225243
    226244    TRACE_EXIT_0();
     
    237255    TRACE_ENTRY("state %d error %d", state(), aError);
    238256
    239     __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic));
     257    __ASSERT_ALWAYS(LoadingState == state() ||
     258                    progressiveDownloadStalled() && BufferingState == state(),
     259                    Utils::panic(InvalidStatePanic));
    240260
    241261    if (KErrNone == aError)
     
    252272    TRACE_ENTRY("state %d error %d", state(), aError);
    253273
    254     __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic));
     274    __ASSERT_ALWAYS(LoadingState == state() ||
     275                    progressiveDownloadStalled() && BufferingState == state(),
     276                    Utils::panic(InvalidStatePanic));
    255277
    256278    TRAPD(err, getVideoClipParametersL(aError));
     
    358380void MMF::AbstractVideoPlayer::initVideoOutput()
    359381{
     382    Q_ASSERT(m_videoOutput);
     383
    360384    bool connected = connect(
    361385        m_videoOutput, SIGNAL(videoWindowChanged()),
     
    379403    Q_UNUSED(connected);
    380404
    381     // Do these after all connections are complete, to ensure
    382     // that any signals generated get to their destinations.
    383     m_videoOutput->winId();
    384405    m_videoOutput->setVideoSize(m_videoFrameSize);
    385406}
     
    401422void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool apply)
    402423{
     424    Q_ASSERT(m_videoOutput);
     425
    403426    if (m_videoFrameSize.isValid()) {
    404427        QRect videoRect;
     
    460483void MMF::AbstractVideoPlayer::parametersChanged(VideoParameters parameters)
    461484{
    462     if (state() == LoadingState)
     485    if (state() == LoadingState || progressiveDownloadStalled() && BufferingState == state())
    463486        m_pendingChanges |= parameters;
    464487    else
  • trunk/src/3rdparty/phonon/mmf/abstractvideoplayer.h

    r769 r846  
    6565    virtual void doSeek(qint64 milliseconds);
    6666    virtual int setDeviceVolume(int mmfVolume);
     67    virtual int openFile(const QString &fileName);
    6768    virtual int openFile(RFile &file);
    68     virtual int openUrl(const QString &url);
     69    virtual int openUrl(const QString &url, int iap);
     70    virtual int openDescriptor(const TDesC8 &des);
    6971    virtual int bufferStatus() const;
    70     virtual void close();
     72    virtual void doClose();
    7173
    7274    // MediaObjectInterface
    7375    virtual bool hasVideo() const;
    74     virtual qint64 currentTime() const;
    7576    virtual qint64 totalTime() const;
    7677
     
    7980
    8081    // AbstractMediaPlayer
     82    virtual qint64 getCurrentTime() const;
    8183    virtual int numberOfMetaDataEntries() const;
    8284    virtual QPair<QString, QString> metaDataEntry(int index) const;
  • trunk/src/3rdparty/phonon/mmf/audiooutput.cpp

    r561 r846  
    7979    Q_ASSERT_X(index == AudioOutputDeviceID, Q_FUNC_INFO,
    8080               "We only support one output device, with id 0");
     81#ifdef QT_NO_DEBUG
     82    Q_UNUSED(index)
     83#endif
    8184    return true;
    8285}
  • trunk/src/3rdparty/phonon/mmf/audioplayer.cpp

    r769 r846  
    1717*/
    1818
     19#include <QDir>
    1920#include <QUrl>
    2021
     
    110111}
    111112
     113int MMF::AudioPlayer::openFile(const QString &fileName)
     114{
     115    const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
     116    TRAPD(err, m_player->OpenFileL(*nativeFileName));
     117    return err;
     118}
     119
    112120int MMF::AudioPlayer::openFile(RFile& file)
    113121{
     
    127135}
    128136
    129 int MMF::AudioPlayer::openUrl(const QString& /*url*/)
     137int MMF::AudioPlayer::openUrl(const QString& /*url*/, int /*iap*/)
    130138{
    131139    // Streaming playback is generally not supported by the implementation
     
    138146}
    139147
     148int MMF::AudioPlayer::openDescriptor(const TDesC8 &des)
     149{
     150    TRAPD(err, m_player->OpenDesL(des));
     151    return err;
     152}
     153
    140154int MMF::AudioPlayer::bufferStatus() const
    141155{
     
    145159}
    146160
    147 void MMF::AudioPlayer::close()
     161void MMF::AudioPlayer::doClose()
    148162{
    149163    m_player->Close();
     
    155169}
    156170
    157 qint64 MMF::AudioPlayer::currentTime() const
    158 {
    159     TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi);
     171qint64 MMF::AudioPlayer::getCurrentTime() const
     172{
     173    TRACE_CONTEXT(AudioPlayer::getCurrentTime, EAudioApi);
    160174
    161175    TTimeIntervalMicroSeconds us;
     
    198212    TRACE_ENTRY("state %d error %d", state(), aError);
    199213
    200     __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic));
     214    __ASSERT_ALWAYS(LoadingState == state() ||
     215                    progressiveDownloadStalled() && BufferingState == state(),
     216                    Utils::panic(InvalidStatePanic));
    201217
    202218    if (KErrNone == aError) {
  • trunk/src/3rdparty/phonon/mmf/audioplayer.h

    r561 r846  
    6666    virtual void doSeek(qint64 milliseconds);
    6767    virtual int setDeviceVolume(int mmfVolume);
     68    virtual int openFile(const QString &fileName);
    6869    virtual int openFile(RFile& file);
    69     virtual int openUrl(const QString& url);
     70    virtual int openUrl(const QString& url, int iap);
     71    virtual int openDescriptor(const TDesC8 &des);
    7072    virtual int bufferStatus() const;
    71     virtual void close();
     73    virtual void doClose();
    7274
    7375    // MediaObjectInterface
    7476    virtual bool hasVideo() const;
    75     virtual qint64 currentTime() const;
    7677    virtual qint64 totalTime() const;
    7778
    7879    // AbstractMediaPlayer
     80    virtual qint64 getCurrentTime() const;
    7981    virtual int numberOfMetaDataEntries() const;
    8082    virtual QPair<QString, QString> metaDataEntry(int index) const;
  • trunk/src/3rdparty/phonon/mmf/bassboost.cpp

    r651 r846  
    5050    QList<EffectParameter> &parameters)
    5151{
     52    Q_UNUSED(parameters)
    5253    QScopedPointer<CBassBoost> effect;
    5354    TRAPD(err, effect.reset(CBassBoost::NewL(*stream)));
  • trunk/src/3rdparty/phonon/mmf/dummyplayer.cpp

    r561 r846  
    9393}
    9494
    95 void MMF::DummyPlayer::open(const Phonon::MediaSource &, RFile &)
     95void MMF::DummyPlayer::open()
    9696{
    9797
    9898}
    9999
     100void MMF::DummyPlayer::close()
     101{
     102
     103}
    100104
    101105//-----------------------------------------------------------------------------
  • trunk/src/3rdparty/phonon/mmf/dummyplayer.h

    r561 r846  
    5858
    5959    // AbstractPlayer
    60     virtual void open(const Phonon::MediaSource&, RFile&);
     60    virtual void open();
     61    virtual void close();
    6162    virtual void doSetTickInterval(qint32 interval);
    6263};
  • trunk/src/3rdparty/phonon/mmf/effectfactory.cpp

    r651 r846  
    184184    data.m_parameters.append(param);
    185185
    186     if (data.m_supported = BackendNode::getParameters
    187             (stream.data(), data.m_parameters)) {
     186    data.m_supported = BackendNode::getParameters(stream.data(),
     187                                                  data.m_parameters);
     188    if (data.m_supported) {
    188189        const QString description = QCoreApplication::translate
    189190            ("Phonon::MMF::EffectFactory", BackendNode::description());
  • trunk/src/3rdparty/phonon/mmf/loudness.cpp

    r651 r846  
    5050    QList<EffectParameter> &parameters)
    5151{
     52    Q_UNUSED(parameters)
    5253    QScopedPointer<CLoudness> effect;
    5354    TRAPD(err, effect.reset(CLoudness::NewL(*stream)));
  • trunk/src/3rdparty/phonon/mmf/mediaobject.cpp

    r769 r846  
    3535
    3636#include <QDir>
     37#include <QResource>
    3738#include <QUrl>
     39#include <cdbcols.h>
     40#include <cdblen.h>
     41#include <commdb.h>
     42#include <mmf/common/mmfcontrollerframeworkbase.h>
    3843
    3944QT_BEGIN_NAMESPACE
     
    5358                                               , m_recognizerOpened(false)
    5459                                               , m_nextSourceSet(false)
     60                                               , m_file(0)
     61                                               , m_resource(0)
    5562{
    5663    m_player.reset(new DummyPlayer());
     
    5966    TRACE_ENTRY_0();
    6067
    61     Q_UNUSED(parent);
     68    const int err = m_fileServer.Connect();
     69    QT_TRAP_THROWING(User::LeaveIfError(err));
     70
     71    parent->installEventFilter(this);
     72    m_iap = KUseDefaultIap;
    6273
    6374    TRACE_EXIT_0();
     
    6980    TRACE_ENTRY_0();
    7081
    71     m_file.Close();
     82    parent()->removeEventFilter(this);
     83    delete m_resource;
     84
     85    if (m_file)
     86        m_file->Close();
     87    delete m_file;
     88
    7289    m_fileServer.Close();
    7390    m_recognizer.Close();
     
    89106        if (KErrNone != err) {
    90107            TRACE("RApaLsSession::Connect error %d", err);
    91             return false;
    92         }
    93 
    94         err = m_fileServer.Connect();
    95         if (KErrNone != err) {
    96             TRACE("RFs::Connect error %d", err);
    97108            return false;
    98109        }
     
    120131
    121132    if (openRecognizer()) {
    122 
    123         const QHBufC fileNameSymbian(QDir::toNativeSeparators(fileName));
    124 
    125         m_file.Close();
    126         TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly);
    127 
     133        TInt err = openFileHandle(fileName);
     134        const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
    128135        if (KErrNone == err) {
    129136            TDataRecognitionResult recognizerResult;
    130             err = m_recognizer.RecognizeData(m_file, recognizerResult);
     137            err = m_recognizer.RecognizeData(*m_file, recognizerResult);
    131138            if (KErrNone == err) {
    132139                const TPtrC mimeType = recognizerResult.iDataType.Des();
    133140                result = Utils::mimeTypeToMediaType(mimeType);
    134141            } else {
    135                 TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err);
     142                TRACE("RApaLsSession::RecognizeData filename %S error %d", nativeFileName.data(), err);
    136143            }
    137144        } else {
    138             TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err);
     145            TRACE("RFile::Open filename %S error %d", nativeFileName.data(), err);
    139146        }
    140147    }
     
    143150}
    144151
     152int MMF::MediaObject::openFileHandle(const QString &fileName)
     153{
     154    TRACE_CONTEXT(MediaObject::openFileHandle, EAudioInternal);
     155    const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
     156    TRACE_ENTRY("filename %S", nativeFileName.data());
     157    if (m_file)
     158        m_file->Close();
     159    delete m_file;
     160    m_file = 0;
     161    m_file = new RFile;
     162    TInt err = m_file->Open(m_fileServer, *nativeFileName, EFileRead | EFileShareReadersOrWriters);
     163    return err;
     164}
     165
     166MMF::MediaType MMF::MediaObject::bufferMediaType(const uchar *data, qint64 size)
     167{
     168    TRACE_CONTEXT(MediaObject::bufferMediaType, EAudioInternal);
     169    MediaType result = MediaTypeUnknown;
     170    if (openRecognizer()) {
     171        TDataRecognitionResult recognizerResult;
     172        const TPtrC8 des(data, size);
     173        const TInt err = m_recognizer.RecognizeData(KNullDesC, des, recognizerResult);
     174        if (KErrNone == err) {
     175            const TPtrC mimeType = recognizerResult.iDataType.Des();
     176            result = Utils::mimeTypeToMediaType(mimeType);
     177        } else {
     178            TRACE("RApaLsSession::RecognizeData error %d", err);
     179        }
     180    }
     181    return result;
     182}
    145183
    146184//-----------------------------------------------------------------------------
     
    229267void MMF::MediaObject::switchToSource(const MediaSource &source)
    230268{
     269    if (m_file)
     270        m_file->Close();
     271    delete m_file;
     272    m_file = 0;
     273
     274    delete m_resource;
     275    m_resource = 0;
     276
    231277    createPlayer(source);
    232278    m_source = source;
    233     m_player->open(m_source, m_file);
     279    m_player->open();
    234280    emit currentSourceChanged(m_source);
    235281}
     
    273319    case MediaSource::Invalid:
    274320    case MediaSource::Disc:
     321        errorMessage = tr("Error opening source: type not supported");
     322        break;
     323
    275324    case MediaSource::Stream:
    276         errorMessage = tr("Error opening source: type not supported");
     325        {
     326            const QString fileName = source.url().toLocalFile();
     327            if (fileName.startsWith(QLatin1String(":/")) || fileName.startsWith(QLatin1String("qrc://"))) {
     328                Q_ASSERT(!m_resource);
     329                m_resource = new QResource(fileName);
     330                if (m_resource->isValid()) {
     331                    if (m_resource->isCompressed())
     332                        errorMessage = tr("Error opening source: resource is compressed");
     333                    else
     334                        mediaType = bufferMediaType(m_resource->data(), m_resource->size());
     335                } else {
     336                    errorMessage = tr("Error opening source: resource not valid");
     337                }
     338            } else {
     339                errorMessage = tr("Error opening source: type not supported");
     340            }
     341        }
    277342        break;
    278343
     
    281346        break;
    282347    }
     348
     349    if (oldPlayer)
     350        oldPlayer->close();
    283351
    284352    AbstractPlayer* newPlayer = 0;
     
    372440}
    373441
     442RFile* MMF::MediaObject::file() const
     443{
     444    return m_file;
     445}
     446
     447QResource* MMF::MediaObject::resource() const
     448{
     449    return m_resource;
     450}
     451
    374452//-----------------------------------------------------------------------------
    375453// MediaNode
     
    422500
    423501//-----------------------------------------------------------------------------
     502// IAP support
     503//-----------------------------------------------------------------------------
     504
     505int MMF::MediaObject::currentIAP() const
     506{
     507    return m_iap;
     508}
     509
     510bool MMF::MediaObject::eventFilter(QObject *watched, QEvent *event)
     511{
     512    if (event->type() == QEvent::DynamicPropertyChange ) {
     513        QDynamicPropertyChangeEvent* dynamicEvent = static_cast<QDynamicPropertyChangeEvent*>(event);
     514        if (dynamicEvent->propertyName() == "InternetAccessPointName") {
     515            QVariant value = watched->property("InternetAccessPointName");
     516            if (value.isValid()) {
     517                QString iapName = value.toString();
     518                TRAPD(err, setIAPIdFromNameL(iapName));
     519                if (err)
     520                    m_player->setError(tr("Failed to set requested IAP"), err);
     521            }
     522        }
     523    }
     524    return false;
     525}
     526
     527void MMF::MediaObject::setIAPIdFromNameL(const QString& iapString)
     528{
     529    TRACE_CONTEXT(MediaObject::getIapIdFromName, EVideoInternal);
     530    TBuf<KCommsDbSvrMaxColumnNameLength> iapDes = qt_QString2TPtrC(iapString);
     531    CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
     532    CleanupStack::PushL(commsDb);
     533    commsDb->ShowHiddenRecords();
     534    CCommsDbTableView *view = commsDb->OpenTableLC(TPtrC(IAP));
     535    for (TInt l = view->GotoFirstRecord(); l != KErrNotFound; l = view->GotoNextRecord()) {
     536        TBuf<KCommsDbSvrMaxColumnNameLength> iapName;
     537        view->ReadTextL(TPtrC(COMMDB_NAME), iapName);
     538        TRACE("found IAP %S", &iapName);
     539        if (iapName.CompareF(iapDes) == 0) {
     540            TUint32 uiap;
     541            view->ReadUintL(TPtrC(COMMDB_ID), uiap);
     542            TRACE("matched IAP %S, setting m_iap %d", &iapName, uiap);
     543            m_iap = uiap;
     544            break;
     545        }
     546    }
     547    CleanupStack::PopAndDestroy(2); // commsDb, view
     548}
     549
     550//-----------------------------------------------------------------------------
    424551// Other private functions
    425552//-----------------------------------------------------------------------------
  • trunk/src/3rdparty/phonon/mmf/mediaobject.h

    r769 r846  
    2424#include <QScopedPointer>
    2525#include <QTimer>
     26#include <QString>
    2627
    2728// For recognizer
     
    3334
    3435QT_BEGIN_NAMESPACE
     36
     37class QResource;
    3538
    3639namespace Phonon
     
    8891    void setVideoOutput(AbstractVideoOutput* videoOutput);
    8992
     93    int openFileHandle(const QString &fileName);
     94    RFile* file() const;
     95    QResource* resource() const;
     96    int currentIAP() const;
     97
    9098public Q_SLOTS:
    9199    void volumeChanged(qreal volume);
     
    108116    void tick(qint64 time);
    109117
     118protected:
     119    bool eventFilter(QObject *watched, QEvent *event);
     120
    110121private Q_SLOTS:
    111122    void handlePrefinishMarkReached(qint32);
     
    115126    void createPlayer(const MediaSource &source);
    116127    bool openRecognizer();
     128    void setIAPIdFromNameL(const QString& iapString);
    117129
    118130    // Audio / video media type recognition
    119131    MediaType fileMediaType(const QString& fileName);
     132    MediaType bufferMediaType(const uchar *data, qint64 size);
    120133    // TODO: urlMediaType function
    121134
     
    133146    bool                                m_nextSourceSet;
    134147
    135     // Storing the file handle here to work around KErrInUse error
    136     // from MMF player utility OpenFileL functions
    137     RFile                               m_file;
     148    RFile*                              m_file;
     149    QResource*                          m_resource;
    138150
    139151    QScopedPointer<AbstractPlayer>      m_player;
     152    int                                 m_iap;
    140153
    141154};
  • trunk/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp

    r769 r846  
    6262void MMF::DsaVideoPlayer::videoWindowScreenRectChanged()
    6363{
     64    Q_ASSERT(m_videoOutput);
     65
    6466    QRect windowRect = static_cast<DsaVideoOutput *>(m_videoOutput)->videoWindowScreenRect();
    6567
     
    125127    // CVideoPlayerUtility::NewL starts DSA
    126128    m_dsaActive = true;
    127 
    128     m_player->RegisterForVideoLoadingNotification(*this);
    129129}
    130130
    131131void MMF::DsaVideoPlayer::initVideoOutput()
    132132{
     133    Q_ASSERT(m_videoOutput);
     134
    133135    bool connected = connect(
    134136        m_videoOutput, SIGNAL(videoWindowScreenRectChanged()),
     
    157159void MMF::DsaVideoPlayer::prepareCompleted()
    158160{
    159     videoWindowScreenRectChanged();
     161    if (m_videoOutput)
     162        videoWindowScreenRectChanged();
    160163}
    161164
  • trunk/src/3rdparty/phonon/mmf/videoplayer_surface.cpp

    r769 r846  
    6060void MMF::SurfaceVideoPlayer::videoWindowSizeChanged()
    6161{
    62     updateScaleFactors(m_videoOutput->videoWindowSize());
     62    if (m_videoOutput)
     63        updateScaleFactors(m_videoOutput->videoWindowSize());
    6364}
    6465
     
    8182void MMF::SurfaceVideoPlayer::initVideoOutput()
    8283{
     84    Q_ASSERT(m_videoOutput);
     85
    8386    bool connected = connect(
    8487        m_videoOutput, SIGNAL(videoWindowSizeChanged()),
     
    105108void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters)
    106109{
     110    TRACE_CONTEXT(SurfaceVideoPlayer::handleParametersChanged, EVideoApi);
     111    TRACE_ENTRY("parameters 0x%x", parameters.operator int());
     112
    107113    TRect rect;
    108114    if (m_videoOutput) {
     
    116122        int err = KErrNone;
    117123        if (parameters & WindowHandle) {
    118             if (m_displayWindow)
    119                 player->RemoveDisplayWindow(*m_displayWindow);
    120 
    121             RWindow *window = static_cast<RWindow *>(m_window);
    122             if (window) {
    123                 window->SetBackgroundColor(TRgb(0, 0, 0, 255));
    124                 TRAP(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect));
    125                 if (KErrNone != err) {
    126                     setError(tr("Video display error"), err);
    127                     window = 0;
    128                 }
    129             }
    130             m_displayWindow = window;
     124            removeDisplayWindow();
     125            addDisplayWindow(rect);
    131126        }
    132127
    133128        if (KErrNone == err) {
    134129            if (parameters & ScaleFactors) {
     130                if (!m_displayWindow)
     131                    addDisplayWindow(rect);
    135132                Q_ASSERT(m_displayWindow);
    136133                TRAP(err, player->SetVideoExtentL(*m_displayWindow, rect));
     
    144141        }
    145142    }
     143
     144    TRACE_EXIT_0();
     145}
     146
     147void MMF::SurfaceVideoPlayer::addDisplayWindow(const TRect &rect)
     148{
     149    TRACE_CONTEXT(SurfaceVideoPlayer::addDisplayWindow, EVideoApi);
     150    TRACE_ENTRY("rect %d %d - %d %d", rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY);
     151
     152    Q_ASSERT(!m_displayWindow);
     153    RWindow *window = static_cast<RWindow *>(m_window);
     154
     155    TRACE("window 0x%08x", window);
     156
     157    if (window) {
     158        window->SetBackgroundColor(TRgb(0, 0, 0, 255));
     159        CVideoPlayerUtility2 *player = static_cast<CVideoPlayerUtility2 *>(m_player.data());
     160        Q_ASSERT(player);
     161        TRAPD(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect));
     162        if (KErrNone == err)
     163            m_displayWindow = window;
     164        else
     165            setError(tr("Video display error"), err);
     166        TRACE("err %d", err);
     167    }
     168
     169    TRACE_EXIT_0();
     170}
     171
     172void MMF::SurfaceVideoPlayer::removeDisplayWindow()
     173{
     174    TRACE_CONTEXT(SurfaceVideoPlayer::removeDisplayWindow, EVideoApi);
     175    TRACE("player 0x%08x window 0x%08x", m_player.data(), m_displayWindow);
     176
     177    CVideoPlayerUtility2 *player = static_cast<CVideoPlayerUtility2 *>(m_player.data());
     178    if (player && m_displayWindow) {
     179        player->RemoveDisplayWindow(*m_displayWindow);
     180        m_displayWindow = 0;
     181    }
    146182}
    147183
  • trunk/src/3rdparty/phonon/mmf/videoplayer_surface.h

    r769 r846  
    6363    void handleParametersChanged(VideoParameters parameters);
    6464
     65    void addDisplayWindow(const TRect &rect);
     66    void removeDisplayWindow();
     67
    6568private:
    6669    // Window handle which has been passed to the MMF via
  • trunk/src/3rdparty/phonon/mmf/videowidget.cpp

    r769 r846  
    6565    TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi);
    6666    TRACE_ENTRY_0();
     67
     68    parent->setProperty("_q_DummyWindowSurface", true);
    6769
    6870    TRACE_EXIT_0();
  • trunk/src/3rdparty/phonon/phonon/CMakeLists.txt

    r2 r846  
    88
    99add_subdirectory(experimental)
     10
     11set(PULSEAUDIO_MINIMUM_VERSION "0.9.15")
     12macro_optional_find_package(PulseAudio)
     13if (PULSEAUDIO_FOUND)
     14    # PULSEAUDIO_DEVICE_MANAGER feature check could be moved to FindPulseAudio.cmake, hint hint. -- Rex
     15    macro_ensure_version("0.9.21" "${PULSEAUDIO_VERSION}" PULSEAUDIO_DEVICE_MANAGER)
     16endif (PULSEAUDIO_FOUND)
     17macro_log_feature(PULSEAUDIO_FOUND "PulseAudio" "A cross-platform, networked sound server." "http://www.pulseaudio.org" FALSE "" "Allows audio playback via the PulseAudio soundserver when it is running")
     18macro_optional_find_package(GLIB2)
     19macro_log_feature(GLIB2_FOUND "GLib2" "GLib 2 is required to compile the pulseaudio for Phonon" "http://www.gtk.org/download/" FALSE)
     20
     21
     22if (GLIB2_FOUND AND PULSEAUDIO_FOUND)
     23   add_definitions(-DHAVE_PULSEAUDIO)
     24   include_directories(${GLIB2_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIR})
     25   if (PULSEAUDIO_DEVICE_MANAGER)
     26      add_definitions(-DHAVE_PULSEAUDIO_DEVICE_MANAGER)
     27   endif(PULSEAUDIO_DEVICE_MANAGER)
     28else(GLIB2_FOUND AND PULSEAUDIO_FOUND)
     29   set(PULSEAUDIO_INCLUDE_DIR "")
     30   set(PULSEAUDIO_LIBRARY "")
     31   set(PULSEAUDIO_MAINLOOP_LIBRARY "")
     32endif(GLIB2_FOUND AND PULSEAUDIO_FOUND)
     33
    1034
    1135set(phonon_LIB_SRCS
     
    3660   videoplayer.cpp
    3761   seekslider.cpp
     62   swiftslider.cpp
    3863   volumeslider.cpp
    3964   effectwidget.cpp
    4065   iodevicestream.cpp
     66   audiodataoutput.cpp
     67   pulsesupport.cpp
    4168   )
    4269
     
    5178automoc4_add_library(phonon SHARED ${phonon_LIB_SRCS})
    5279target_link_libraries(phonon ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
     80if (GLIB2_FOUND AND PULSEAUDIO_FOUND)
     81target_link_libraries(phonon ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES} ${PULSEAUDIO_LIBRARY} ${PULSEAUDIO_MAINLOOP_LIBRARY})
     82endif (GLIB2_FOUND AND PULSEAUDIO_FOUND)
     83
    5384if (QT_QTDBUS_FOUND)
    5485  target_link_libraries(phonon ${QT_QTDBUS_LIBRARY})
     
    100131   effectwidget.h
    101132   platformplugin.h
     133   audiodataoutput.h
     134   audiodataoutputinterface.h
     135   globalconfig.h
     136   pulsesupport.h
    102137   DESTINATION ${INCLUDE_INSTALL_DIR}/phonon COMPONENT Devel)
    103138
  • trunk/src/3rdparty/phonon/phonon/audiooutput.cpp

    r561 r846  
    2525#include "objectdescription.h"
    2626#include "audiooutputadaptor_p.h"
    27 #include "globalconfig_p.h"
     27#include "globalconfig.h"
    2828#include "audiooutputinterface.h"
    2929#include "phononnamespace_p.h"
    3030#include "platform_p.h"
     31#include "pulsesupport.h"
    3132
    3233#include <QtCore/qmath.h>
     34#include <QtCore/quuid.h>
    3335
    3436#define PHONON_CLASSNAME AudioOutput
     
    4345{
    4446
    45 static inline bool callSetOutputDevice(MediaNodePrivate *const d, int index)
    46 {
     47static inline bool callSetOutputDevice(AudioOutputPrivate *const d, int index)
     48{
     49    PulseSupport *pulse = PulseSupport::getInstance();
     50    if (pulse->isActive())
     51        return pulse->setOutputDevice(d->getStreamUuid(), index);
     52
    4753    Iface<IFACES2> iface(d);
    4854    if (iface) {
     
    5258}
    5359
    54 static inline bool callSetOutputDevice(MediaNodePrivate *const d, const AudioOutputDevice &dev)
    55 {
     60static inline bool callSetOutputDevice(AudioOutputPrivate *const d, const AudioOutputDevice &dev)
     61{
     62    PulseSupport *pulse = PulseSupport::getInstance();
     63    if (pulse->isActive())
     64        return pulse->setOutputDevice(d->getStreamUuid(), dev.index());
     65
    5666    Iface<IFACES2> iface(d);
    5767    if (iface) {
     
    90100
    91101    category = c;
    92 
    93     // select hardware device according to the category
    94     device = AudioOutputDevice::fromIndex(GlobalConfig().audioOutputDeviceFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices));
     102    streamUuid = QUuid::createUuid().toString();
     103    PulseSupport *pulse = PulseSupport::getInstance();
     104    pulse->setStreamPropList(category, streamUuid);
     105    q->connect(pulse, SIGNAL(usingDevice(QString,int)), SLOT(_k_deviceChanged(QString,int)));
    95106
    96107    createBackendObject();
     
    99110}
    100111
    101 
     112QString AudioOutputPrivate::getStreamUuid()
     113{
     114    return streamUuid;
     115}
    102116
    103117void AudioOutputPrivate::createBackendObject()
     
    107121    Q_Q(AudioOutput);
    108122    m_backendObject = Factory::createAudioOutput(q);
     123    device = AudioOutputDevice::fromIndex(GlobalConfig().audioOutputDeviceFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices));
    109124    if (m_backendObject) {
    110125        setupBackendObject();
     
    221236    K_D(AudioOutput);
    222237    if (!newAudioOutputDevice.isValid()) {
    223         d->outputDeviceOverridden = false;
     238        d->outputDeviceOverridden = d->forceMove = false;
    224239        const int newIndex = GlobalConfig().audioOutputDeviceFor(d->category);
    225240        if (newIndex == d->device.index()) {
     
    228243        d->device = AudioOutputDevice::fromIndex(newIndex);
    229244    } else {
    230         d->outputDeviceOverridden = true;
     245        d->outputDeviceOverridden = d->forceMove = true;
    231246        if (d->device == newAudioOutputDevice) {
    232247            return true;
     
    235250    }
    236251    if (k_ptr->backendObject()) {
    237         return callSetOutputDevice(k_ptr, d->device.index());
     252        return callSetOutputDevice(d, d->device.index());
    238253    }
    239254    return true;
     
    262277#ifndef QT_NO_PHONON_SETTINGSGROUP
    263278    // if the output device is not available and the device was not explicitly set
    264     if (!callSetOutputDevice(this, device) && !outputDeviceOverridden) {
     279    // There is no need to set the output device initially if PA is used as
     280    // we know it will not work (stream doesn't exist yet) and that this will be
     281    // handled by _k_deviceChanged()
     282    if (!PulseSupport::getInstance()->isActive() && !callSetOutputDevice(this, device) && !outputDeviceOverridden) {
    265283        // fall back in the preference list of output devices
    266284        QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices);
     
    307325void AudioOutputPrivate::_k_audioDeviceFailed()
    308326{
     327    if (PulseSupport::getInstance()->isActive())
     328        return;
     329
     330#ifndef QT_NO_PHONON_SETTINGSGROUP
     331
    309332    pDebug() << Q_FUNC_INFO;
    310333    // outputDeviceIndex identifies a failing device
    311334    // fall back in the preference list of output devices
    312 #ifndef QT_NO_PHONON_SETTINGSGROUP
    313335    const QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices);
    314336    for (int i = 0; i < deviceList.count(); ++i) {
     
    332354void AudioOutputPrivate::_k_deviceListChanged()
    333355{
     356    if (PulseSupport::getInstance()->isActive())
     357        return;
     358
     359#ifndef QT_NO_PHONON_SETTINGSGROUP
    334360    pDebug() << Q_FUNC_INFO;
    335 #ifndef QT_NO_PHONON_SETTINGSGROUP
     361    // Check to see if we have an override and do not change to a higher priority device if the overridden device is still present.
     362    if (outputDeviceOverridden && device.property("available").toBool()) {
     363        return;
     364    }
    336365    // let's see if there's a usable device higher in the preference list
    337366    const QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings);
     
    360389    }
    361390#endif //QT_NO_PHONON_SETTINGSGROUP
     391}
     392
     393void AudioOutputPrivate::_k_deviceChanged(QString inStreamUuid, int deviceIndex)
     394{
     395    // Note that this method is only used by PulseAudio at present.
     396    if (inStreamUuid == streamUuid) {
     397        // 1. Check to see if we are overridden. If we are, and devices do not match,
     398        //    then try and apply our own device as the output device.
     399        //    We only do this the first time
     400        if (outputDeviceOverridden && forceMove) {
     401            forceMove = false;
     402            const AudioOutputDevice &currentDevice = AudioOutputDevice::fromIndex(deviceIndex);
     403            if (currentDevice != device) {
     404                if (!callSetOutputDevice(this, device)) {
     405                    // What to do if we are overridden and cannot change to our preferred device?
     406                }
     407            }
     408        }
     409        // 2. If we are not overridden, then we need to update our perception of what
     410        //    device we are using. If the devices do not match, something lower in the
     411        //    stack is overriding our preferences (e.g. a per-application stream preference,
     412        //    specific application move, priority list changed etc. etc.)
     413        else if (!outputDeviceOverridden) {
     414            const AudioOutputDevice &currentDevice = AudioOutputDevice::fromIndex(deviceIndex);
     415            if (currentDevice != device) {
     416                // The device is not what we think it is, so lets say what is happening.
     417                handleAutomaticDeviceChange(currentDevice, SoundSystemChange);
     418            }
     419        }
     420    }
    362421}
    363422
     
    406465        }
    407466        break;
     467    case SoundSystemChange:
     468        {
     469#ifndef QT_NO_PHONON_PLATFORMPLUGIN
     470        if (device1.property("available").toBool()) {
     471            const QString text = AudioOutput::tr("<html>Switching to the audio playback device <b>%1</b><br/>"
     472                    "which has higher preference or is specifically configured for this stream.</html>").arg(device2.name());
     473            Platform::notification("AudioDeviceFallback", text,
     474                    QStringList(AudioOutput::tr("Revert back to device '%1'").arg(device1.name())),
     475                    q, SLOT(_k_revertFallback()));
     476        } else {
     477            const QString &text =
     478                AudioOutput::tr("<html>The audio playback device <b>%1</b> does not work.<br/>"
     479                        "Falling back to <b>%2</b>.</html>").arg(device1.name()).arg(device2.name());
     480            Platform::notification("AudioDeviceFallback", text);
     481        }
     482#endif //QT_NO_PHONON_PLATFORMPLUGIN
     483        //outputDeviceOverridden = true;
     484        g_lastFallback.first = 0;
     485        g_lastFallback.second = 0;
     486        }
     487        break;
    408488    }
    409489}
     
    411491AudioOutputPrivate::~AudioOutputPrivate()
    412492{
     493    PulseSupport::getInstance()->clearStreamCache(streamUuid);
    413494#ifndef QT_NO_DBUS
    414495    if (adaptor) {
  • trunk/src/3rdparty/phonon/phonon/audiooutput.h

    r561 r846  
    170170            Q_PRIVATE_SLOT(k_func(), void _k_audioDeviceFailed())
    171171            Q_PRIVATE_SLOT(k_func(), void _k_deviceListChanged())
     172            Q_PRIVATE_SLOT(k_func(), void _k_deviceChanged(QString streamUuid, int device))
    172173    };
    173174} //namespace Phonon
  • trunk/src/3rdparty/phonon/phonon/audiooutput_p.h

    r561 r846  
    4747        }
    4848        void init(Phonon::Category c);
     49        QString getStreamUuid();
    4950
    5051
     
    5960            deviceBeforeFallback(-1),
    6061            outputDeviceOverridden(false),
     62            forceMove(false),
    6163            muted(false)
    6264        {
     
    6769        enum DeviceChangeType {
    6870            FallbackChange,
    69             HigherPreferenceChange
     71            HigherPreferenceChange,
     72            SoundSystemChange
    7073        };
    7174        void handleAutomaticDeviceChange(const AudioOutputDevice &newDev, DeviceChangeType type);
     
    7578        void _k_audioDeviceFailed();
    7679        void _k_deviceListChanged();
     80        void _k_deviceChanged(QString streamUuid, int deviceIndex);
    7781
    7882    private:
     
    8084        Phonon::AudioOutputDevice device;
    8185        qreal volume;
     86        QString streamUuid;
    8287#ifndef QT_NO_DBUS
    8388        Phonon::AudioOutputAdaptor *adaptor;
     
    8691        int deviceBeforeFallback;
    8792        bool outputDeviceOverridden;
     93        bool forceMove;
    8894        bool muted;
    8995};
  • trunk/src/3rdparty/phonon/phonon/audiooutputinterface.h

    r561 r846  
    6565         * samples are multiplied by 2).
    6666         *
    67          * Everytime the volume in the backend changes it should emit volumeChanged(qreal), also
     67         * Every time the volume in the backend changes it should emit volumeChanged(qreal), also
    6868         * inside this function.
    6969         */
  • trunk/src/3rdparty/phonon/phonon/backendcapabilities.cpp

    r561 r846  
    2727#include "backendinterface.h"
    2828#include "factory_p.h"
    29 #include "globalconfig_p.h"
     29#include "globalconfig.h"
    3030#include "globalstatic_p.h"
    3131#include "objectdescription.h"
  • trunk/src/3rdparty/phonon/phonon/effectwidget.cpp

    r651 r846  
    113113
    114114        QWidget *control = 0;
    115         switch (para.type()) {
     115        switch (int(para.type())) {
    116116        case QVariant::String:
    117117            {
  • trunk/src/3rdparty/phonon/phonon/factory.cpp

    r561 r846  
    135135            }
    136136
    137                         QStringList plugins(dir.entryList(QDir::Files));
     137            QStringList plugins(dir.entryList(QDir::Files));
    138138
    139139#ifdef Q_OS_SYMBIAN
    140             /* On Symbian OS we might have two plugins, one which uses Symbian
    141              * MMF framework("phonon_mmf"), and one which uses Real Networks's
    142              * Helix("hxphonon"). We prefer the latter because it's more
    143              * sophisticated, so we make sure the Helix backend is attempted
    144              * to be loaded first, and the MMF backend is used for backup. */
    145             {
    146 
    147                 const int hxphonon = plugins.indexOf(QLatin1String("hxphonon"));
    148                 if (hxphonon != -1)
    149                     plugins.move(hxphonon, 0);
    150 
    151                 // Code for debugging the MMF backend.
    152                 if(hxphonon != -1) {
    153                     qDebug() << "Found hxphonon backend and removed it from the lookup list.";
    154                     plugins.removeAll(QLatin1String("hxphonon"));
    155                 }
    156             }
     140            static const QString preferredPluginName = QLatin1String("phonon_mmf");
     141            const int preferredPluginIndex = plugins.indexOf(preferredPluginName + ".qtplugin");
     142            if (preferredPluginIndex != -1)
     143                plugins.move(preferredPluginIndex, 0);
    157144#endif
    158145
     146            const QStringList files = dir.entryList(QDir::Files);
    159147            for (int i = 0; i < plugins.count(); ++i) {
    160148                QPluginLoader pluginLoader(libPath + plugins.at(i));
     
    351339FACTORY_IMPL(VideoWidget)
    352340#endif //QT_NO_PHONON_VIDEO
     341FACTORY_IMPL(AudioDataOutput)
    353342
    354343#undef FACTORY_IMPL
     
    470459{
    471460    if (o) {
    472         QObject::connect(o, SIGNAL(destroyed(QObject*)), globalFactory, SLOT(objectDestroyed(QObject*)), Qt::DirectConnection);
     461        QObject::connect(o, SIGNAL(destroyed(QObject *)), globalFactory, SLOT(objectDestroyed(QObject *)), Qt::DirectConnection);
    473462        globalFactory->objects.append(o);
    474463    }
  • trunk/src/3rdparty/phonon/phonon/factory_p.h

    r561 r846  
    123123
    124124    /**
     125    * Create a new backend object for a AudioDataOutput.
     126    *
     127    * \return a pointer to the AudioDataOutput the backend provides.
     128    */
     129    PHONON_EXPORT QObject *createAudioDataOutput(QObject *parent = 0);
     130
     131    /**
    125132     * \return a pointer to the backend interface.
    126133     */
  • trunk/src/3rdparty/phonon/phonon/globalconfig.cpp

    r561 r846  
    2121*/
    2222
     23#include "globalconfig.h"
    2324#include "globalconfig_p.h"
    2425
     
    3031#include "qsettingsgroup_p.h"
    3132#include "phononnamespace_p.h"
     33#include "pulsesupport.h"
    3234
    3335#include <QtCore/QList>
     
    3941{
    4042
     43GlobalConfigPrivate::GlobalConfigPrivate() : config(QLatin1String("kde.org"), QLatin1String("libphonon"))
     44{
     45}
     46
    4147GlobalConfig::GlobalConfig()
    42 #ifndef QT_NO_SETTINGS
    43     : m_config(QLatin1String("kde.org"), QLatin1String("libphonon"))
    44 #endif //QT_NO_SETTINGS
     48    : k_ptr(new GlobalConfigPrivate)
    4549{
    4650}
     
    4852GlobalConfig::~GlobalConfig()
    4953{
     54    delete k_ptr;
    5055}
    5156
     
    6065    QMutableListIterator<int> it(*list);
    6166    while (it.hasNext()) {
    62         const QHash<QByteArray, QVariant> properties = backendIface->objectDescriptionProperties(type, it.next());
     67        QHash<QByteArray, QVariant> properties;
     68        if (backendIface)
     69            properties = backendIface->objectDescriptionProperties(type, it.next());
     70        else
     71            properties = PulseSupport::getInstance()->objectDescriptionProperties(type, it.next());
    6372        QVariant var;
    6473        if (whatToFilter & FilterAdvancedDevices) {
     
    7483                it.remove();
    7584                continue;
     85#ifndef QT_NO_PHONON_SETTINGSGROUP
    7686            }
    7787        }
     
    8696}
    8797
    88 #ifndef QT_NO_PHONON_SETTINGSGROUP
    89 static QList<int> listSortedByConfig(const QSettingsGroup &backendConfig, Phonon::Category category, QList<int> &defaultList)
    90 {
     98static QList<int> sortDevicesByCategoryPriority(const GlobalConfig *config, const QSettingsGroup *backendConfig, ObjectDescriptionType type, Phonon::Category category, QList<int> &defaultList)
     99{
     100    Q_ASSERT(config); Q_UNUSED(config);
     101    Q_ASSERT(backendConfig);
     102    Q_ASSERT(type == AudioOutputDeviceType || type == AudioCaptureDeviceType);
     103
    91104    if (defaultList.size() <= 1) {
    92105        // nothing to sort
     
    105118    }
    106119
    107     QString categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(category));
    108     if (!backendConfig.hasKey(categoryKey)) {
    109         // no list in config for the given category
    110         categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(Phonon::NoCategory));
    111         if (!backendConfig.hasKey(categoryKey)) {
    112             // no list in config for NoCategory
    113             return defaultList;
    114         }
    115     }
    116 
    117     //Now the list from m_config
    118     QList<int> deviceList = backendConfig.value(categoryKey, QList<int>());
    119 
    120     //if there are devices in m_config that the backend doesn't report, remove them from the list
     120    QList<int> deviceList;
     121    PulseSupport *pulse = PulseSupport::getInstance();
     122    if (pulse->isActive()) {
     123        deviceList = pulse->objectIndexesByCategory(type, category);
     124    } else {
     125        QString categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(category));
     126        if (!backendConfig->hasKey(categoryKey)) {
     127            // no list in config for the given category
     128            categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(Phonon::NoCategory));
     129            if (!backendConfig->hasKey(categoryKey)) {
     130                // no list in config for NoCategory
     131                return defaultList;
     132            }
     133        }
     134
     135        //Now the list from d->config
     136        deviceList = backendConfig->value(categoryKey, QList<int>());
     137    }
     138
     139    //if there are devices in d->config that the backend doesn't report, remove them from the list
    121140    QMutableListIterator<int> i(deviceList);
    122141    while (i.hasNext()) {
     
    126145    }
    127146
    128     //if the backend reports more devices that are not in m_config append them to the list
     147    //if the backend reports more devices that are not in d->config append them to the list
    129148    deviceList += defaultList;
    130149
    131150    return deviceList;
     151}
     152
     153bool GlobalConfig::hideAdvancedDevices() const
     154{
     155    K_D(const GlobalConfig);
     156    //The devices need to be stored independently for every backend
     157    const QSettingsGroup generalGroup(&d->config, QLatin1String("General"));
     158    return generalGroup.value(QLatin1String("HideAdvancedDevices"), true);
     159}
     160
     161void GlobalConfig::setHideAdvancedDevices(bool hide)
     162{
     163    K_D(GlobalConfig);
     164    QSettingsGroup generalGroup(&d->config, QLatin1String("General"));
     165    generalGroup.setValue(QLatin1String("HideAdvancedDevices"), hide);
     166}
     167
     168static bool isHiddenAudioOutputDevice(const GlobalConfig *config, int i)
     169{
     170    Q_ASSERT(config);
     171
     172    if (!config->hideAdvancedDevices())
     173        return false;
     174
     175    AudioOutputDevice ad = AudioOutputDevice::fromIndex(i);
     176    const QVariant var = ad.property("isAdvanced");
     177    return (var.isValid() && var.toBool());
     178}
     179
     180#ifndef QT_NO_PHONON_AUDIOCAPTURE
     181static bool isHiddenAudioCaptureDevice(const GlobalConfig *config, int i)
     182{
     183    Q_ASSERT(config);
     184
     185    if (!config->hideAdvancedDevices())
     186        return false;
     187
     188    AudioCaptureDevice ad = AudioCaptureDevice::fromIndex(i);
     189    const QVariant var = ad.property("isAdvanced");
     190    return (var.isValid() && var.toBool());
     191}
     192#endif
     193
     194static QList<int> reindexList(const GlobalConfig *config, Phonon::Category category, QList<int>newOrder, bool output)
     195{
     196    Q_ASSERT(config);
     197#ifdef QT_NO_PHONON_AUDIOCAPTURE
     198    Q_ASSERT(output);
     199#endif
     200
     201    /*QString sb;
     202    sb = QString("(Size %1)").arg(currentList.size());
     203    foreach (int i, currentList)
     204    sb += QString("%1, ").arg(i);
     205    fprintf(stderr, "=== Reindex Current: %s\n", sb.toUtf8().constData());
     206    sb = QString("(Size %1)").arg(newOrder.size());
     207    foreach (int i, newOrder)
     208    sb += QString("%1, ").arg(i);
     209    fprintf(stderr, "=== Reindex Before : %s\n", sb.toUtf8().constData());*/
     210
     211    QList<int> currentList;
     212    if (output)
     213        currentList = config->audioOutputDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices);
     214#ifndef QT_NO_PHONON_AUDIOCAPTURE
     215    else
     216        currentList = config->audioCaptureDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices);
     217#endif
     218
     219    QList<int> newList;
     220
     221    foreach (int i, newOrder) {
     222        int found = currentList.indexOf(i);
     223        if (found < 0) {
     224            // It's not in the list, so something is odd (e.g. client error). Ignore it.
     225            continue;
     226        }
     227
     228        // Iterate through the list from this point onward. If there are hidden devices
     229        // immediately following, take them too.
     230        newList.append(currentList.takeAt(found));
     231        while (found < currentList.size()) {
     232            bool hidden = true;
     233            if (output)
     234                hidden = isHiddenAudioOutputDevice(config, currentList.at(found));
     235#ifndef QT_NO_PHONON_AUDIOCAPTURE
     236            else
     237                hidden = isHiddenAudioCaptureDevice(config, currentList.at(found));
     238#endif
     239
     240            if (!hidden)
     241                break;
     242            newList.append(currentList.takeAt(found));
     243        }
     244    }
     245
     246    // If there are any devices left in.. just tack them on the end.
     247    if (currentList.size() > 0)
     248        newList += currentList;
     249
     250    /*sb = QString("(Size %1)").arg(newList.size());
     251    foreach (int i, newList)
     252    sb += QString("%1, ").arg(i);
     253    fprintf(stderr, "=== Reindex After  : %s\n", sb.toUtf8().constData());*/
     254    return newList;
     255}
     256
     257
     258void GlobalConfig::setAudioOutputDeviceListFor(Phonon::Category category, QList<int> order)
     259{
     260    PulseSupport *pulse = PulseSupport::getInstance();
     261    if (pulse->isActive()) {
     262        pulse->setOutputDevicePriorityForCategory(category, order);
     263        return;
     264    }
     265
     266    K_D(GlobalConfig);
     267    QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier());
     268
     269    order = reindexList(this, category, order, true);
     270
     271    const QList<int> noCategoryOrder = audioOutputDeviceListFor(Phonon::NoCategory, ShowUnavailableDevices|ShowAdvancedDevices);
     272    if (category != Phonon::NoCategory && order == noCategoryOrder) {
     273        backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category));
     274    } else {
     275        backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order);
     276    }
    132277}
    133278#endif //QT_NO_PHONON_SETTINGSGROUP
     
    136281QList<int> GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int override) const
    137282{
    138     //The devices need to be stored independently for every backend
    139     const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioOutputDevice")); // + Factory::identifier());
    140     const QSettingsGroup generalGroup(&m_config, QLatin1String("General"));
    141     const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings)
    142             ? generalGroup.value(QLatin1String("HideAdvancedDevices"), true)
     283    K_D(const GlobalConfig);
     284
     285    const bool hide = ((override & AdvancedDevicesFromSettings)
     286            ? hideAdvancedDevices()
    143287            : static_cast<bool>(override & HideAdvancedDevices));
    144288
    145289    QList<int> defaultList;
    146 #ifndef QT_NO_PHONON_PLATFORMPLUGIN
    147     if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
    148         // the platform plugin lists the audio devices for the platform
    149         // this list already is in default order (as defined by the platform plugin)
    150         defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
    151         if (hideAdvancedDevices) {
    152             QMutableListIterator<int> it(defaultList);
    153             while (it.hasNext()) {
    154                 AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next());
    155                 const QVariant var = objDesc.property("isAdvanced");
    156                 if (var.isValid() && var.toBool()) {
    157                     it.remove();
    158                 }
    159             }
    160         }
    161     }
    162 #endif //QT_NO_PHONON_PLATFORMPLUGIN
    163 
    164     // lookup the available devices directly from the backend (mostly for virtual devices)
    165     if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend())) {
    166         // this list already is in default order (as defined by the backend)
    167         QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
    168         if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
    169             filter(AudioOutputDeviceType, backendIface, &list,
    170                     (hideAdvancedDevices ? FilterAdvancedDevices : 0)
    171                     // the platform plugin already provided the hardware devices
    172                     | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
     290
     291    PulseSupport *pulse = PulseSupport::getInstance();
     292    if (pulse->isActive()) {
     293        defaultList = pulse->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
     294        if (hide || (override & HideUnavailableDevices)) {
     295            filter(AudioOutputDeviceType, NULL, &defaultList,
     296                    (hide ? FilterAdvancedDevices : 0)
    173297                    | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
    174298                    );
    175299        }
    176         defaultList += list;
    177     }
    178 
    179     return listSortedByConfig(backendConfig, category, defaultList);
     300    } else {
     301        BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend());
     302
     303#ifndef QT_NO_PHONON_PLATFORMPLUGIN
     304        if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
     305            // the platform plugin lists the audio devices for the platform
     306            // this list already is in default order (as defined by the platform plugin)
     307            defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
     308            if (hide) {
     309                QMutableListIterator<int> it(defaultList);
     310                while (it.hasNext()) {
     311                    AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next());
     312                    const QVariant var = objDesc.property("isAdvanced");
     313                    if (var.isValid() && var.toBool()) {
     314                        it.remove();
     315                    }
     316                }
     317            }
     318        }
     319#endif //QT_NO_PHONON_PLATFORMPLUGIN
     320
     321        // lookup the available devices directly from the backend
     322        if (backendIface) {
     323            // this list already is in default order (as defined by the backend)
     324            QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
     325            if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
     326                filter(AudioOutputDeviceType, backendIface, &list,
     327                        (hide ? FilterAdvancedDevices : 0)
     328                        // the platform plugin maybe already provided the hardware devices?
     329                        | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
     330                        | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
     331                        );
     332            }
     333            defaultList += list;
     334        }
     335    }
     336
     337    const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier());
     338    return sortDevicesByCategoryPriority(this, &backendConfig, AudioOutputDeviceType, category, defaultList);
    180339}
    181340#endif //QT_NO_PHONON_SETTINGSGROUP
     
    191350
    192351#ifndef QT_NO_PHONON_AUDIOCAPTURE
     352void GlobalConfig::setAudioCaptureDeviceListFor(Phonon::Category category, QList<int> order)
     353{
     354#ifndef QT_NO_PHONON_SETTINGSGROUP
     355    PulseSupport *pulse = PulseSupport::getInstance();
     356    if (pulse->isActive()) {
     357        pulse->setCaptureDevicePriorityForCategory(category, order);
     358        return;
     359    }
     360
     361    K_D(GlobalConfig);
     362    QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier());
     363
     364    order = reindexList(this, category, order, false);
     365
     366    const QList<int> noCategoryOrder = audioCaptureDeviceListFor(Phonon::NoCategory, ShowUnavailableDevices|ShowAdvancedDevices);
     367    if (category != Phonon::NoCategory && order == noCategoryOrder) {
     368        backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category));
     369    } else {
     370        backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order);
     371    }
     372}
     373
    193374QList<int> GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, int override) const
    194375{
    195 #ifndef QT_NO_PHONON_SETTINGSGROUP
    196     //The devices need to be stored independently for every backend
    197     const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier());
    198     const QSettingsGroup generalGroup(&m_config, QLatin1String("General"));
    199     const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings)
    200             ? generalGroup.value(QLatin1String("HideAdvancedDevices"), true)
     376    K_D(const GlobalConfig);
     377
     378    const bool hide = ((override & AdvancedDevicesFromSettings)
     379            ? hideAdvancedDevices()
    201380            : static_cast<bool>(override & HideAdvancedDevices));
    202381
    203382    QList<int> defaultList;
     383
     384    PulseSupport *pulse = PulseSupport::getInstance();
     385    if (pulse->isActive()) {
     386        defaultList = pulse->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
     387        if (hide || (override & HideUnavailableDevices)) {
     388            filter(AudioCaptureDeviceType, NULL, &defaultList,
     389                    (hide ? FilterAdvancedDevices : 0)
     390                    | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
     391                    );
     392        }
     393    } else {
     394        BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend());
     395
    204396#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    205     if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
    206         // the platform plugin lists the audio devices for the platform
    207         // this list already is in default order (as defined by the platform plugin)
    208         defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
    209         if (hideAdvancedDevices) {
    210             QMutableListIterator<int> it(defaultList);
    211             while (it.hasNext()) {
    212                 AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next());
    213                 const QVariant var = objDesc.property("isAdvanced");
    214                 if (var.isValid() && var.toBool()) {
    215                     it.remove();
    216                 }
    217             }
    218         }
    219     }
    220 #endif //QT_NO_PHONON_PLATFORMPLUGIN
    221 
    222     // lookup the available devices directly from the backend (mostly for virtual devices)
    223     if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend())) {
    224         // this list already is in default order (as defined by the backend)
    225         QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
    226         if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
    227             filter(AudioCaptureDeviceType, backendIface, &list,
    228                     (hideAdvancedDevices ? FilterAdvancedDevices : 0)
    229                     // the platform plugin already provided the hardware devices
    230                     | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
    231                     | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
    232                   );
    233         }
    234         defaultList += list;
    235     }
    236 
    237     return listSortedByConfig(backendConfig, category, defaultList);
    238397#else //QT_NO_SETTINGSGROUP
    239398    return QList<int>();
    240399#endif //QT_NO_SETTINGSGROUP
     400        if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
     401            // the platform plugin lists the audio devices for the platform
     402            // this list already is in default order (as defined by the platform plugin)
     403            defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
     404            if (hide) {
     405                QMutableListIterator<int> it(defaultList);
     406                while (it.hasNext()) {
     407                    AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next());
     408                    const QVariant var = objDesc.property("isAdvanced");
     409                    if (var.isValid() && var.toBool()) {
     410                        it.remove();
     411                    }
     412                }
     413            }
     414        }
     415#endif //QT_NO_PHONON_PLATFORMPLUGIN
     416
     417        // lookup the available devices directly from the backend
     418        if (backendIface) {
     419            // this list already is in default order (as defined by the backend)
     420            QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
     421            if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
     422                filter(AudioCaptureDeviceType, backendIface, &list,
     423                        (hide ? FilterAdvancedDevices : 0)
     424                        // the platform plugin maybe already provided the hardware devices?
     425                        | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
     426                        | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
     427                      );
     428            }
     429            defaultList += list;
     430        }
     431    }
     432
     433    const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier());
     434    return sortDevicesByCategoryPriority(this, &backendConfig, AudioCaptureDeviceType, category, defaultList);
    241435}
    242436
  • trunk/src/3rdparty/phonon/phonon/globalconfig_p.h

    r561 r846  
    2727
    2828#include "phonon_export.h"
    29 #include "phononnamespace.h"
    3029
    3130QT_BEGIN_HEADER
     
    3433namespace Phonon
    3534{
    36     class PHONON_EXPORT GlobalConfig
     35    class GlobalConfigPrivate
    3736    {
    38     public:
    39         GlobalConfig();
    40         virtual ~GlobalConfig();
     37        public:
     38            GlobalConfigPrivate();
     39            virtual ~GlobalConfigPrivate() {}
    4140
    42         enum DevicesToHideFlag {
    43             ShowUnavailableDevices = 0,
    44             ShowAdvancedDevices = 0,
    45             HideAdvancedDevices = 1,
    46             AdvancedDevicesFromSettings = 2,
    47             HideUnavailableDevices = 4
    48         };
    49 #ifndef QT_NO_PHONON_SETTINGSGROUP
    50         QList<int> audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
    51 #endif //QT_NO_PHONON_SETTINGSGROUP
    52         int audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
    53 
    54 #ifndef QT_NO_PHONON_AUDIOCAPTURE
    55         QList<int> audioCaptureDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
    56         int audioCaptureDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
    57 #endif //QT_NO_PHONON_AUDIOCAPTURE
    58 
    59     protected:
    60 #ifndef QT_NO_SETTINGS
    61         QSettings m_config;
    62 #endif //QT_NO_SETTINGS
     41            QSettings config;
    6342    };
    6443} // namespace Phonon
  • trunk/src/3rdparty/phonon/phonon/mediacontroller.cpp

    r561 r846  
    7777{
    7878    if (!d || !d->media) {
    79         return false;
    80     }
    81     IFACE false;
     79        return Features();
     80    }
     81    IFACE Features();
    8282    Features ret;
    8383    if (iface->hasInterface(AddonInterface::AngleInterface)) {
  • trunk/src/3rdparty/phonon/phonon/mediaobject.cpp

    r561 r846  
    454454
    455455#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
    456     QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SLOT(_k_stateChanged(Phonon::State,Phonon::State)));
     456    QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SLOT(_k_stateChanged(Phonon::State, Phonon::State)));
    457457#else
    458     QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SIGNAL(stateChanged(Phonon::State,Phonon::State)));
     458    QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SIGNAL(stateChanged(Phonon::State, Phonon::State)));
    459459#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM
    460460    QObject::connect(m_backendObject, SIGNAL(tick(qint64)),             q, SIGNAL(tick(qint64)));
     
    468468    QObject::connect(m_backendObject, SIGNAL(prefinishMarkReached(qint32)), q, SIGNAL(prefinishMarkReached(qint32)));
    469469    QObject::connect(m_backendObject, SIGNAL(totalTimeChanged(qint64)), q, SIGNAL(totalTimeChanged(qint64)));
    470     QObject::connect(m_backendObject, SIGNAL(metaDataChanged(QMultiMap<QString,QString>)),
    471             q, SLOT(_k_metaDataChanged(QMultiMap<QString,QString>)));
    472     QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(MediaSource)),
    473         q, SLOT(_k_currentSourceChanged(MediaSource)));
     470    QObject::connect(m_backendObject, SIGNAL(metaDataChanged(const QMultiMap<QString, QString> &)),
     471            q, SLOT(_k_metaDataChanged(const QMultiMap<QString, QString> &)));
     472    QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(const MediaSource&)),
     473        q, SLOT(_k_currentSourceChanged(const MediaSource&)));
    474474
    475475    // set up attributes
  • trunk/src/3rdparty/phonon/phonon/mediasource.cpp

    r561 r846  
    5151    if (fileInfo.exists()) {
    5252        bool localFs = QAbstractFileEngine::LocalDiskFlag & QFSFileEngine(filename).fileFlags(QAbstractFileEngine::LocalDiskFlag);
    53         if (localFs) {
     53        if (localFs && !filename.startsWith(QLatin1String(":/")) && !filename.startsWith(QLatin1String("qrc://"))) {
    5454            d->url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
    5555        } else {
     
    5959            d->ioDevice = new QFile(filename);
    6060            d->setStream(new IODeviceStream(d->ioDevice, d->ioDevice));
     61            d->url =  QUrl::fromLocalFile(fileInfo.absoluteFilePath());
    6162#else
    6263            d->type = Invalid;
  • trunk/src/3rdparty/phonon/phonon/objectdescription.cpp

    r561 r846  
    3030#include "backendinterface.h"
    3131#include "platformplugin.h"
     32#include "pulsesupport.h"
    3233
    3334QT_BEGIN_NAMESPACE
     
    109110ObjectDescriptionData *ObjectDescriptionData::fromIndex(ObjectDescriptionType type, int index)
    110111{
    111     // prefer to get the ObjectDescriptionData from the platform plugin for audio devices
     112    bool is_audio_device = (AudioOutputDeviceType == type || AudioCaptureDeviceType == type);
     113
     114    PulseSupport *pulse = PulseSupport::getInstance();
     115    if (is_audio_device && pulse->isActive()) {
     116        QList<int> indexes = pulse->objectDescriptionIndexes(type);
     117        if (indexes.contains(index)) {
     118            QHash<QByteArray, QVariant> properties = pulse->objectDescriptionProperties(type, index);
     119            return new ObjectDescriptionData(index, properties);
     120        }
     121    } else {
     122        BackendInterface *iface = qobject_cast<BackendInterface *>(Factory::backend());
     123
     124        // prefer to get the ObjectDescriptionData from the platform plugin for audio devices
    112125#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    113     if (type == AudioOutputDeviceType || type == AudioCaptureDeviceType) {
    114         PlatformPlugin *platformPlugin = Factory::platformPlugin();
    115         if (platformPlugin) {
    116             QList<int> indexes = platformPlugin->objectDescriptionIndexes(type);
     126        if (is_audio_device) {
     127            PlatformPlugin *platformPlugin = Factory::platformPlugin();
     128            if (platformPlugin) {
     129                QList<int> indexes = platformPlugin->objectDescriptionIndexes(type);
     130                if (indexes.contains(index)) {
     131                    QHash<QByteArray, QVariant> properties = platformPlugin->objectDescriptionProperties(type, index);
     132                    return new ObjectDescriptionData(index, properties);
     133                }
     134            }
     135        }
     136#endif //QT_NO_PHONON_PLATFORMPLUGIN
     137
     138        if (iface) {
     139            QList<int> indexes = iface->objectDescriptionIndexes(type);
    117140            if (indexes.contains(index)) {
    118                 QHash<QByteArray, QVariant> properties = platformPlugin->objectDescriptionProperties(type, index);
     141                QHash<QByteArray, QVariant> properties = iface->objectDescriptionProperties(type, index);
    119142                return new ObjectDescriptionData(index, properties);
    120143            }
    121         }
    122     }
    123 #endif //QT_NO_PHONON_PLATFORMPLUGIN
    124 
    125     QObject *b = Factory::backend();
    126     BackendInterface *iface = qobject_cast<BackendInterface *>(b);
    127     if (iface) {
    128         QList<int> indexes = iface->objectDescriptionIndexes(type);
    129         if (indexes.contains(index)) {
    130             QHash<QByteArray, QVariant> properties = iface->objectDescriptionProperties(type, index);
    131             return new ObjectDescriptionData(index, properties);
    132144        }
    133145    }
  • trunk/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp

    r561 r846  
    6868{
    6969
    70 #if !defined(Q_CC_MINGW) || __MINGW32_MAJOR_VERSION >= 4
    71 
    7270template<> const QMetaObject ObjectDescriptionModel<AudioOutputDeviceType>::staticMetaObject = {
    7371    { &QAbstractListModel::staticMetaObject, qt_meta_stringdata_Phonon__ObjectDescriptionModel_AudioOutputDeviceType,
     
    140138}
    141139*/
    142 #endif
    143140
    144141int ObjectDescriptionModelData::rowCount(const QModelIndex &parent) const
     
    366363}
    367364
    368 #if !defined(Q_CC_MINGW) || __MINGW32_MAJOR_VERSION >= 4
    369 #if !defined(Q_CC_MSVC) || _MSC_VER > 1300 || defined(Q_CC_INTEL)
     365#if !defined(Q_CC_MSVC) || _MSC_VER > 1300 || defined(Q_CC_INTEL) || defined(Q_CC_MINGW)
    370366#define INSTANTIATE_META_FUNCTIONS(type) \
    371367template const QMetaObject *ObjectDescriptionModel<type>::metaObject() const; \
     
    385381INSTANTIATE_META_FUNCTIONS(VisualizationType);
    386382*/
    387 #endif //Q_CC_MINGW
    388383} // namespace Phonon
    389384
  • trunk/src/3rdparty/phonon/phonon/objectdescriptionmodel.h

    r561 r846  
    196196            Q_OBJECT_CHECK
    197197
    198 /* MinGW 3.4.x gives an ICE when trying to instantiate one of the
    199    ObjectDescriptionModel<foo> classes because it can't handle
    200    half exported classes correct. gcc 4.3.x has a fix for this but
    201    we currently there's no official gcc 4.3 on windows available.
    202    Because of this we need this little hack
    203  */
    204 #if !defined(Q_CC_MINGW) || __MINGW32_MAJOR_VERSION >= 4
    205198            /** \internal */
    206199            static PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject staticMetaObject;
     
    210203            PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void *qt_metacast(const char *_clname);
    211204            //int qt_metacall(QMetaObject::Call _c, int _id, void **_a);
    212 #endif
    213205
    214206            /**
  • trunk/src/3rdparty/phonon/phonon/path.cpp

    r561 r846  
    311311        return false;
    312312
    313     QList<QObjectPair>::const_iterator it = disconnections.constBegin();
    314     for(;it != disconnections.constEnd();++it) {
     313    QList<QObjectPair>::const_iterator it = disconnections.begin();
     314    for(;it != disconnections.end();++it) {
    315315        const QObjectPair &pair = *it;
    316316        if (!backend->disconnectNodes(pair.first, pair.second)) {
     
    328328    }
    329329
    330     for(it = connections.constBegin(); it != connections.constEnd(); ++it) {
    331         const QObjectPair pair = *it;
     330    for(it = connections.begin(); it != connections.end();++it) {
     331        const QObjectPair &pair = *it;
    332332        if (!backend->connectNodes(pair.first, pair.second)) {
    333333            //Error: a connection failed
  • trunk/src/3rdparty/phonon/phonon/phonondefs.h

    r561 r846  
    3030QT_BEGIN_NAMESPACE
    3131
     32#ifdef PHONON_BACKEND_VERSION_4_4
     33# ifndef PHONON_BACKEND_VERSION_4_3
     34#  define PHONON_BACKEND_VERSION_4_3
     35# endif
     36#endif
    3237#ifdef PHONON_BACKEND_VERSION_4_3
    3338# ifndef PHONON_BACKEND_VERSION_4_2
  • trunk/src/3rdparty/phonon/phonon/phononnamespace.h

    r561 r846  
    4242 * PHONON_VERSION is (major << 16) + (minor << 8) + patch.
    4343 */
    44 #define PHONON_VERSION PHONON_VERSION_CHECK(4, 3, 1)
     44#define PHONON_VERSION PHONON_VERSION_CHECK(4, 4, 0)
    4545
    4646/**
    4747 * PHONON_VERSION_STR is "major.minor.patch". E.g. "4.2.1"
    4848 */
    49 #define PHONON_VERSION_STR "4.3.1"
     49#define PHONON_VERSION_STR "4.4.0"
    5050
    5151QT_BEGIN_HEADER
  • trunk/src/3rdparty/phonon/phonon/seekslider.cpp

    r561 r846  
    7373
    7474    if (media) {
    75         connect(media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
     75        connect(media, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
    7676                SLOT(_k_stateChanged(Phonon::State)));
    7777        connect(media, SIGNAL(totalTimeChanged(qint64)), SLOT(_k_length(qint64)));
    7878        connect(media, SIGNAL(tick(qint64)), SLOT(_k_tick(qint64)));
    7979        connect(media, SIGNAL(seekableChanged(bool)), SLOT(_k_seekableChanged(bool)));
    80         connect(media, SIGNAL(currentSourceChanged(Phonon::MediaSource)), SLOT(_k_currentSourceChanged()));
     80        connect(media, SIGNAL(currentSourceChanged(const Phonon::MediaSource&)), SLOT(_k_currentSourceChanged()));
    8181        d->_k_stateChanged(media->state());
    8282        d->_k_seekableChanged(media->isSeekable());
  • trunk/src/3rdparty/phonon/phonon/seekslider_p.h

    r561 r846  
    2525
    2626#include "seekslider.h"
     27#include "swiftslider_p.h"
    2728#include <QtGui/QBoxLayout>
    28 #include <QtGui/QSlider>
    2929#include <QtGui/QLabel>
    3030#include <QtGui/QPixmap>
     
    8585
    8686        QBoxLayout layout;
    87         QSlider slider;
     87        SwiftSlider slider;
    8888        QLabel iconLabel;
    8989        QPointer<MediaObject> media;
  • trunk/src/3rdparty/phonon/phonon/videowidget.cpp

    r561 r846  
    2929
    3030#include <QtGui/QAction>
    31 
    32 #define PHONON_INTERFACENAME VideoWidgetInterface
     31#define IFACES4 VideoWidgetInterface44
     32#define IFACES0 VideoWidgetInterface, IFACES4
     33#define PHONON_INTERFACENAME IFACES0
    3334
    3435QT_BEGIN_NAMESPACE
     
    4849    setMouseTracking(true);
    4950}
     51
     52
    5053
    5154VideoWidget::VideoWidget(VideoWidgetPrivate &dd, QWidget *parent)
     
    98101PHONON_INTERFACE_GETTER(qreal, saturation, d->saturation)
    99102PHONON_INTERFACE_SETTER(setSaturation, saturation, qreal)
     103
     104
     105QImage VideoWidget::snapshot() const {
     106    K_D(const VideoWidget);
     107    ConstIface<IFACES4> iface(d);
     108    if(iface) return iface->snapshot();
     109    return QImage(); // TODO not implemented in VideoInterface
     110}
     111
    100112
    101113void VideoWidget::setFullScreen(bool newFullScreen)
  • trunk/src/3rdparty/phonon/phonon/videowidget.h

    r561 r846  
    173173            qreal hue() const;
    174174            qreal saturation() const;
     175            QImage snapshot() const;
    175176
    176177            //TODO: bar colors property
  • trunk/src/3rdparty/phonon/phonon/videowidgetinterface.h

    r561 r846  
    5454//X        virtual bool createOverlay(QWidget *widget, int type) = 0;
    5555};
     56
     57class VideoWidgetInterface44 : public VideoWidgetInterface
     58{
     59    public:
     60        virtual QImage snapshot() const = 0;
     61};
    5662}
    5763
     64#ifdef PHONON_BACKEND_VERSION_4_4
     65namespace Phonon { typedef VideoWidgetInterface44 VideoWidgetInterfaceLatest; }
     66#else
     67namespace Phonon { typedef VideoWidgetInterface VideoWidgetInterfaceLatest; }
     68#endif
     69
     70Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface44, "VideoWidgetInterface44.phonon.kde.org")
    5871Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface, "VideoWidgetInterface3.phonon.kde.org")
    5972
  • trunk/src/3rdparty/phonon/phonon/volumeslider_p.h

    r561 r846  
    2525
    2626#include "volumeslider.h"
     27#include "swiftslider_p.h"
    2728#include <QtGui/QBoxLayout>
    28 #include <QtGui/QSlider>
    2929#include <QtGui/QLabel>
    3030#include <QtGui/QPixmap>
     
    8484    private:
    8585        QBoxLayout layout;
    86         QSlider slider;
     86        SwiftSlider slider;
    8787        QToolButton muteButton;
    8888        QIcon volumeIcon;
  • trunk/src/3rdparty/phonon/qt7/audionode.h

    r2 r846  
    7373
    7474            // Only the following methods needs to
    75             // be overidden by only_one-audio-unit nodes:
     75            // be overridden by only_one-audio-unit nodes:
    7676            virtual ComponentDescription getAudioNodeDescription() const;
    7777            virtual void initializeAudioUnit();
  • trunk/src/3rdparty/phonon/qt7/audionode.mm

    r2 r846  
    7878    // deal with at the moment, so we'll take the "deprecated" warning instead.
    7979    err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode);
     80       
    8081    BACKEND_ASSERT2(err != kAUGraphErr_OutputNodeErr, "A MediaObject can only be connected to one audio output device.", FATAL_ERROR)
    8182    BACKEND_ASSERT2(err == noErr, "Could not create new AUNode.", FATAL_ERROR)
  • trunk/src/3rdparty/phonon/qt7/backendinfo.mm

    r2 r846  
    1616*/
    1717
    18 #include "backendinfo.h"
    19 #include "backendheader.h"
    20 
    21 #include <AudioToolbox/AudioToolbox.h>
    22 #include <AudioUnit/AudioUnit.h>
    23 #include <CoreServices/CoreServices.h>
    24 
    25 #include <QtGui/qmacdefines_mac.h>
    2618#import <QTKit/QTMovie.h>
    27 
    2819#ifdef QUICKTIME_C_API_AVAILABLE
    2920    #include <QuickTime/QuickTime.h>
    3021    #undef check // avoid name clash;
    3122#endif
     23
     24#include "backendinfo.h"
     25#include "backendheader.h"
     26
     27#include <AudioToolbox/AudioToolbox.h>
     28#include <AudioUnit/AudioUnit.h>
     29#include <CoreServices/CoreServices.h>
     30
    3231
    3332QT_BEGIN_NAMESPACE
  • trunk/src/3rdparty/phonon/qt7/mediaobject.h

    r561 r846  
    2626#include "medianode.h"
    2727
    28 #if QT_ALLOW_QUICKTIME
    29     #include <QuickTime/QuickTime.h>
    30 #endif
    31 
    3228QT_BEGIN_NAMESPACE
    3329
     
    4339
    4440    class MediaObject : public MediaNode,
    45         public Phonon::MediaObjectInterface
    46 #ifndef QT_NO_PHONON_MEDIACONTROLLER
    47         , public Phonon::AddonInterface
    48 #endif
     41        public Phonon::MediaObjectInterface, public Phonon::AddonInterface
    4942    {
    5043        Q_OBJECT
     
    10093                int videoOutputCount();
    10194
    102 #if QT_ALLOW_QUICKTIME
    103         void displayLinkEvent();
    104 #endif
    105 
    10695    signals:
    10796        void stateChanged(Phonon::State,Phonon::State);
     
    116105        void metaDataChanged(QMultiMap<QString,QString>);
    117106        void currentSourceChanged(const MediaSource &newSource);
    118 
    119         // Add-on interface:
    120         void availableSubtitlesChanged();
    121         void availableAudioChannelsChanged();
    122         void titleChanged(int);
    123         void availableTitlesChanged(int);
    124         void chapterChanged(int);
    125         void availableChaptersChanged(int);
    126         void angleChanged(int);
    127         void availableAnglesChanged(int);
    128107
    129108    protected:
     
    140119        QuickTimeAudioPlayer *m_nextAudioPlayer;
    141120        MediaObjectAudioNode *m_mediaObjectAudioNode;
    142 
    143 #if QT_ALLOW_QUICKTIME
    144         CVDisplayLinkRef m_displayLink;
    145         QMutex m_displayLinkMutex;
    146         bool m_pendingDisplayLinkEvent;
    147         void startDisplayLink();
    148         void stopDisplayLink();
    149 #endif
     121        QuickTimeMetaData *m_metaData;
    150122
    151123        qint32 m_tickInterval;
     
    156128
    157129        int m_tickTimer;
    158         int m_videoTimer;
    159         int m_audioTimer;
     130        int m_bufferTimer;
    160131        int m_rapidTimer;
    161132
     
    163134        int m_swapTimeLeft;
    164135        QTime m_swapTime;
    165         bool m_autoplayTitles;
    166136
    167137        void synchAudioVideo();
     
    172142        void play_internal();
    173143        void setupAudioSystem();
    174         void restartAudioVideoTimers();
     144        void updateTimer(int &timer, int interval);
     145        void bufferAudioVideo();
    175146        void updateRapidly();
    176147        void updateCrossFade();
     
    184155        void inspectGraph();
    185156        bool isCrossFading();
    186         void setCurrentTrack(int track);
    187157
    188158        QString m_errorString;
  • trunk/src/3rdparty/phonon/qt7/mediaobject.mm

    r561 r846  
    4747    setAudioNode(m_mediaObjectAudioNode);
    4848
     49    m_metaData = new QuickTimeMetaData();
    4950    m_audioGraph = new AudioGraph(this);
    5051
     
    5556    m_percentageLoaded = 0;
    5657    m_waitNextSwap = false;
    57     m_autoplayTitles = true;
    5858    m_audioEffectCount = 0;
    5959    m_audioOutputCount = 0;
     
    6464
    6565    m_tickTimer = 0;
    66     m_videoTimer = 0;
    67     m_audioTimer = 0;
     66    m_bufferTimer = 0;
    6867    m_rapidTimer = 0;
    6968
    70 #if QT_ALLOW_QUICKTIME
    71     m_displayLink = 0;
    72     m_pendingDisplayLinkEvent = false;
    73 #endif
    74 
    7569    checkForError();
    7670}
    7771
    7872MediaObject::~MediaObject()
    79 {
    80     // m_mediaObjectAudioNode is owned by super class.
    81 #if QT_ALLOW_QUICKTIME
    82     stopDisplayLink();
    83 #endif
     73{   
     74    // m_mediaObjectAudioNode is owned by super class.   
    8475    m_audioPlayer->unsetVideoPlayer();
    8576    m_nextAudioPlayer->unsetVideoPlayer();
    8677    delete m_videoPlayer;
    8778    delete m_nextVideoPlayer;
     79    delete m_metaData;
    8880    checkForError();
    8981}
     
    9789        if (m_state != state){
    9890            // End-application did something
    99             // upon  receiving the signal.
     91            // upon  receiving the signal. 
    10092            return false;
    10193        }
     
    131123    // effects or outputs connected. This will have
    132124    // influence on the audio system and video system that ends up beeing used:
    133     int prevVideoOutputCount = m_videoOutputCount;
     125    int prevVideoOutputCount = m_videoOutputCount;     
    134126    m_audioEffectCount = 0;
    135127    m_audioOutputCount = 0;
     
    143135            MediaNodeEvent e1(MediaNodeEvent::VideoOutputCountChanged, &m_videoOutputCount);
    144136            notify(&e1);
    145     }
     137        }       
    146138}
    147139
     
    176168    if (newAudioSystem == m_audioSystem)
    177169        return;
    178 
     170 
    179171    // Enable selected audio system:
    180     m_audioSystem = newAudioSystem;
     172    m_audioSystem = newAudioSystem; 
    181173    switch (newAudioSystem){
    182174        case AS_Silent:
    183175            m_audioGraph->stop();
    184176            m_videoPlayer->enableAudio(false);
    185             m_nextVideoPlayer->enableAudio(false);
     177            m_nextVideoPlayer->enableAudio(false);   
    186178            m_audioPlayer->enableAudio(false);
    187179            m_nextAudioPlayer->enableAudio(false);
     
    223215        PhononAutoReleasePool pool;
    224216    setState(Phonon::LoadingState);
    225 
     217   
    226218    // Save current state for event/signal handling below:
    227219    bool prevHasVideo = m_videoPlayer->hasVideo();
    228220    qint64 prevTotalTime = totalTime();
    229     int prevTrackCount = m_videoPlayer->trackCount();
    230221    m_waitNextSwap = false;
    231 
     222       
    232223    // Cancel cross-fade if any:
    233224    m_nextVideoPlayer->pause();
    234225    m_nextAudioPlayer->pause();
    235226    m_mediaObjectAudioNode->cancelCrossFade();
    236 
     227   
    237228    // Set new source:
    238229    m_audioPlayer->unsetVideoPlayer();
    239230    m_videoPlayer->setMediaSource(source);
    240231    m_audioPlayer->setVideoPlayer(m_videoPlayer);
    241 
    242     m_audioGraph->updateStreamSpecifications();
     232    m_metaData->setVideo(m_videoPlayer);       
     233
     234    m_audioGraph->updateStreamSpecifications();       
    243235    m_nextAudioPlayer->unsetVideoPlayer();
    244     m_nextVideoPlayer->unsetCurrentMediaSource();
     236    m_nextVideoPlayer->unsetVideo();
    245237    m_currentTime = 0;
    246 
     238       
    247239    // Emit/notify information about the new source:
    248240    QRect videoRect = m_videoPlayer->videoRect();
     
    255247
    256248    emit currentSourceChanged(source);
    257     emit metaDataChanged(m_videoPlayer->metaData());
     249    emit metaDataChanged(m_metaData->metaData());
    258250
    259251    if (prevHasVideo != m_videoPlayer->hasVideo())
    260         emit hasVideoChanged(m_videoPlayer->hasVideo());
     252        emit hasVideoChanged(m_videoPlayer->hasVideo());       
    261253    if (prevTotalTime != totalTime())
    262         emit totalTimeChanged(totalTime());
    263     if (prevTrackCount != m_videoPlayer->trackCount())
    264         emit availableTitlesChanged(m_videoPlayer->trackCount());
     254        emit totalTimeChanged(totalTime());       
    265255    if (checkForError())
    266256        return;
     
    271261    if (!m_videoPlayer->canPlayMedia())
    272262        SET_ERROR("Cannot play media.", FATAL_ERROR)
    273 
     263       
    274264    // The state might have changed from LoadingState
    275265    // as a response to an error state change. So we
     
    298288    bool prevHasVideo = m_videoPlayer->hasVideo();
    299289    qint64 prevTotalTime = totalTime();
    300     int prevTrackCount = m_videoPlayer->trackCount();
    301290
    302291    qSwap(m_audioPlayer, m_nextAudioPlayer);
     
    304293    m_mediaObjectAudioNode->startCrossFade(transitionTime);
    305294    m_audioGraph->updateStreamSpecifications();
     295    m_metaData->setVideo(m_videoPlayer);
    306296
    307297    m_waitNextSwap = false;
    308298    m_currentTime = 0;
    309 
     299       
    310300    // Emit/notify information about the new source:
    311301    QRect videoRect = m_videoPlayer->videoRect();
     
    314304
    315305    emit currentSourceChanged(m_videoPlayer->mediaSource());
    316     emit metaDataChanged(m_videoPlayer->metaData());
     306    emit metaDataChanged(m_metaData->metaData());
    317307
    318308    if (prevHasVideo != m_videoPlayer->hasVideo())
    319         emit hasVideoChanged(m_videoPlayer->hasVideo());
     309        emit hasVideoChanged(m_videoPlayer->hasVideo());       
    320310    if (prevTotalTime != totalTime())
    321311        emit totalTimeChanged(totalTime());
    322     if (prevTrackCount != m_videoPlayer->trackCount())
    323         emit availableTitlesChanged(m_videoPlayer->trackCount());
    324312    if (checkForError())
    325313        return;
     
    340328}
    341329
    342 #if QT_ALLOW_QUICKTIME
    343 static CVReturn displayLinkCallback(CVDisplayLinkRef /*displayLink*/,
    344                                                                  const CVTimeStamp */*inNow*/,
    345                                                                  const CVTimeStamp */*inOutputTime*/,
    346                                                                  CVOptionFlags /*flagsIn*/,
    347                                                                  CVOptionFlags */*flagsOut*/,
    348                                  void *userData)
    349 {
    350     MediaObject *mediaObject = static_cast<MediaObject *>(userData);
    351     mediaObject->displayLinkEvent();
    352     return kCVReturnSuccess;
    353 }
    354 
    355 void MediaObject::displayLinkEvent()
    356 {
    357     // This function is called from a
    358     // thread != gui thread. So we post the event.
    359     // But we need to make sure that we don't post faster
    360     // than the event loop can eat:
    361     m_displayLinkMutex.lock();
    362     bool pending = m_pendingDisplayLinkEvent;
    363     m_pendingDisplayLinkEvent = true;
    364     m_displayLinkMutex.unlock();
    365 
    366     if (!pending)
    367         qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority);
    368 }
    369 
    370 void MediaObject::startDisplayLink()
    371 {
    372     if (m_displayLink)
    373         return;
    374     OSStatus err = CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &m_displayLink);
    375     if (err != noErr)
    376         goto fail;
    377     err = CVDisplayLinkSetCurrentCGDisplay(m_displayLink, kCGDirectMainDisplay);
    378     if (err != noErr)
    379         goto fail;
    380     err = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this);
    381     if (err != noErr)
    382         goto fail;
    383     err = CVDisplayLinkStart(m_displayLink);
    384     if (err != noErr)
    385         goto fail;
    386     return;
    387 fail:
    388     stopDisplayLink();
    389 }
    390 
    391 void MediaObject::stopDisplayLink()
    392 {
    393     if (!m_displayLink)
    394         return;
    395     CVDisplayLinkStop(m_displayLink);
    396     CFRelease(m_displayLink);
    397     m_displayLink = 0;
    398 }
    399 #endif
    400 
    401 void MediaObject::restartAudioVideoTimers()
    402 {
    403     if (m_videoTimer)
    404         killTimer(m_videoTimer);
    405     if (m_audioTimer)
    406         killTimer(m_audioTimer);
    407 
    408 #if QT_ALLOW_QUICKTIME
    409     // We prefer to use a display link as timer if available, since
    410     // it is more steady, and results in better and smoother frame drawing:
    411     startDisplayLink();
    412     if (!m_displayLink){
    413         float fps = m_videoPlayer->staticFps();
    414         long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001;
    415         m_videoTimer = startTimer(videoUpdateFrequency);
    416     }
    417 #else
    418     float fps = m_videoPlayer->staticFps();
    419     long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001;
    420     m_videoTimer = startTimer(videoUpdateFrequency);
    421 #endif
    422 
    423     long audioUpdateFrequency = m_audioPlayer->regularTaskFrequency();
    424     m_audioTimer = startTimer(audioUpdateFrequency);
    425     updateVideoFrames();
    426     updateAudioBuffers();
     330void MediaObject::updateTimer(int &timer, int interval)
     331{
     332    if (timer)
     333        killTimer(timer);
     334    timer = 0;
     335    if (interval >= 0)   
     336        timer = startTimer(interval);
    427337}
    428338
     
    431341    // Play main audio/video:
    432342    m_videoPlayer->play();
    433     m_audioPlayer->play();
     343    m_audioPlayer->play();     
    434344    updateLipSynch(0);
    435345    // Play old audio/video to finish cross-fade:
     
    438348        m_nextAudioPlayer->play();
    439349    }
    440     restartAudioVideoTimers();
    441     if (!m_rapidTimer)
    442         m_rapidTimer = startTimer(100);
     350    bufferAudioVideo();
     351    updateTimer(m_rapidTimer, 100);
    443352}
    444353
     
    450359    m_videoPlayer->pause();
    451360    m_nextVideoPlayer->pause();
    452     killTimer(m_rapidTimer);
    453     killTimer(m_videoTimer);
    454     killTimer(m_audioTimer);
    455     m_rapidTimer = 0;
    456     m_videoTimer = 0;
    457     m_audioTimer = 0;
    458 #if QT_ALLOW_QUICKTIME
    459     stopDisplayLink();
    460 #endif
     361    updateTimer(m_rapidTimer, -1);
     362    updateTimer(m_bufferTimer, -1);
     363
    461364    if (m_waitNextSwap)
    462365        m_swapTimeLeft = m_swapTime.msecsTo(QTime::currentTime());
     
    480383        return;
    481384    if (!setState(Phonon::PlayingState))
    482         return;
     385        return;       
    483386    if (m_audioSystem == AS_Graph){
    484387        m_audioGraph->start();
     
    521424        return;
    522425    m_waitNextSwap = false;
    523     m_nextVideoPlayer->unsetCurrentMediaSource();
     426    m_nextVideoPlayer->unsetVideo();
    524427    m_nextAudioPlayer->unsetVideoPlayer();
    525428    pause_internal();
     
    533436    if (m_state == Phonon::ErrorState)
    534437        return;
    535 
     438       
    536439    // Stop cross-fade if any:
    537     m_nextVideoPlayer->unsetCurrentMediaSource();
     440    m_nextVideoPlayer->unsetVideo();
    538441    m_nextAudioPlayer->unsetVideoPlayer();
    539442    m_mediaObjectAudioNode->cancelCrossFade();
     
    544447    m_audioPlayer->seek(m_videoPlayer->currentTime());
    545448    m_mediaObjectAudioNode->setMute(false);
    546 
     449   
    547450    // Update time and cancel pending swap:
    548451    if (m_currentTime < m_videoPlayer->duration())
     
    655558{
    656559    IMPLEMENTED_SILENT;
    657     const_cast<MediaObject *>(this)->updateCurrentTime();
     560    const_cast<MediaObject *>(this)->updateCurrentTime(); 
    658561    return m_currentTime;
    659562}
     
    665568    quint64 total = m_videoPlayer->duration();
    666569
    667     if (m_videoPlayer->currentTrack() < m_videoPlayer->trackCount() - 1){
    668         // There are still more tracks to play after the current track.
    669         if (m_autoplayTitles) {
    670             if (lastUpdateTime < m_currentTime && m_currentTime == total)
    671                 setCurrentTrack(m_videoPlayer->currentTrack() + 1);
    672         }
    673     } else if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){
    674         // There is no more sources or tracks to play after the current source.
    675         // Check if it's time to emit aboutToFinish:
    676         quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000));
    677         if (lastUpdateTime < mark && mark <= m_currentTime)
    678             emit aboutToFinish();
    679 
    680         // Check if it's time to emit prefinishMarkReached:
    681         mark = qMax(quint64(0), total - m_prefinishMark);
    682         if (lastUpdateTime < mark && mark <= m_currentTime)
    683             emit prefinishMarkReached(total - m_currentTime);
    684 
     570    // Check if it's time to emit aboutToFinish:
     571    quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000));
     572    if (lastUpdateTime < mark && mark <= m_currentTime)
     573        emit aboutToFinish();
     574
     575    // Check if it's time to emit prefinishMarkReached:
     576    mark = qMax(quint64(0), total - m_prefinishMark);
     577    if (lastUpdateTime < mark && mark <= m_currentTime)
     578        emit prefinishMarkReached(total - m_currentTime);
     579
     580    if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){
     581        // There is no next source in que.
     582        // Check if it's time to emit finished:
    685583        if (lastUpdateTime < m_currentTime && m_currentTime == total){
    686584            emit finished();
     
    692590        // We have a next source.
    693591        // Check if it's time to swap to next source:
    694         quint32 mark = qMax(quint64(0), total + m_transitionTime);
     592        mark = qMax(quint64(0), total + m_transitionTime);
    695593        if (m_waitNextSwap && m_state == Phonon::PlayingState &&
    696594            m_transitionTime < m_swapTime.msecsTo(QTime::currentTime())){
     
    795693void MediaObject::updateCrossFade()
    796694{
    797     m_mediaObjectAudioNode->updateCrossFade(m_currentTime);
     695    m_mediaObjectAudioNode->updateCrossFade(m_currentTime);   
    798696    // Clean-up previous movie if done fading:
    799697    if (m_mediaObjectAudioNode->m_fadeDuration == 0){
    800698        if (m_nextVideoPlayer->isPlaying() || m_nextAudioPlayer->isPlaying()){
    801             m_nextVideoPlayer->unsetCurrentMediaSource();
     699            m_nextVideoPlayer->unsetVideo();
    802700            m_nextAudioPlayer->unsetVideoPlayer();
    803701        }
    804     }
     702    }       
    805703}
    806704
     
    831729    if (m_videoPlayer->videoFrameChanged()){
    832730        updateLipSynch(50);
    833         VideoFrame frame(m_videoPlayer);
     731        VideoFrame frame(m_videoPlayer);           
    834732        if (m_nextVideoPlayer->isPlaying()
    835733            && m_nextVideoPlayer->hasVideo()
     
    839737            frame.setBaseOpacity(m_mediaObjectAudioNode->m_volume1);
    840738        }
    841 
     739       
    842740        // Send the frame through the graph:
    843         updateVideo(frame);
     741        updateVideo(frame);   
    844742        checkForError();
    845743    }
     
    852750    if (m_videoSinkList.isEmpty() || m_audioSinkList.isEmpty())
    853751        return;
    854 
     752       
    855753    if (m_videoPlayer->hasVideo()){
    856754        qint64 diff = m_audioPlayer->currentTime() - m_videoPlayer->currentTime();
     
    864762            m_nextAudioPlayer->seek(m_nextVideoPlayer->currentTime());
    865763    }
     764}
     765
     766void MediaObject::bufferAudioVideo()
     767{
     768    long nextVideoUpdate = m_videoPlayer->hasVideo() ? 30 : INT_MAX;
     769    long nextAudioUpdate = m_audioPlayer->regularTaskFrequency();
     770    updateAudioBuffers();
     771    updateVideoFrames();
     772    if (m_state == Phonon::PlayingState)
     773        updateTimer(m_bufferTimer, qMin(nextVideoUpdate, nextAudioUpdate));
    866774}
    867775
     
    890798            checkForError();
    891799            m_mediaObjectAudioNode->setMute(false);
    892             if (m_state == Phonon::PlayingState)
    893                 restartAudioVideoTimers();
     800             if (m_state == Phonon::PlayingState)
     801                bufferAudioVideo();
    894802            break;
    895803        case MediaNodeEvent::AudioGraphCannotPlay:
     
    902810                m_mediaObjectAudioNode->setMute(false);
    903811            }
     812            break;
     813        default:
     814            break;
     815    }
     816}
     817
     818bool MediaObject::event(QEvent *event)
     819{
     820    switch (event->type()){
     821        case QEvent::Timer: {
     822            QTimerEvent *timerEvent = static_cast<QTimerEvent *>(event);
     823            if (timerEvent->timerId() == m_rapidTimer)
     824                updateRapidly();
     825            else if (timerEvent->timerId() == m_tickTimer)
     826                emit tick(currentTime());
     827            else if (timerEvent->timerId() == m_bufferTimer)
     828                bufferAudioVideo();
     829            }
    904830            break;
    905831        default:
    906832            break;
    907833    }
    908 }
    909 
    910 bool MediaObject::event(QEvent *event)
    911 {
    912     switch (event->type()){
    913 #if QT_ALLOW_QUICKTIME
    914         case QEvent::User:{
    915             m_displayLinkMutex.lock();
    916             m_pendingDisplayLinkEvent = false;
    917             m_displayLinkMutex.unlock();
    918             updateVideoFrames();
    919             break; }
    920 #endif
    921         case QEvent::Timer:{
    922             int timerId = static_cast<QTimerEvent *>(event)->timerId();
    923             if (timerId == m_rapidTimer)
    924                 updateRapidly();
    925             else if (timerId == m_tickTimer)
    926                 emit tick(currentTime());
    927             else if (timerId == m_videoTimer)
    928                 updateVideoFrames();
    929             else if (timerId == m_audioTimer)
    930                 updateAudioBuffers();
    931             break; }
    932         default:
    933             break;
    934     }
    935834    return QObject::event(event);
    936835}
    937836
    938 void MediaObject::setCurrentTrack(int track)
    939 {
    940     if (track == m_videoPlayer->currentTrack() || track < 0 || track >= m_videoPlayer->trackCount())
    941         return;
    942 
    943     m_videoPlayer->setCurrentTrack(track);
    944     emit titleChanged(track);
    945     emit metaDataChanged(m_videoPlayer->metaData());
    946 }
    947 
    948 bool MediaObject::hasInterface(Interface iface) const
    949 {
    950     return iface == AddonInterface::TitleInterface;
    951 }
    952 
    953 QVariant MediaObject::interfaceCall(Interface iface, int command, const QList<QVariant> &params)
    954 {
    955     switch (iface) {
    956         case TitleInterface:
    957             switch (command) {
    958                 case availableTitles:
    959                     return m_videoPlayer->trackCount();
    960                 case title:
    961                     return m_videoPlayer->currentTrack();
    962                 case setTitle:
    963                     setCurrentTrack(params.first().toInt());
    964                     break;
    965                 case autoplayTitles:
    966                     return m_autoplayTitles;
    967                 case setAutoplayTitles:
    968                     m_autoplayTitles = params.first().toBool();
    969                     break;
    970             }
    971         default:
    972             break;
    973     }
     837bool MediaObject::hasInterface(Interface /*interface*/) const
     838{
     839    return false;
     840}
     841
     842QVariant MediaObject::interfaceCall(Interface /*interface*/, int /*command*/, const QList<QVariant> &/*arguments*/)
     843{
    974844    return QVariant();
    975845}
  • trunk/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm

    r2 r846  
    1515    along with this library.  If not, see <http://www.gnu.org/licenses/>.
    1616*/
     17
     18#import <QTKit/QTMovie.h>
    1719
    1820#include "mediaobjectaudionode.h"
  • trunk/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm

    r2 r846  
    1515    along with this library.  If not, see <http://www.gnu.org/licenses/>.
    1616*/
     17
     18#import <QTKit/QTMovie.h>
    1719
    1820#include "quicktimeaudioplayer.h"
  • trunk/src/3rdparty/phonon/qt7/quicktimemetadata.h

    r561 r846  
    3939    {
    4040        public:
    41             QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer);
    42             void update();
     41            QuickTimeMetaData();
     42            virtual ~QuickTimeMetaData();
     43
     44            void setVideo(QuickTimeVideoPlayer *videoPlayer);
    4345            QMultiMap<QString, QString> metaData();
    4446
     
    4850            QuickTimeVideoPlayer *m_videoPlayer;
    4951            void readMetaData();
    50             void guessMetaDataForCD();
    51             void readMetaDataFromMovie();
    5252
    5353#ifdef QUICKTIME_C_API_AVAILABLE
  • trunk/src/3rdparty/phonon/qt7/quicktimemetadata.mm

    r561 r846  
    1616*/
    1717
    18 #include <QtCore/QFileInfo>
     18#import <QTKit/QTMovie.h>
     19
    1920#include "quicktimemetadata.h"
    2021#include "quicktimevideoplayer.h"
     
    2728{
    2829
    29 QuickTimeMetaData::QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer)
     30QuickTimeMetaData::QuickTimeMetaData()
    3031{
    31     m_videoPlayer = videoPlayer;
     32    m_videoPlayer = 0;
    3233    m_movieChanged = false;
    3334}
    3435
    35 void QuickTimeMetaData::update()
     36QuickTimeMetaData::~QuickTimeMetaData()
    3637{
     38}
     39
     40void QuickTimeMetaData::setVideo(QuickTimeVideoPlayer *videoPlayer)
     41{
     42    m_videoPlayer = videoPlayer;
    3743    m_movieChanged = true;
    3844    m_metaData.clear();
     
    142148#endif // QUICKTIME_C_API_AVAILABLE
    143149
    144 void QuickTimeMetaData::guessMetaDataForCD()
     150void QuickTimeMetaData::readMetaData()
    145151{
    146     QString album = QFileInfo(m_videoPlayer->movieCompactDiscPath()).fileName();
    147     QString title = QFileInfo(m_videoPlayer->currentTrackPath()).fileName();
    148     title = title.left(title.lastIndexOf('.'));
    149     m_metaData.insert(QLatin1String("ALBUM"), album);
    150     m_metaData.insert(QLatin1String("TITLE"), title);
    151     m_metaData.insert(QLatin1String("TRACKNUMBER"), QString::number(m_videoPlayer->currentTrack()));
    152 }
    153 
    154 void QuickTimeMetaData::readMetaDataFromMovie()
    155 {
     152        if (!m_videoPlayer)
     153        return;
    156154    QMultiMap<QString, QString> metaMap;
    157 
     155   
    158156#ifdef QUICKTIME_C_API_AVAILABLE
    159     QTMetaDataRef metaDataRef;
     157        QTMetaDataRef metaDataRef;       
    160158        OSStatus err = QTCopyMovieMetaData([m_videoPlayer->qtMovie() quickTimeMovie], &metaDataRef);
    161159    BACKEND_ASSERT2(err == noErr, "Could not read QuickTime meta data", NORMAL_ERROR)
     
    178176}
    179177
    180 void QuickTimeMetaData::readMetaData()
    181 {
    182         if (!m_videoPlayer)
    183         return;
    184 
    185     if (m_videoPlayer->mediaSource().type() == Phonon::MediaSource::Disc)
    186         guessMetaDataForCD();
    187     else
    188         readMetaDataFromMovie();
    189 }
    190 
    191178QMultiMap<QString, QString> QuickTimeMetaData::metaData()
    192179{
  • trunk/src/3rdparty/phonon/qt7/quicktimevideoplayer.h

    r561 r846  
    2121#include "backendheader.h"
    2222
    23 #include <QtGui/qmacdefines_mac.h>
    2423#import <QTKit/QTDataReference.h>
    2524#import <QTKit/QTMovie.h>
     
    4039{
    4140    class QuickTimeStreamReader;
    42     class QuickTimeMetaData;
    4341        class VideoRenderWidgetQTMovieView;
    4442
     
    5856            void setMediaSource(const MediaSource &source);
    5957            MediaSource mediaSource() const;
    60             void unsetCurrentMediaSource();
     58            void unsetVideo();
    6159
    6260            void play();
     
    6967                        void *currentFrameAsCIImage();
    7068            QImage currentFrameAsQImage();
    71             void releaseImageCache();
    7269            QRect videoRect() const;
    7370
     
    7572            quint64 currentTime() const;
    7673            long timeScale() const;
    77             float staticFps();
    7874            QString currentTimeString();
    7975
     
    8884            void setPlaybackRate(float rate);
    8985            QTMovie *qtMovie() const;
    90             QMultiMap<QString, QString> metaData();
    9186
    9287            float playbackRate() const;
     
    108103            quint64 timeLoaded();
    109104
    110             int trackCount() const;
    111             int currentTrack() const;
    112             void setCurrentTrack(int track);
    113             QString movieCompactDiscPath() const;
    114             QString currentTrackPath() const;
    115 
    116105            static QString timeToString(quint64 ms);
    117106
     
    127116            State m_state;
    128117            QGLPixelBuffer *m_QImagePixelBuffer;
    129             QuickTimeMetaData *m_metaData;
    130 
    131             CVOpenGLTextureRef m_cachedCVTextureRef;
    132             QImage m_cachedQImage;
    133118
    134119            bool m_playbackRateSat;
     
    141126            float m_relativeVolume;
    142127            float m_playbackRate;
    143             float m_staticFps;
    144128            quint64 m_currentTime;
    145129            MediaSource m_mediaSource;
    146 
    147130                        void *m_primaryRenderingCIImage;
    148131                        qreal m_brightness;
     
    150133                        qreal m_hue;
    151134                        qreal m_saturation;
    152             NSArray *m_folderTracks;
    153             int m_currentTrack;
    154             QString m_movieCompactDiscPath;
    155135
    156136#ifdef QUICKTIME_C_API_AVAILABLE
     
    160140            QuickTimeStreamReader *m_streamReader;
    161141
    162             void prepareCurrentMovieForPlayback();
    163142            void createVisualContext();
    164143            void openMovieFromCurrentMediaSource();
     
    167146            void openMovieFromUrl();
    168147            void openMovieFromStream();
    169             void openMovieFromCompactDisc();
    170148            void openMovieFromData(QByteArray *data, char *fileType);
    171149            void openMovieFromDataGuessType(QByteArray *data);
    172150                        QString mediaSourcePath();
    173151                        bool codecExistsAccordingToSuffix(const QString &fileName);
    174             NSString* pathToCompactDisc();
    175             bool isCompactDisc(NSString *path);
    176             NSArray* scanFolder(NSString *path);
    177152
    178153            void setError(NSError *error);
    179154            bool errorOccured();
    180155            void readProtection();
    181             void calculateStaticFps();
    182156            void checkIfVideoAwailable();
    183157            bool movieNotLoaded();
  • trunk/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm

    r561 r846  
    2121#include "audiodevice.h"
    2222#include "quicktimestreamreader.h"
    23 #include "quicktimemetadata.h"
    2423
    2524#include <QtCore/QCoreApplication>
     
    5453    m_state = NoMedia;
    5554    m_mediaSource = MediaSource();
    56     m_metaData = new QuickTimeMetaData(this);
    5755    m_QTMovie = 0;
    5856    m_streamReader = 0;
     
    6462    m_audioEnabled = false;
    6563    m_hasVideo = false;
    66     m_staticFps = 0;
    6764    m_playbackRateSat = false;
    6865    m_isDrmProtected = false;
     
    7168        m_primaryRenderingCIImage = 0;
    7269    m_QImagePixelBuffer = 0;
    73     m_cachedCVTextureRef = 0;
    74     m_folderTracks = 0;
    75     m_currentTrack = 0;
    7670
    7771#ifdef QUICKTIME_C_API_AVAILABLE
     
    8478QuickTimeVideoPlayer::~QuickTimeVideoPlayer()
    8579{
    86         PhononAutoReleasePool pool;
    87     unsetCurrentMediaSource();
    88     delete m_metaData;
     80    unsetVideo();
    8981    [(NSObject*)m_primaryRenderingTarget release];
    9082    m_primaryRenderingTarget = 0;
     
    9385        CFRelease(m_visualContext);
    9486#endif
    95 }
    96 
    97 void QuickTimeVideoPlayer::releaseImageCache()
    98 {
    99     if (m_cachedCVTextureRef){
    100         CVOpenGLTextureRelease(m_cachedCVTextureRef);
    101         m_cachedCVTextureRef = 0;
    102     }
    103     m_cachedQImage = QImage();
    10487}
    10588
     
    143126
    144127    QTVisualContextTask(m_visualContext);
    145     bool changed = QTVisualContextIsNewImageAvailable(m_visualContext, 0);
    146     if (changed)
    147         releaseImageCache();
    148     return changed;
     128    return QTVisualContextIsNewImageAvailable(m_visualContext, 0);
    149129
    150130#elif defined(QT_MAC_USE_COCOA)
     
    161141    if (!m_visualContext)
    162142        return 0;
    163     if (!m_cachedCVTextureRef){
    164         OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &m_cachedCVTextureRef);
    165         BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0)
    166     }
    167     return m_cachedCVTextureRef;
     143    CVOpenGLTextureRef texture = 0;
     144    OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &texture);
     145    BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0)
     146    return texture;
    168147
    169148#else
     
    174153QImage QuickTimeVideoPlayer::currentFrameAsQImage()
    175154{
    176     if (!m_cachedQImage.isNull())
    177         return m_cachedQImage;
    178 
    179155#ifdef QUICKTIME_C_API_AVAILABLE
    180156    QGLContext *prevContext = const_cast<QGLContext *>(QGLContext::currentContext());
     
    206182    glEnd();
    207183
    208     m_cachedQImage = m_QImagePixelBuffer->toImage();
     184    QImage image = m_QImagePixelBuffer->toImage();
     185    CVOpenGLTextureRelease(texture);
    209186    // Because of QuickTime, m_QImagePixelBuffer->doneCurrent() will fail.
    210187    // So we store, and restore, the context our selves:
    211188    prevContext->makeCurrent();
    212     return m_cachedQImage;
     189    return image;
    213190#else
    214191        CIImage *img = (CIImage *)currentFrameAsCIImage();
     
    219196        CGRect bounds = [img extent];
    220197        QImage qImg([bitmap bitmapData], bounds.size.width, bounds.size.height, QImage::Format_ARGB32);
    221         m_cachedQImage = qImg.rgbSwapped();
     198        QImage swapped = qImg.rgbSwapped();
    222199        [bitmap release];
    223200        [img release];
    224         return m_cachedQImage;
     201        return swapped;
    225202#endif
    226203}
     
    274251        CVOpenGLTextureRef cvImg = currentFrameAsCVTexture();
    275252        CIImage *img = [[CIImage alloc] initWithCVImageBuffer:cvImg];
    276         return img;
     253        CVOpenGLTextureRelease(cvImg);
     254        return img;     
    277255#else
    278256        return 0;
     
    296274    int samplesPerPixel = [bitmap samplesPerPixel];
    297275    if (![bitmap isPlanar] && (samplesPerPixel == 3 || samplesPerPixel == 4)){
    298         glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0,
     276        glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 
    299277            samplesPerPixel == 4 ? GL_RGBA8 : GL_RGB8,
    300278            [bitmap pixelsWide], [bitmap pixelsHigh],
     
    325303    m_relativeVolume = relativeVolume;
    326304    if (!m_QTMovie || !m_audioEnabled || m_mute)
    327         return;
     305        return;               
    328306    [m_QTMovie setVolume:(m_masterVolume * m_relativeVolume)];
    329307}
     
    336314
    337315    // Work-around bug that happends if you set/unset mute
    338     // before movie is playing, and audio is not played
     316    // before movie is playing, and audio is not played 
    339317    // through graph. Then audio is delayed.
    340318    [m_QTMovie setMuted:mute];
     
    349327
    350328    // Work-around bug that happends if you set/unset mute
    351     // before movie is playing, and audio is not played
     329    // before movie is playing, and audio is not played 
    352330    // through graph. Then audio is delayed.
    353331    [m_QTMovie setMuted:(!enable || m_mute)];
     
    368346    // The following code will not work for some media codecs that
    369347    // typically mingle audio/video frames (e.g mpeg).
    370     CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id));
     348    CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id));       
    371349    QTAudioContextRef context;
    372350    QTAudioContextCreateForAudioDevice(kCFAllocatorDefault, idString, 0, &context);
     
    392370    saturation += 1;
    393371
    394     if (m_brightness == brightness
    395         && m_contrast == contrast
    396         && m_hue == hue
    397         && m_saturation == saturation)
    398         return;
    399 
    400372        m_brightness = brightness;
    401373        m_contrast = contrast;
    402374        m_hue = hue;
    403375        m_saturation = saturation;
     376       
    404377#ifdef QUICKTIME_C_API_AVAILABLE
    405378    Float32 value;
     
    413386    SetMovieVisualSaturation([m_QTMovie quickTimeMovie], value, 0);
    414387#endif
    415     releaseImageCache();
    416388}
    417389
     
    426398}
    427399
    428 void QuickTimeVideoPlayer::unsetCurrentMediaSource()
     400void QuickTimeVideoPlayer::unsetVideo()
    429401{
    430402    if (!m_QTMovie)
     
    439411    m_isDrmProtected = false;
    440412    m_isDrmAuthorized = true;
    441     m_hasVideo = false;
    442     m_staticFps = 0;
    443413    m_mediaSource = MediaSource();
    444     m_movieCompactDiscPath.clear();
    445414        [(CIImage *)m_primaryRenderingCIImage release];
    446415        m_primaryRenderingCIImage = 0;
    447416    delete m_QImagePixelBuffer;
    448417    m_QImagePixelBuffer = 0;
    449     releaseImageCache();
    450     [m_folderTracks release];
    451     m_folderTracks = 0;
    452418}
    453419
     
    559525{
    560526    PhononAutoReleasePool pool;
    561     unsetCurrentMediaSource();
    562 
     527    unsetVideo();
    563528    m_mediaSource = mediaSource;
    564529    if (mediaSource.type() == MediaSource::Empty || mediaSource.type() == MediaSource::Invalid){
     
    566531        return;
    567532    }
    568 
    569533    openMovieFromCurrentMediaSource();
    570534    if (errorOccured()){
    571         unsetCurrentMediaSource();
    572         return;
    573     }
    574 
    575     prepareCurrentMovieForPlayback();
    576 }
    577 
    578 void QuickTimeVideoPlayer::prepareCurrentMovieForPlayback()
    579 {
     535        unsetVideo();
     536        return;
     537    }
     538
    580539#ifdef QUICKTIME_C_API_AVAILABLE
    581540    if (m_visualContext)
     
    585544    waitStatePlayable();
    586545    if (errorOccured()){
    587         unsetCurrentMediaSource();
     546        unsetVideo();
    588547        return;
    589548    }
     
    592551    preRollMovie();
    593552    if (errorOccured()){
    594         unsetCurrentMediaSource();
     553        unsetVideo();
    595554        return;
    596555    }
     
    599558        m_playbackRate = prefferedPlaybackRate();
    600559    checkIfVideoAwailable();
    601     calculateStaticFps();
    602560    enableAudio(m_audioEnabled);
    603561    setMute(m_mute);
    604562    setVolume(m_masterVolume, m_relativeVolume);
    605     m_metaData->update();
    606563    pause();
    607564}
     
    617574        break;
    618575    case MediaSource::Disc:
    619         openMovieFromCompactDisc();
     576        CASE_UNSUPPORTED("Could not open media source.", FATAL_ERROR)
    620577        break;
    621578    case MediaSource::Stream:
     
    679636    // codecs *think* they can decode the stream, and crash...
    680637#define TryOpenMovieWithCodec(type) gClearError(); \
    681     openMovieFromData(data, (char *)"."type); \
     638    openMovieFromData(data, "."type); \
    682639    if (m_QTMovie) return;
    683640
     
    719676}
    720677
    721 typedef void (*qt_sighandler_t)(int);
    722 static void sigtest(int) {
    723     qApp->exit(0);
    724 }
    725 
    726 void QuickTimeVideoPlayer::openMovieFromCompactDisc()
    727 {
    728     // Interrupting the application while the device is open
    729     // causes the application to hang. So we need to handle
    730     // this in a more graceful way:
    731     qt_sighandler_t hndl = signal(SIGINT, sigtest);
    732     if (hndl)
    733         signal(SIGINT, hndl);
    734 
    735     PhononAutoReleasePool pool;
    736     NSString *cd = 0;
    737     QString devName = m_mediaSource.deviceName();
    738     if (devName.isEmpty()) {
    739         cd = pathToCompactDisc();
    740         if (!cd) {
    741             SET_ERROR("Could not open media source.", NORMAL_ERROR)
    742             return;
    743         }
    744         m_movieCompactDiscPath = PhononCFString::toQString(reinterpret_cast<CFStringRef>(cd));
    745     } else {
    746        if (!QFileInfo(devName).isAbsolute())
    747            devName = QLatin1String("/Volumes/") + devName;
    748        cd = [reinterpret_cast<const NSString *>(PhononCFString::toCFStringRef(devName)) autorelease];
    749        if (!isCompactDisc(cd)) {
    750            SET_ERROR("Could not open media source.", NORMAL_ERROR)
    751            return;
    752        }
    753        m_movieCompactDiscPath = devName;
    754     }
    755 
    756     m_folderTracks = [scanFolder(cd) retain];
    757     setCurrentTrack(0);
    758 }
    759 
    760 QString QuickTimeVideoPlayer::movieCompactDiscPath() const
    761 {
    762     return m_movieCompactDiscPath;
    763 }
    764 
    765678MediaSource QuickTimeVideoPlayer::mediaSource() const
    766679{
     
    806719        PhononAutoReleasePool pool;
    807720    return [[m_QTMovie attributeForKey:@"QTMovieTimeScaleAttribute"] longValue];
    808 }
    809 
    810 float QuickTimeVideoPlayer::staticFps()
    811 {
    812     return m_staticFps;
    813 }
    814 
    815 void QuickTimeVideoPlayer::calculateStaticFps()
    816 {
    817     if (!m_hasVideo){
    818         m_staticFps = 0;
    819         return;
    820     }
    821 
    822 #ifdef QT_ALLOW_QUICKTIME
    823     Boolean isMpeg = false;
    824     Track videoTrack = GetMovieIndTrackType([m_QTMovie quickTimeMovie], 1,
    825             FOUR_CHAR_CODE('vfrr'), // 'vfrr' means: has frame rate
    826             movieTrackCharacteristic | movieTrackEnabledOnly);
    827     Media media = GetTrackMedia(videoTrack);
    828     MediaHandler mediaH = GetMediaHandler(media);
    829     MediaHasCharacteristic(mediaH, FOUR_CHAR_CODE('mpeg'), &isMpeg);
    830 
    831     if (isMpeg){
    832         MHInfoEncodedFrameRateRecord frameRate;
    833         Size frameRateSize = sizeof(frameRate);
    834         MediaGetPublicInfo(mediaH, kMHInfoEncodedFrameRate, &frameRate, &frameRateSize);
    835         m_staticFps = float(Fix2X(frameRate.encodedFrameRate));
    836     } else {
    837         Media media = GetTrackMedia(videoTrack);
    838         long sampleCount = GetMediaSampleCount(media);
    839         TimeValue64 duration = GetMediaDisplayDuration(media);
    840         TimeValue64 timeScale = GetMediaTimeScale(media);
    841         m_staticFps = float((double)sampleCount * (double)timeScale / (double)duration);
    842     }
    843 #else
    844     m_staticFps = 30.0f;
    845 #endif
    846721}
    847722
     
    1076951}
    1077952
    1078 QMultiMap<QString, QString> QuickTimeVideoPlayer::metaData()
    1079 {
    1080     return m_metaData->metaData();
    1081 }
    1082 
    1083 int QuickTimeVideoPlayer::trackCount() const
    1084 {
    1085     if (!m_folderTracks)
    1086         return 0;
    1087     return [m_folderTracks count];
    1088 }
    1089 
    1090 int QuickTimeVideoPlayer::currentTrack() const
    1091 {
    1092     return m_currentTrack;
    1093 }
    1094 
    1095 QString QuickTimeVideoPlayer::currentTrackPath() const
    1096 {
    1097     if (!m_folderTracks)
    1098         return QString();
    1099 
    1100     PhononAutoReleasePool pool;
    1101     NSString *trackPath = [m_folderTracks objectAtIndex:m_currentTrack];
    1102     return PhononCFString::toQString(reinterpret_cast<CFStringRef>(trackPath));
    1103 }
    1104 
    1105 NSString* QuickTimeVideoPlayer::pathToCompactDisc()
    1106 {
    1107     PhononAutoReleasePool pool;
    1108     NSArray *devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
    1109     for (unsigned int i=0; i<[devices count]; ++i) {
    1110         NSString *dev = [devices objectAtIndex:i];
    1111         if (isCompactDisc(dev))
    1112             return [dev retain];
    1113     }
    1114     return 0;
    1115 }
    1116 
    1117 bool QuickTimeVideoPlayer::isCompactDisc(NSString *path)
    1118 {
    1119     PhononAutoReleasePool pool;
    1120     NSString *type = [NSString string];
    1121     [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:path
    1122         isRemovable:0
    1123         isWritable:0
    1124         isUnmountable:0
    1125         description:0
    1126         type:&type];
    1127     return [type hasPrefix:@"cdd"];
    1128 }
    1129 
    1130 NSArray* QuickTimeVideoPlayer::scanFolder(NSString *path)
    1131 {
    1132     NSMutableArray *tracks = [NSMutableArray arrayWithCapacity:20];
    1133     if (!path)
    1134         return tracks;
    1135 
    1136     NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path];
    1137     while (NSString *track = [enumerator nextObject]) {
    1138         if (![track hasPrefix:@"."])
    1139             [tracks addObject:[path stringByAppendingPathComponent:track]];
    1140     }
    1141     return tracks;
    1142 }
    1143 
    1144 void QuickTimeVideoPlayer::setCurrentTrack(int track)
    1145 {
    1146     PhononAutoReleasePool pool;
    1147     [m_QTMovie release];
    1148         m_QTMovie = 0;
    1149     m_currentTime = 0;
    1150     m_currentTrack = track;
    1151 
    1152     if (!m_folderTracks)
    1153         return;
    1154     if (track < 0 || track >= (int)[m_folderTracks count])
    1155         return;
    1156 
    1157     NSString *trackPath = [m_folderTracks objectAtIndex:track];
    1158     QTDataReference *dataRef = [QTDataReference dataReferenceWithReferenceToFile:trackPath];
    1159     State currentState = m_state;
    1160     openMovieFromDataRef(dataRef);
    1161     prepareCurrentMovieForPlayback();
    1162     if (currentState == Playing)
    1163         play();
    1164 }
    1165 
    1166953}}
    1167954
  • trunk/src/3rdparty/phonon/qt7/videoframe.mm

    r561 r846  
    2020#import <QuartzCore/CIFilter.h>
    2121#import <QuartzCore/CIContext.h>
    22 
    23 //#define CACHE_CV_TEXTURE
    2422
    2523QT_BEGIN_NAMESPACE
     
    7371    void VideoFrame::copyMembers(const VideoFrame& frame)
    7472    {
    75 #ifdef CACHE_CV_TEXTURE
    7673        m_cachedCVTextureRef = frame.m_cachedCVTextureRef;
    77 #endif
    7874                m_cachedCIImage = frame.m_cachedCIImage;
    7975                m_cachedQImage = frame.m_cachedQImage;
     
    110106    CVOpenGLTextureRef VideoFrame::cachedCVTexture() const
    111107    {
    112 #ifdef CACHE_CV_TEXTURE
    113108        if (!m_cachedCVTextureRef && m_videoPlayer){
    114109            m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation);
    115110            (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = m_videoPlayer->currentFrameAsCVTexture();
    116             CVOpenGLTextureRetain((const_cast<VideoFrame *>(this))->m_cachedCVTextureRef);
    117111        }
    118112        return m_cachedCVTextureRef;
    119 #else
    120         if (m_videoPlayer){
    121             m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation);
    122             return m_videoPlayer->currentFrameAsCVTexture();
    123         }
    124         return 0;
    125 #endif
    126113    }
    127114
     
    343330    void VideoFrame::invalidateImage() const
    344331    {
    345 #ifdef CACHE_CV_TEXTURE
    346332        if (m_cachedCVTextureRef){
    347333            CVOpenGLTextureRelease(m_cachedCVTextureRef);
    348334            (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0;
    349335        }
    350 #endif
    351336        if (m_cachedCIImage){
    352337                        [(CIImage *) m_cachedCIImage release];
     
    362347    void VideoFrame::retain() const
    363348    {
    364 #ifdef CACHE_CV_TEXTURE
    365349        if (m_cachedCVTextureRef)
    366350            CVOpenGLTextureRetain(m_cachedCVTextureRef);
    367 #endif
    368351                if (m_cachedCIImage)
    369352                        [(CIImage *) m_cachedCIImage retain];
     
    376359    void VideoFrame::release() const
    377360    {
    378 #ifdef CACHE_CV_TEXTURE
    379         if (m_cachedCVTextureRef){
     361        if (m_cachedCVTextureRef)
    380362            CVOpenGLTextureRelease(m_cachedCVTextureRef);
    381             (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0;
    382         }
    383 #endif
    384363                if (m_cachedCIImage)
    385364                        [(CIImage *) m_cachedCIImage release];
     
    390369
    391370        (const_cast<VideoFrame *>(this))->m_backgroundFrame = 0;
     371        (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0;
    392372        (const_cast<VideoFrame *>(this))->m_cachedCIImage = 0;
    393373        (const_cast<VideoFrame *>(this))->m_cachedNSBitmap = 0;
  • trunk/src/3rdparty/phonon/waveout/mediaobject.cpp

    r561 r846  
    5151            ushort b[256];
    5252            waveOutGetErrorText(error, (LPWSTR)b, 256);
    53             return QString::fromUtf16(b);
     53            return QString((const QChar *)b);
    5454        }
    5555
     
    7171
    7272
    73         void CALLBACK MediaObject::WaveOutCallBack(HWAVEOUT m_hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
     73        void QT_WIN_CALLBACK MediaObject::WaveOutCallBack(HWAVEOUT m_hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
    7474        {
    7575            Q_UNUSED(m_hWaveOut);
  • trunk/src/3rdparty/phonon/waveout/mediaobject.h

    r2 r846  
    113113            void playBuffer(WAVEHDR *waveHeader);
    114114
    115             static void CALLBACK WaveOutCallBack(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
     115            static void QT_WIN_CALLBACK WaveOutCallBack(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
    116116
    117117             struct {
Note: See TracChangeset for help on using the changeset viewer.