From 3f39d630d3dcc161c4a85127129274ca7ea857a2 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 21 Aug 2009 11:39:36 +0100 Subject: Further tidied up volume handling --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 75 +++++++++++++----------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 13 +++- src/3rdparty/phonon/mmf/abstractplayer.cpp | 34 ++--------- src/3rdparty/phonon/mmf/abstractplayer.h | 18 ++---- src/3rdparty/phonon/mmf/audiooutput.cpp | 36 +++++------- src/3rdparty/phonon/mmf/audiooutput.h | 16 +++-- src/3rdparty/phonon/mmf/audioplayer.cpp | 4 +- src/3rdparty/phonon/mmf/audioplayer.h | 2 +- src/3rdparty/phonon/mmf/backend.cpp | 13 +++- src/3rdparty/phonon/mmf/dummyplayer.cpp | 14 +++-- src/3rdparty/phonon/mmf/dummyplayer.h | 4 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 12 ++-- src/3rdparty/phonon/mmf/mediaobject.h | 24 ++++---- src/3rdparty/phonon/mmf/videooutput.cpp | 45 ++++++++++++++ src/3rdparty/phonon/mmf/videooutput.h | 42 +++++++++++++ src/3rdparty/phonon/mmf/videoplayer.cpp | 8 +-- src/3rdparty/phonon/mmf/videoplayer.h | 6 +- src/3rdparty/phonon/mmf/videowidget.cpp | 5 +- src/3rdparty/phonon/mmf/videowidget.h | 5 +- src/3rdparty/phonon/mmf/volumecontrolinterface.h | 48 --------------- src/3rdparty/phonon/mmf/volumeobserver.h | 40 +++++++++++++ src/plugins/phonon/mmf/mmf.pro | 4 +- 22 files changed, 269 insertions(+), 199 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/videooutput.cpp create mode 100644 src/3rdparty/phonon/mmf/videooutput.h delete mode 100644 src/3rdparty/phonon/mmf/volumecontrolinterface.h create mode 100644 src/3rdparty/phonon/mmf/volumeobserver.h diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index be34fef..6342f37 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -17,6 +17,7 @@ along with this library. If not, see . */ #include "abstractmediaplayer.h" +#include "defs.h" #include "utils.h" using namespace Phonon; @@ -36,7 +37,9 @@ const int NullMaxVolume = -1; MMF::AbstractMediaPlayer::AbstractMediaPlayer() : m_state(GroundState) , m_error(NoError) + , m_playPending(false) , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) , m_mmfMaxVolume(NullMaxVolume) { connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); @@ -46,7 +49,9 @@ MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : AbstractPlayer(player) , m_state(GroundState) , m_error(NoError) + , m_playPending(false) , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) , m_mmfMaxVolume(NullMaxVolume) { connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); @@ -292,47 +297,51 @@ void MMF::AbstractMediaPlayer::setNextSource(const MediaSource &source) //----------------------------------------------------------------------------- -// VolumeControlInterface +// VolumeObserver //----------------------------------------------------------------------------- -bool MMF::AbstractMediaPlayer::doSetVolume(qreal volume) +void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) { - TRACE_CONTEXT(AbstractMediaPlayer::doSetVolume, EAudioInternal); + TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); TRACE_ENTRY("state %d", m_state); - - bool result = true; - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: + m_volume = volume; + doVolumeChanged(); + + TRACE_EXIT_0(); +} + + +void MMF::AbstractMediaPlayer::doVolumeChanged() +{ + switch(m_state) + { + case GroundState: + case LoadingState: + case ErrorState: // Do nothing - break; + break; - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - const int err = doSetMmfVolume(volume * m_mmfMaxVolume); - - if(KErrNone != err) - { + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: + { + const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); + + if(KErrNone != err) + { m_error = NormalError; changeState(ErrorState); - result = false; - } - break; - } + } + break; + } - // Protection against adding new states and forgetting to update this - // switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_RETURN("%d", result); + // Protection against adding new states and forgetting to update this + // switch + default: + Utils::panic(InvalidStatePanic); + } } @@ -350,10 +359,10 @@ void MMF::AbstractMediaPlayer::stopTickTimer() m_tickTimer->stop(); } -void MMF::AbstractMediaPlayer::initVolume(int mmfMaxVolume) +void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) { m_mmfMaxVolume = mmfMaxVolume; - doSetVolume(volume() * m_mmfMaxVolume); + doVolumeChanged(); } Phonon::State MMF::AbstractMediaPlayer::phononState() const diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 9e0d3c8..58aca84 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -57,24 +57,26 @@ namespace Phonon virtual MediaSource source() const; virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); protected: // AbstractPlayer virtual void doSetTickInterval(qint32 interval); - virtual bool doSetVolume(qreal volume); protected: virtual void doPlay() = 0; virtual void doPause() = 0; virtual void doStop() = 0; - virtual int doSetMmfVolume(int mmfVolume) = 0; + virtual int setDeviceVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; virtual void close() = 0; protected: void startTickTimer(); void stopTickTimer(); - void initVolume(int maxVolume); + void maxVolumeChanged(int maxVolume); /** * Defined private state enumeration in order to add GroundState @@ -111,6 +113,9 @@ namespace Phonon void setError(Phonon::ErrorType error); static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + + private: + void doVolumeChanged(); Q_SIGNALS: void tick(qint64 time); @@ -135,6 +140,8 @@ namespace Phonon bool m_playPending; QScopedPointer m_tickTimer; + + qreal m_volume; int m_mmfMaxVolume; MediaSource m_source; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 7786d8b..870b50f 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -27,18 +27,16 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AbstractPlayer::AbstractPlayer() : - m_tickInterval(DefaultTickInterval) - , m_volume(InitialVolume) +MMF::AbstractPlayer::AbstractPlayer() + : m_tickInterval(DefaultTickInterval) , m_transitionTime(0) , m_prefinishMark(0) { } -MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) : - m_tickInterval(player.tickInterval()) - , m_volume(player.volume()) +MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) + : m_tickInterval(player.tickInterval()) , m_transitionTime(player.transitionTime()) , m_prefinishMark(player.prefinishMark()) { @@ -81,27 +79,3 @@ void MMF::AbstractPlayer::setTransitionTime(qint32 time) } -//----------------------------------------------------------------------------- -// VolumeControlInterface -//----------------------------------------------------------------------------- - -qreal MMF::AbstractPlayer::volume() const -{ - return m_volume; -} - -bool MMF::AbstractPlayer::setVolume(qreal volume) -{ - bool result = false; - if(volume != m_volume) - { - result = doSetVolume(volume); - if(result) - { - m_volume = volume; - } - } - return result; -} - - diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 546d929..4b899d2 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -23,7 +23,7 @@ along with this library. If not, see . #include #include -#include "volumecontrolinterface.h" +#include "volumeobserver.h" class RFile; @@ -44,7 +44,7 @@ namespace Phonon * - Video, in which case the implementation is VideoPlayer */ class AbstractPlayer : public QObject - , public VolumeControlInterface + , public VolumeObserver { // Required although this class has no signals or slots // Without this, qobject_cast will fail @@ -81,19 +81,13 @@ namespace Phonon virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; virtual void setNextSource(const Phonon::MediaSource &) = 0; - // VolumeControlInterface - qreal volume() const; - bool setVolume(qreal volume); - private: virtual void doSetTickInterval(qint32 interval) = 0; - virtual bool doSetVolume(qreal volume) = 0; - private: - qint32 m_tickInterval; - qreal m_volume; - qint32 m_transitionTime; - qint32 m_prefinishMark; + private: + qint32 m_tickInterval; + qint32 m_transitionTime; + qint32 m_prefinishMark; }; } diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 2e5cbc6..13b953d 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -21,7 +21,7 @@ along with this library. If not, see . #include "audiooutput.h" #include "defs.h" #include "utils.h" -#include "volumecontrolinterface.h" +#include "volumeobserver.h" using namespace Phonon; using namespace Phonon::MMF; @@ -33,7 +33,7 @@ using namespace Phonon::MMF; MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) , m_volume(InitialVolume) - , m_volumeControl(NULL) + , m_observer(NULL) { } @@ -45,32 +45,26 @@ MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) qreal MMF::AudioOutput::volume() const { - TRACE_CONTEXT(AudioOutput::volume, EAudioApi); - TRACE_ENTRY("control 0x%08x ", m_volumeControl); - - const qreal result = m_volumeControl ? m_volumeControl->volume() : m_volume; - - TRACE_RETURN("%f", result); + return m_volume; } void MMF::AudioOutput::setVolume(qreal volume) { TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi); - TRACE_ENTRY("control 0x%08x volume %f", m_volumeControl, volume); + TRACE_ENTRY("observer 0x%08x volume %f", m_observer, volume); - if(m_volumeControl) + if(volume != m_volume) { - if(m_volumeControl->setVolume(volume)) + if(m_observer) { - TRACE("emit volumeChanged(%f)", volume) - emit volumeChanged(volume); + m_observer->volumeChanged(volume); } - } - else - { + m_volume = volume; + TRACE("emit volumeChanged(%f)", volume) + emit volumeChanged(volume); } - + TRACE_EXIT_0(); } @@ -89,10 +83,10 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) return true; } -void MMF::AudioOutput::setVolumeControl(VolumeControlInterface *volumeControl) +void MMF::AudioOutput::setVolumeObserver(VolumeObserver& observer) { - Q_ASSERT(!m_volumeControl); - m_volumeControl = volumeControl; - m_volumeControl->setVolume(m_volume); + Q_ASSERT(!m_observer); + m_observer = &observer; + m_observer->volumeChanged(m_volume); } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index ad39626..38623a8 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -19,19 +19,19 @@ along with this library. If not, see . #ifndef PHONON_MMF_AUDIOOUTPUT_H #define PHONON_MMF_AUDIOOUTPUT_H -#include +#include namespace Phonon { namespace MMF { class Backend; - class VolumeControlInterface; + class VolumeObserver; /** * @short AudioOutputInterface implementation for MMF. * - * Forwards volume commands to the VolumeControlInterface instance, + * Forwards volume commands to the VolumeObserver instance, * which is provided by the backend when MediaNode objects are * connected. * @@ -70,19 +70,17 @@ namespace Phonon /** * Called by backend when nodes are connected. */ - void setVolumeControl(VolumeControlInterface *volumeControl); + void setVolumeObserver(VolumeObserver& observer); Q_SIGNALS: void volumeChanged(qreal volume); void audioDeviceFailed(); private: - /** - * This value is used when m_volumeControl is NULL. - */ - qreal m_volume; + qreal m_volume; - VolumeControlInterface * m_volumeControl; + // Not owned + VolumeObserver* m_observer; }; } } diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index e812af5..67ed7a5 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -84,7 +84,7 @@ void MMF::AudioPlayer::doStop() m_player->Stop(); } -int MMF::AudioPlayer::doSetMmfVolume(int mmfVolume) +int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { return m_player->SetVolume(mmfVolume); } @@ -177,7 +177,7 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, if(KErrNone == aError) { - initVolume(m_player->MaxVolume()); + maxVolumeChanged(m_player->MaxVolume()); emit totalTimeChanged(); changeState(StoppedState); diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index b73ea44..29ed12e 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -58,7 +58,7 @@ namespace Phonon virtual void doPlay(); virtual void doPause(); virtual void doStop(); - virtual int doSetMmfVolume(int mmfVolume); + virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index f610b60..ad60046 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -98,17 +98,24 @@ bool Backend::connectNodes(QObject *source, QObject *target) MediaObject *const mediaObject = qobject_cast(source); AudioOutput *const audioOutput = qobject_cast(target); - + VideoWidget *const videoWidget = qobject_cast(target); + bool result = false; if(mediaObject and audioOutput) { TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); - - audioOutput->setVolumeControl(mediaObject); + audioOutput->setVolumeObserver(*mediaObject); result = true; } + if(mediaObject and videoWidget) + { + TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); + // TODO: the actual connection :) + result = true; + } + TRACE_RETURN("%d", result); } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index 737af78..9154984 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -113,19 +113,25 @@ void MMF::DummyPlayer::setNextSource(const MediaSource &) //----------------------------------------------------------------------------- -// AbstractPlayer +// VolumeObserver //----------------------------------------------------------------------------- -void MMF::DummyPlayer::doSetTickInterval(qint32) +void MMF::DummyPlayer::volumeChanged(qreal) { } -bool MMF::DummyPlayer::doSetVolume(qreal) + +//----------------------------------------------------------------------------- +// AbstractPlayer +//----------------------------------------------------------------------------- + +void MMF::DummyPlayer::doSetTickInterval(qint32) { - return true; + } + diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 6a2ad73..5846d88 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -60,9 +60,11 @@ namespace Phonon virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); + // VolumeObserver + virtual void volumeChanged(qreal volume); + // AbstractPlayer virtual void doSetTickInterval(qint32 interval); - virtual bool doSetVolume(qreal volume); }; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 4b5c4f0..bf0356e 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -366,18 +366,14 @@ void MMF::MediaObject::setTransitionTime(qint32 time) m_player->setTransitionTime(time); } + //----------------------------------------------------------------------------- -// VolumeControlInterface +// VolumeObserver //----------------------------------------------------------------------------- -qreal MMF::MediaObject::volume() const -{ - return m_player->volume(); -} - -bool MMF::MediaObject::setVolume(qreal volume) +void MMF::MediaObject::volumeChanged(qreal volume) { - return m_player->setVolume(volume); + m_player->volumeChanged(volume); } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index a6d932d..2e12b72 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -27,7 +27,7 @@ along with this library. If not, see . // For recognizer #include -#include "volumecontrolinterface.h" +#include "volumeobserver.h" namespace Phonon { @@ -35,13 +35,13 @@ namespace Phonon { class AbstractPlayer; class AudioOutput; - + /** * @short Facade class which wraps MMF client utility instance */ class MediaObject : public QObject , public MediaObjectInterface - , public VolumeControlInterface + , public VolumeObserver { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) @@ -71,10 +71,9 @@ namespace Phonon virtual void setPrefinishMark(qint32); virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); - - // VolumeControlInterface - qreal volume() const; - bool setVolume(qreal volume); + + // VolumeObserver + void volumeChanged(qreal volume); Q_SIGNALS: void totalTimeChanged(); @@ -97,15 +96,16 @@ namespace Phonon private: // Audio / video media type recognition - bool m_recognizerOpened; - RApaLsSession m_recognizer; - RFs m_fileServer; + bool m_recognizerOpened; + RApaLsSession m_recognizer; + RFs m_fileServer; // Storing the file handle here to work around KErrInUse error // from MMF player utility OpenFileL functions - RFile m_file; + RFile m_file; - QScopedPointer m_player; + QScopedPointer m_player; + }; } } diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp new file mode 100644 index 0000000..5e32b28 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -0,0 +1,45 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "utils.h" +#include "videooutput.h" + +using namespace Phonon; +using namespace Phonon::MMF; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoOutput::VideoOutput(QWidget* parent) + : QWidget(parent) +{ + +} + +MMF::VideoOutput::~VideoOutput() +{ + +} + + +//----------------------------------------------------------------------------- +// Public API +//----------------------------------------------------------------------------- + diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h new file mode 100644 index 0000000..8b08402 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -0,0 +1,42 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VIDEOOUTPUT_H +#define PHONON_MMF_VIDEOOUTPUT_H + +#include + +namespace Phonon +{ + namespace MMF + { + class VideoOutput : public QWidget + { + Q_OBJECT + + public: + VideoOutput(QWidget* parent); + ~VideoOutput(); + + private: + + }; + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 45d4f65..3868672 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -33,14 +33,14 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer() : m_widget(new QWidget()) +MMF::VideoPlayer::VideoPlayer() : m_widget(new VideoOutput(NULL)) { construct(); } MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) : AbstractMediaPlayer(player) - , m_widget(new QWidget()) + , m_widget(new VideoOutput(NULL)) // TODO: copy?? { construct(); } @@ -117,7 +117,7 @@ void MMF::VideoPlayer::doStop() m_player->Stop(); } -int MMF::VideoPlayer::doSetMmfVolume(int mmfVolume) +int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) { TRAPD(err, m_player->SetVolumeL(mmfVolume)); return err; @@ -233,7 +233,7 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) if(KErrNone == aError) { - initVolume(m_player->MaxVolume()); + maxVolumeChanged(m_player->MaxVolume()); emit totalTimeChanged(); changeState(StoppedState); diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index b4cfa69..ce3b3ac 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -22,9 +22,9 @@ along with this library. If not, see . #include #include "abstractmediaplayer.h" +#include "videooutput.h" class CVideoPlayerUtility; -class QSymbianControl; namespace Phonon { @@ -51,7 +51,7 @@ namespace Phonon virtual void doPlay(); virtual void doPause(); virtual void doStop(); - virtual int doSetMmfVolume(int mmfVolume); + virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); @@ -79,7 +79,7 @@ namespace Phonon private: CVideoPlayerUtility* m_player; - QScopedPointer m_widget; + QScopedPointer m_widget; }; } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 194c885..e08fcea 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -41,7 +41,7 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : QWidget(parent) + : m_widget(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) @@ -149,7 +149,6 @@ void MMF::VideoWidget::setSaturation(qreal saturation) QWidget* MMF::VideoWidget::widget() { - return this; + return m_widget.data(); } - diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 3c33a56..6967f7e 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -22,12 +22,13 @@ along with this library. If not, see . #include #include #include +#include "videooutput.h" namespace Phonon { namespace MMF { - class VideoWidget : public QWidget + class VideoWidget : public QObject , public Phonon::VideoWidgetInterface { Q_OBJECT @@ -53,6 +54,8 @@ namespace Phonon virtual QWidget *widget(); private: + QScopedPointer m_widget; + Phonon::VideoWidget::AspectRatio m_aspectRatio; qreal m_brightness; Phonon::VideoWidget::ScaleMode m_scaleMode; diff --git a/src/3rdparty/phonon/mmf/volumecontrolinterface.h b/src/3rdparty/phonon/mmf/volumecontrolinterface.h deleted file mode 100644 index 7965dd4..0000000 --- a/src/3rdparty/phonon/mmf/volumecontrolinterface.h +++ /dev/null @@ -1,48 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#ifndef PHONON_MMF_VOLUMECONTROLINTERFACE_H -#define PHONON_MMF_VOLUMECONTROLINTERFACE_H - -#include - -namespace Phonon -{ - namespace MMF - { - /** - * Interface used by AudioOutput to pass volume control commands - * back along the audio path to the MediaObject. - */ - class VolumeControlInterface - { - public: - virtual qreal volume() const = 0; - - /** - * Returns true if the volume of the underlying audio stack is - * changed as a result of this call. The return value is used - * by the AudioDevice to determine whether to emit a - * volumeChanged signal. - */ - virtual bool setVolume(qreal volume) = 0; - }; - } -} - -#endif diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h new file mode 100644 index 0000000..11ee960 --- /dev/null +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -0,0 +1,40 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VOLUMEOBSERVER_H +#define PHONON_MMF_VOLUMEOBSERVER_H + +#include + +namespace Phonon +{ + namespace MMF + { + /** + * Interface used by AudioOutput to pass volume control commands + * back along the audio path to the MediaObject. + */ + class VolumeObserver + { + public: + virtual void volumeChanged(qreal volume) = 0; + }; + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index bb614b4..cc46894 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -31,9 +31,10 @@ HEADERS += \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ + $$PHONON_MMF_DIR/videooutput.h \ $$PHONON_MMF_DIR/videoplayer.h \ $$PHONON_MMF_DIR/videowidget.h \ - $$PHONON_MMF_DIR/volumecontrolinterface.h + $$PHONON_MMF_DIR/volumeobserver.h SOURCES += \ $$PHONON_MMF_DIR/abstractplayer.cpp \ @@ -44,6 +45,7 @@ SOURCES += \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp \ + $$PHONON_MMF_DIR/videooutput.cpp \ $$PHONON_MMF_DIR/videoplayer.cpp \ $$PHONON_MMF_DIR/videowidget.cpp -- cgit v0.12