summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/arch/qatomic_s390.h16
-rw-r--r--src/corelib/arch/qatomic_symbian.h2
-rw-r--r--src/corelib/codecs/qtextcodec.h2
-rw-r--r--src/corelib/concurrent/qfuture.h2
-rw-r--r--src/corelib/io/qdatastream.cpp5
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp4
-rw-r--r--src/corelib/tools/qcontiguouscache.h2
-rw-r--r--src/corelib/tools/qhash.h6
-rw-r--r--src/corelib/tools/qlinkedlist.h6
-rw-r--r--src/corelib/tools/qlist.h6
-rw-r--r--src/corelib/tools/qmap.h6
-rw-r--r--src/corelib/tools/qset.h7
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h4
-rw-r--r--src/corelib/tools/qvector.h6
-rw-r--r--src/corelib/xml/qxmlstream_p.h2
-rw-r--r--src/gui/dialogs/qcolordialog.cpp6
-rw-r--r--src/gui/dialogs/qfontdialog.cpp64
-rw-r--r--src/gui/dialogs/qfontdialog.h3
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm148
-rw-r--r--src/gui/dialogs/qfontdialog_p.h6
-rw-r--r--src/gui/effects/qgraphicseffect.cpp12
-rw-r--r--src/gui/egl/qegl.cpp23
-rw-r--r--src/gui/egl/qegl_symbian.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp4
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp5
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp5
-rw-r--r--src/gui/itemviews/qtreeview.cpp9
-rw-r--r--src/gui/kernel/qapplication_win.cpp5
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp29
-rw-r--r--src/gui/kernel/qsoftkeymanager_p.h2
-rw-r--r--src/gui/painting/qdrawhelper_neon.cpp130
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp18
-rw-r--r--src/gui/styles/qs60style.cpp37
-rw-r--r--src/gui/styles/qs60style_p.h3
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp7
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp4
-rw-r--r--src/gui/widgets/qcombobox.cpp6
-rw-r--r--src/gui/widgets/qdockarealayout.cpp2
-rw-r--r--src/gui/widgets/qmainwindow.cpp5
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp1
-rw-r--r--src/gui/widgets/qmenu.cpp20
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp22
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h5
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp77
-rw-r--r--src/network/access/qhttpnetworkreply.cpp13
-rw-r--r--src/network/access/qhttpnetworkreply_p.h2
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp2
-rw-r--r--src/network/access/qnetworkrequest.cpp2
-rw-r--r--src/network/socket/qabstractsocket.cpp10
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp4
-rw-r--r--src/openvg/qpaintengine_vg.cpp128
-rw-r--r--src/plugins/audio/audio.pro8
-rw-r--r--src/plugins/audio/symbian/main.cpp121
-rw-r--r--src/plugins/audio/symbian/symbian.pro31
-rw-r--r--src/plugins/audio/symbian/symbianaudio.h76
-rw-r--r--src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp191
-rw-r--r--src/plugins/audio/symbian/symbianaudiodeviceinfo.h94
-rw-r--r--src/plugins/audio/symbian/symbianaudioinput.cpp595
-rw-r--r--src/plugins/audio/symbian/symbianaudioinput.h177
-rw-r--r--src/plugins/audio/symbian/symbianaudiooutput.cpp697
-rw-r--r--src/plugins/audio/symbian/symbianaudiooutput.h199
-rw-r--r--src/plugins/audio/symbian/symbianaudioutils.cpp395
-rw-r--r--src/plugins/audio/symbian/symbianaudioutils.h125
-rw-r--r--src/qbase.pri4
-rw-r--r--src/s60installs/qt.iby6
-rw-r--r--src/s60installs/s60installs.pro6
-rw-r--r--src/script/api/qscriptengine.cpp2
-rw-r--r--src/script/api/qscriptengine_p.h12
68 files changed, 3311 insertions, 327 deletions
diff --git a/src/corelib/arch/qatomic_s390.h b/src/corelib/arch/qatomic_s390.h
index 21f5037..273c17b 100644
--- a/src/corelib/arch/qatomic_s390.h
+++ b/src/corelib/arch/qatomic_s390.h
@@ -366,11 +366,9 @@ template <typename T>
Q_INLINE_TEMPLATE T* QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
{
#ifndef __s390x__
- return (T*)__CS_OLD_LOOP(reinterpret_cast<volatile long*>(_q_value), (int)newValue, "lr",
- "", "bcr 15,0\n");
+ return (T*)__CS_OLD_LOOP(&_q_value, (int)newValue, "lr", "", "");
#else
- return (T*)__CSG_OLD_LOOP(reinterpret_cast<volatile long*>(_q_value), (long)newValue, "lgr",
- "", "bcr 15,0\n");
+ return (T*)__CSG_OLD_LOOP(&_q_value, (long)newValue, "lgr", "", "");
#endif
}
@@ -378,9 +376,9 @@ template <typename T>
Q_INLINE_TEMPLATE T* QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
{
#ifndef __s390x__
- return (T*)__CS_OLD_LOOP(reinterpret_cast<volatile long*>(_q_value), (int)newValue, "lr", "", "");
+ return (T*)__CS_OLD_LOOP(&_q_value, (int)newValue, "lr", "", "bcr 15,0 \n");
#else
- return (T*)__CSG_OLD_LOOP(reinterpret_cast<volatile long*>(_q_value), (long)newValue, "lgr", "", "");
+ return (T*)__CSG_OLD_LOOP(&_q_value, (long)newValue, "lgr", "", "bcr 15,0 \n");
#endif
}
@@ -388,11 +386,9 @@ template <typename T>
Q_INLINE_TEMPLATE T* QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
{
#ifndef __s390x__
- return (T*)__CS_OLD_LOOP(reinterpret_cast<volatile long*>(_q_value), (int)newValue, "lr",
- "bcr 15,0 \n", "");
+ return (T*)__CS_OLD_LOOP(&_q_value, (int)newValue, "lr", "bcr 15,0 \n", "");
#else
- return (T*)__CSG_OLD_LOOP(reinterpret_cast<volatile long*>(_q_value), (long)newValue, "lgr",
- "bcr 15,0\n", "");
+ return (T*)__CSG_OLD_LOOP(&_q_value, (long)newValue, "lgr", "bcr 15,0\n", "");
#endif
}
diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h
index f1d332f..fa4e4a9 100644
--- a/src/corelib/arch/qatomic_symbian.h
+++ b/src/corelib/arch/qatomic_symbian.h
@@ -42,7 +42,7 @@
#ifndef QATOMIC_SYMBIAN_H
#define QATOMIC_SYMBIAN_H
-#include <qglobal.h>
+#include <QtCore/qglobal.h>
#include <e32std.h>
QT_BEGIN_HEADER
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index 23c91c7..169fe82 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -170,7 +170,7 @@ private:
friend class QXmlStreamWriter;
friend class QXmlStreamWriterPrivate;
-#if defined Q_XMLSTREAM_RENAME_SYMBOLS
+#if defined(Q_OS_MAC32) || defined(Q_OS_AIX)
friend class QCoreXmlStreamWriter;
friend class QCoreXmlStreamWriterPrivate;
#endif
diff --git a/src/corelib/concurrent/qfuture.h b/src/corelib/concurrent/qfuture.h
index e402335..02ae40a 100644
--- a/src/corelib/concurrent/qfuture.h
+++ b/src/corelib/concurrent/qfuture.h
@@ -111,7 +111,7 @@ public:
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index f27ecc1..0b98e1e 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -158,10 +158,9 @@ QT_BEGIN_NAMESPACE
\section1 Reading and writing Qt collection classes
- The Qt collection classes can also be serialized to a QDataStream.
+ The Qt container classes can also be serialized to a QDataStream.
These include QList, QLinkedList, QVector, QSet, QHash, and QMap.
- These classes have have stream operators declared as non-member of
- the class.
+ The stream operators are declared as non-members of the classes.
\target Serializing Qt Classes
\section1 Reading and writing other Qt classes.
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 93becc8..8010a76 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -510,8 +510,8 @@ LRESULT CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
MSG *msg = (MSG *) lp;
if (localSerialNumber != d->lastSerialNumber
// if this message IS the one that triggers sendPostedEvents(), no need to post it again
- && msg->hwnd != d->internalHwnd
- && msg->message != WM_QT_SENDPOSTEDEVENTS) {
+ && (msg->hwnd != d->internalHwnd
+ || msg->message != WM_QT_SENDPOSTEDEVENTS)) {
PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0);
}
}
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index aa5603d..f767962 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -97,7 +97,7 @@ public:
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef int size_type;
explicit QContiguousCache(int capacity = 0);
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 5e93523..05eae42 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -329,7 +329,7 @@ public:
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef T *pointer;
typedef T &reference;
@@ -394,7 +394,7 @@ public:
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
@@ -478,7 +478,7 @@ public:
// STL compatibility
typedef T mapped_type;
typedef Key key_type;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef int size_type;
inline bool empty() const { return isEmpty(); }
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index f6de966..bfcf24f 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -113,7 +113,7 @@ public:
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef T *pointer;
typedef T &reference;
@@ -146,7 +146,7 @@ public:
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
@@ -212,7 +212,7 @@ public:
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
#ifndef QT_NO_STL
static inline QLinkedList<T> fromStdList(const std::list<T> &list)
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 120442d..1ad7528 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -163,7 +163,7 @@ public:
public:
Node *i;
typedef std::random_access_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef T *pointer;
typedef T &reference;
@@ -210,7 +210,7 @@ public:
public:
Node *i;
typedef std::random_access_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
@@ -289,7 +289,7 @@ public:
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
#ifdef QT3_SUPPORT
inline QT3_SUPPORT iterator remove(iterator pos) { return erase(pos); }
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index e71064c..4679812 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -213,7 +213,7 @@ public:
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef T *pointer;
typedef T &reference;
@@ -281,7 +281,7 @@ public:
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
@@ -384,7 +384,7 @@ public:
// STL compatibility
typedef Key key_type;
typedef T mapped_type;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef int size_type;
inline bool empty() const { return isEmpty(); }
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index 6525880..b266deb 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -97,7 +97,7 @@ public:
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
@@ -132,7 +132,7 @@ public:
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
@@ -188,11 +188,10 @@ public:
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef int size_type;
inline bool empty() const { return isEmpty(); }
-
// comfort
inline QSet<T> &operator<<(const T &value) { insert(value); return *this; }
inline QSet<T> &operator|=(const QSet<T> &other) { unite(other); return *this; }
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 8fbfcda..964b279 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -132,7 +132,7 @@ namespace QtSharedPointer {
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
inline T *data() const { return value; }
inline bool isNull() const { return !data(); }
@@ -541,7 +541,7 @@ public:
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
inline bool isNull() const { return d == 0 || d->strongref == 0 || value == 0; }
#ifndef Q_CC_NOKIAX86
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 90b7442..ac7c795 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -163,7 +163,7 @@ public:
public:
T *i;
typedef std::random_access_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef T *pointer;
typedef T &reference;
@@ -196,7 +196,7 @@ public:
public:
T *i;
typedef std::random_access_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
typedef const T &reference;
@@ -260,7 +260,7 @@ public:
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
- typedef ptrdiff_t difference_type;
+ typedef qptrdiff difference_type;
typedef iterator Iterator;
typedef const_iterator ConstIterator;
typedef int size_type;
diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h
index 6b911d2..ac421cf 100644
--- a/src/corelib/xml/qxmlstream_p.h
+++ b/src/corelib/xml/qxmlstream_p.h
@@ -54,7 +54,7 @@
#ifndef QXMLSTREAM_P_H
#define QXMLSTREAM_P_H
-#if defined(Q_OS_VXWORKS) && defined(ERROR)
+#if defined(ERROR)
# undef ERROR
#endif
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index 83ecc30..e6abf7f 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1078,8 +1078,7 @@ QColorShower::QColorShower(QColorDialog *parent)
#ifdef QT_SMALL_COLORDIALOG
# ifdef Q_WS_S60
- QS60Data s60Data = QS60Data();
- const bool nonTouchUI = !s60Data.hasTouchscreen;
+ const bool nonTouchUI = !S60->hasTouchscreen;
# elif defined Q_WS_MAEMO_5
const bool nonTouchUI = false;
# endif
@@ -1506,8 +1505,7 @@ void QColorDialogPrivate::init(const QColor &initial)
#if defined(QT_SMALL_COLORDIALOG)
# if defined(Q_WS_S60)
- QS60Data s60Data = QS60Data();
- const bool nonTouchUI = !s60Data.hasTouchscreen;
+ const bool nonTouchUI = !S60->hasTouchscreen;
# elif defined(Q_WS_MAEMO_5)
const bool nonTouchUI = false;
# endif
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
index 56580a9..a4bf15d 100644
--- a/src/gui/dialogs/qfontdialog.cpp
+++ b/src/gui/dialogs/qfontdialog.cpp
@@ -989,34 +989,24 @@ void QFontDialog::open(QObject *receiver, const char *member)
void QFontDialog::setVisible(bool visible)
{
Q_D(QFontDialog);
- if (visible)
- d->selectedFont = QFont();
-
-#if defined(Q_WS_MAC)
- bool isCurrentlyVisible = (isVisible() || d->delegate);
-
- if (!visible == !isCurrentlyVisible)
- return;
-
if (visible) {
- if (!(d->opts & DontUseNativeDialog) && QFontDialogPrivate::sharedFontPanelAvailable) {
- d->delegate = QFontDialogPrivate::openCocoaFontPanel(
- currentFont(), parentWidget(), windowTitle(), options(), d);
- QFontDialogPrivate::sharedFontPanelAvailable = false;
- return;
- }
-
- setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
- } else {
- if (d->delegate) {
- QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
- d->delegate = 0;
- QFontDialogPrivate::sharedFontPanelAvailable = true;
+ if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
return;
+ } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
+ return;
+#ifdef Q_WS_MAC
+ if (d->canBeNativeDialog()){
+ if (d->setVisible_sys(visible)){
+ d->nativeDialogInUse = true;
+ // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
+ // updates the state correctly, but skips showing the non-native version:
+ setAttribute(Qt::WA_DontShowOnScreen, true);
+ } else {
+ d->nativeDialogInUse = false;
+ setAttribute(Qt::WA_DontShowOnScreen, false);
}
}
-#endif
-
+#endif // Q_WS_MAC
QDialog::setVisible(visible);
}
@@ -1032,11 +1022,14 @@ void QFontDialog::done(int result)
Q_D(QFontDialog);
QDialog::done(result);
if (result == Accepted) {
- d->selectedFont = currentFont();
+ // We check if this is the same font we had before, if so we emit currentFontChanged
+ QFont selectedFont = currentFont();
+ if(selectedFont != d->selectedFont)
+ emit(currentFontChanged(selectedFont));
+ d->selectedFont = selectedFont;
emit fontSelected(d->selectedFont);
- } else {
+ } else
d->selectedFont = QFont();
- }
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(fontSelected(QFont)),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
@@ -1045,6 +1038,23 @@ void QFontDialog::done(int result)
d->memberToDisconnectOnClose.clear();
}
+#ifdef Q_WS_MAC
+bool QFontDialogPrivate::canBeNativeDialog()
+{
+ Q_Q(QFontDialog);
+ if (nativeDialogInUse)
+ return true;
+ if (q->testAttribute(Qt::WA_DontShowOnScreen))
+ return false;
+ if (opts & QFontDialog::DontUseNativeDialog)
+ return false;
+
+ QLatin1String staticName(QFontDialog::staticMetaObject.className());
+ QLatin1String dynamicName(q->metaObject()->className());
+ return (staticName == dynamicName);
+}
+#endif // Q_WS_MAC
+
/*!
\fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name)
\since 4.5
diff --git a/src/gui/dialogs/qfontdialog.h b/src/gui/dialogs/qfontdialog.h
index e6f209e..6035a3a 100644
--- a/src/gui/dialogs/qfontdialog.h
+++ b/src/gui/dialogs/qfontdialog.h
@@ -131,6 +131,9 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_styleHighlighted(int))
Q_PRIVATE_SLOT(d_func(), void _q_sizeHighlighted(int))
Q_PRIVATE_SLOT(d_func(), void _q_updateSample())
+#if defined(Q_WS_MAC)
+ Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
+#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QFontDialog::FontDialogOptions)
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 68f5f00..67d32b8 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -49,6 +49,7 @@
#include <private/qfontengine_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
+#include <qabstracteventdispatcher.h>
#include <qdebug.h>
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
@@ -372,7 +373,12 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
[NSApp endModalSession:mModalSession];
mModalSession = 0;
}
-
+ // Hack alert!
+ // Since this code path was never intended to be followed when starting from exec
+ // we need to force the dialog to communicate the new font, otherwise the signal
+ // won't get emitted.
+ if(code == NSOKButton)
+ mPriv->sampleEdit->setFont([self qtFont]);
mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
} else {
[NSApp stopModalWithCode:code];
@@ -567,7 +573,6 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial,
[ourPanel makeKeyAndOrderFront:ourPanel];
}
}
-
return delegate;
}
@@ -640,6 +645,145 @@ void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
[static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font];
}
+void *QFontDialogPrivate::_q_constructNativePanel()
+{
+ QMacCocoaAutoReleasePool pool;
+
+ bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists];
+ NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel];
+ [sharedFontPanel setHidesOnDeactivate:false];
+
+ // hack to ensure that QCocoaApplication's validModesForFontPanel:
+ // implementation is honored
+ if (!sharedFontPanelExisted) {
+ [sharedFontPanel makeKeyAndOrderFront:sharedFontPanel];
+ [sharedFontPanel close];
+ }
+
+ NSPanel *ourPanel = 0;
+ NSView *stolenContentView = 0;
+ NSButton *okButton = 0;
+ NSButton *cancelButton = 0;
+
+ CGFloat dialogExtraWidth = 0.0;
+ CGFloat dialogExtraHeight = 0.0;
+
+ // compute dialogExtra{Width,Height}
+ dialogExtraWidth = 2.0 * DialogSideMargin;
+ dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight
+ + ButtonBottomMargin;
+
+ // compute initial contents rectangle
+ NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]];
+ contentRect.size.width += dialogExtraWidth;
+ contentRect.size.height += dialogExtraHeight;
+
+ // create the new panel
+ ourPanel = [[NSPanel alloc] initWithContentRect:contentRect
+ styleMask:StyleMask
+ backing:NSBackingStoreBuffered
+ defer:YES];
+ [ourPanel setReleasedWhenClosed:YES];
+
+ stolenContentView = [sharedFontPanel contentView];
+
+ // steal the font panel's contents view
+ [stolenContentView retain];
+ [sharedFontPanel setContentView:0];
+
+ {
+ // create a new content view and add the stolen one as a subview
+ NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
+ NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
+ [ourContentView addSubview:stolenContentView];
+
+ // create OK and Cancel buttons and add these as subviews
+ okButton = macCreateButton("&OK", ourContentView);
+ cancelButton = macCreateButton("Cancel", ourContentView);
+
+ [ourPanel setContentView:ourContentView];
+ [ourPanel setDefaultButtonCell:[okButton cell]];
+ }
+ // create a delegate and set it
+ QCocoaFontPanelDelegate *delegate =
+ [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
+ stolenContentView:stolenContentView
+ okButton:okButton
+ cancelButton:cancelButton
+ priv:this
+ extraWidth:dialogExtraWidth
+ extraHeight:dialogExtraHeight];
+ [ourPanel setDelegate:delegate];
+ [[NSFontManager sharedFontManager] setDelegate:delegate];
+#ifdef QT_MAC_USE_COCOA
+ [[NSFontManager sharedFontManager] setTarget:delegate];
+#endif
+ setFont(delegate, QApplication::font());
+
+ {
+ // hack to get correct initial layout
+ NSRect frameRect = [ourPanel frame];
+ frameRect.size.width += 1.0;
+ [ourPanel setFrame:frameRect display:NO];
+ frameRect.size.width -= 1.0;
+ frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size];
+ [ourPanel setFrame:frameRect display:NO];
+ [ourPanel center];
+ }
+ NSString *title = @"Select font";
+ [ourPanel setTitle:title];
+
+ [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
+ return delegate;
+}
+
+void QFontDialogPrivate::mac_nativeDialogModalHelp()
+{
+ // Copied from QFileDialogPrivate
+ // Do a queued meta-call to open the native modal dialog so it opens after the new
+ // event loop has started to execute (in QDialog::exec). Using a timer rather than
+ // a queued meta call is intentional to ensure that the call is only delivered when
+ // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
+ // running (which is the case if e.g a top-most QEventLoop has been
+ // interrupted, and the second-most event loop has not yet been reactivated (regardless
+ // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
+ if (nativeDialogInUse) {
+ Q_Q(QFontDialog);
+ QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+ }
+}
+
+// The problem with the native font dialog is that OS X does not
+// offer a proper dialog, but a panel (i.e. without Ok and Cancel buttons).
+// This means we need to "construct" a native dialog by taking the panel
+// and "adding" the buttons.
+void QFontDialogPrivate::_q_macRunNativeAppModalPanel()
+{
+ QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
+ Q_Q(QFontDialog);
+ QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel();
+ NSWindow *ourPanel = [delegate actualPanel];
+ [ourPanel retain];
+ int rval = [NSApp runModalForWindow:ourPanel];
+ QAbstractEventDispatcher::instance()->interrupt();
+ [ourPanel release];
+ [delegate cleanUpAfterMyself];
+ [delegate release];
+ bool isOk = (rval == NSOKButton);
+ if(isOk)
+ rescode = QDialog::Accepted;
+ else
+ rescode = QDialog::Rejected;
+}
+
+bool QFontDialogPrivate::setVisible_sys(bool visible)
+{
+ Q_Q(QFontDialog);
+ if (!visible == q->isHidden())
+ return false;
+ return visible;
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/gui/dialogs/qfontdialog_p.h b/src/gui/dialogs/qfontdialog_p.h
index ca2b10b..7654a80 100644
--- a/src/gui/dialogs/qfontdialog_p.h
+++ b/src/gui/dialogs/qfontdialog_p.h
@@ -152,6 +152,12 @@ public:
inline QFontDialog *fontDialog() { return q_func(); }
void *delegate;
+ bool nativeDialogInUse;
+ bool canBeNativeDialog();
+ bool setVisible_sys(bool visible);
+ void *_q_constructNativePanel();
+ void _q_macRunNativeAppModalPanel();
+ void mac_nativeDialogModalHelp();
static bool sharedFontPanelAvailable;
#endif
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 7d1d03d..ce4ce6a 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -726,7 +726,8 @@ void QGraphicsColorizeEffect::draw(QPainter *painter)
elements. The level of detail can be modified using the setBlurRadius()
function. Use setBlurHints() to choose the blur hints.
- By default, the blur radius is 5 pixels.
+ By default, the blur radius is 5 pixels. The blur radius is specified in
+ device coordinates.
\img graphicseffect-blur.png
@@ -781,6 +782,9 @@ QGraphicsBlurEffect::~QGraphicsBlurEffect()
radius results in a more blurred appearance.
By default, the blur radius is 5 pixels.
+
+ The radius is given in device coordinates, meaning it is
+ unaffected by scale.
*/
qreal QGraphicsBlurEffect::blurRadius() const
{
@@ -884,7 +888,8 @@ void QGraphicsBlurEffect::draw(QPainter *painter)
By default, the drop shadow is a semi-transparent dark gray
(QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset
- of 8 pixels towards the lower right.
+ of 8 pixels towards the lower right. The drop shadow offset is specified
+ in device coordinates.
\img graphicseffect-drop-shadow.png
@@ -913,6 +918,9 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect()
By default, the offset is 8 pixels towards the lower right.
+ The offset is given in device coordinates, which means it is
+ unaffected by scale.
+
\sa xOffset(), yOffset(), blurRadius(), color()
*/
QPointF QGraphicsDropShadowEffect::offset() const
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index 4d447cb..0ed95ea 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -101,7 +101,7 @@ bool QEglContext::chooseConfig
// If we want the best pixel format, then return the first
// matching configuration.
if (match == QEgl::BestPixelFormat) {
- eglChooseConfig(dpy, props.properties(), &cfg, 1, &matching);
+ eglChooseConfig(display(), props.properties(), &cfg, 1, &matching);
if (matching < 1)
continue;
return true;
@@ -111,13 +111,13 @@ bool QEglContext::chooseConfig
// first that matches the pixel format we wanted.
EGLint size = matching;
EGLConfig *configs = new EGLConfig [size];
- eglChooseConfig(dpy, props.properties(), configs, size, &matching);
+ eglChooseConfig(display(), props.properties(), configs, size, &matching);
for (EGLint index = 0; index < size; ++index) {
EGLint red, green, blue, alpha;
- eglGetConfigAttrib(dpy, configs[index], EGL_RED_SIZE, &red);
- eglGetConfigAttrib(dpy, configs[index], EGL_GREEN_SIZE, &green);
- eglGetConfigAttrib(dpy, configs[index], EGL_BLUE_SIZE, &blue);
- eglGetConfigAttrib(dpy, configs[index], EGL_ALPHA_SIZE, &alpha);
+ eglGetConfigAttrib(display(), configs[index], EGL_RED_SIZE, &red);
+ eglGetConfigAttrib(display(), configs[index], EGL_GREEN_SIZE, &green);
+ eglGetConfigAttrib(display(), configs[index], EGL_BLUE_SIZE, &blue);
+ eglGetConfigAttrib(display(), configs[index], EGL_ALPHA_SIZE, &alpha);
if (red == props.value(EGL_RED_SIZE) &&
green == props.value(EGL_GREEN_SIZE) &&
blue == props.value(EGL_BLUE_SIZE) &&
@@ -181,7 +181,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties
}
}
if (ctx == EGL_NO_CONTEXT) {
- ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties());
+ ctx = eglCreateContext(display(), cfg, 0, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError());
return false;
@@ -197,7 +197,7 @@ void QEglContext::destroySurface(EGLSurface surface)
if (surface != EGL_NO_SURFACE) {
if (surface == currentSurface)
doneCurrent();
- eglDestroySurface(dpy, surface);
+ eglDestroySurface(display(), surface);
}
}
@@ -205,8 +205,7 @@ void QEglContext::destroySurface(EGLSurface surface)
void QEglContext::destroyContext()
{
if (ctx != EGL_NO_CONTEXT && ownsContext)
- eglDestroyContext(dpy, ctx);
- dpy = EGL_NO_DISPLAY;
+ eglDestroyContext(display(), ctx);
ctx = EGL_NO_CONTEXT;
cfg = 0;
}
@@ -343,7 +342,7 @@ QEglProperties QEglContext::configProperties(EGLConfig cfg) const
QEglProperties props;
for (int name = 0x3020; name <= 0x304F; ++name) {
EGLint value;
- if (name != EGL_NONE && eglGetConfigAttrib(dpy, cfg, name, &value))
+ if (name != EGL_NONE && eglGetConfigAttrib(display(), cfg, name, &value))
props.setValue(name, value);
}
eglGetError(); // Clear the error state.
@@ -417,7 +416,7 @@ void QEglContext::dumpAllConfigs()
if (!eglGetConfigs(display(), 0, 0, &count) || count < 1)
return;
EGLConfig *configs = new EGLConfig [count];
- eglGetConfigs(dpy, configs, count, &count);
+ eglGetConfigs(display(), configs, count, &count);
for (EGLint index = 0; index < count; ++index) {
props = configProperties(configs[index]);
qWarning() << props.toString();
diff --git a/src/gui/egl/qegl_symbian.cpp b/src/gui/egl/qegl_symbian.cpp
index b1c9408..5a010cd 100644
--- a/src/gui/egl/qegl_symbian.cpp
+++ b/src/gui/egl/qegl_symbian.cpp
@@ -78,9 +78,9 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
props = 0;
EGLSurface surf;
if (devType == QInternal::Widget)
- surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, 0);
+ surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, props);
else
- surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, 0);
+ surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, props);
if (surf == EGL_NO_SURFACE)
qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
return surf;
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 96b9373..06b7438 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -3609,6 +3609,8 @@ void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect)
}
/*!
+ \obsolete
+
Draws the items \a items in the scene using \a painter, after the
background and before the foreground are drawn. \a numItems is the number
of items in \a items and options in \a options. \a options is a list of
@@ -3617,7 +3619,7 @@ void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect)
The default implementation calls the scene's drawItems() function.
- \obsolete Since Qt 4.6, this function is not called anymore unless
+ Since Qt 4.6, this function is not called anymore unless
the QGraphicsView::IndirectPainting flag is given as an Optimization
flag.
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 2b91711..1ac8ace 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -113,7 +113,7 @@ void QCoeFepInputContext::update()
updateHints(false);
// For pre-5.0 SDKs, we don't do text updates on S60 side.
- if (QSysInfo::s60Version() != QSysInfo::SV_S60_5_0) {
+ if (QSysInfo::s60Version() < QSysInfo::SV_S60_5_0) {
return;
}
@@ -740,6 +740,9 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin
void QCoeFepInputContext::DoCommitFepInlineEditL()
{
commitCurrentString(false);
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0)
+ ReportAknEdStateEvent(QT_EAknCursorPositionChanged);
+
}
void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction)
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index cbd9a8a..adf3ce3 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1540,6 +1540,11 @@ bool QAbstractItemView::event(QEvent *event)
case QEvent::FontChange:
d->doDelayedItemsLayout(); // the size of the items will change
break;
+#ifdef QT_SOFTKEYS_ENABLED
+ case QEvent::LanguageChange:
+ d->doneSoftKey->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::DoneSoftKey));
+ break;
+#endif
default:
break;
}
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index d0fa22d..706d2a8 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2474,10 +2474,11 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
QVector<QTreeViewItem> insertedItems(delta);
for (int i = 0; i < delta; ++i) {
- insertedItems[i].index = d->model->index(i + start, 0, parent);
- insertedItems[i].level = childLevel;
- insertedItems[i].hasChildren = d->hasVisibleChildren(insertedItems[i].index);
- insertedItems[i].hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1));
+ QTreeViewItem &item = insertedItems[i];
+ item.index = d->model->index(i + start, 0, parent);
+ item.level = childLevel;
+ item.hasChildren = d->hasVisibleChildren(item.index);
+ item.hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1));
}
if (d->viewItems.isEmpty())
d->defaultItemHeight = indexRowSizeHint(insertedItems[0].index);
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 0a4869b..aac834d 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1905,8 +1905,13 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
if (!msg.wParam) {
+#ifdef Q_WS_WINCE
+ // On Windows CE, lParam parameter is a constant, not a char pointer.
+ if (msg.lParam == INI_INTL) {
+#else
QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
if (area == QLatin1String("intl")) {
+#endif
QLocalePrivate::updateSystemPrivate();
if (!widget->testAttribute(Qt::WA_SetLocale))
widget->dptr()->setLocale_helper(QLocale(), true);
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index 6d108b0..c9a94ee 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -55,24 +55,24 @@ QT_BEGIN_NAMESPACE
QSoftKeyManager *QSoftKeyManagerPrivate::self = 0;
-const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
+QString QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
{
- const char *softKeyText = 0;
+ QString softKeyText;
switch (standardKey) {
case OkSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Ok");
+ softKeyText = QSoftKeyManager::tr("Ok");
break;
case SelectSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Select");
+ softKeyText = QSoftKeyManager::tr("Select");
break;
case DoneSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Done");
+ softKeyText = QSoftKeyManager::tr("Done");
break;
case MenuSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Options");
+ softKeyText = QSoftKeyManager::tr("Options");
break;
case CancelSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Cancel");
+ softKeyText = QSoftKeyManager::tr("Cancel");
break;
default:
break;
@@ -100,8 +100,7 @@ QSoftKeyManager::QSoftKeyManager() :
QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *actionWidget)
{
- const char* text = standardSoftKeyText(standardKey);
- QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget);
+ QAction *action = new QAction(standardSoftKeyText(standardKey), actionWidget);
QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey;
switch (standardKey) {
case MenuSoftKey: // FALL-THROUGH
@@ -211,13 +210,11 @@ bool QSoftKeyManager::handleUpdateSoftKeys()
d->requestedSoftKeyActions.clear();
bool recursiveMerging = false;
QWidget *source = softkeySource(NULL, recursiveMerging);
- do {
- if (source) {
- bool added = appendSoftkeys(*source, level);
- source = softkeySource(source, recursiveMerging);
- level = added ? ++level : level;
- }
- } while (source);
+ while (source) {
+ if (appendSoftkeys(*source, level))
+ ++level;
+ source = softkeySource(source, recursiveMerging);
+ }
d->updateSoftKeys_sys();
return true;
diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h
index ce902fe..a6fe17e 100644
--- a/src/gui/kernel/qsoftkeymanager_p.h
+++ b/src/gui/kernel/qsoftkeymanager_p.h
@@ -87,6 +87,7 @@ public:
static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget);
static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget);
+ static QString standardSoftKeyText(StandardSoftKey standardKey);
protected:
bool event(QEvent *e);
@@ -94,7 +95,6 @@ protected:
private:
QSoftKeyManager();
static QSoftKeyManager *instance();
- static const char *standardSoftKeyText(StandardSoftKey standardKey);
bool appendSoftkeys(const QWidget &source, int level);
QWidget *softkeySource(QWidget *previousSource, bool& recursiveMerging);
bool handleUpdateSoftKeys();
diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp
index 25860a0..77c5202 100644
--- a/src/gui/painting/qdrawhelper_neon.cpp
+++ b/src/gui/painting/qdrawhelper_neon.cpp
@@ -48,43 +48,43 @@
QT_BEGIN_NAMESPACE
-static inline int16x8_t qvdiv_255_s16(int16x8_t x, int16x8_t half)
+static inline uint16x8_t qvdiv_255_u16(uint16x8_t x, uint16x8_t half)
{
// result = (x + (x >> 8) + 0x80) >> 8
- const int16x8_t temp = vshrq_n_s16(x, 8); // x >> 8
- const int16x8_t sum_part = vaddq_s16(x, half); // x + 0x80
- const int16x8_t sum = vaddq_s16(temp, sum_part);
+ const uint16x8_t temp = vshrq_n_u16(x, 8); // x >> 8
+ const uint16x8_t sum_part = vaddq_u16(x, half); // x + 0x80
+ const uint16x8_t sum = vaddq_u16(temp, sum_part);
- return vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(sum), 8));
+ return vshrq_n_u16(sum, 8);
}
-static inline int16x8_t qvbyte_mul_s16(int16x8_t x, int16x8_t alpha, int16x8_t half)
+static inline uint16x8_t qvbyte_mul_u16(uint16x8_t x, uint16x8_t alpha, uint16x8_t half)
{
// t = qRound(x * alpha / 255.0)
- const int16x8_t t = vmulq_s16(x, alpha); // t
- return qvdiv_255_s16(t, half);
+ const uint16x8_t t = vmulq_u16(x, alpha); // t
+ return qvdiv_255_u16(t, half);
}
-static inline int16x8_t qvinterpolate_pixel_255(int16x8_t x, int16x8_t a, int16x8_t y, int16x8_t b, int16x8_t half)
+static inline uint16x8_t qvinterpolate_pixel_255(uint16x8_t x, uint16x8_t a, uint16x8_t y, uint16x8_t b, uint16x8_t half)
{
// t = x * a + y * b
- const int16x8_t ta = vmulq_s16(x, a);
- const int16x8_t tb = vmulq_s16(y, b);
+ const uint16x8_t ta = vmulq_u16(x, a);
+ const uint16x8_t tb = vmulq_u16(y, b);
- return qvdiv_255_s16(vaddq_s16(ta, tb), half);
+ return qvdiv_255_u16(vaddq_u16(ta, tb), half);
}
-static inline int16x8_t qvsource_over_s16(int16x8_t src16, int16x8_t dst16, int16x8_t half, int16x8_t full)
+static inline uint16x8_t qvsource_over_u16(uint16x8_t src16, uint16x8_t dst16, uint16x8_t half, uint16x8_t full)
{
- const int16x4_t alpha16_high = vdup_lane_s16(vget_high_s16(src16), 3);
- const int16x4_t alpha16_low = vdup_lane_s16(vget_low_s16(src16), 3);
+ const uint16x4_t alpha16_high = vdup_lane_u16(vget_high_u16(src16), 3);
+ const uint16x4_t alpha16_low = vdup_lane_u16(vget_low_u16(src16), 3);
- const int16x8_t alpha16 = vsubq_s16(full, vcombine_s16(alpha16_low, alpha16_high));
+ const uint16x8_t alpha16 = vsubq_u16(full, vcombine_u16(alpha16_low, alpha16_high));
- return vaddq_s16(src16, qvbyte_mul_s16(dst16, alpha16, half));
+ return vaddq_u16(src16, qvbyte_mul_u16(dst16, alpha16, half));
}
void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
@@ -94,21 +94,21 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
{
const uint *src = (const uint *) srcPixels;
uint *dst = (uint *) destPixels;
- int16x8_t half = vdupq_n_s16(0x80);
- int16x8_t full = vdupq_n_s16(0xff);
+ uint16x8_t half = vdupq_n_u16(0x80);
+ uint16x8_t full = vdupq_n_u16(0xff);
if (const_alpha == 256) {
for (int y = 0; y < h; ++y) {
int x = 0;
for (; x < w-3; x += 4) {
- int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
+ uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
if ((src[x] & src[x+1] & src[x+2] & src[x+3]) >= 0xff000000) {
// all opaque
- vst1q_s32((int32_t *)&dst[x], src32);
+ vst1q_u32((uint32_t *)&dst[x], src32);
} else if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
- int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+ uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
- const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
- const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+ const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
const uint8x8_t src8_low = vget_low_u8(src8);
const uint8x8_t dst8_low = vget_low_u8(dst8);
@@ -116,19 +116,19 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
const uint8x8_t src8_high = vget_high_u8(src8);
const uint8x8_t dst8_high = vget_high_u8(dst8);
- const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
- const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+ const uint16x8_t src16_low = vmovl_u8(src8_low);
+ const uint16x8_t dst16_low = vmovl_u8(dst8_low);
- const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
- const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+ const uint16x8_t src16_high = vmovl_u8(src8_high);
+ const uint16x8_t dst16_high = vmovl_u8(dst8_high);
- const int16x8_t result16_low = qvsource_over_s16(src16_low, dst16_low, half, full);
- const int16x8_t result16_high = qvsource_over_s16(src16_high, dst16_high, half, full);
+ const uint16x8_t result16_low = qvsource_over_u16(src16_low, dst16_low, half, full);
+ const uint16x8_t result16_high = qvsource_over_u16(src16_high, dst16_high, half, full);
- const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
- const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+ const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
+ const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
- vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
}
}
for (; x<w; ++x) {
@@ -143,16 +143,16 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
}
} else if (const_alpha != 0) {
const_alpha = (const_alpha * 255) >> 8;
- int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
+ uint16x8_t const_alpha16 = vdupq_n_u16(const_alpha);
for (int y = 0; y < h; ++y) {
int x = 0;
for (; x < w-3; x += 4) {
if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
- int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
- int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+ uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
+ uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
- const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
- const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+ const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
const uint8x8_t src8_low = vget_low_u8(src8);
const uint8x8_t dst8_low = vget_low_u8(dst8);
@@ -160,22 +160,22 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
const uint8x8_t src8_high = vget_high_u8(src8);
const uint8x8_t dst8_high = vget_high_u8(dst8);
- const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
- const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+ const uint16x8_t src16_low = vmovl_u8(src8_low);
+ const uint16x8_t dst16_low = vmovl_u8(dst8_low);
- const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
- const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+ const uint16x8_t src16_high = vmovl_u8(src8_high);
+ const uint16x8_t dst16_high = vmovl_u8(dst8_high);
- const int16x8_t srcalpha16_low = qvbyte_mul_s16(src16_low, const_alpha16, half);
- const int16x8_t srcalpha16_high = qvbyte_mul_s16(src16_high, const_alpha16, half);
+ const uint16x8_t srcalpha16_low = qvbyte_mul_u16(src16_low, const_alpha16, half);
+ const uint16x8_t srcalpha16_high = qvbyte_mul_u16(src16_high, const_alpha16, half);
- const int16x8_t result16_low = qvsource_over_s16(srcalpha16_low, dst16_low, half, full);
- const int16x8_t result16_high = qvsource_over_s16(srcalpha16_high, dst16_high, half, full);
+ const uint16x8_t result16_low = qvsource_over_u16(srcalpha16_low, dst16_low, half, full);
+ const uint16x8_t result16_high = qvsource_over_u16(srcalpha16_high, dst16_high, half, full);
- const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
- const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+ const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
+ const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
- vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
}
}
for (; x<w; ++x) {
@@ -206,19 +206,19 @@ void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
if (const_alpha != 0) {
const uint *src = (const uint *) srcPixels;
uint *dst = (uint *) destPixels;
- int16x8_t half = vdupq_n_s16(0x80);
+ uint16x8_t half = vdupq_n_u16(0x80);
const_alpha = (const_alpha * 255) >> 8;
int one_minus_const_alpha = 255 - const_alpha;
- int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
- int16x8_t one_minus_const_alpha16 = vdupq_n_s16(255 - const_alpha);
+ uint16x8_t const_alpha16 = vdupq_n_u16(const_alpha);
+ uint16x8_t one_minus_const_alpha16 = vdupq_n_u16(255 - const_alpha);
for (int y = 0; y < h; ++y) {
int x = 0;
for (; x < w-3; x += 4) {
- int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
- int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+ uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
+ uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
- const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
- const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+ const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
const uint8x8_t src8_low = vget_low_u8(src8);
const uint8x8_t dst8_low = vget_low_u8(dst8);
@@ -226,19 +226,19 @@ void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
const uint8x8_t src8_high = vget_high_u8(src8);
const uint8x8_t dst8_high = vget_high_u8(dst8);
- const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
- const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+ const uint16x8_t src16_low = vmovl_u8(src8_low);
+ const uint16x8_t dst16_low = vmovl_u8(dst8_low);
- const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
- const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+ const uint16x8_t src16_high = vmovl_u8(src8_high);
+ const uint16x8_t dst16_high = vmovl_u8(dst8_high);
- const int16x8_t result16_low = qvinterpolate_pixel_255(src16_low, const_alpha16, dst16_low, one_minus_const_alpha16, half);
- const int16x8_t result16_high = qvinterpolate_pixel_255(src16_high, const_alpha16, dst16_high, one_minus_const_alpha16, half);
+ const uint16x8_t result16_low = qvinterpolate_pixel_255(src16_low, const_alpha16, dst16_low, one_minus_const_alpha16, half);
+ const uint16x8_t result16_high = qvinterpolate_pixel_255(src16_high, const_alpha16, dst16_high, one_minus_const_alpha16, half);
- const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
- const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+ const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
+ const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
- vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
}
for (; x<w; ++x) {
uint s = src[x];
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index bc56ed0..3c2cc8c 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -100,10 +100,6 @@
#endif
#include <limits.h>
-#if defined(QT_NO_FPU) || (_MSC_VER >= 1300 && _MSC_VER < 1400)
-# define FLOATING_POINT_BUGGY_OR_NO_FPU
-#endif
-
QT_BEGIN_NAMESPACE
extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
@@ -3679,9 +3675,6 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect)
if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen)
|| (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased))
&& qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT
-#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
- && qMax(rect.width(), rect.height()) < 128 // integer math breakdown
-#endif
&& s->matrix.type() <= QTransform::TxScale) // no shear
{
ensureBrush();
@@ -6054,15 +6047,9 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
ProcessSpans pen_func, ProcessSpans brush_func,
QSpanData *pen_data, QSpanData *brush_data)
{
-#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU // no fpu, so use fixed point
- const QFixed a = QFixed(rect.width()) >> 1;
- const QFixed b = QFixed(rect.height()) >> 1;
- QFixed d = b*b - (a*a*b) + ((a*a) >> 2);
-#else
const qreal a = qreal(rect.width()) / 2;
const qreal b = qreal(rect.height()) / 2;
qreal d = b*b - (a*a*b) + 0.25*a*a;
-#endif
int x = 0;
int y = (rect.height() + 1) / 2;
@@ -6085,12 +6072,7 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
pen_func, brush_func, pen_data, brush_data);
// region 2
-#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
- d = b*b*(x + (QFixed(1) >> 1))*(x + (QFixed(1) >> 1))
- + a*a*((y - 1)*(y - 1) - b*b);
-#else
d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b);
-#endif
const int miny = rect.height() & 0x1;
while (y > miny) {
if (d < 0) { // select SE
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index ea7399f..565cc2c 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -120,6 +120,8 @@ QPixmap *QS60StylePrivate::m_background = 0;
// theme palette
QPalette *QS60StylePrivate::m_themePalette = 0;
+qint64 QS60StylePrivate::m_webPaletteKey = 0;
+
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = {
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter},
{SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed},
@@ -807,8 +809,12 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
QPalette webPalette = *palette;
webPalette.setColor(QPalette::WindowText, Qt::black);
webPalette.setColor(QPalette::Text, Qt::black);
+ webPalette.setBrush(QPalette::Base, Qt::white);
+
QApplication::setPalette(webPalette, "QWebView");
QApplication::setPalette(webPalette, "QGraphicsWebView");
+
+ m_webPaletteKey = webPalette.cacheKey();
}
QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
@@ -896,8 +902,11 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag
return result;
}
-bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush)
+bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget)
{
+ // Always return true for web pages.
+ if (widget && m_webPaletteKey == QApplication::palette(widget).cacheKey())
+ return true;
//If brush is not changed from style's default values, draw theme graphics.
return (backgroundBrush.color() == Qt::transparent ||
backgroundBrush.style() == Qt::NoBrush) ? true : false;
@@ -1901,7 +1910,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_ShapedFrame:
if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) {
const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option);
- if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base()))
+ if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base(), widget))
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags);
else
QCommonStyle::drawControl(element, option, painter, widget);
@@ -2013,7 +2022,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
if (widget && qobject_cast<const QComboBox *>(widget->parentWidget()))
break;
#endif
- if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()))
+ if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget))
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags);
else
commonStyleDraws = true;
@@ -2093,7 +2102,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_PanelButtonTool:
case PE_PanelButtonBevel:
case PE_FrameButtonBevel:
- if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) {
+ if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) {
const bool isPressed = option->state & State_Sunken;
const QS60StylePrivate::SkinElements skinElement =
isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
@@ -2125,7 +2134,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorSpinDown:
case PE_IndicatorSpinUp:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base())) {
+ if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) {
QStyleOptionSpinBox optionSpinBox = *spinBox;
const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
QS60StyleEnums::SP_QgnGrafScrollArrowUp :
@@ -2140,7 +2149,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
#endif //QT_NO_SPINBOX
#ifndef QT_NO_COMBOBOX
if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) {
+ if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) {
// We want to draw down arrow here for comboboxes as well.
QStyleOptionFrame optionsComboBox = *cmb;
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
@@ -2179,7 +2188,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
#endif //QT_NO_MENU
) {
//Need extra check since dialogs have their own theme background
- if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()) &&
+ if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) &&
option->palette.window().texture().cacheKey() ==
QS60StylePrivate::m_themePalette->window().texture().cacheKey())
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags);
@@ -2387,10 +2396,20 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_PushButton:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
//FIXME properly - style should calculate the location of border frame-part
- sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin));
- if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget)))
+ if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) {
if (buttonWidget->isCheckable())
sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0);
+ const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0;
+ const int textHeight = (buttonWidget->text().length() > 0) ?
+ buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : 0;
+ const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0;
+
+ const int contentHeight =
+ qMax(qMax(iconHeight, decoratorHeight) + pixelMetric(PM_ButtonMargin),
+ textHeight + 2*pixelMetric(PM_ButtonMargin));
+ sz.setHeight(contentHeight);
+ sz += QSize(2 * pixelMetric(PM_ButtonMargin), 0);
+ }
break;
case CT_LineEdit:
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt))
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index ea30b81..16d82e7 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -542,7 +542,7 @@ public:
//Checks that the current brush is transparent or has BrushStyle NoBrush,
//so that theme graphic background can be drawn.
- static bool canDrawThemeBackground(const QBrush &backgroundBrush);
+ static bool canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget);
static int currentAnimationFrame(QS60StyleEnums::SkinParts part);
#ifdef Q_WS_S60
@@ -596,6 +596,7 @@ private:
QPalette m_originalPalette;
QPointer<QFocusFrame> m_focusFrame;
+ static qint64 m_webPaletteKey;
#ifdef Q_WS_S60
//list of progress bars having animation running
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index b36294a..c550938 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -5743,6 +5743,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
}
+#ifndef QT_NO_TOOLBAR
+ case SE_ToolBarHandle:
+ if (hasStyleRule(w, PseudoElement_ToolBarHandle))
+ return ParentStyle::subElementRect(se, opt, w);
+ break;
+#endif //QT_NO_TOOLBAR
+
default:
break;
}
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 319c4b0..adc4fc1 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -48,7 +48,6 @@
#include <qurl.h>
#include <private/qcore_symbian_p.h>
-#include <miutset.h> // KUidMsgTypeSMTP
#include <txtrich.h> // CRichText
#include <f32file.h> // TDriveUnit etc
#include <eikenv.h> // CEikonEnv
@@ -57,6 +56,9 @@
#include <rsendas.h> // RSendAs
#include <rsendasmessage.h> // RSendAsMessage
+// copied from miutset.h, so we don't get a dependency into the app layer
+const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592
+
#ifdef Q_WS_S60
# include <pathinfo.h> // PathInfo
# ifdef USE_DOCUMENTHANDLER
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 72f32dc..585db70 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -607,7 +607,13 @@ void QComboBoxPrivateContainer::changeEvent(QEvent *e)
view->setMouseTracking(combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) ||
combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo));
setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo));
+#ifdef QT_SOFTKEYS_ENABLED
+ } else if (e->type() == QEvent::LanguageChange) {
+ selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey));
+ cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey));
+#endif
}
+
QWidget::changeEvent(e);
}
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index d754800..0c39f42 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -2635,7 +2635,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
- fallbackToSizeHints = !have_central;
+ fallbackToSizeHints = false;
if (_ver_struct_list != 0) {
QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 269cd12..e7c4f45 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -1426,6 +1426,11 @@ bool QMainWindow::event(QEvent *event)
}
break;
#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ case QEvent::LanguageChange:
+ d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey));
+ break;
+#endif
default:
break;
}
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index fc75c92..593e391 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1772,6 +1772,7 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
if (savedState.isValid()) {
#ifndef QT_NO_DOCKWIDGET
savedState.dockAreaLayout.centralWidgetItem = layoutState.dockAreaLayout.centralWidgetItem;
+ savedState.dockAreaLayout.fallbackToSizeHints = true;
#else
savedState.centralWidgetItem = layoutState.centralWidgetItem;
#endif
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 8ce7cc0..42b7406 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -117,7 +117,7 @@ public:
if (parentWidget->parentWidget())
parentWidget = parentWidget->parentWidget();
setParent(parentWidget, Qt::Window | Qt::Tool);
- setAttribute(Qt::WA_DeleteOnClose, true);
+ setAttribute(Qt::WA_DeleteOnClose, true);
setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);
setWindowTitle(p->windowTitle());
setEnabled(p->isEnabled());
@@ -1226,7 +1226,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
else if (action->isSeparator())
option->menuItemType = QStyleOptionMenuItem::Separator;
else if (d->defaultAction == action)
- option->menuItemType = QStyleOptionMenuItem::DefaultItem;
+ option->menuItemType = QStyleOptionMenuItem::DefaultItem;
else
option->menuItemType = QStyleOptionMenuItem::Normal;
if (action->isIconVisibleInMenu())
@@ -1719,7 +1719,14 @@ bool QMenu::isEmpty() const
void QMenu::clear()
{
QList<QAction*> acts = actions();
+
for(int i = 0; i < acts.size(); i++) {
+#ifdef QT_SOFTKEYS_ENABLED
+ Q_D(QMenu);
+ // Lets not touch to our internal softkey actions
+ if(acts[i] == d->selectAction || acts[i] == d->cancelAction)
+ continue;
+#endif
removeAction(acts[i]);
if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
delete acts[i];
@@ -2408,6 +2415,13 @@ QMenu::event(QEvent *e)
}
return true;
#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ case QEvent::LanguageChange: {
+ d->selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey));
+ d->cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey));
+ }
+ break;
+#endif
default:
break;
}
@@ -2919,7 +2933,7 @@ void QMenu::actionEvent(QActionEvent *e)
#endif
if (isVisible()) {
d->updateActionRects();
- resize(sizeHint());
+ resize(sizeHint());
update();
}
}
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index cc6a1c8..62aa2d7 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -404,6 +404,7 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor
QHttpNetworkReply *reply = new QHttpNetworkReply(request.url());
reply->setRequest(request);
reply->d_func()->connection = q;
+ reply->d_func()->connectionChannel = &channels[0]; // will have the correct one set later
HttpMessagePair pair = qMakePair(request, reply);
switch (request.priority()) {
@@ -688,14 +689,12 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
if (channels[i].resendCurrent) {
channels[i].resendCurrent = false;
channels[i].state = QHttpNetworkConnectionChannel::IdleState;
- if (channels[i].reply) {
- // if this is not possible, error will be emitted and connection terminated
- if (!channels[i].resetUploadData())
- continue;
+ // if this is not possible, error will be emitted and connection terminated
+ if (!channels[i].resetUploadData())
+ continue;
- channels[i].sendRequest();
- }
+ channels[i].sendRequest();
}
}
@@ -861,17 +860,6 @@ QNetworkProxy QHttpNetworkConnection::transparentProxy() const
// SSL support below
#ifndef QT_NO_OPENSSL
-QSslConfiguration QHttpNetworkConnectionPrivate::sslConfiguration(const QHttpNetworkReply &reply) const
-{
- if (!encrypt)
- return QSslConfiguration();
-
- for (int i = 0; i < channelCount; ++i)
- if (channels[i].reply == &reply)
- return static_cast<QSslSocket *>(channels[0].socket)->sslConfiguration();
- return QSslConfiguration(); // pending or done request
-}
-
void QHttpNetworkConnection::setSslConfiguration(const QSslConfiguration &config)
{
Q_D(QHttpNetworkConnection);
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index 03cf09c..823774e 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -210,11 +210,6 @@ public:
void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode);
bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend);
-
-#ifndef QT_NO_OPENSSL
- QSslConfiguration sslConfiguration(const QHttpNetworkReply &reply) const;
-#endif
-
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy networkProxy;
void emitProxyAuthenticationRequired(const QHttpNetworkConnectionChannel *chan, const QNetworkProxy &proxy, QAuthenticator* auth);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 2a3036b..dbee72a 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -124,6 +124,13 @@ void QHttpNetworkConnectionChannel::close()
bool QHttpNetworkConnectionChannel::sendRequest()
{
+ if (!reply) {
+ // heh, how should that happen!
+ qWarning() << "QHttpNetworkConnectionChannel::sendRequest() called without QHttpNetworkReply";
+ state = QHttpNetworkConnectionChannel::IdleState;
+ return false;
+ }
+
switch (state) {
case QHttpNetworkConnectionChannel::IdleState: { // write the header
if (!ensureConnection()) {
@@ -134,13 +141,13 @@ bool QHttpNetworkConnectionChannel::sendRequest()
}
written = 0; // excluding the header
bytesTotal = 0;
- if (reply) {
- reply->d_func()->clear();
- reply->d_func()->connection = connection;
- reply->d_func()->autoDecompress = request.d->autoDecompress;
- reply->d_func()->pipeliningUsed = false;
- }
- state = QHttpNetworkConnectionChannel::WritingState;
+
+ reply->d_func()->clear();
+ reply->d_func()->connection = connection;
+ reply->d_func()->connectionChannel = this;
+ reply->d_func()->autoDecompress = request.d->autoDecompress;
+ reply->d_func()->pipeliningUsed = false;
+
pendingEncrypt = false;
// if the url contains authentication parameters, use the new ones
// both channels will use the new authentication parameters
@@ -174,13 +181,15 @@ bool QHttpNetworkConnectionChannel::sendRequest()
QObject::connect(uploadByteDevice, SIGNAL(readyRead()),this, SLOT(_q_uploadDataReadyRead()));
bytesTotal = request.contentLength();
+
+ state = QHttpNetworkConnectionChannel::WritingState; // start writing data
+ sendRequest(); //recurse
} else {
- state = QHttpNetworkConnectionChannel::WaitingState;
- sendRequest();
- break;
+ state = QHttpNetworkConnectionChannel::WaitingState; // now wait for response
+ sendRequest(); //recurse
}
- // write the initial chunk together with the headers
- // fall through
+
+ break;
}
case QHttpNetworkConnectionChannel::WritingState:
{
@@ -190,7 +199,7 @@ bool QHttpNetworkConnectionChannel::sendRequest()
if (uploadByteDevice)
emit reply->dataSendProgress(written, bytesTotal);
state = QHttpNetworkConnectionChannel::WaitingState; // now wait for response
- sendRequest();
+ sendRequest(); // recurse
break;
}
@@ -278,16 +287,25 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
{
Q_ASSERT(socket);
+ if (!reply) {
+ // heh, how should that happen!
+ qWarning() << "QHttpNetworkConnectionChannel::_q_receiveReply() called without QHttpNetworkReply,"
+ << socket->bytesAvailable() << "bytes on socket.";
+ close();
+ return;
+ }
+
qint64 bytes = 0;
QAbstractSocket::SocketState socketState = socket->state();
// connection might be closed to signal the end of data
if (socketState == QAbstractSocket::UnconnectedState) {
if (socket->bytesAvailable() <= 0) {
- if (reply && reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState) {
+ if (reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState) {
// finish this reply. this case happens when the server did not send a content length
reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState;
allDone();
+ return;
} else {
handleUnexpectedEOF();
return;
@@ -299,12 +317,13 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
// read loop for the response
while (socket->bytesAvailable()) {
- QHttpNetworkReplyPrivate::ReplyState state = reply ? reply->d_func()->state : QHttpNetworkReplyPrivate::AllDoneState;
+ QHttpNetworkReplyPrivate::ReplyState state = reply->d_func()->state;
switch (state) {
case QHttpNetworkReplyPrivate::NothingDoneState: {
// only eat whitespace on the first call
eatWhitespace();
state = reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState;
+ // fallthrough
}
case QHttpNetworkReplyPrivate::ReadingStatusState: {
qint64 statusBytes = reply->d_func()->readStatus(socket);
@@ -412,8 +431,10 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
#endif
}
}
+ // still in ReadingDataState? This function will be called again by the socket's readyRead
if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState)
break;
+
// everything done, fall through
}
case QHttpNetworkReplyPrivate::AllDoneState:
@@ -568,7 +589,8 @@ void QHttpNetworkConnectionChannel::allDone()
handleStatus();
// ### at this point there should be no more data on the socket
// close if server requested
- if (reply->d_func()->isConnectionCloseEnabled())
+ bool connectionCloseEnabled = reply->d_func()->isConnectionCloseEnabled();
+ if (connectionCloseEnabled)
close();
// queue the finished signal, this is required since we might send new requests from
// slot connected to it. The socket will not fire readyRead signal, if we are already
@@ -579,14 +601,22 @@ void QHttpNetworkConnectionChannel::allDone()
// in case of failures, each channel will attempt two reconnects before emitting error.
reconnectAttempts = 2;
+ detectPipeliningSupport();
+
// now the channel can be seen as free/idle again, all signal emissions for the reply have been done
this->state = QHttpNetworkConnectionChannel::IdleState;
- detectPipeliningSupport();
+ // if it does not need to be sent again we can set it to 0
+ // the previous code did not do that and we had problems with accidental re-sending of a
+ // finished request.
+ // Note that this may trigger a segfault at some other point. But then we can fix the underlying
+ // problem.
+ if (!resendCurrent)
+ reply = 0;
// move next from pipeline to current request
if (!alreadyPipelinedRequests.isEmpty()) {
- if (resendCurrent || reply->d_func()->isConnectionCloseEnabled() || socket->state() != QAbstractSocket::ConnectedState) {
+ if (resendCurrent || connectionCloseEnabled || socket->state() != QAbstractSocket::ConnectedState) {
// move the pipelined ones back to the main queue
requeueCurrentlyPipelinedRequests();
close();
@@ -742,12 +772,11 @@ void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)
QHttpNetworkRequest &request = pair.first;
QHttpNetworkReply *reply = pair.second;
- if (reply) {
- reply->d_func()->clear();
- reply->d_func()->connection = connection;
- reply->d_func()->autoDecompress = request.d->autoDecompress;
- reply->d_func()->pipeliningUsed = true;
- }
+ reply->d_func()->clear();
+ reply->d_func()->connection = connection;
+ reply->d_func()->connectionChannel = this;
+ reply->d_func()->autoDecompress = request.d->autoDecompress;
+ reply->d_func()->pipeliningUsed = true;
#ifndef QT_NO_NETWORKPROXY
QByteArray header = QHttpNetworkRequestPrivate::header(request,
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 512c045..984f557 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -230,6 +230,7 @@ void QHttpNetworkReplyPrivate::clear()
currentChunkRead = 0;
connectionCloseEnabled = true;
connection = 0;
+ connectionChannel = 0;
#ifndef QT_NO_COMPRESS
if (initInflate)
inflateEnd(&inflateStrm);
@@ -803,9 +804,15 @@ void QHttpNetworkReplyPrivate::eraseData()
QSslConfiguration QHttpNetworkReply::sslConfiguration() const
{
Q_D(const QHttpNetworkReply);
- if (d->connection)
- return d->connection->d_func()->sslConfiguration(*this);
- return QSslConfiguration();
+
+ if (!d->connectionChannel)
+ return QSslConfiguration();
+
+ QSslSocket *sslSocket = qobject_cast<QSslSocket*>(d->connectionChannel->socket);
+ if (!sslSocket)
+ return QSslConfiguration();
+
+ return sslSocket->sslConfiguration();
}
void QHttpNetworkReply::setSslConfiguration(const QSslConfiguration &config)
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index af9266b..fa240ec 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -86,6 +86,7 @@ static const unsigned char gz_magic[2] = {0x1f, 0x8b}; // gzip magic header
QT_BEGIN_NAMESPACE
class QHttpNetworkConnection;
+class QHttpNetworkConnectionChannel;
class QHttpNetworkRequest;
class QHttpNetworkConnectionPrivate;
class QHttpNetworkReplyPrivate;
@@ -218,6 +219,7 @@ public:
qint64 currentChunkSize;
qint64 currentChunkRead;
QPointer<QHttpNetworkConnection> connection;
+ QPointer<QHttpNetworkConnectionChannel> connectionChannel;
bool initInflate;
bool streamEnd;
#ifndef QT_NO_COMPRESS
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 61a95fe..af971a7 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -976,7 +976,7 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
// of writes to disk when using a QNetworkDiskCache (i.e. don't
// write to disk when only the date changes).
// However, without the date we cannot calculate the age of the page
- // anymore. Consider a proper fix of that problem for 4.6.1.
+ // anymore.
//if (header == "date")
//continue;
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index a2bef67..c4ff24d 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -138,6 +138,8 @@ QT_BEGIN_NAMESPACE
default follow redirections: it's up to the application to
determine if the requested redirection should be allowed,
according to its security policies.
+ The returned URL might be relative. Use QUrl::resolved()
+ to create an absolute URL out of it.
\value ConnectionEncryptedAttribute
Replies only, type: QVariant::Bool (default: false)
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 829df89..275c436 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -155,6 +155,9 @@
See the \l network/fortuneclient and \l network/blockingfortuneclient
examples for an overview of both approaches.
+ \note We discourage the use of the blocking functions together
+ with signals. One of the two possibilities should be used.
+
QAbstractSocket can be used with QTextStream and QDataStream's
stream operators (operator<<() and operator>>()). There is one
issue to be aware of, though: You must make sure that enough data
@@ -1682,9 +1685,12 @@ static int qt_timeout_value(int msecs, int elapsed)
If msecs is -1, this function will not time out.
- Note: This function may wait slightly longer than \a msecs,
+ \note This function may wait slightly longer than \a msecs,
depending on the time it takes to complete the host lookup.
+ \note Multiple calls to this functions do not accumulate the time.
+ If the function times out, the connecting process will be aborted.
+
\sa connectToHost(), connected()
*/
bool QAbstractSocket::waitForConnected(int msecs)
@@ -1722,7 +1728,7 @@ bool QAbstractSocket::waitForConnected(int msecs)
d->_q_startConnecting(QHostInfo::fromName(d->hostName));
}
if (state() == UnconnectedState)
- return false;
+ return false; // connect not im progress anymore!
bool timedOut = true;
#if defined (QABSTRACTSOCKET_DEBUG)
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 8235a5c..c08d04a 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -89,6 +89,9 @@
QT_BEGIN_NAMESPACE
//#define QT_GL_NO_SCISSOR_TEST
+#if defined(Q_WS_WIN)
+extern Q_GUI_EXPORT bool qt_cleartype_enabled;
+#endif
extern QImage qt_imageForBrush(int brushStyle, bool invert);
@@ -1555,7 +1558,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
#if !defined(QT_OPENGL_ES_2)
#if defined(Q_WS_WIN)
- extern Q_GUI_EXPORT bool qt_cleartype_enabled;
if (qt_cleartype_enabled)
#endif
d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 6813d2f..4192dbb 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -131,8 +131,9 @@ public:
void draw(VGPath path, const QPen& pen, const QBrush& brush, VGint rule = VG_EVEN_ODD);
void stroke(VGPath path, const QPen& pen);
void fill(VGPath path, const QBrush& brush, VGint rule = VG_EVEN_ODD);
- VGPath vectorPathToVGPath(const QVectorPath& path);
- VGPath painterPathToVGPath(const QPainterPath& path);
+ inline void releasePath(VGPath path);
+ VGPath vectorPathToVGPath(const QVectorPath& path, bool forceNewPath = false);
+ VGPath painterPathToVGPath(const QPainterPath& path, bool forceNewPath = false);
VGPath roundedRectPath(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode);
VGPaintType setBrush
(VGPaint paint, const QBrush& brush, VGMatrixMode mode,
@@ -178,6 +179,8 @@ public:
VGPath roundRectPath; // Cached path for quick drawing of rounded rects.
#endif
+ VGPath reusablePath; // Reusable path for vectorPathToVGPath(), etc.
+
QTransform transform; // Currently active transform.
bool simpleTransform; // True if the transform is simple (non-projective).
qreal penScale; // Pen scaling factor from "transform".
@@ -350,6 +353,8 @@ void QVGPaintEnginePrivate::init()
roundRectPath = 0;
#endif
+ reusablePath = 0;
+
simpleTransform = true;
pathTransformSet = false;
penScale = 1.0;
@@ -446,6 +451,15 @@ void QVGPaintEnginePrivate::initObjects()
VG_PATH_CAPABILITY_ALL);
vgAppendPathData(linePath, 2, segments, coords);
#endif
+
+ // This path can be reused over and over by calling vgClearPath().
+ reusablePath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ 32 + 1, // segmentCapacityHint
+ 32 * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
}
void QVGPaintEnginePrivate::destroy()
@@ -465,6 +479,8 @@ void QVGPaintEnginePrivate::destroy()
if (roundRectPath)
vgDestroyPath(roundRectPath);
#endif
+ if (reusablePath)
+ vgDestroyPath(reusablePath);
#if !defined(QVG_NO_DRAW_GLYPHS)
QVGFontCache::Iterator it;
@@ -541,19 +557,32 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev)
qt_scaleForTransform(transform, &penScale);
}
-VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
+inline void QVGPaintEnginePrivate::releasePath(VGPath path)
+{
+ if (path == reusablePath)
+ vgClearPath(path, VG_PATH_CAPABILITY_ALL);
+ else
+ vgDestroyPath(path);
+}
+
+VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path, bool forceNewPath)
{
int count = path.elementCount();
const qreal *points = path.points();
const QPainterPath::ElementType *elements = path.elements();
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath;
+ if (forceNewPath) {
+ vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ count + 1, // segmentCapacityHint
+ count * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ } else {
+ vgpath = reusablePath;
+ }
// Size is sufficient segments for drawRoundedRect() paths.
QVarLengthArray<VGubyte, 20> segments;
@@ -725,17 +754,22 @@ VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
return vgpath;
}
-VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path)
+VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path, bool forceNewPath)
{
int count = path.elementCount();
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath;
+ if (forceNewPath) {
+ vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ count + 1, // segmentCapacityHint
+ count * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ } else {
+ vgpath = reusablePath;
+ }
if (count == 0)
return vgpath;
@@ -954,13 +988,7 @@ VGPath QVGPaintEnginePrivate::roundedRectPath(const QRectF &rect, qreal xRadius,
vgModifyPathCoords(vgpath, 0, 9, pts);
}
#else
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 10, // segmentCapacityHint
- 17 * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath = reusablePath;
vgAppendPathData(vgpath, 10, roundedrect_types, pts);
#endif
@@ -1516,7 +1544,7 @@ void QVGPaintEngine::draw(const QVectorPath &path)
d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
else
d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
@@ -1527,7 +1555,7 @@ void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
d->fill(vgpath, brush, VG_EVEN_ODD);
else
d->fill(vgpath, brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
@@ -1535,7 +1563,7 @@ void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
Q_D(QVGPaintEngine);
VGPath vgpath = d->vectorPathToVGPath(path);
d->stroke(vgpath, pen);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
// Determine if a co-ordinate transform is simple enough to allow
@@ -1731,7 +1759,7 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
default: break;
}
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
vgSeti(VG_MASKING, VG_TRUE);
d->maskValid = true;
@@ -2048,7 +2076,7 @@ void QVGPaintEngine::clip(const QPainterPath &path, Qt::ClipOperation op)
default: break;
}
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
vgSeti(VG_MASKING, VG_TRUE);
d->maskValid = true;
@@ -2399,7 +2427,7 @@ void QVGPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
return;
// Check to see if we can use vgClear() for faster filling.
- if (brush.style() == Qt::SolidPattern &&
+ if (brush.style() == Qt::SolidPattern && brush.isOpaque() &&
clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
clearRect(rect, brush.color())) {
return;
@@ -2442,7 +2470,7 @@ void QVGPaintEngine::fillRect(const QRectF &rect, const QColor &color)
Q_D(QVGPaintEngine);
// Check to see if we can use vgClear() for faster filling.
- if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
+ if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f && color.alpha() == 255 &&
clearRect(rect, color)) {
return;
}
@@ -2487,7 +2515,7 @@ void QVGPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad,
VGPath vgpath = d->roundedRectPath(rect, xrad, yrad, mode);
d->draw(vgpath, s->pen, s->brush);
#if defined(QVG_NO_MODIFY_PATH)
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
#endif
} else {
QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
@@ -2636,13 +2664,7 @@ void QVGPaintEngine::drawEllipse(const QRectF &r)
Q_D(QVGPaintEngine);
if (d->simpleTransform) {
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 4, // segmentCapacityHint
- 12, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
static VGubyte segments[4] = {
VG_MOVE_TO_ABS,
VG_SCCWARC_TO_REL,
@@ -2666,7 +2688,7 @@ void QVGPaintEngine::drawEllipse(const QRectF &r)
coords[11] = 0.0f;
vgAppendPathData(path, 4, segments, coords);
d->draw(path, s->pen, s->brush);
- vgDestroyPath(path);
+ d->releasePath(path);
} else {
// The projective transform version of an ellipse is difficult.
// Generate a QVectorPath containing cubic curves and transform that.
@@ -2690,7 +2712,7 @@ void QVGPaintEngine::drawPath(const QPainterPath &path)
d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
else
d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::drawPoints(const QPointF *points, int pointCount)
@@ -2765,13 +2787,7 @@ void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonD
{
Q_D(QVGPaintEngine);
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
QVarLengthArray<VGfloat, 16> coords;
QVarLengthArray<VGubyte, 10> segments;
for (int i = 0; i < pointCount; ++i, ++points) {
@@ -2805,20 +2821,14 @@ void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonD
d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
break;
}
- vgDestroyPath(path);
+ d->releasePath(path);
}
void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
{
Q_D(QVGPaintEngine);
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
QVarLengthArray<VGfloat, 16> coords;
QVarLengthArray<VGubyte, 10> segments;
for (int i = 0; i < pointCount; ++i, ++points) {
@@ -2852,7 +2862,7 @@ void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDr
d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
break;
}
- vgDestroyPath(path);
+ d->releasePath(path);
}
void QVGPaintEnginePrivate::setImageOptions()
@@ -3251,7 +3261,7 @@ void QVGFontGlyphCache::cacheGlyphs
ti.fontEngine->getUnscaledGlyph(glyph, &path, &metrics);
VGPath vgPath;
if (!path.isEmpty()) {
- vgPath = d->painterPathToVGPath(path);
+ vgPath = d->painterPathToVGPath(path, true);
} else {
// Probably a "space" character with no visible outline.
vgPath = VG_INVALID_HANDLE;
diff --git a/src/plugins/audio/audio.pro b/src/plugins/audio/audio.pro
index e93b369..5f75a8d 100644
--- a/src/plugins/audio/audio.pro
+++ b/src/plugins/audio/audio.pro
@@ -1,3 +1,9 @@
TEMPLATE = subdirs
+SUBDIRS =
+
+contains(QT_CONFIG, audio-backend) {
+ symbian {
+ SUBDIRS += symbian
+ }
+}
-#SUBDIRS += ossaudio
diff --git a/src/plugins/audio/symbian/main.cpp b/src/plugins/audio/symbian/main.cpp
new file mode 100644
index 0000000..536a8ec
--- /dev/null
+++ b/src/plugins/audio/symbian/main.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtMultimedia/qaudioengineplugin.h>
+#include <QtMultimedia/qaudioengine.h>
+
+#include <qstringlist.h>
+#include <qiodevice.h>
+#include <qbytearray.h>
+#include <qdebug.h>
+
+#include "symbianaudiodeviceinfo.h"
+#include "symbianaudioinput.h"
+#include "symbianaudiooutput.h"
+
+QT_BEGIN_NAMESPACE
+
+class SymbianAudioPlugin : public QAudioEnginePlugin
+{
+public:
+ SymbianAudioPlugin(QObject *parent = 0);
+ ~SymbianAudioPlugin();
+
+ QStringList keys() const;
+
+ QList<QByteArray> availableDevices(QAudio::Mode) const;
+ QAbstractAudioInput* createInput(const QByteArray& device,
+ const QAudioFormat& format = QAudioFormat());
+ QAbstractAudioOutput* createOutput(const QByteArray& device,
+ const QAudioFormat& format = QAudioFormat());
+ QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device,
+ QAudio::Mode mode);
+};
+
+SymbianAudioPlugin::SymbianAudioPlugin(QObject *parent)
+ : QAudioEnginePlugin(parent)
+{
+
+}
+
+SymbianAudioPlugin::~SymbianAudioPlugin()
+{
+
+}
+
+QStringList SymbianAudioPlugin::keys() const
+{
+ QStringList keys(QLatin1String("default"));
+ keys << QLatin1String("default");
+ return keys;
+}
+
+QList<QByteArray> SymbianAudioPlugin::availableDevices(QAudio::Mode mode) const
+{
+ Q_UNUSED(mode)
+ QList<QByteArray> devices;
+ devices.append("default");
+ return devices;
+}
+
+QAbstractAudioInput* SymbianAudioPlugin::createInput(
+ const QByteArray &device, const QAudioFormat &format)
+{
+ return new SymbianAudioInput(device, format);
+}
+
+QAbstractAudioOutput* SymbianAudioPlugin::createOutput(
+ const QByteArray &device, const QAudioFormat &format)
+{
+ return new SymbianAudioOutput(device, format);
+}
+
+QAbstractAudioDeviceInfo* SymbianAudioPlugin::createDeviceInfo(
+ const QByteArray& device, QAudio::Mode mode)
+{
+ return new SymbianAudioDeviceInfo(device, mode);
+}
+
+Q_EXPORT_STATIC_PLUGIN(SymbianAudioPlugin)
+Q_EXPORT_PLUGIN2(qaudio, SymbianAudioPlugin)
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/audio/symbian/symbian.pro b/src/plugins/audio/symbian/symbian.pro
new file mode 100644
index 0000000..7355daa
--- /dev/null
+++ b/src/plugins/audio/symbian/symbian.pro
@@ -0,0 +1,31 @@
+QT += multimedia
+TARGET = qaudio
+
+# Paths to DevSound headers
+INCLUDEPATH += /epoc32/include/mmf/common
+INCLUDEPATH += /epoc32/include/mmf/server
+
+HEADERS += \
+ symbianaudio.h \
+ symbianaudiodeviceinfo.h \
+ symbianaudioinput.h \
+ symbianaudiooutput.h \
+ symbianaudioutils.h
+
+SOURCES += \
+ main.cpp \
+ symbianaudiodeviceinfo.cpp \
+ symbianaudioinput.cpp \
+ symbianaudiooutput.cpp \
+ symbianaudioutils.cpp
+
+LIBS += -lmmfdevsound
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/audio
+target.path = $$[QT_INSTALL_PLUGINS]/audio
+INSTALLS += target
+
+include(../../qpluginbase.pri)
+
+TARGET.UID3 = 0x2001E630
+
diff --git a/src/plugins/audio/symbian/symbianaudio.h b/src/plugins/audio/symbian/symbianaudio.h
new file mode 100644
index 0000000..3fc0419
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudio.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBIANAUDIO_H
+#define SYMBIANAUDIO_H
+
+#include <QtCore/qnamespace.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace SymbianAudio {
+
+/**
+ * Default values used by audio input and output classes, when underlying
+ * DevSound instance has not yet been created.
+ */
+
+const int DefaultBufferSize = 4096; // bytes
+const int DefaultNotifyInterval = 1000; // ms
+
+/**
+ * Enumeration used to track state of internal DevSound instances.
+ * Values are translated to the corresponding QAudio::State values by
+ * SymbianAudio::Utils::stateNativeToQt.
+ */
+enum State {
+ ClosedState
+ , InitializingState
+ , ActiveState
+ , IdleState
+ , SuspendedState
+};
+
+} // namespace SymbianAudio
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp b/src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp
new file mode 100644
index 0000000..9701dad
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "symbianaudiodeviceinfo.h"
+#include "symbianaudioutils.h"
+
+QT_BEGIN_NAMESPACE
+
+SymbianAudioDeviceInfo::SymbianAudioDeviceInfo(QByteArray device,
+ QAudio::Mode mode)
+ : m_deviceName(device)
+ , m_mode(mode)
+ , m_updated(false)
+{
+ QT_TRAP_THROWING(m_devsound.reset(CMMFDevSound::NewL()));
+}
+
+SymbianAudioDeviceInfo::~SymbianAudioDeviceInfo()
+{
+
+}
+
+QAudioFormat SymbianAudioDeviceInfo::preferredFormat() const
+{
+ QAudioFormat format;
+ switch (m_mode) {
+ case QAudio::AudioOutput:
+ format.setFrequency(44100);
+ format.setChannels(2);
+ format.setSampleSize(16);
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::SignedInt);
+ format.setCodec(QLatin1String("audio/pcm"));
+ break;
+
+ case QAudio::AudioInput:
+ format.setFrequency(8000);
+ format.setChannels(1);
+ format.setSampleSize(16);
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::SignedInt);
+ format.setCodec(QLatin1String("audio/pcm"));
+ break;
+
+ default:
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode");
+ }
+
+ if (!isFormatSupported(format)) {
+ if (m_frequencies.size())
+ format.setFrequency(m_frequencies[0]);
+ if (m_channels.size())
+ format.setChannels(m_channels[0]);
+ if (m_sampleSizes.size())
+ format.setSampleSize(m_sampleSizes[0]);
+ if (m_byteOrders.size())
+ format.setByteOrder(m_byteOrders[0]);
+ if (m_sampleTypes.size())
+ format.setSampleType(m_sampleTypes[0]);
+ }
+
+ return format;
+}
+
+bool SymbianAudioDeviceInfo::isFormatSupported(
+ const QAudioFormat &format) const
+{
+ getSupportedFormats();
+ const bool supported =
+ m_codecs.contains(format.codec())
+ && m_frequencies.contains(format.frequency())
+ && m_channels.contains(format.channels())
+ && m_sampleSizes.contains(format.sampleSize())
+ && m_byteOrders.contains(format.byteOrder())
+ && m_sampleTypes.contains(format.sampleType());
+
+ return supported;
+}
+
+QAudioFormat SymbianAudioDeviceInfo::nearestFormat(const QAudioFormat &format) const
+{
+ if (isFormatSupported(format))
+ return format;
+ else
+ return preferredFormat();
+}
+
+QString SymbianAudioDeviceInfo::deviceName() const
+{
+ return m_deviceName;
+}
+
+QStringList SymbianAudioDeviceInfo::codecList()
+{
+ getSupportedFormats();
+ return m_codecs;
+}
+
+QList<int> SymbianAudioDeviceInfo::frequencyList()
+{
+ getSupportedFormats();
+ return m_frequencies;
+}
+
+QList<int> SymbianAudioDeviceInfo::channelsList()
+{
+ getSupportedFormats();
+ return m_channels;
+}
+
+QList<int> SymbianAudioDeviceInfo::sampleSizeList()
+{
+ getSupportedFormats();
+ return m_sampleSizes;
+}
+
+QList<QAudioFormat::Endian> SymbianAudioDeviceInfo::byteOrderList()
+{
+ getSupportedFormats();
+ return m_byteOrders;
+}
+
+QList<QAudioFormat::SampleType> SymbianAudioDeviceInfo::sampleTypeList()
+{
+ getSupportedFormats();
+ return m_sampleTypes;
+}
+
+QList<QByteArray> SymbianAudioDeviceInfo::deviceList(QAudio::Mode mode)
+{
+ Q_UNUSED(mode)
+ QList<QByteArray> devices;
+ devices.append("default");
+ return devices;
+}
+
+void SymbianAudioDeviceInfo::getSupportedFormats() const
+{
+ if (!m_updated) {
+ QScopedPointer<SymbianAudio::DevSoundCapabilities> caps(
+ new SymbianAudio::DevSoundCapabilities(*m_devsound, m_mode));
+
+ SymbianAudio::Utils::capabilitiesNativeToQt(*caps,
+ m_frequencies, m_channels, m_sampleSizes,
+ m_byteOrders, m_sampleTypes);
+
+ m_codecs.append(QLatin1String("audio/pcm"));
+
+ m_updated = true;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/audio/symbian/symbianaudiodeviceinfo.h b/src/plugins/audio/symbian/symbianaudiodeviceinfo.h
new file mode 100644
index 0000000..250804d
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudiodeviceinfo.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBIANAUDIODEVICEINFO_H
+#define SYMBIANAUDIODEVICEINFO_H
+
+#include <QtMultimedia/qaudioengine.h>
+#include <sounddevice.h>
+
+QT_BEGIN_NAMESPACE
+
+class SymbianAudioDeviceInfo
+ : public QAbstractAudioDeviceInfo
+{
+ Q_OBJECT
+
+public:
+ SymbianAudioDeviceInfo(QByteArray device, QAudio::Mode mode);
+ ~SymbianAudioDeviceInfo();
+
+ // QAbstractAudioDeviceInfo
+ QAudioFormat preferredFormat() const;
+ bool isFormatSupported(const QAudioFormat &format) const;
+ QAudioFormat nearestFormat(const QAudioFormat &format) const;
+ QString deviceName() const;
+ QStringList codecList();
+ QList<int> frequencyList();
+ QList<int> channelsList();
+ QList<int> sampleSizeList();
+ QList<QAudioFormat::Endian> byteOrderList();
+ QList<QAudioFormat::SampleType> sampleTypeList();
+ QList<QByteArray> deviceList(QAudio::Mode);
+
+private:
+ void getSupportedFormats() const;
+
+private:
+ QScopedPointer<CMMFDevSound> m_devsound;
+
+ QString m_deviceName;
+ QAudio::Mode m_mode;
+
+ // Mutable to allow lazy initialization when called from const-qualified
+ // public functions (isFormatSupported, nearestFormat)
+ mutable bool m_updated;
+ mutable QStringList m_codecs;
+ mutable QList<int> m_frequencies;
+ mutable QList<int> m_channels;
+ mutable QList<int> m_sampleSizes;
+ mutable QList<QAudioFormat::Endian> m_byteOrders;
+ mutable QList<QAudioFormat::SampleType> m_sampleTypes;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/audio/symbian/symbianaudioinput.cpp b/src/plugins/audio/symbian/symbianaudioinput.cpp
new file mode 100644
index 0000000..8200925
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudioinput.cpp
@@ -0,0 +1,595 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "symbianaudioinput.h"
+#include "symbianaudioutils.h"
+
+QT_BEGIN_NAMESPACE
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+
+const int PushInterval = 50; // ms
+
+
+//-----------------------------------------------------------------------------
+// Private class
+//-----------------------------------------------------------------------------
+
+SymbianAudioInputPrivate::SymbianAudioInputPrivate(
+ SymbianAudioInput *audioDevice)
+ : m_audioDevice(audioDevice)
+{
+
+}
+
+SymbianAudioInputPrivate::~SymbianAudioInputPrivate()
+{
+
+}
+
+qint64 SymbianAudioInputPrivate::readData(char *data, qint64 len)
+{
+ qint64 totalRead = 0;
+
+ if (m_audioDevice->state() == QAudio::ActiveState ||
+ m_audioDevice->state() == QAudio::IdleState) {
+
+ while (totalRead < len) {
+ const qint64 read = m_audioDevice->read(data + totalRead,
+ len - totalRead);
+ if (read > 0)
+ totalRead += read;
+ else
+ break;
+ }
+ }
+
+ return totalRead;
+}
+
+qint64 SymbianAudioInputPrivate::writeData(const char *data, qint64 len)
+{
+ Q_UNUSED(data)
+ Q_UNUSED(len)
+ return 0;
+}
+
+void SymbianAudioInputPrivate::dataReady()
+{
+ emit readyRead();
+}
+
+
+//-----------------------------------------------------------------------------
+// Public functions
+//-----------------------------------------------------------------------------
+
+SymbianAudioInput::SymbianAudioInput(const QByteArray &device,
+ const QAudioFormat &format)
+ : m_device(device)
+ , m_format(format)
+ , m_clientBufferSize(SymbianAudio::DefaultBufferSize)
+ , m_notifyInterval(SymbianAudio::DefaultNotifyInterval)
+ , m_notifyTimer(new QTimer(this))
+ , m_error(QAudio::NoError)
+ , m_internalState(SymbianAudio::ClosedState)
+ , m_externalState(QAudio::StoppedState)
+ , m_pullMode(false)
+ , m_sink(0)
+ , m_pullTimer(new QTimer(this))
+ , m_devSoundBuffer(0)
+ , m_devSoundBufferSize(0)
+ , m_totalBytesReady(0)
+ , m_devSoundBufferPos(0)
+ , m_totalSamplesRecorded(0)
+{
+ connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify()));
+
+ SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC,
+ m_nativeFormat);
+
+ m_pullTimer->setInterval(PushInterval);
+ connect(m_pullTimer.data(), SIGNAL(timeout()), this, SLOT(pullData()));
+}
+
+SymbianAudioInput::~SymbianAudioInput()
+{
+ close();
+}
+
+QIODevice* SymbianAudioInput::start(QIODevice *device)
+{
+ stop();
+
+ open();
+ if (SymbianAudio::ClosedState != m_internalState) {
+ if (device) {
+ m_pullMode = true;
+ m_sink = device;
+ } else {
+ m_sink = new SymbianAudioInputPrivate(this);
+ m_sink->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ }
+
+ m_elapsed.restart();
+ }
+
+ return m_sink;
+}
+
+void SymbianAudioInput::stop()
+{
+ close();
+}
+
+void SymbianAudioInput::reset()
+{
+ m_totalSamplesRecorded += getSamplesRecorded();
+ m_devSound->Stop();
+ startRecording();
+}
+
+void SymbianAudioInput::suspend()
+{
+ if (SymbianAudio::ActiveState == m_internalState
+ || SymbianAudio::IdleState == m_internalState) {
+ m_notifyTimer->stop();
+ m_pullTimer->stop();
+ m_devSound->Pause();
+ const qint64 samplesRecorded = getSamplesRecorded();
+ m_totalSamplesRecorded += samplesRecorded;
+
+ if (m_devSoundBuffer) {
+ m_devSoundBufferQ.append(m_devSoundBuffer);
+ m_devSoundBuffer = 0;
+ }
+
+ setState(SymbianAudio::SuspendedState);
+ }
+}
+
+void SymbianAudioInput::resume()
+{
+ if (SymbianAudio::SuspendedState == m_internalState)
+ startDataTransfer();
+}
+
+int SymbianAudioInput::bytesReady() const
+{
+ Q_ASSERT(m_devSoundBufferPos <= m_totalBytesReady);
+ return m_totalBytesReady - m_devSoundBufferPos;
+}
+
+int SymbianAudioInput::periodSize() const
+{
+ return bufferSize();
+}
+
+void SymbianAudioInput::setBufferSize(int value)
+{
+ // Note that DevSound does not allow its client to specify the buffer size.
+ // This functionality is available via custom interfaces, but since these
+ // cannot be guaranteed to work across all DevSound implementations, we
+ // do not use them here.
+ // In order to comply with the expected bevahiour of QAudioInput, we store
+ // the value and return it from bufferSize(), but the underlying DevSound
+ // buffer size remains unchanged.
+ if (value > 0)
+ m_clientBufferSize = value;
+}
+
+int SymbianAudioInput::bufferSize() const
+{
+ return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize;
+}
+
+void SymbianAudioInput::setNotifyInterval(int ms)
+{
+ if (ms > 0) {
+ const int oldNotifyInterval = m_notifyInterval;
+ m_notifyInterval = ms;
+ if (m_notifyTimer->isActive() && ms != oldNotifyInterval)
+ m_notifyTimer->start(m_notifyInterval);
+ }
+}
+
+int SymbianAudioInput::notifyInterval() const
+{
+ return m_notifyInterval;
+}
+
+qint64 SymbianAudioInput::processedUSecs() const
+{
+ int samplesPlayed = 0;
+ if (m_devSound && SymbianAudio::SuspendedState != m_internalState)
+ samplesPlayed = getSamplesRecorded();
+
+ // Protect against division by zero
+ Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency");
+
+ const qint64 result = qint64(1000000) *
+ (samplesPlayed + m_totalSamplesRecorded)
+ / m_format.frequency();
+
+ return result;
+}
+
+qint64 SymbianAudioInput::elapsedUSecs() const
+{
+ const qint64 result = (QAudio::StoppedState == state()) ?
+ 0 : m_elapsed.elapsed() * 1000;
+ return result;
+}
+
+QAudio::Error SymbianAudioInput::error() const
+{
+ return m_error;
+}
+
+QAudio::State SymbianAudioInput::state() const
+{
+ return m_externalState;
+}
+
+QAudioFormat SymbianAudioInput::format() const
+{
+ return m_format;
+}
+
+//-----------------------------------------------------------------------------
+// MDevSoundObserver implementation
+//-----------------------------------------------------------------------------
+
+void SymbianAudioInput::InitializeComplete(TInt aError)
+{
+ Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState,
+ Q_FUNC_INFO, "Invalid state");
+
+ if (KErrNone == aError)
+ startRecording();
+}
+
+void SymbianAudioInput::ToneFinished(TInt aError)
+{
+ Q_UNUSED(aError)
+ // This class doesn't use DevSound's tone playback functions, so should
+ // never receive this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioInput::BufferToBeFilled(CMMFBuffer *aBuffer)
+{
+ Q_UNUSED(aBuffer)
+ // This class doesn't use DevSound in play mode, so should never receive
+ // this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioInput::PlayError(TInt aError)
+{
+ Q_UNUSED(aError)
+ // This class doesn't use DevSound in play mode, so should never receive
+ // this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioInput::BufferToBeEmptied(CMMFBuffer *aBuffer)
+{
+ // Following receipt of this callback, DevSound should not provide another
+ // buffer until we have returned the current one.
+ Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held");
+
+ CMMFDataBuffer *const buffer = static_cast<CMMFDataBuffer*>(aBuffer);
+
+ if (!m_devSoundBufferSize)
+ m_devSoundBufferSize = buffer->Data().MaxLength();
+
+ m_totalBytesReady += buffer->Data().Length();
+
+ if (SymbianAudio::SuspendedState == m_internalState) {
+ m_devSoundBufferQ.append(buffer);
+ } else {
+ // Will be returned to DevSound by bufferEmptied().
+ m_devSoundBuffer = buffer;
+ m_devSoundBufferPos = 0;
+
+ if (bytesReady() && !m_pullMode)
+ pushData();
+ }
+}
+
+void SymbianAudioInput::RecordError(TInt aError)
+{
+ Q_UNUSED(aError)
+ setError(QAudio::IOError);
+}
+
+void SymbianAudioInput::ConvertError(TInt aError)
+{
+ Q_UNUSED(aError)
+ // This class doesn't use DevSound's format conversion functions, so
+ // should never receive this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioInput::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg)
+{
+ Q_UNUSED(aMessageType)
+ Q_UNUSED(aMsg)
+ // Ignore this callback.
+}
+
+//-----------------------------------------------------------------------------
+// Private functions
+//-----------------------------------------------------------------------------
+
+void SymbianAudioInput::open()
+{
+ Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState,
+ Q_FUNC_INFO, "DevSound already opened");
+
+ QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) )
+
+ QScopedPointer<SymbianAudio::DevSoundCapabilities> caps(
+ new SymbianAudio::DevSoundCapabilities(*m_devSound, QAudio::AudioInput));
+
+ int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ?
+ KErrNone : KErrNotSupported;
+
+ if (KErrNone == err) {
+ setState(SymbianAudio::InitializingState);
+ TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC,
+ EMMFStateRecording));
+ }
+
+ if (KErrNone != err) {
+ setError(QAudio::OpenError);
+ m_devSound.reset();
+ }
+}
+
+void SymbianAudioInput::startRecording()
+{
+ const int samplesRecorded = m_devSound->SamplesRecorded();
+ Q_ASSERT(samplesRecorded == 0);
+
+ TRAPD(err, startDevSoundL());
+ if (KErrNone == err) {
+ startDataTransfer();
+ } else {
+ setError(QAudio::OpenError);
+ close();
+ }
+}
+
+void SymbianAudioInput::startDevSoundL()
+{
+ TMMFCapabilities nativeFormat = m_devSound->Config();
+ m_nativeFormat.iBufferSize = nativeFormat.iBufferSize;
+ m_devSound->SetConfigL(m_nativeFormat);
+ m_devSound->RecordInitL();
+}
+
+void SymbianAudioInput::startDataTransfer()
+{
+ m_notifyTimer->start(m_notifyInterval);
+
+ if (m_pullMode)
+ m_pullTimer->start();
+
+ if (bytesReady()) {
+ setState(SymbianAudio::ActiveState);
+ if (!m_pullMode)
+ pushData();
+ } else {
+ if (SymbianAudio::SuspendedState == m_internalState)
+ setState(SymbianAudio::ActiveState);
+ else
+ setState(SymbianAudio::IdleState);
+ }
+}
+
+CMMFDataBuffer* SymbianAudioInput::currentBuffer() const
+{
+ CMMFDataBuffer *result = m_devSoundBuffer;
+ if (!result && !m_devSoundBufferQ.empty())
+ result = m_devSoundBufferQ.front();
+ return result;
+}
+
+void SymbianAudioInput::pushData()
+{
+ Q_ASSERT_X(bytesReady(), Q_FUNC_INFO, "No data available");
+ Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, "pushData called when in pull mode");
+ qobject_cast<SymbianAudioInputPrivate *>(m_sink)->dataReady();
+}
+
+qint64 SymbianAudioInput::read(char *data, qint64 len)
+{
+ // SymbianAudioInputPrivate is ready to read data
+
+ Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO,
+ "read called when in pull mode");
+
+ qint64 bytesRead = 0;
+
+ CMMFDataBuffer *buffer = 0;
+ while ((buffer = currentBuffer()) && (bytesRead < len)) {
+ if (SymbianAudio::IdleState == m_internalState)
+ setState(SymbianAudio::ActiveState);
+
+ TDesC8 &inputBuffer = buffer->Data();
+
+ const qint64 inputBytes = bytesReady();
+ const qint64 outputBytes = len - bytesRead;
+ const qint64 copyBytes = outputBytes < inputBytes ?
+ outputBytes : inputBytes;
+
+ memcpy(data, inputBuffer.Ptr() + m_devSoundBufferPos, copyBytes);
+
+ m_devSoundBufferPos += copyBytes;
+ data += copyBytes;
+ bytesRead += copyBytes;
+
+ if (!bytesReady())
+ bufferEmptied();
+ }
+
+ return bytesRead;
+}
+
+void SymbianAudioInput::pullData()
+{
+ Q_ASSERT_X(m_pullMode, Q_FUNC_INFO,
+ "pullData called when in push mode");
+
+ CMMFDataBuffer *buffer = 0;
+ while (buffer = currentBuffer()) {
+ if (SymbianAudio::IdleState == m_internalState)
+ setState(SymbianAudio::ActiveState);
+
+ TDesC8 &inputBuffer = buffer->Data();
+
+ const qint64 inputBytes = bytesReady();
+ const qint64 bytesPushed = m_sink->write(
+ (char*)inputBuffer.Ptr() + m_devSoundBufferPos, inputBytes);
+
+ m_devSoundBufferPos += bytesPushed;
+
+ if (!bytesReady())
+ bufferEmptied();
+
+ if (!bytesPushed)
+ break;
+ }
+}
+
+void SymbianAudioInput::bufferEmptied()
+{
+ m_devSoundBufferPos = 0;
+
+ if (m_devSoundBuffer) {
+ m_totalBytesReady -= m_devSoundBuffer->Data().Length();
+ m_devSoundBuffer = 0;
+ m_devSound->RecordData();
+ } else {
+ Q_ASSERT(!m_devSoundBufferQ.empty());
+ m_totalBytesReady -= m_devSoundBufferQ.front()->Data().Length();
+ m_devSoundBufferQ.erase(m_devSoundBufferQ.begin());
+
+ // If the queue has been emptied, resume transfer from the hardware
+ if (m_devSoundBufferQ.empty())
+ m_devSound->RecordInitL();
+ }
+
+ Q_ASSERT(m_totalBytesReady >= 0);
+}
+
+void SymbianAudioInput::close()
+{
+ m_notifyTimer->stop();
+ m_pullTimer->stop();
+
+ m_error = QAudio::NoError;
+
+ if (m_devSound)
+ m_devSound->Stop();
+ m_devSound.reset();
+ m_devSoundBuffer = 0;
+ m_devSoundBufferSize = 0;
+ m_totalBytesReady = 0;
+
+ if (!m_pullMode) // m_sink is owned
+ delete m_sink;
+ m_pullMode = false;
+ m_sink = 0;
+
+ m_devSoundBufferQ.clear();
+ m_devSoundBufferPos = 0;
+ m_totalSamplesRecorded = 0;
+
+ setState(SymbianAudio::ClosedState);
+}
+
+qint64 SymbianAudioInput::getSamplesRecorded() const
+{
+ qint64 result = 0;
+ if (m_devSound)
+ result = qint64(m_devSound->SamplesRecorded());
+ return result;
+}
+
+void SymbianAudioInput::setError(QAudio::Error error)
+{
+ m_error = error;
+
+ // Although no state transition actually occurs here, a stateChanged event
+ // must be emitted to inform the client that the call to start() was
+ // unsuccessful.
+ if (QAudio::OpenError == error)
+ emit stateChanged(QAudio::StoppedState);
+
+ // Close the DevSound instance. This causes a transition to StoppedState.
+ // This must be done asynchronously in case the current function was called
+ // from a DevSound event handler, in which case deleting the DevSound
+ // instance may cause an exception.
+ QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
+}
+
+void SymbianAudioInput::setState(SymbianAudio::State newInternalState)
+{
+ const QAudio::State oldExternalState = m_externalState;
+ m_internalState = newInternalState;
+ m_externalState = SymbianAudio::Utils::stateNativeToQt(
+ m_internalState, initializingState());
+
+ if (m_externalState != oldExternalState)
+ emit stateChanged(m_externalState);
+}
+
+QAudio::State SymbianAudioInput::initializingState() const
+{
+ return QAudio::IdleState;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/audio/symbian/symbianaudioinput.h b/src/plugins/audio/symbian/symbianaudioinput.h
new file mode 100644
index 0000000..34b7d38
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudioinput.h
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBIANAUDIOINPUT_H
+#define SYMBIANAUDIOINPUT_H
+
+#include <QtMultimedia/qaudioengine.h>
+#include <QTime>
+#include <QTimer>
+#include <sounddevice.h>
+#include "symbianaudio.h"
+
+QT_BEGIN_NAMESPACE
+
+class SymbianAudioInput;
+
+class SymbianAudioInputPrivate : public QIODevice
+{
+ friend class SymbianAudioInput;
+ Q_OBJECT
+public:
+ SymbianAudioInputPrivate(SymbianAudioInput *audio);
+ ~SymbianAudioInputPrivate();
+
+ qint64 readData(char *data, qint64 len);
+ qint64 writeData(const char *data, qint64 len);
+
+ void dataReady();
+
+private:
+ SymbianAudioInput *const m_audioDevice;
+};
+
+class SymbianAudioInput
+ : public QAbstractAudioInput
+ , public MDevSoundObserver
+{
+ friend class SymbianAudioInputPrivate;
+ Q_OBJECT
+public:
+ SymbianAudioInput(const QByteArray &device,
+ const QAudioFormat &audioFormat);
+ ~SymbianAudioInput();
+
+ // QAbstractAudioInput
+ QIODevice* start(QIODevice *device = 0);
+ void stop();
+ void reset();
+ void suspend();
+ void resume();
+ int bytesReady() const;
+ int periodSize() const;
+ void setBufferSize(int value);
+ int bufferSize() const;
+ void setNotifyInterval(int milliSeconds);
+ int notifyInterval() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
+ QAudio::Error error() const;
+ QAudio::State state() const;
+ QAudioFormat format() const;
+
+ // MDevSoundObserver
+ void InitializeComplete(TInt aError);
+ void ToneFinished(TInt aError);
+ void BufferToBeFilled(CMMFBuffer *aBuffer);
+ void PlayError(TInt aError);
+ void BufferToBeEmptied(CMMFBuffer *aBuffer);
+ void RecordError(TInt aError);
+ void ConvertError(TInt aError);
+ void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg);
+
+private slots:
+ void pullData();
+
+private:
+ void open();
+ void startRecording();
+ void startDevSoundL();
+ void startDataTransfer();
+ CMMFDataBuffer* currentBuffer() const;
+ void pushData();
+ qint64 read(char *data, qint64 len);
+ void bufferEmptied();
+ Q_INVOKABLE void close();
+
+ qint64 getSamplesRecorded() const;
+
+ void setError(QAudio::Error error);
+ void setState(SymbianAudio::State state);
+
+ QAudio::State initializingState() const;
+
+private:
+ const QByteArray m_device;
+ const QAudioFormat m_format;
+
+ int m_clientBufferSize;
+ int m_notifyInterval;
+ QScopedPointer<QTimer> m_notifyTimer;
+ QTime m_elapsed;
+ QAudio::Error m_error;
+
+ SymbianAudio::State m_internalState;
+ QAudio::State m_externalState;
+
+ bool m_pullMode;
+ QIODevice *m_sink;
+
+ QScopedPointer<QTimer> m_pullTimer;
+
+ QScopedPointer<CMMFDevSound> m_devSound;
+ TUint32 m_nativeFourCC;
+ TMMFCapabilities m_nativeFormat;
+
+ // Latest buffer provided by DevSound, to be empied of data.
+ CMMFDataBuffer *m_devSoundBuffer;
+
+ int m_devSoundBufferSize;
+
+ // Total amount of data in buffers provided by DevSound
+ int m_totalBytesReady;
+
+ // Queue of buffers returned after call to CMMFDevSound::Pause().
+ QList<CMMFDataBuffer *> m_devSoundBufferQ;
+
+ // Current read position within m_devSoundBuffer
+ qint64 m_devSoundBufferPos;
+
+ // Samples recorded up to the last call to suspend(). It is necessary
+ // to cache this because suspend() is implemented using
+ // CMMFDevSound::Stop(), which resets DevSound's SamplesRecorded() counter.
+ quint32 m_totalSamplesRecorded;
+
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/audio/symbian/symbianaudiooutput.cpp b/src/plugins/audio/symbian/symbianaudiooutput.cpp
new file mode 100644
index 0000000..385e169
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudiooutput.cpp
@@ -0,0 +1,697 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "symbianaudiooutput.h"
+#include "symbianaudioutils.h"
+
+QT_BEGIN_NAMESPACE
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+
+const int UnderflowTimerInterval = 50; // ms
+
+
+//-----------------------------------------------------------------------------
+// Private class
+//-----------------------------------------------------------------------------
+
+SymbianAudioOutputPrivate::SymbianAudioOutputPrivate(
+ SymbianAudioOutput *audioDevice)
+ : m_audioDevice(audioDevice)
+{
+
+}
+
+SymbianAudioOutputPrivate::~SymbianAudioOutputPrivate()
+{
+
+}
+
+qint64 SymbianAudioOutputPrivate::readData(char *data, qint64 len)
+{
+ Q_UNUSED(data)
+ Q_UNUSED(len)
+ return 0;
+}
+
+qint64 SymbianAudioOutputPrivate::writeData(const char *data, qint64 len)
+{
+ qint64 totalWritten = 0;
+
+ if (m_audioDevice->state() == QAudio::ActiveState ||
+ m_audioDevice->state() == QAudio::IdleState) {
+
+ while (totalWritten < len) {
+ const qint64 written = m_audioDevice->pushData(data + totalWritten,
+ len - totalWritten);
+ if (written > 0)
+ totalWritten += written;
+ else
+ break;
+ }
+ }
+
+ return totalWritten;
+}
+
+
+//-----------------------------------------------------------------------------
+// Public functions
+//-----------------------------------------------------------------------------
+
+SymbianAudioOutput::SymbianAudioOutput(const QByteArray &device,
+ const QAudioFormat &format)
+ : m_device(device)
+ , m_format(format)
+ , m_clientBufferSize(SymbianAudio::DefaultBufferSize)
+ , m_notifyInterval(SymbianAudio::DefaultNotifyInterval)
+ , m_notifyTimer(new QTimer(this))
+ , m_error(QAudio::NoError)
+ , m_internalState(SymbianAudio::ClosedState)
+ , m_externalState(QAudio::StoppedState)
+ , m_pullMode(false)
+ , m_source(0)
+ , m_devSoundBuffer(0)
+ , m_devSoundBufferSize(0)
+ , m_bytesWritten(0)
+ , m_pushDataReady(false)
+ , m_bytesPadding(0)
+ , m_underflow(false)
+ , m_lastBuffer(false)
+ , m_underflowTimer(new QTimer(this))
+ , m_samplesPlayed(0)
+ , m_totalSamplesPlayed(0)
+{
+ connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify()));
+
+ SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC,
+ m_nativeFormat);
+
+ m_underflowTimer->setInterval(UnderflowTimerInterval);
+ connect(m_underflowTimer.data(), SIGNAL(timeout()), this,
+ SLOT(underflowTimerExpired()));
+}
+
+SymbianAudioOutput::~SymbianAudioOutput()
+{
+ close();
+}
+
+QIODevice* SymbianAudioOutput::start(QIODevice *device)
+{
+ stop();
+
+ // We have to set these before the call to open() because of the
+ // logic in initializingState()
+ if (device) {
+ m_pullMode = true;
+ m_source = device;
+ }
+
+ open();
+
+ if (SymbianAudio::ClosedState != m_internalState) {
+ if (device) {
+ connect(m_source, SIGNAL(readyRead()), this, SLOT(dataReady()));
+ } else {
+ m_source = new SymbianAudioOutputPrivate(this);
+ m_source->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
+ }
+
+ m_elapsed.restart();
+ }
+
+ return m_source;
+}
+
+void SymbianAudioOutput::stop()
+{
+ close();
+}
+
+void SymbianAudioOutput::reset()
+{
+ m_totalSamplesPlayed += getSamplesPlayed();
+ m_devSound->Stop();
+ m_bytesPadding = 0;
+ startPlayback();
+}
+
+void SymbianAudioOutput::suspend()
+{
+ if (SymbianAudio::ActiveState == m_internalState
+ || SymbianAudio::IdleState == m_internalState) {
+ m_notifyTimer->stop();
+ m_underflowTimer->stop();
+
+ const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples(
+ m_format, m_bytesWritten);
+ m_bytesWritten = 0;
+
+ const qint64 samplesPlayed = getSamplesPlayed();
+
+ // CMMFDevSound::Pause() is not guaranteed to work correctly in all
+ // implementations, for play-mode DevSound sessions. We therefore
+ // have to implement suspend() by calling CMMFDevSound::Stop().
+ // Because this causes buffered data to be dropped, we replace the
+ // lost data with silence following a call to resume(), in order to
+ // ensure that processedUSecs() returns the correct value.
+ m_devSound->Stop();
+ m_totalSamplesPlayed += samplesPlayed;
+
+ // Calculate the amount of data dropped
+ const qint64 paddingSamples = samplesWritten - samplesPlayed;
+ m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format,
+ paddingSamples);
+
+ setState(SymbianAudio::SuspendedState);
+ }
+}
+
+void SymbianAudioOutput::resume()
+{
+ if (SymbianAudio::SuspendedState == m_internalState)
+ startPlayback();
+}
+
+int SymbianAudioOutput::bytesFree() const
+{
+ int result = 0;
+ if (m_devSoundBuffer) {
+ const TDes8 &outputBuffer = m_devSoundBuffer->Data();
+ result = outputBuffer.MaxLength() - outputBuffer.Length();
+ }
+ return result;
+}
+
+int SymbianAudioOutput::periodSize() const
+{
+ return bufferSize();
+}
+
+void SymbianAudioOutput::setBufferSize(int value)
+{
+ // Note that DevSound does not allow its client to specify the buffer size.
+ // This functionality is available via custom interfaces, but since these
+ // cannot be guaranteed to work across all DevSound implementations, we
+ // do not use them here.
+ // In order to comply with the expected bevahiour of QAudioOutput, we store
+ // the value and return it from bufferSize(), but the underlying DevSound
+ // buffer size remains unchanged.
+ if (value > 0)
+ m_clientBufferSize = value;
+}
+
+int SymbianAudioOutput::bufferSize() const
+{
+ return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize;
+}
+
+void SymbianAudioOutput::setNotifyInterval(int ms)
+{
+ if (ms > 0) {
+ const int oldNotifyInterval = m_notifyInterval;
+ m_notifyInterval = ms;
+ if (m_notifyTimer->isActive() && ms != oldNotifyInterval)
+ m_notifyTimer->start(m_notifyInterval);
+ }
+}
+
+int SymbianAudioOutput::notifyInterval() const
+{
+ return m_notifyInterval;
+}
+
+qint64 SymbianAudioOutput::processedUSecs() const
+{
+ int samplesPlayed = 0;
+ if (m_devSound && SymbianAudio::SuspendedState != m_internalState)
+ samplesPlayed = getSamplesPlayed();
+
+ // Protect against division by zero
+ Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency");
+
+ const qint64 result = qint64(1000000) *
+ (samplesPlayed + m_totalSamplesPlayed)
+ / m_format.frequency();
+
+ return result;
+}
+
+qint64 SymbianAudioOutput::elapsedUSecs() const
+{
+ const qint64 result = (QAudio::StoppedState == state()) ?
+ 0 : m_elapsed.elapsed() * 1000;
+ return result;
+}
+
+QAudio::Error SymbianAudioOutput::error() const
+{
+ return m_error;
+}
+
+QAudio::State SymbianAudioOutput::state() const
+{
+ return m_externalState;
+}
+
+QAudioFormat SymbianAudioOutput::format() const
+{
+ return m_format;
+}
+
+//-----------------------------------------------------------------------------
+// MDevSoundObserver implementation
+//-----------------------------------------------------------------------------
+
+void SymbianAudioOutput::InitializeComplete(TInt aError)
+{
+ Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState,
+ Q_FUNC_INFO, "Invalid state");
+
+ if (KErrNone == aError)
+ startPlayback();
+}
+
+void SymbianAudioOutput::ToneFinished(TInt aError)
+{
+ Q_UNUSED(aError)
+ // This class doesn't use DevSound's tone playback functions, so should
+ // never receive this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioOutput::BufferToBeFilled(CMMFBuffer *aBuffer)
+{
+ // Following receipt of this callback, DevSound should not provide another
+ // buffer until we have returned the current one.
+ Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held");
+
+ // Will be returned to DevSound by bufferFilled().
+ m_devSoundBuffer = static_cast<CMMFDataBuffer*>(aBuffer);
+
+ if (!m_devSoundBufferSize)
+ m_devSoundBufferSize = m_devSoundBuffer->Data().MaxLength();
+
+ writePaddingData();
+
+ if (m_pullMode && isDataReady() && !m_bytesPadding)
+ pullData();
+}
+
+void SymbianAudioOutput::PlayError(TInt aError)
+{
+ switch (aError) {
+ case KErrUnderflow:
+ m_underflow = true;
+ if (m_pullMode && !m_lastBuffer)
+ setError(QAudio::UnderrunError);
+ else
+ setState(SymbianAudio::IdleState);
+ break;
+ default:
+ setError(QAudio::IOError);
+ break;
+ }
+}
+
+void SymbianAudioOutput::BufferToBeEmptied(CMMFBuffer *aBuffer)
+{
+ Q_UNUSED(aBuffer)
+ // This class doesn't use DevSound in record mode, so should never receive
+ // this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioOutput::RecordError(TInt aError)
+{
+ Q_UNUSED(aError)
+ // This class doesn't use DevSound in record mode, so should never receive
+ // this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioOutput::ConvertError(TInt aError)
+{
+ Q_UNUSED(aError)
+ // This class doesn't use DevSound's format conversion functions, so
+ // should never receive this callback.
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback");
+}
+
+void SymbianAudioOutput::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg)
+{
+ Q_UNUSED(aMessageType)
+ Q_UNUSED(aMsg)
+ // Ignore this callback.
+}
+
+//-----------------------------------------------------------------------------
+// Private functions
+//-----------------------------------------------------------------------------
+
+void SymbianAudioOutput::dataReady()
+{
+ // Client-provided QIODevice has data ready to read.
+
+ Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO,
+ "readyRead signal received, but no data available");
+
+ if (!m_bytesPadding)
+ pullData();
+}
+
+void SymbianAudioOutput::underflowTimerExpired()
+{
+ const TInt samplesPlayed = getSamplesPlayed();
+ if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) {
+ setError(QAudio::UnderrunError);
+ } else {
+ m_samplesPlayed = samplesPlayed;
+ m_underflowTimer->start();
+ }
+}
+
+void SymbianAudioOutput::open()
+{
+ Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState,
+ Q_FUNC_INFO, "DevSound already opened");
+
+ QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) )
+
+ QScopedPointer<SymbianAudio::DevSoundCapabilities> caps(
+ new SymbianAudio::DevSoundCapabilities(*m_devSound,
+ QAudio::AudioOutput));
+
+ int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ?
+ KErrNone : KErrNotSupported;
+
+ if (KErrNone == err) {
+ setState(SymbianAudio::InitializingState);
+ TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC,
+ EMMFStatePlaying));
+ }
+
+ if (KErrNone != err) {
+ setError(QAudio::OpenError);
+ m_devSound.reset();
+ }
+}
+
+void SymbianAudioOutput::startPlayback()
+{
+ TRAPD(err, startDevSoundL());
+ if (KErrNone == err) {
+ if (isDataReady())
+ setState(SymbianAudio::ActiveState);
+ else
+ setState(SymbianAudio::IdleState);
+
+ m_notifyTimer->start(m_notifyInterval);
+ m_underflow = false;
+
+ Q_ASSERT(m_devSound->SamplesPlayed() == 0);
+
+ writePaddingData();
+
+ if (m_pullMode && m_source->bytesAvailable() && !m_bytesPadding)
+ dataReady();
+ } else {
+ setError(QAudio::OpenError);
+ close();
+ }
+}
+
+void SymbianAudioOutput::startDevSoundL()
+{
+ TMMFCapabilities nativeFormat = m_devSound->Config();
+ m_nativeFormat.iBufferSize = nativeFormat.iBufferSize;
+ m_devSound->SetConfigL(m_nativeFormat);
+ m_devSound->PlayInitL();
+}
+
+void SymbianAudioOutput::writePaddingData()
+{
+ // See comments in suspend()
+
+ while (m_devSoundBuffer && m_bytesPadding) {
+ if (SymbianAudio::IdleState == m_internalState)
+ setState(SymbianAudio::ActiveState);
+
+ TDes8 &outputBuffer = m_devSoundBuffer->Data();
+ const qint64 outputBytes = bytesFree();
+ const qint64 paddingBytes = outputBytes < m_bytesPadding ?
+ outputBytes : m_bytesPadding;
+ unsigned char *ptr = const_cast<unsigned char*>(outputBuffer.Ptr());
+ Mem::FillZ(ptr, paddingBytes);
+ outputBuffer.SetLength(outputBuffer.Length() + paddingBytes);
+ m_bytesPadding -= paddingBytes;
+
+ if (m_pullMode && m_source->atEnd())
+ lastBufferFilled();
+ if (paddingBytes == outputBytes)
+ bufferFilled();
+ }
+}
+
+qint64 SymbianAudioOutput::pushData(const char *data, qint64 len)
+{
+ // Data has been written to SymbianAudioOutputPrivate
+
+ Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO,
+ "pushData called when in pull mode");
+
+ const unsigned char *const inputPtr =
+ reinterpret_cast<const unsigned char*>(data);
+ qint64 bytesWritten = 0;
+
+ if (SymbianAudio::IdleState == m_internalState)
+ setState(SymbianAudio::ActiveState);
+
+ while (m_devSoundBuffer && (bytesWritten < len)) {
+ // writePaddingData() is called from BufferToBeFilled(), so we should
+ // never have any padding data left at this point.
+ Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO,
+ "Padding bytes remaining in pushData");
+
+ TDes8 &outputBuffer = m_devSoundBuffer->Data();
+
+ const qint64 outputBytes = bytesFree();
+ const qint64 inputBytes = len - bytesWritten;
+ const qint64 copyBytes = outputBytes < inputBytes ?
+ outputBytes : inputBytes;
+
+ outputBuffer.Append(inputPtr + bytesWritten, copyBytes);
+ bytesWritten += copyBytes;
+
+ bufferFilled();
+ }
+
+ m_pushDataReady = (bytesWritten < len);
+
+ // If DevSound is still initializing (m_internalState == InitializingState),
+ // we cannot transition m_internalState to ActiveState, but we must emit
+ // an (external) state change from IdleState to ActiveState. The following
+ // call triggers this signal.
+ setState(m_internalState);
+
+ return bytesWritten;
+}
+
+void SymbianAudioOutput::pullData()
+{
+ Q_ASSERT_X(m_pullMode, Q_FUNC_INFO,
+ "pullData called when in push mode");
+
+ if (m_bytesPadding)
+ m_bytesPadding = 1;
+
+ // writePaddingData() is called by BufferToBeFilled() before pullData(),
+ // so we should never have any padding data left at this point.
+ Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO,
+ "Padding bytes remaining in pullData");
+
+ qint64 inputBytes = m_source->bytesAvailable();
+ while (m_devSoundBuffer && inputBytes) {
+ if (SymbianAudio::IdleState == m_internalState)
+ setState(SymbianAudio::ActiveState);
+
+ TDes8 &outputBuffer = m_devSoundBuffer->Data();
+
+ const qint64 outputBytes = bytesFree();
+ const qint64 copyBytes = outputBytes < inputBytes ?
+ outputBytes : inputBytes;
+
+ char *outputPtr = (char*)(outputBuffer.Ptr() + outputBuffer.Length());
+ const qint64 bytesCopied = m_source->read(outputPtr, copyBytes);
+ Q_ASSERT(bytesCopied == copyBytes);
+ outputBuffer.SetLength(outputBuffer.Length() + bytesCopied);
+ inputBytes -= bytesCopied;
+
+ if (m_source->atEnd())
+ lastBufferFilled();
+ else if (copyBytes == outputBytes)
+ bufferFilled();
+ }
+}
+
+void SymbianAudioOutput::bufferFilled()
+{
+ Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to return");
+
+ const TDes8 &outputBuffer = m_devSoundBuffer->Data();
+ m_bytesWritten += outputBuffer.Length();
+
+ m_devSoundBuffer = 0;
+
+ m_samplesPlayed = getSamplesPlayed();
+ m_underflowTimer->start();
+
+ if (QAudio::UnderrunError == m_error)
+ m_error = QAudio::NoError;
+
+ m_devSound->PlayData();
+}
+
+void SymbianAudioOutput::lastBufferFilled()
+{
+ Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to fill");
+ Q_ASSERT_X(!m_lastBuffer, Q_FUNC_INFO, "Last buffer already sent");
+ m_lastBuffer = true;
+ m_devSoundBuffer->SetLastBuffer(ETrue);
+ bufferFilled();
+}
+
+void SymbianAudioOutput::close()
+{
+ m_notifyTimer->stop();
+ m_underflowTimer->stop();
+
+ m_error = QAudio::NoError;
+
+ if (m_devSound)
+ m_devSound->Stop();
+ m_devSound.reset();
+ m_devSoundBuffer = 0;
+ m_devSoundBufferSize = 0;
+
+ if (!m_pullMode) // m_source is owned
+ delete m_source;
+ m_pullMode = false;
+ m_source = 0;
+
+ m_bytesWritten = 0;
+ m_pushDataReady = false;
+ m_bytesPadding = 0;
+ m_underflow = false;
+ m_lastBuffer = false;
+ m_samplesPlayed = 0;
+ m_totalSamplesPlayed = 0;
+
+ setState(SymbianAudio::ClosedState);
+}
+
+qint64 SymbianAudioOutput::getSamplesPlayed() const
+{
+ qint64 result = 0;
+ if (m_devSound) {
+ const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples(
+ m_format, m_bytesWritten);
+
+ if (m_underflow) {
+ result = samplesWritten;
+ } else {
+ // This is necessary because some DevSound implementations report
+ // that they have played more data than has actually been provided to them
+ // by the client.
+ const qint64 devSoundSamplesPlayed(m_devSound->SamplesPlayed());
+ result = qMin(devSoundSamplesPlayed, samplesWritten);
+ }
+ }
+ return result;
+}
+
+void SymbianAudioOutput::setError(QAudio::Error error)
+{
+ m_error = error;
+
+ // Although no state transition actually occurs here, a stateChanged event
+ // must be emitted to inform the client that the call to start() was
+ // unsuccessful.
+ if (QAudio::OpenError == error)
+ emit stateChanged(QAudio::StoppedState);
+
+ if (QAudio::UnderrunError == error)
+ setState(SymbianAudio::IdleState);
+ else
+ // Close the DevSound instance. This causes a transition to
+ // StoppedState. This must be done asynchronously in case the
+ // current function was called from a DevSound event handler, in which
+ // case deleting the DevSound instance may cause an exception.
+ QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
+}
+
+void SymbianAudioOutput::setState(SymbianAudio::State newInternalState)
+{
+ const QAudio::State oldExternalState = m_externalState;
+ m_internalState = newInternalState;
+ m_externalState = SymbianAudio::Utils::stateNativeToQt(
+ m_internalState, initializingState());
+
+ if (m_externalState != oldExternalState)
+ emit stateChanged(m_externalState);
+}
+
+bool SymbianAudioOutput::isDataReady() const
+{
+ return (m_source && m_source->bytesAvailable())
+ || m_bytesPadding
+ || m_pushDataReady;
+}
+
+QAudio::State SymbianAudioOutput::initializingState() const
+{
+ return isDataReady() ? QAudio::ActiveState : QAudio::IdleState;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/audio/symbian/symbianaudiooutput.h b/src/plugins/audio/symbian/symbianaudiooutput.h
new file mode 100644
index 0000000..8994e46
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudiooutput.h
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBIANAUDIOOUTPUT_H
+#define SYMBIANAUDIOOUTPUT_H
+
+#include <QtMultimedia/qaudioengine.h>
+#include <QTime>
+#include <QTimer>
+#include <sounddevice.h>
+#include "symbianaudio.h"
+
+QT_BEGIN_NAMESPACE
+
+class SymbianAudioOutput;
+
+class SymbianAudioOutputPrivate : public QIODevice
+{
+ friend class SymbianAudioOutput;
+ Q_OBJECT
+public:
+ SymbianAudioOutputPrivate(SymbianAudioOutput *audio);
+ ~SymbianAudioOutputPrivate();
+
+ qint64 readData(char *data, qint64 len);
+ qint64 writeData(const char *data, qint64 len);
+
+private:
+ SymbianAudioOutput *const m_audioDevice;
+};
+
+class SymbianAudioOutput
+ : public QAbstractAudioOutput
+ , public MDevSoundObserver
+{
+ friend class SymbianAudioOutputPrivate;
+ Q_OBJECT
+public:
+ SymbianAudioOutput(const QByteArray &device,
+ const QAudioFormat &audioFormat);
+ ~SymbianAudioOutput();
+
+ // QAbstractAudioOutput
+ QIODevice* start(QIODevice *device = 0);
+ void stop();
+ void reset();
+ void suspend();
+ void resume();
+ int bytesFree() const;
+ int periodSize() const;
+ void setBufferSize(int value);
+ int bufferSize() const;
+ void setNotifyInterval(int milliSeconds);
+ int notifyInterval() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
+ QAudio::Error error() const;
+ QAudio::State state() const;
+ QAudioFormat format() const;
+
+ // MDevSoundObserver
+ void InitializeComplete(TInt aError);
+ void ToneFinished(TInt aError);
+ void BufferToBeFilled(CMMFBuffer *aBuffer);
+ void PlayError(TInt aError);
+ void BufferToBeEmptied(CMMFBuffer *aBuffer);
+ void RecordError(TInt aError);
+ void ConvertError(TInt aError);
+ void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg);
+
+private slots:
+ void dataReady();
+ void underflowTimerExpired();
+
+private:
+ void open();
+ void startPlayback();
+ void startDevSoundL();
+ void writePaddingData();
+ qint64 pushData(const char *data, qint64 len);
+ void pullData();
+ void bufferFilled();
+ void lastBufferFilled();
+ Q_INVOKABLE void close();
+
+ qint64 getSamplesPlayed() const;
+
+ void setError(QAudio::Error error);
+ void setState(SymbianAudio::State state);
+
+ bool isDataReady() const;
+ QAudio::State initializingState() const;
+
+private:
+ const QByteArray m_device;
+ const QAudioFormat m_format;
+
+ int m_clientBufferSize;
+ int m_notifyInterval;
+ QScopedPointer<QTimer> m_notifyTimer;
+ QTime m_elapsed;
+ QAudio::Error m_error;
+
+ SymbianAudio::State m_internalState;
+ QAudio::State m_externalState;
+
+ bool m_pullMode;
+ QIODevice *m_source;
+
+ QScopedPointer<CMMFDevSound> m_devSound;
+ TUint32 m_nativeFourCC;
+ TMMFCapabilities m_nativeFormat;
+
+ // Buffer provided by DevSound, to be filled with data.
+ CMMFDataBuffer *m_devSoundBuffer;
+
+ int m_devSoundBufferSize;
+
+ // Number of bytes transferred from QIODevice to QAudioOutput. It is
+ // necessary to count this because data is dropped when suspend() is
+ // called. The difference between the position reported by DevSound and
+ // this value allows us to calculate m_bytesPadding;
+ quint32 m_bytesWritten;
+
+ // True if client has provided data while the audio subsystem was not
+ // ready to consume it.
+ bool m_pushDataReady;
+
+ // Number of zero bytes which will be written when client calls resume().
+ quint32 m_bytesPadding;
+
+ // True if PlayError(KErrUnderflow) has been called.
+ bool m_underflow;
+
+ // True if a buffer marked with the "last buffer" flag has been provided
+ // to DevSound.
+ bool m_lastBuffer;
+
+ // Some DevSound implementations ignore all underflow errors raised by the
+ // audio driver, unless the last buffer flag has been set by the client.
+ // In push-mode playback, this flag will never be set, so the underflow
+ // error will never be reported. In order to work around this, a timer
+ // is used, which gets reset every time the client provides more data. If
+ // the timer expires, an underflow error is raised by this object.
+ QScopedPointer<QTimer> m_underflowTimer;
+
+ // Result of previous call to CMMFDevSound::SamplesPlayed(). This value is
+ // used to determine whether, when m_underflowTimer expires, an
+ // underflow error has actually occurred.
+ quint32 m_samplesPlayed;
+
+ // Samples played up to the last call to suspend(). It is necessary
+ // to cache this because suspend() is implemented using
+ // CMMFDevSound::Stop(), which resets DevSound's SamplesPlayed() counter.
+ quint32 m_totalSamplesPlayed;
+
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/audio/symbian/symbianaudioutils.cpp b/src/plugins/audio/symbian/symbianaudioutils.cpp
new file mode 100644
index 0000000..f04c198
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudioutils.cpp
@@ -0,0 +1,395 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "symbianaudioutils.h"
+#include <mmffourcc.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace SymbianAudio {
+
+DevSoundCapabilities::DevSoundCapabilities(CMMFDevSound &devsound,
+ QAudio::Mode mode)
+{
+ QT_TRAP_THROWING(constructL(devsound, mode));
+}
+
+DevSoundCapabilities::~DevSoundCapabilities()
+{
+ m_fourCC.Close();
+}
+
+void DevSoundCapabilities::constructL(CMMFDevSound &devsound,
+ QAudio::Mode mode)
+{
+ m_caps = devsound.Capabilities();
+
+ TMMFPrioritySettings settings;
+
+ switch (mode) {
+ case QAudio::AudioOutput:
+ settings.iState = EMMFStatePlaying;
+ devsound.GetSupportedInputDataTypesL(m_fourCC, settings);
+ break;
+
+ case QAudio::AudioInput:
+ settings.iState = EMMFStateRecording;
+ devsound.GetSupportedInputDataTypesL(m_fourCC, settings);
+ break;
+
+ default:
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode");
+ }
+}
+
+namespace Utils {
+
+//-----------------------------------------------------------------------------
+// Static data
+//-----------------------------------------------------------------------------
+
+// Sample rate / frequency
+
+typedef TMMFSampleRate SampleRateNative;
+typedef int SampleRateQt;
+
+const int SampleRateCount = 12;
+
+const SampleRateNative SampleRateListNative[SampleRateCount] = {
+ EMMFSampleRate8000Hz
+ , EMMFSampleRate11025Hz
+ , EMMFSampleRate12000Hz
+ , EMMFSampleRate16000Hz
+ , EMMFSampleRate22050Hz
+ , EMMFSampleRate24000Hz
+ , EMMFSampleRate32000Hz
+ , EMMFSampleRate44100Hz
+ , EMMFSampleRate48000Hz
+ , EMMFSampleRate64000Hz
+ , EMMFSampleRate88200Hz
+ , EMMFSampleRate96000Hz
+};
+
+const SampleRateQt SampleRateListQt[SampleRateCount] = {
+ 8000
+ , 11025
+ , 12000
+ , 16000
+ , 22050
+ , 24000
+ , 32000
+ , 44100
+ , 48000
+ , 64000
+ , 88200
+ , 96000
+};
+
+// Channels
+
+typedef TMMFMonoStereo ChannelsNative;
+typedef int ChannelsQt;
+
+const int ChannelsCount = 2;
+
+const ChannelsNative ChannelsListNative[ChannelsCount] = {
+ EMMFMono
+ , EMMFStereo
+};
+
+const ChannelsQt ChannelsListQt[ChannelsCount] = {
+ 1
+ , 2
+};
+
+// Encoding
+
+const int EncodingCount = 6;
+
+const TUint32 EncodingFourCC[EncodingCount] = {
+ KMMFFourCCCodePCM8 // 0
+ , KMMFFourCCCodePCMU8 // 1
+ , KMMFFourCCCodePCM16 // 2
+ , KMMFFourCCCodePCMU16 // 3
+ , KMMFFourCCCodePCM16B // 4
+ , KMMFFourCCCodePCMU16B // 5
+};
+
+// The characterised DevSound API specification states that the iEncoding
+// field in TMMFCapabilities is ignored, and that the FourCC should be used
+// to specify the PCM encoding.
+// See "SGL.GT0287.102 Multimedia DevSound Baseline Compatibility.doc" in the
+// mm_info/mm_docs repository.
+const TMMFSoundEncoding EncodingNative[EncodingCount] = {
+ EMMFSoundEncoding16BitPCM // 0
+ , EMMFSoundEncoding16BitPCM // 1
+ , EMMFSoundEncoding16BitPCM // 2
+ , EMMFSoundEncoding16BitPCM // 3
+ , EMMFSoundEncoding16BitPCM // 4
+ , EMMFSoundEncoding16BitPCM // 5
+};
+
+
+const int EncodingSampleSize[EncodingCount] = {
+ 8 // 0
+ , 8 // 1
+ , 16 // 2
+ , 16 // 3
+ , 16 // 4
+ , 16 // 5
+};
+
+const QAudioFormat::Endian EncodingByteOrder[EncodingCount] = {
+ QAudioFormat::LittleEndian // 0
+ , QAudioFormat::LittleEndian // 1
+ , QAudioFormat::LittleEndian // 2
+ , QAudioFormat::LittleEndian // 3
+ , QAudioFormat::BigEndian // 4
+ , QAudioFormat::BigEndian // 5
+};
+
+const QAudioFormat::SampleType EncodingSampleType[EncodingCount] = {
+ QAudioFormat::SignedInt // 0
+ , QAudioFormat::UnSignedInt // 1
+ , QAudioFormat::SignedInt // 2
+ , QAudioFormat::UnSignedInt // 3
+ , QAudioFormat::SignedInt // 4
+ , QAudioFormat::UnSignedInt // 5
+};
+
+
+//-----------------------------------------------------------------------------
+// Private functions
+//-----------------------------------------------------------------------------
+
+// Helper functions for implementing parameter conversions
+
+template<typename Input>
+bool findValue(const Input *inputArray, int length, Input input, int &index) {
+ bool result = false;
+ for (int i=0; !result && i<length; ++i)
+ if (inputArray[i] == input) {
+ index = i;
+ result = true;
+ }
+ return result;
+}
+
+template<typename Input, typename Output>
+bool convertValue(const Input *inputArray, const Output *outputArray,
+ int length, Input input, Output &output) {
+ int index;
+ const bool result = findValue<Input>(inputArray, length, input, index);
+ if (result)
+ output = outputArray[index];
+ return result;
+}
+
+/**
+ * Macro which is used to generate the implementation of the conversion
+ * functions. The implementation is just a wrapper around the templated
+ * convertValue function, e.g.
+ *
+ * CONVERSION_FUNCTION_IMPL(SampleRate, Qt, Native)
+ *
+ * expands to
+ *
+ * bool SampleRateQtToNative(int input, TMMFSampleRate &output) {
+ * return convertValue<SampleRateQt, SampleRateNative>
+ * (SampleRateListQt, SampleRateListNative, SampleRateCount,
+ * input, output);
+ * }
+ */
+#define CONVERSION_FUNCTION_IMPL(FieldLc, Field, Input, Output) \
+bool FieldLc##Input##To##Output(Field##Input input, Field##Output &output) { \
+ return convertValue<Field##Input, Field##Output>(Field##List##Input, \
+ Field##List##Output, Field##Count, input, output); \
+}
+
+//-----------------------------------------------------------------------------
+// Local helper functions
+//-----------------------------------------------------------------------------
+
+CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Qt, Native)
+CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Native, Qt)
+CONVERSION_FUNCTION_IMPL(channels, Channels, Qt, Native)
+CONVERSION_FUNCTION_IMPL(channels, Channels, Native, Qt)
+
+bool sampleInfoQtToNative(int inputSampleSize,
+ QAudioFormat::Endian inputByteOrder,
+ QAudioFormat::SampleType inputSampleType,
+ TUint32 &outputFourCC,
+ TMMFSoundEncoding &outputEncoding) {
+
+ bool found = false;
+
+ for (int i=0; i<EncodingCount && !found; ++i) {
+ if ( EncodingSampleSize[i] == inputSampleSize
+ && EncodingByteOrder[i] == inputByteOrder
+ && EncodingSampleType[i] == inputSampleType) {
+ outputFourCC = EncodingFourCC[i];
+ outputEncoding = EncodingNative[i]; // EMMFSoundEncoding16BitPCM
+ found = true;
+ }
+ }
+
+ return found;
+}
+
+//-----------------------------------------------------------------------------
+// Public functions
+//-----------------------------------------------------------------------------
+
+void capabilitiesNativeToQt(const DevSoundCapabilities &caps,
+ QList<int> &frequencies,
+ QList<int> &channels,
+ QList<int> &sampleSizes,
+ QList<QAudioFormat::Endian> &byteOrders,
+ QList<QAudioFormat::SampleType> &sampleTypes) {
+
+ frequencies.clear();
+ sampleSizes.clear();
+ byteOrders.clear();
+ sampleTypes.clear();
+ channels.clear();
+
+ for (int i=0; i<SampleRateCount; ++i)
+ if (caps.caps().iRate & SampleRateListNative[i])
+ frequencies += SampleRateListQt[i];
+
+ for (int i=0; i<ChannelsCount; ++i)
+ if (caps.caps().iChannels & ChannelsListNative[i])
+ channels += ChannelsListQt[i];
+
+ for (int i=0; i<EncodingCount; ++i) {
+ if (caps.fourCC().Find(EncodingFourCC[i]) != KErrNotFound) {
+ sampleSizes += EncodingSampleSize[i];
+ byteOrders += EncodingByteOrder[i];
+ sampleTypes += EncodingSampleType[i];
+ }
+ }
+
+}
+
+bool isFormatSupported(const QAudioFormat &formatQt,
+ const DevSoundCapabilities &caps) {
+ TMMFCapabilities formatNative;
+ TUint32 fourCC;
+
+ bool result = false;
+ if (formatQt.codec() == "audio/pcm" &&
+ formatQtToNative(formatQt, fourCC, formatNative)) {
+ result =
+ (formatNative.iRate & caps.caps().iRate)
+ && (formatNative.iChannels & caps.caps().iChannels)
+ && (caps.fourCC().Find(fourCC) != KErrNotFound);
+ }
+ return result;
+}
+
+bool formatQtToNative(const QAudioFormat &inputFormat,
+ TUint32 &outputFourCC,
+ TMMFCapabilities &outputFormat) {
+
+ bool result = false;
+
+ // Need to use temporary variables because TMMFCapabilities fields are all
+ // TInt, rather than MMF enumerated types.
+ TMMFSampleRate outputSampleRate;
+ TMMFMonoStereo outputChannels;
+ TMMFSoundEncoding outputEncoding;
+
+ if (inputFormat.codec() == "audio/pcm") {
+ result =
+ sampleRateQtToNative(inputFormat.frequency(), outputSampleRate)
+ && channelsQtToNative(inputFormat.channels(), outputChannels)
+ && sampleInfoQtToNative(inputFormat.sampleSize(),
+ inputFormat.byteOrder(),
+ inputFormat.sampleType(),
+ outputFourCC,
+ outputEncoding);
+ }
+
+ if (result) {
+ outputFormat.iRate = outputSampleRate;
+ outputFormat.iChannels = outputChannels;
+ outputFormat.iEncoding = outputEncoding;
+ }
+
+ return result;
+}
+
+QAudio::State stateNativeToQt(State nativeState,
+ QAudio::State initializingState)
+{
+ switch (nativeState) {
+ case ClosedState:
+ return QAudio::StoppedState;
+ case InitializingState:
+ return initializingState;
+ case ActiveState:
+ return QAudio::ActiveState;
+ case IdleState:
+ return QAudio::IdleState;
+ case SuspendedState:
+ return QAudio::SuspendedState;
+ default:
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid state");
+ return QAudio::StoppedState; // suppress compiler warning
+ }
+}
+
+qint64 bytesToSamples(const QAudioFormat &format, qint64 length)
+{
+ return length / ((format.sampleSize() / 8) * format.channels());
+}
+
+qint64 samplesToBytes(const QAudioFormat &format, qint64 samples)
+{
+ return samples * (format.sampleSize() / 8) * format.channels();
+}
+
+} // namespace Utils
+} // namespace SymbianAudio
+
+QT_END_NAMESPACE
+
+
diff --git a/src/plugins/audio/symbian/symbianaudioutils.h b/src/plugins/audio/symbian/symbianaudioutils.h
new file mode 100644
index 0000000..53274e0
--- /dev/null
+++ b/src/plugins/audio/symbian/symbianaudioutils.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBIANAUDIOUTILS_H
+#define SYMBIANAUDIOUTILS_H
+
+#include <QtCore/qnamespace.h>
+#include <QtMultimedia/qaudioformat.h>
+#include <QtMultimedia/qaudio.h>
+#include <sounddevice.h>
+#include "symbianaudio.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace SymbianAudio {
+
+/*
+ * Helper class for querying DevSound codec / format support
+ */
+class DevSoundCapabilities {
+public:
+ DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode);
+ ~DevSoundCapabilities();
+
+ const RArray<TFourCC>& fourCC() const { return m_fourCC; }
+ const TMMFCapabilities& caps() const { return m_caps; }
+
+private:
+ void constructL(CMMFDevSound &devsound, QAudio::Mode mode);
+
+private:
+ RArray<TFourCC> m_fourCC;
+ TMMFCapabilities m_caps;
+};
+
+namespace Utils {
+
+/**
+ * Convert native audio capabilities to QAudio lists.
+ */
+void capabilitiesNativeToQt(const DevSoundCapabilities &caps,
+ QList<int> &frequencies,
+ QList<int> &channels,
+ QList<int> &sampleSizes,
+ QList<QAudioFormat::Endian> &byteOrders,
+ QList<QAudioFormat::SampleType> &sampleTypes);
+
+/**
+ * Check whether format is supported.
+ */
+bool isFormatSupported(const QAudioFormat &format,
+ const DevSoundCapabilities &caps);
+
+/**
+ * Convert QAudioFormat to native format types.
+ *
+ * Note that, despite the name, DevSound uses TMMFCapabilities to specify
+ * single formats as well as capabilities.
+ *
+ * Note that this function does not modify outputFormat.iBufferSize.
+ */
+bool formatQtToNative(const QAudioFormat &inputFormat,
+ TUint32 &outputFourCC,
+ TMMFCapabilities &outputFormat);
+
+/**
+ * Convert internal states to QAudio states.
+ */
+QAudio::State stateNativeToQt(State nativeState,
+ QAudio::State initializingState);
+
+/**
+ * Convert data length to number of samples.
+ */
+qint64 bytesToSamples(const QAudioFormat &format, qint64 length);
+
+/**
+ * Convert number of samples to data length.
+ */
+qint64 samplesToBytes(const QAudioFormat &format, qint64 samples);
+
+} // namespace Utils
+} // namespace SymbianAudio
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qbase.pri b/src/qbase.pri
index db55365..6f2dfa4 100644
--- a/src/qbase.pri
+++ b/src/qbase.pri
@@ -108,6 +108,10 @@ symbian {
}
}
load(armcc_warnings)
+
+ # workaround for the fact that some of our required includes in Symbian^3
+ # now depend upon files in epoc32/include/platform
+ INCLUDEPATH += $$OS_LAYER_SYSTEMINCLUDE
}
win32-borland:INCLUDEPATH += kernel
diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby
index a6a96ec..724451b 100644
--- a/src/s60installs/qt.iby
+++ b/src/s60installs/qt.iby
@@ -80,6 +80,9 @@ file=ABI_DIR\BUILD_DIR\qsvgicon.dll SHARED_LIB_DIR\qsvgicon.dll PAG
// Phonon MMF backend
file=ABI_DIR\BUILD_DIR\phonon_mmf.dll SHARED_LIB_DIR\phonon_mmf.dll PAGED
+// QtMultimedia audio backend
+file=ABI_DIR\BUILD_DIR\qaudio.dll SHARED_LIB_DIR\qaudio.dll PAGED
+
// graphicssystems
file=ABI_DIR\BUILD_DIR\qvggraphicssystem.dll SHARED_LIB_DIR\qvggraphicssystem.dll PAGED
@@ -109,6 +112,9 @@ data=\epoc32\data\z\resource\qt\plugins\iconengines\qsvgicon.qtplugin resou
// Phonon MMF backend
data=\epoc32\data\z\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin
+// QtMultimedia audio backend
+data=\epoc32\data\qt\qtlibspluginstubs\qaudio.qtplugin resource\qt\plugins\audio\qaudio.qtplugin
+
// graphicssystems
data=\epoc32\data\z\resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin
diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro
index 5318693..1f3b4a6 100644
--- a/src/s60installs/s60installs.pro
+++ b/src/s60installs/s60installs.pro
@@ -78,6 +78,12 @@ symbian: {
DEPLOYMENT += phonon_backend_plugins
}
+ contains(QT_CONFIG, audio-backend) {
+ qaudio_backend_plugins.sources += qaudio.dll
+ qaudio_backend_plugins.path = c:$$QT_PLUGINS_BASE_DIR/audio
+ DEPLOYMENT += qaudio_backend_plugins
+ }
+
# Support backup & restore for Qt libraries
qtbackup.sources = backup_registration.xml
qtbackup.path = c:/private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,)
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 1bd7377..1199263 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -768,7 +768,7 @@ static QScriptValue __setupPackage__(QScriptContext *ctx, QScriptEngine *eng)
} // namespace QScript
QScriptEnginePrivate::QScriptEnginePrivate()
- : registeredScriptValues(0), freeScriptValues(0),
+ : registeredScriptValues(0), freeScriptValues(0), freeScriptValuesCount(0),
registeredScriptStrings(0), inEval(false)
{
qMetaTypeId<QScriptValue>();
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 6780b2c..401d6d2 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -255,6 +255,8 @@ public:
int agentLineNumber;
QScriptValuePrivate *registeredScriptValues;
QScriptValuePrivate *freeScriptValues;
+ static const int maxFreeScriptValues = 256;
+ int freeScriptValuesCount;
QScriptStringPrivate *registeredScriptStrings;
QHash<int, QScriptTypeInfo*> m_typeInfos;
int processEventsInterval;
@@ -377,6 +379,7 @@ inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(siz
if (freeScriptValues) {
QScriptValuePrivate *p = freeScriptValues;
freeScriptValues = p->next;
+ --freeScriptValuesCount;
return p;
}
return reinterpret_cast<QScriptValuePrivate*>(qMalloc(size));
@@ -384,8 +387,13 @@ inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(siz
inline void QScriptEnginePrivate::freeScriptValuePrivate(QScriptValuePrivate *p)
{
- p->next = freeScriptValues;
- freeScriptValues = p;
+ if (freeScriptValuesCount < maxFreeScriptValues) {
+ p->next = freeScriptValues;
+ freeScriptValues = p;
+ ++freeScriptValuesCount;
+ } else {
+ qFree(p);
+ }
}
inline void QScriptEnginePrivate::registerScriptValue(QScriptValuePrivate *value)