diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-04-06 14:59:54 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-04-08 12:19:36 +0000 |
commit | 89de5fe956d32d68490b2ee29963ab18b651be0f (patch) | |
tree | 3e0e18e070503959310cb53723576982f0d6a606 | |
parent | 66c339928cde3e582d75ef8350d91f3359dd86a5 (diff) |
Get rid of QMediaPlayer::setCustomRole() and related
setAudioRole should be enough here. And if more roles
are required, let's rather extend the enum.
Change-Id: I40194171c6053ffa1d3adf309e77d85a8c6524e2
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
24 files changed, 52 insertions, 528 deletions
diff --git a/examples/multimediawidgets/player/main.cpp b/examples/multimediawidgets/player/main.cpp index cc4418a1d..49c82d877 100644 --- a/examples/multimediawidgets/player/main.cpp +++ b/examples/multimediawidgets/player/main.cpp @@ -64,21 +64,14 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationName("QtProject"); QCoreApplication::setApplicationVersion(QT_VERSION_STR); QCommandLineParser parser; - QCommandLineOption customAudioRoleOption("custom-audio-role", - "Set a custom audio role for the player.", - "role"); parser.setApplicationDescription("Qt MultiMedia Player Example"); parser.addHelpOption(); parser.addVersionOption(); - parser.addOption(customAudioRoleOption); parser.addPositionalArgument("url", "The URL(s) to open."); parser.process(app); Player player; - if (parser.isSet(customAudioRoleOption)) - player.setCustomAudioRole(parser.value(customAudioRoleOption)); - if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) { QList<QUrl> urls; for (auto &a: parser.positionalArguments()) diff --git a/examples/multimediawidgets/player/player.cpp b/examples/multimediawidgets/player/player.cpp index 3612c49c9..fbdac1263 100644 --- a/examples/multimediawidgets/player/player.cpp +++ b/examples/multimediawidgets/player/player.cpp @@ -284,11 +284,6 @@ void Player::addToPlaylist(const QList<QUrl> &urls) } } -void Player::setCustomAudioRole(const QString &role) -{ - m_player->setCustomAudioRole(role); -} - void Player::durationChanged(qint64 duration) { m_duration = duration / 1000; diff --git a/examples/multimediawidgets/player/player.h b/examples/multimediawidgets/player/player.h index 7385d27a9..9ccecb891 100644 --- a/examples/multimediawidgets/player/player.h +++ b/examples/multimediawidgets/player/player.h @@ -82,7 +82,6 @@ public: bool isPlayerAvailable() const; void addToPlaylist(const QList<QUrl> &urls); - void setCustomAudioRole(const QString &role); signals: void fullScreenChanged(bool fullScreen); diff --git a/src/imports/multimedia/Video.qml b/src/imports/multimedia/Video.qml index 7887ef7ce..45e0ec7e8 100644 --- a/src/imports/multimedia/Video.qml +++ b/src/imports/multimedia/Video.qml @@ -319,31 +319,13 @@ Item { \li MediaPlayer.AccessibilityRole - for accessibility, such as with a screen reader. \li MediaPlayer.SonificationRole - sonification, such as with user interface sounds. \li MediaPlayer.GameRole - game audio. - \li MediaPlayer.CustomRole - The role is specified by customAudioRole. \endlist - customAudioRole is cleared when this property is set to anything other than CustomRole. - \since 5.6 */ property alias audioRole: player.audioRole /*! - \qmlproperty string Video::customAudioRole - - This property holds the role of the audio stream when the backend supports audio roles - unknown to Qt. It can be set to specify the type of audio being played, allowing the - system to make appropriate decisions when it comes to volume, routing or post-processing. - - The audio role must be set before setting the source property. - - audioRole is set to CustomRole when this property is set. - - \since 5.11 - */ - property alias customAudioRole: player.customAudioRole - - /*! \qmlproperty bool Video::seekable This property holds whether the playback position of the video can be diff --git a/src/imports/multimedia/plugins.qmltypes b/src/imports/multimedia/plugins.qmltypes index 8074e380d..a386e73b0 100644 --- a/src/imports/multimedia/plugins.qmltypes +++ b/src/imports/multimedia/plugins.qmltypes @@ -427,7 +427,6 @@ Module { "UnknownRole": 0, "AccessibilityRole": 7, "AlarmRole": 4, - "CustomRole": 10, "GameRole": 9, "MusicRole": 1, "NotificationRole": 5, @@ -463,7 +462,6 @@ Module { } Property { name: "availability"; type: "Availability"; isReadonly: true } Property { name: "audioRole"; revision: 1; type: "AudioRole" } - Property { name: "customAudioRole"; revision: 3; type: "string" } Property { name: "notifyInterval"; revision: 2; type: "int" } Property { name: "videoOutput"; revision: 15; type: "QVariant" } Signal { name: "playlistChanged"; revision: 1 } @@ -472,7 +470,6 @@ Module { Signal { name: "stopped" } Signal { name: "playing" } Signal { name: "audioRoleChanged"; revision: 1 } - Signal { name: "customAudioRoleChanged"; revision: 3 } Signal { name: "error" Parameter { name: "error"; type: "QDeclarativeAudio::Error" } diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 998ca5f2b..1c83dfd83 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -210,11 +210,8 @@ bool QDeclarativeAudio::isAvailable() const \li AccessibilityRole - for accessibility, such as with a screen reader. \li SonificationRole - sonification, such as with user interface sounds. \li GameRole - game audio. - \li CustomRole - The role is specified by customAudioRole. \endlist - customAudioRole is cleared when this property is set to anything other than CustomRole. - \since 5.6 */ QDeclarativeAudio::AudioRole QDeclarativeAudio::audioRole() const @@ -230,49 +227,12 @@ void QDeclarativeAudio::setAudioRole(QDeclarativeAudio::AudioRole audioRole) if (m_complete) { m_player->setAudioRole(QAudio::Role(audioRole)); } else { - if (!m_customAudioRole.isEmpty()) { - m_customAudioRole.clear(); - emit customAudioRoleChanged(); - } m_audioRole = audioRole; emit audioRoleChanged(); } } /*! - \qmlproperty string QtMultimedia::Audio::customAudioRole - - This property holds the role of the audio stream when the backend supports audio - roles unknown to Qt. It can be set to specify the type of audio being played, - allowing the system to make appropriate decisions when it comes to volume, - routing or post-processing. - - The audio role must be set before setting the source property. - - audioRole is set to CustomRole when this property is set. - - \since 5.11 -*/ -QString QDeclarativeAudio::customAudioRole() const -{ - return !m_complete ? m_customAudioRole : m_player->customAudioRole(); -} - -void QDeclarativeAudio::setCustomAudioRole(const QString &audioRole) -{ - if (this->customAudioRole() == audioRole) - return; - - if (m_complete) { - m_player->setCustomAudioRole(audioRole); - } else { - setAudioRole(QDeclarativeAudio::CustomRole); - m_customAudioRole = audioRole; - emit customAudioRoleChanged(); - } -} - -/*! \qmlproperty int QtMultimedia::Audio::notifyInterval The interval at which notifiable properties will update. @@ -864,8 +824,6 @@ void QDeclarativeAudio::classBegin() this, SIGNAL(hasVideoChanged())); connect(m_player, SIGNAL(audioRoleChanged(QAudio::Role)), this, SIGNAL(audioRoleChanged())); - connect(m_player, SIGNAL(customAudioRoleChanged(const QString &)), - this, SIGNAL(customAudioRoleChanged())); connect(m_player, SIGNAL(notifyIntervalChanged(int)), this, SIGNAL(notifyIntervalChanged())); @@ -887,8 +845,6 @@ void QDeclarativeAudio::componentComplete() m_player->setPlaybackRate(m_playbackRate); if (m_audioRole != UnknownRole) m_player->setAudioRole(QAudio::Role(m_audioRole)); - if (!m_customAudioRole.isEmpty()) - m_player->setCustomAudioRole(m_customAudioRole); if (m_notifyInterval != m_player->notifyInterval()) m_player->setNotifyInterval(m_notifyInterval); @@ -1189,30 +1145,12 @@ void QDeclarativeAudio::_q_mediaChanged(const QUrl &) \li AccessibilityRole - for accessibility, such as with a screen reader. \li SonificationRole - sonification, such as with user interface sounds. \li GameRole - game audio. - \li CustomRole - The role is specified by customAudioRole. \endlist - customAudioRole is cleared when this property is set to anything other than CustomRole. - \since 5.6 */ /*! - \qmlproperty string QtMultimedia::MediaPlayer::customAudioRole - - This property holds the role of the audio stream when the backend supports audio - roles unknown to Qt. It can be set to specify the type of audio being played, - allowing the system to make appropriate decisions when it comes to volume, - routing or post-processing. - - The audio role must be set before setting the source property. - - audioRole is set to CustomRole when this property is set. - - \since 5.11 -*/ - -/*! \qmlmethod list<int> QtMultimedia::MediaPlayer::supportedAudioRoles() Returns a list of supported audio roles. diff --git a/src/imports/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h index 5f5944768..da6db0885 100644 --- a/src/imports/multimedia/qdeclarativeaudio_p.h +++ b/src/imports/multimedia/qdeclarativeaudio_p.h @@ -87,7 +87,6 @@ class QDeclarativeAudio : public QObject, public QQmlParserStatus Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) Q_PROPERTY(QDeclarativeMediaMetaData *metaData READ metaData CONSTANT) Q_PROPERTY(AudioRole audioRole READ audioRole WRITE setAudioRole NOTIFY audioRoleChanged REVISION 1) - Q_PROPERTY(QString customAudioRole READ customAudioRole WRITE setCustomAudioRole NOTIFY customAudioRoleChanged REVISION 3) Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged REVISION 2) Q_PROPERTY(QVariant videoOutput READ videoOutput WRITE setVideoOutput NOTIFY videoOutputChanged REVISION 15) Q_ENUMS(Status) @@ -136,7 +135,6 @@ public: UnknownRole = QAudio::UnknownRole, AccessibilityRole = QAudio::AccessibilityRole, AlarmRole = QAudio::AlarmRole, - CustomRole = QAudio::CustomRole, GameRole = QAudio::GameRole, MusicRole = QAudio::MusicRole, NotificationRole = QAudio::NotificationRole, @@ -167,8 +165,6 @@ public: AudioRole audioRole() const; void setAudioRole(AudioRole audioRole); - QString customAudioRole() const; - void setCustomAudioRole(const QString &audioRole); QUrl source() const; void setSource(const QUrl &url); @@ -241,7 +237,6 @@ Q_SIGNALS: void playbackRateChanged(); Q_REVISION(1) void audioRoleChanged(); - Q_REVISION(3) void customAudioRoleChanged(); void errorChanged(); void error(QDeclarativeAudio::Error error, const QString &errorString); @@ -268,7 +263,6 @@ private: qreal m_vol; qreal m_playbackRate; AudioRole m_audioRole; - QString m_customAudioRole; QMediaPlayer::State m_playbackState; QMediaPlayer::MediaStatus m_status; diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp index 55fe44e14..4b75f0127 100644 --- a/src/multimedia/audio/qaudio.cpp +++ b/src/multimedia/audio/qaudio.cpp @@ -104,7 +104,6 @@ QT_BEGIN_NAMESPACE \value AccessibilityRole For accessibility, such as with a screen reader \value SonificationRole Sonification, such as with user interface sounds \value GameRole Game audio - \value CustomRole The role is specified by QMediaPlayer::customAudioRole() \since 5.6 \sa QMediaPlayer::setAudioRole() @@ -337,9 +336,6 @@ QDebug operator<<(QDebug dbg, QAudio::Role role) case QAudio::VoiceCommunicationRole: dbg << "VoiceCommunicationRole"; break; - case QAudio::CustomRole: - dbg << "CustomRole"; - break; } return dbg; } diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h index 3b4696dfd..8e644a79f 100644 --- a/src/multimedia/audio/qaudio.h +++ b/src/multimedia/audio/qaudio.h @@ -68,7 +68,6 @@ namespace QAudio AccessibilityRole, SonificationRole, GameRole, - CustomRole }; enum VolumeScale { diff --git a/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol.cpp b/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol.cpp index 16dafc854..b1aaaf0ce 100644 --- a/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol.cpp +++ b/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol.cpp @@ -271,35 +271,6 @@ QList<QAudio::Role> QAndroidMediaPlayerControl::supportedAudioRoles() const << QAudio::GameRole; } -void QAndroidMediaPlayerControl::setCustomAudioRole(const QString &role) -{ - mMediaPlayer->setCustomAudioRole(role); -} - -QStringList QAndroidMediaPlayerControl::supportedCustomAudioRoles() const -{ - return QStringList() - << QLatin1String("CONTENT_TYPE_MOVIE") - << QLatin1String("CONTENT_TYPE_MUSIC") - << QLatin1String("CONTENT_TYPE_SONIFICATION") - << QLatin1String("CONTENT_TYPE_SPEECH") - << QLatin1String("USAGE_ALARM") - << QLatin1String("USAGE_ASSISTANCE_ACCESSIBILITY") - << QLatin1String("USAGE_ASSISTANCE_NAVIGATION_GUIDANCE") - << QLatin1String("USAGE_ASSISTANCE_SONIFICATION") - << QLatin1String("USAGE_ASSISTANT") - << QLatin1String("USAGE_GAME") - << QLatin1String("USAGE_MEDIA") - << QLatin1String("USAGE_NOTIFICATION") - << QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_DELAYED") - << QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_INSTANT") - << QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_REQUEST") - << QLatin1String("USAGE_NOTIFICATION_EVENT") - << QLatin1String("USAGE_NOTIFICATION_RINGTONE") - << QLatin1String("USAGE_VOICE_COMMUNICATION") - << QLatin1String("USAGE_VOICE_COMMUNICATION_SIGNALLING"); -} - QMediaMetaData QAndroidMediaPlayerControl::metaData() const { return QAndroidMetaData::extractMetadata(mMediaContent); diff --git a/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol_p.h b/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol_p.h index 12298d4d5..4f098bd86 100644 --- a/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol_p.h +++ b/src/multimedia/platform/android/mediaplayer/qandroidmediaplayercontrol_p.h @@ -88,8 +88,6 @@ public: void setAudioRole(QAudio::Role role) override; QList<QAudio::Role> supportedAudioRoles() const override; - void setCustomAudioRole(const QString &role) override; - QStringList supportedCustomAudioRoles() const override; QMediaMetaData metaData() const override; diff --git a/src/multimedia/platform/android/wrappers/jni/androidmediaplayer.cpp b/src/multimedia/platform/android/wrappers/jni/androidmediaplayer.cpp index fd64b7d25..6b5655f58 100644 --- a/src/multimedia/platform/android/wrappers/jni/androidmediaplayer.cpp +++ b/src/multimedia/platform/android/wrappers/jni/androidmediaplayer.cpp @@ -233,89 +233,80 @@ void AndroidMediaPlayer::setDisplay(AndroidSurfaceTexture *surfaceTexture) void AndroidMediaPlayer::setAudioRole(QAudio::Role role) { - QString str; + QString r; switch (role) { case QAudio::MusicRole: - str = QLatin1String("CONTENT_TYPE_MUSIC"); + r = QLatin1String("CONTENT_TYPE_MUSIC"); break; case QAudio::VideoRole: - str = QLatin1String("CONTENT_TYPE_MOVIE"); + r = QLatin1String("CONTENT_TYPE_MOVIE"); break; case QAudio::VoiceCommunicationRole: - str = QLatin1String("USAGE_VOICE_COMMUNICATION"); + r = QLatin1String("USAGE_VOICE_COMMUNICATION"); break; case QAudio::AlarmRole: - str = QLatin1String("USAGE_ALARM"); + r = QLatin1String("USAGE_ALARM"); break; case QAudio::NotificationRole: - str = QLatin1String("USAGE_NOTIFICATION"); + r = QLatin1String("USAGE_NOTIFICATION"); break; case QAudio::RingtoneRole: - str = QLatin1String("USAGE_NOTIFICATION_RINGTONE"); + r = QLatin1String("USAGE_NOTIFICATION_RINGTONE"); break; case QAudio::AccessibilityRole: - str = QLatin1String("USAGE_ASSISTANCE_ACCESSIBILITY"); + r = QLatin1String("USAGE_ASSISTANCE_ACCESSIBILITY"); break; case QAudio::SonificationRole: - str = QLatin1String("CONTENT_TYPE_SONIFICATION"); + r = QLatin1String("CONTENT_TYPE_SONIFICATION"); break; case QAudio::GameRole: - str = QLatin1String("USAGE_GAME"); + r = QLatin1String("USAGE_GAME"); break; default: - break; + return; } - setCustomAudioRole(str); -} - -void AndroidMediaPlayer::setCustomAudioRole(const QString &role) -{ - QStringList roles = role.split(",", Qt::SkipEmptyParts); - int type = 0; // CONTENT_TYPE_UNKNOWN int usage = 0; // USAGE_UNKNOWN - for (int i = 0; i < qMin(2, roles.size()); ++i) { - auto r = roles[i]; - if (r == QLatin1String("CONTENT_TYPE_MOVIE")) - type = 3; - else if (r == QLatin1String("CONTENT_TYPE_MUSIC")) - type = 2; - else if (r == QLatin1String("CONTENT_TYPE_SONIFICATION")) - type = 4; - else if (r == QLatin1String("CONTENT_TYPE_SPEECH")) - type = 1; - else if (r == QLatin1String("USAGE_ALARM")) - usage = 4; - else if (r == QLatin1String("USAGE_ASSISTANCE_ACCESSIBILITY")) - usage = 11; - else if (r == QLatin1String("USAGE_ASSISTANCE_NAVIGATION_GUIDANCE")) - usage = 12; - else if (r == QLatin1String("USAGE_ASSISTANCE_SONIFICATION")) - usage = 13; - else if (r == QLatin1String("USAGE_ASSISTANT")) - usage = 16; - else if (r == QLatin1String("USAGE_GAME")) - usage = 14; - else if (r == QLatin1String("USAGE_MEDIA")) - usage = 1; - else if (r == QLatin1String("USAGE_NOTIFICATION")) - usage = 5; - else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_DELAYED")) - usage = 9; - else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_INSTANT")) - usage = 8; - else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_REQUEST")) - usage = 7; - else if (r == QLatin1String("USAGE_NOTIFICATION_EVENT")) - usage = 10; - else if (r == QLatin1String("USAGE_NOTIFICATION_RINGTONE")) - usage = 6; - else if (r == QLatin1String("USAGE_VOICE_COMMUNICATION")) - usage = 2; - else if (r == QLatin1String("USAGE_VOICE_COMMUNICATION_SIGNALLING")) - usage = 3; - } + + if (r == QLatin1String("CONTENT_TYPE_MOVIE")) + type = 3; + else if (r == QLatin1String("CONTENT_TYPE_MUSIC")) + type = 2; + else if (r == QLatin1String("CONTENT_TYPE_SONIFICATION")) + type = 4; + else if (r == QLatin1String("CONTENT_TYPE_SPEECH")) + type = 1; + else if (r == QLatin1String("USAGE_ALARM")) + usage = 4; + else if (r == QLatin1String("USAGE_ASSISTANCE_ACCESSIBILITY")) + usage = 11; + else if (r == QLatin1String("USAGE_ASSISTANCE_NAVIGATION_GUIDANCE")) + usage = 12; + else if (r == QLatin1String("USAGE_ASSISTANCE_SONIFICATION")) + usage = 13; + else if (r == QLatin1String("USAGE_ASSISTANT")) + usage = 16; + else if (r == QLatin1String("USAGE_GAME")) + usage = 14; + else if (r == QLatin1String("USAGE_MEDIA")) + usage = 1; + else if (r == QLatin1String("USAGE_NOTIFICATION")) + usage = 5; + else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_DELAYED")) + usage = 9; + else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_INSTANT")) + usage = 8; + else if (r == QLatin1String("USAGE_NOTIFICATION_COMMUNICATION_REQUEST")) + usage = 7; + else if (r == QLatin1String("USAGE_NOTIFICATION_EVENT")) + usage = 10; + else if (r == QLatin1String("USAGE_NOTIFICATION_RINGTONE")) + usage = 6; + else if (r == QLatin1String("USAGE_VOICE_COMMUNICATION")) + usage = 2; + else if (r == QLatin1String("USAGE_VOICE_COMMUNICATION_SIGNALLING")) + usage = 3; mMediaPlayer.callMethod<void>("setAudioAttributes", "(II)V", jint(type), jint(usage)); } diff --git a/src/multimedia/platform/android/wrappers/jni/androidmediaplayer_p.h b/src/multimedia/platform/android/wrappers/jni/androidmediaplayer_p.h index bf7a7002b..e1f6c34e4 100644 --- a/src/multimedia/platform/android/wrappers/jni/androidmediaplayer_p.h +++ b/src/multimedia/platform/android/wrappers/jni/androidmediaplayer_p.h @@ -130,7 +130,6 @@ public: bool setPlaybackRate(qreal rate); void setDisplay(AndroidSurfaceTexture *surfaceTexture); void setAudioRole(QAudio::Role role); - void setCustomAudioRole(const QString &role); static bool initJNI(JNIEnv *env); diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp index 7099c3a46..71474d791 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp +++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp @@ -37,7 +37,6 @@ ** ****************************************************************************/ #include "mmrendereraudiorolecontrol_p.h" -#include "mmrenderercustomaudiorolecontrol_p.h" #include "mmrenderermediaplayercontrol_p.h" #include "mmrendererplayervideorenderercontrol_p.h" #include "mmrendererutil_p.h" @@ -216,9 +215,7 @@ void MmRendererMediaPlayerControl::attach() } if (m_audioId != -1) { - QString audioType = m_role == QAudio::CustomRole - ? m_customRole - : qnxAudioType(m_role); + QString audioType = qnxAudioType(m_role); QByteArray latin1AudioType = audioType.toLatin1(); if (!audioType.isEmpty() && latin1AudioType == audioType) { strm_dict_t *dict = strm_dict_new(); @@ -564,7 +561,6 @@ void MmRendererMediaPlayerControl::stop() void MmRendererMediaPlayerControl::setAudioRole(QAudio::Role role) { m_role = role; - m_customRole.clear(); } QList<QAudio::Role> MmRendererMediaPlayerControl::supportedAudioRoles() const @@ -572,17 +568,6 @@ QList<QAudio::Role> MmRendererMediaPlayerControl::supportedAudioRoles() const return qnxSupportedAudioRoles(); } -void MmRendererMediaPlayerControl::setCustomAudioRole(const QString &role) -{ - m_role = QAudio::CustomRole; - m_customRole = role; -} - -QStringList MmRendererMediaPlayerControl::supportedCustomAudioRoles() const -{ - return QStringList(); -} - MmRendererPlayerVideoRendererControl *MmRendererMediaPlayerControl::videoRendererControl() const { return m_videoRendererControl; diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol_p.h b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol_p.h index 2e1ae24af..5cb958785 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol_p.h +++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayercontrol_p.h @@ -64,7 +64,6 @@ typedef struct strm_dict strm_dict_t; QT_BEGIN_NAMESPACE class MmRendererAudioRoleControl; -class MmRendererCustomAudioRoleControl; class MmRendererPlayerVideoRendererControl; class MmRendererVideoWindowControl; @@ -112,9 +111,6 @@ public: void setAudioRole(QAudio::Role role) override; QList<QAudio::Role> supportedAudioRoles() const override; - void setCustomAudioRole(const QString &role) override; - QStringList supportedCustomAudioRoles() const override; - MmRendererPlayerVideoRendererControl *videoRendererControl() const; void setVideoRendererControl(MmRendererPlayerVideoRendererControl *videoControl); diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrendererutil.cpp b/src/multimedia/platform/qnx/mediaplayer/mmrendererutil.cpp index af19f7368..8ded95bcd 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrendererutil.cpp +++ b/src/multimedia/platform/qnx/mediaplayer/mmrendererutil.cpp @@ -92,7 +92,7 @@ static const unsigned int numMmErrors = sizeof(mmErrors) / sizeof(MmError); static QBasicMutex roleMapMutex; static bool roleMapInitialized = false; -static QString roleMap[QAudio::CustomRole + 1]; +static QString roleMap[QAudio::GameRole + 1]; template <typename T, size_t N> constexpr size_t countof(T (&)[N]) @@ -166,15 +166,9 @@ static void loadRoleMap() loadRoleMapping(AccessibilityRole); loadRoleMapping(SonificationRole); loadRoleMapping(GameRole); - loadRoleMapping(CustomRole); } #undef loadRoleMapping #pragma GCC diagnostic pop - - if (!roleMap[QAudio::CustomRole].isEmpty()) { - qWarning("CustomRole mapping ignored"); - roleMap[QAudio::CustomRole].clear(); - } } roleMapInitialized = true; diff --git a/src/multimedia/platform/qplatformmediaplayer.cpp b/src/multimedia/platform/qplatformmediaplayer.cpp index cec5f4fd6..8b289de04 100644 --- a/src/multimedia/platform/qplatformmediaplayer.cpp +++ b/src/multimedia/platform/qplatformmediaplayer.cpp @@ -370,26 +370,6 @@ void QPlatformMediaPlayer::error(int error, const QString &errorString) */ /*! - \fn QAudio::Role QPlatformMediaPlayer::customAudioRole() const - - Returns the audio role of the media played by the media service. -*/ - -/*! - \fn void QPlatformMediaPlayer::setCustomAudioRole(const QString &role) - - Sets the audio \a role of the media played by the media service. -*/ - -/*! - \fn QStringList QPlatformMediaPlayer::supportedCustomAudioRoles() const - - Returns a list of custom audio roles that the media service supports. An - empty list may indicate that the supported custom audio roles aren't known. - The list may not be complete. -*/ - -/*! \fn QPlatformMediaPlayer::error(int error, const QString &errorString) Signals that an \a error has occurred. The \a errorString provides a more detailed explanation. diff --git a/src/multimedia/platform/qplatformmediaplayer_p.h b/src/multimedia/platform/qplatformmediaplayer_p.h index 1a7c4d65a..f972187d8 100644 --- a/src/multimedia/platform/qplatformmediaplayer_p.h +++ b/src/multimedia/platform/qplatformmediaplayer_p.h @@ -104,9 +104,6 @@ public: virtual void setAudioRole(QAudio::Role /*role*/) {} virtual QList<QAudio::Role> supportedAudioRoles() const { return {}; } - virtual void setCustomAudioRole(const QString &/*role*/) {} - virtual QStringList supportedCustomAudioRoles() const { return {}; } - virtual bool streamPlaybackSupported() const { return false; } virtual bool setAudioOutput(const QAudioDeviceInfo &) { return false; } diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index be46703af..4941c12ad 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -754,10 +754,6 @@ void QMediaPlayer::setAudioRole(QAudio::Role audioRole) d->audioRole = audioRole; d->control->setAudioRole(audioRole); - if (!d->customAudioRole.isEmpty()) { - d->customAudioRole.clear(); - emit customAudioRoleChanged(QString()); - } emit audioRoleChanged(audioRole); } @@ -777,42 +773,6 @@ QList<QAudio::Role> QMediaPlayer::supportedAudioRoles() const return d->control->supportedAudioRoles(); } -QString QMediaPlayer::customAudioRole() const -{ - Q_D(const QMediaPlayer); - - return d->customAudioRole; -} - -void QMediaPlayer::setCustomAudioRole(const QString &audioRole) -{ - Q_D(QMediaPlayer); - if (d->audioRole == QAudio::CustomRole && d->customAudioRole == audioRole) - return; - - d->customAudioRole = audioRole; - d->control->setCustomAudioRole(audioRole); - if (d->audioRole != QAudio::CustomRole) { - d->audioRole = QAudio::CustomRole; - emit audioRoleChanged(QAudio::CustomRole); - } - emit customAudioRoleChanged(audioRole); -} - -/*! - Returns a list of supported custom audio roles. An empty list may - indicate that the supported custom audio roles aren't known. The - list may not be complete. - - \since 5.11 - \sa customAudioRole -*/ -QStringList QMediaPlayer::supportedCustomAudioRoles() const -{ - Q_D(const QMediaPlayer); - return d->control->supportedCustomAudioRoles(); -} - // Enums /*! \enum QMediaPlayer::State @@ -919,14 +879,6 @@ QStringList QMediaPlayer::supportedCustomAudioRoles() const \since 5.6 */ -/*! - \fn void QMediaPlayer::customAudioRoleChanged(const QString &role) - - Signals that the audio \a role of the media player has changed. - - \since 5.11 -*/ - // Properties /*! \property QMediaPlayer::state @@ -1081,30 +1033,11 @@ QStringList QMediaPlayer::supportedCustomAudioRoles() const The audio role must be set before calling setMedia(). - customAudioRole is cleared when this property is set to anything other than - QAudio::CustomRole. - \since 5.6 \sa supportedAudioRoles() */ /*! - \property QMediaPlayer::customAudioRole - \brief the role of the audio stream played by the media player. - - It can be set to specify the type of audio being played when the backend supports - audio roles unknown to Qt. Specifying a role allows the system to make appropriate - decisions when it comes to volume, routing or post-processing. - - The audio role must be set before calling setMedia(). - - audioRole is set to QAudio::CustomRole when this property is set. - - \since 5.11 - \sa supportedCustomAudioRoles() -*/ - -/*! \fn void QMediaPlayer::durationChanged(qint64 duration) Signal the duration of the content has changed to \a duration, expressed in milliseconds. diff --git a/src/multimedia/playback/qmediaplayer.h b/src/multimedia/playback/qmediaplayer.h index 9ad29a7a9..31f584c98 100644 --- a/src/multimedia/playback/qmediaplayer.h +++ b/src/multimedia/playback/qmediaplayer.h @@ -69,7 +69,6 @@ class Q_MULTIMEDIA_EXPORT QMediaPlayer : public QObject Q_PROPERTY(State state READ state NOTIFY stateChanged) Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged) Q_PROPERTY(QAudio::Role audioRole READ audioRole WRITE setAudioRole NOTIFY audioRoleChanged) - Q_PROPERTY(QString customAudioRole READ customAudioRole WRITE setCustomAudioRole NOTIFY customAudioRoleChanged) Q_PROPERTY(QMediaMetaData metaData READ metaData NOTIFY metaDataChanged) Q_PROPERTY(QString error READ errorString) Q_ENUMS(State) @@ -166,9 +165,6 @@ public: QAudio::Role audioRole() const; void setAudioRole(QAudio::Role audioRole); QList<QAudio::Role> supportedAudioRoles() const; - QString customAudioRole() const; - void setCustomAudioRole(const QString &audioRole); - QStringList supportedCustomAudioRoles() const; public Q_SLOTS: void play(); @@ -205,7 +201,6 @@ Q_SIGNALS: void playbackRateChanged(qreal rate); void audioRoleChanged(QAudio::Role role); - void customAudioRoleChanged(const QString &role); void metaDataChanged(); diff --git a/src/multimedia/playback/qmediaplayer_p.h b/src/multimedia/playback/qmediaplayer_p.h index 815364bd3..b0e775a6c 100644 --- a/src/multimedia/playback/qmediaplayer_p.h +++ b/src/multimedia/playback/qmediaplayer_p.h @@ -88,7 +88,6 @@ public: bool hasStreamPlaybackFeature = false; QAudio::Role audioRole = QAudio::UnknownRole; - QString customAudioRole; void setMedia(const QUrl &media, QIODevice *stream = nullptr); diff --git a/tests/auto/unit/mockbackend/mockmediaplayer.h b/tests/auto/unit/mockbackend/mockmediaplayer.h index 495e668ad..a761545dc 100644 --- a/tests/auto/unit/mockbackend/mockmediaplayer.h +++ b/tests/auto/unit/mockbackend/mockmediaplayer.h @@ -134,20 +134,6 @@ public: << QAudio::NotificationRole; } - void setCustomAudioRole(const QString &role) - { - m_customAudioRole = role; - m_audioRole = QAudio::CustomRole; - } - - QStringList supportedCustomAudioRoles() const - { - if (!hasCustomAudioRole) - return {}; - return QStringList() << QStringLiteral("customRole") - << QStringLiteral("customRole2"); - } - void setVideoSink(QVideoSink *) {} void emitError(QMediaPlayer::Error err, const QString &errorString) @@ -187,14 +173,11 @@ public: _isValid = false; _errorString = QString(); hasAudioRole = true; - hasCustomAudioRole = true; } bool hasAudioRole = true; - bool hasCustomAudioRole = true; QAudio::Role m_audioRole = QAudio::UnknownRole; - QString m_customAudioRole; QMediaPlayer::State _state; QMediaPlayer::MediaStatus _mediaStatus; diff --git a/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp index defe7e1d4..2e724b879 100644 --- a/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp +++ b/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp @@ -124,7 +124,6 @@ private slots: void testQrc_data(); void testQrc(); void testAudioRole(); - void testCustomAudioRole(); private: void setupNotifyTests(); @@ -1122,93 +1121,5 @@ void tst_QMediaPlayer::testAudioRole() } } -void tst_QMediaPlayer::testCustomAudioRole() -{ - { - mockPlayer->hasCustomAudioRole = false; - QMediaPlayer player; - - QVERIFY(player.customAudioRole().isEmpty()); - QVERIFY(player.supportedCustomAudioRoles().isEmpty()); - - QSignalSpy spyRole(&player, SIGNAL(audioRoleChanged(QAudio::Role))); - QSignalSpy spyCustomRole(&player, SIGNAL(customAudioRoleChanged(const QString &))); - player.setCustomAudioRole(QStringLiteral("customRole")); - QCOMPARE(player.audioRole(), QAudio::CustomRole); - QCOMPARE(player.customAudioRole(), QStringLiteral("customRole")); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(spyCustomRole.count(), 1); - } - - { - mockPlayer->reset(); - mockPlayer->hasAudioRole = false; - QMediaPlayer player; - - QVERIFY(player.customAudioRole().isEmpty()); - QVERIFY(!player.supportedCustomAudioRoles().isEmpty()); - - QSignalSpy spyRole(&player, SIGNAL(audioRoleChanged(QAudio::Role))); - QSignalSpy spyCustomRole(&player, SIGNAL(customAudioRoleChanged(const QString &))); - player.setCustomAudioRole(QStringLiteral("customRole")); - QCOMPARE(player.audioRole(), QAudio::CustomRole); - QCOMPARE(player.customAudioRole(), QStringLiteral("customRole")); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(spyCustomRole.count(), 1); - } - - { - mockPlayer->reset(); - QMediaPlayer player; - QSignalSpy spyRole(&player, SIGNAL(audioRoleChanged(QAudio::Role))); - QSignalSpy spyCustomRole(&player, SIGNAL(customAudioRoleChanged(const QString &))); - - QCOMPARE(player.audioRole(), QAudio::UnknownRole); - QVERIFY(player.customAudioRole().isEmpty()); - QVERIFY(!player.supportedCustomAudioRoles().isEmpty()); - - QString customRole(QStringLiteral("customRole")); - player.setCustomAudioRole(customRole); - QCOMPARE(player.audioRole(), QAudio::CustomRole); - QCOMPARE(player.customAudioRole(), customRole); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(qvariant_cast<QAudio::Role>(spyRole.last().value(0)), QAudio::CustomRole); - QCOMPARE(spyCustomRole.count(), 1); - QCOMPARE(qvariant_cast<QString>(spyCustomRole.last().value(0)), customRole); - - spyRole.clear(); - spyCustomRole.clear(); - - QString customRole2(QStringLiteral("customRole2")); - player.setProperty("customAudioRole", QVariant::fromValue(customRole2)); - QCOMPARE(qvariant_cast<QString>(player.property("customAudioRole")), customRole2); - QCOMPARE(player.customAudioRole(), customRole2); - QCOMPARE(spyRole.count(), 0); - QCOMPARE(spyCustomRole.count(), 1); - QCOMPARE(qvariant_cast<QString>(spyCustomRole.last().value(0)), customRole2); - - spyRole.clear(); - spyCustomRole.clear(); - - player.setAudioRole(QAudio::MusicRole); - QCOMPARE(player.audioRole(), QAudio::MusicRole); - QVERIFY(player.customAudioRole().isEmpty()); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(qvariant_cast<QAudio::Role>(spyRole.last().value(0)), QAudio::MusicRole); - QCOMPARE(spyCustomRole.count(), 1); - QVERIFY(qvariant_cast<QString>(spyCustomRole.last().value(0)).isEmpty()); - - spyRole.clear(); - spyCustomRole.clear(); - - player.setAudioRole(QAudio::CustomRole); - QCOMPARE(player.audioRole(), QAudio::CustomRole); - QVERIFY(player.customAudioRole().isEmpty()); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(qvariant_cast<QAudio::Role>(spyRole.last().value(0)), QAudio::CustomRole); - QCOMPARE(spyCustomRole.count(), 0); - } -} - QTEST_GUILESS_MAIN(tst_QMediaPlayer) #include "tst_qmediaplayer.moc" diff --git a/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp index f4fa1bfb6..9227a8ec0 100644 --- a/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ b/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp @@ -71,7 +71,6 @@ private slots: void error(); void loops(); void audioRole(); - void customAudioRole(); void videoOutput(); private: @@ -783,106 +782,6 @@ void tst_QDeclarativeAudio::audioRole() } } -void tst_QDeclarativeAudio::customAudioRole() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.setData("import QtQuick 2.0 \n import QtMultimedia 5.11 \n Audio { }", QUrl()); - auto *player = mockIntegration->lastPlayer(); - - { - player->hasCustomAudioRole = false; - QObject *audio = component.create(); - QVERIFY(audio); - - QMetaEnum audioRoleEnum = enumerator(audio->metaObject(), "AudioRole"); - int AudioRole_CustomRoleValue = keyToValue(audioRoleEnum, "CustomRole"); - QVERIFY(!QTest::currentTestFailed()); - - QVERIFY(audio->property("customAudioRole").toString().isEmpty()); - - QSignalSpy spyRole(audio, SIGNAL(audioRoleChanged())); - QSignalSpy spyCustomRole(audio, SIGNAL(customAudioRoleChanged())); - audio->setProperty("customAudioRole", QStringLiteral("customRole")); - QCOMPARE(audio->property("audioRole").toInt(), AudioRole_CustomRoleValue); - QCOMPARE(audio->property("customAudioRole").toString(), QStringLiteral("customRole")); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(spyCustomRole.count(), 1); - } - - { - player->hasAudioRole = false; - - QObject *audio = component.create(); - QVERIFY(audio); - - QMetaEnum audioRoleEnum = enumerator(audio->metaObject(), "AudioRole"); - int AudioRole_CustomRoleValue = keyToValue(audioRoleEnum, "CustomRole"); - QVERIFY(!QTest::currentTestFailed()); - - QVERIFY(audio->property("customAudioRole").toString().isEmpty()); - - QSignalSpy spyRole(audio, SIGNAL(audioRoleChanged())); - QSignalSpy spyCustomRole(audio, SIGNAL(customAudioRoleChanged())); - audio->setProperty("customAudioRole", QStringLiteral("customRole")); - QCOMPARE(audio->property("audioRole").toInt(), AudioRole_CustomRoleValue); - QCOMPARE(audio->property("customAudioRole").toString(), QStringLiteral("customRole")); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(spyCustomRole.count(), 1); - } - - { - QObject *audio = component.create(); - QVERIFY(audio); - - QMetaEnum audioRoleEnum = enumerator(audio->metaObject(), "AudioRole"); - int AudioRole_UnknownRoleValue = keyToValue(audioRoleEnum, "UnknownRole"); - int AudioRole_CustomRoleValue = keyToValue(audioRoleEnum, "CustomRole"); - int AudioRole_MusicRoleValue = keyToValue(audioRoleEnum, "MusicRole"); - QVERIFY(!QTest::currentTestFailed()); - - QSignalSpy spyRole(audio, SIGNAL(audioRoleChanged())); - QSignalSpy spyCustomRole(audio, SIGNAL(customAudioRoleChanged())); - - QCOMPARE(audio->property("audioRole").toInt(), AudioRole_UnknownRoleValue); - QVERIFY(audio->property("customAudioRole").toString().isEmpty()); - - QString customRole(QStringLiteral("customRole")); - audio->setProperty("customAudioRole", customRole); - QCOMPARE(audio->property("audioRole").toInt(), AudioRole_CustomRoleValue); - QCOMPARE(audio->property("customAudioRole").toString(), customRole); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(spyCustomRole.count(), 1); - - spyRole.clear(); - spyCustomRole.clear(); - - QString customRole2(QStringLiteral("customRole2")); - audio->setProperty("customAudioRole", customRole2); - QCOMPARE(audio->property("customAudioRole").toString(), customRole2); - QCOMPARE(spyRole.count(), 0); - QCOMPARE(spyCustomRole.count(), 1); - - spyRole.clear(); - spyCustomRole.clear(); - - audio->setProperty("audioRole", AudioRole_MusicRoleValue); - QCOMPARE(audio->property("audioRole").toInt(), AudioRole_MusicRoleValue); - QVERIFY(audio->property("customAudioRole").toString().isEmpty()); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(spyCustomRole.count(), 1); - - spyRole.clear(); - spyCustomRole.clear(); - - audio->setProperty("audioRole", AudioRole_CustomRoleValue); - QCOMPARE(audio->property("audioRole").toInt(), AudioRole_CustomRoleValue); - QVERIFY(audio->property("customAudioRole").toString().isEmpty()); - QCOMPARE(spyRole.count(), 1); - QCOMPARE(spyCustomRole.count(), 0); - } -} - void tst_QDeclarativeAudio::enumerator(const QMetaObject *object, const char *name, QMetaEnum *result) |