summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-12-14 09:51:56 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-20 15:05:58 +0000
commit46381711557aad4f264470e555c77f7d6d07cbb9 (patch)
treeed1a7eae55fcd0172df1a64961b4d1b255ad39a7 /src/multimedia/audio
parent3a054924c1fd96171af18d3006faef15a9e952ac (diff)
Kill QSound
The class has been deprecated since Qt 4 and has a replacement with QSoundEffect. Change-Id: Id8cf389f539c23494e85c130ffada2dc211953fd Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r--src/multimedia/audio/audio.pri2
-rw-r--r--src/multimedia/audio/qsound.cpp244
-rw-r--r--src/multimedia/audio/qsound.h85
3 files changed, 0 insertions, 331 deletions
diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri
index 388124205..a7ae3d3cf 100644
--- a/src/multimedia/audio/audio.pri
+++ b/src/multimedia/audio/audio.pri
@@ -10,7 +10,6 @@ PUBLIC_HEADERS += \
audio/qaudiosystemplugin.h \
audio/qaudiosystem.h \
audio/qsoundeffect.h \
- audio/qsound.h \
audio/qaudioprobe.h \
audio/qaudiodecoder.h
@@ -34,7 +33,6 @@ SOURCES += \
audio/qsoundeffect.cpp \
audio/qwavedecoder_p.cpp \
audio/qsamplecache_p.cpp \
- audio/qsound.cpp \
audio/qaudiobuffer.cpp \
audio/qaudioprobe.cpp \
audio/qaudiodecoder.cpp \
diff --git a/src/multimedia/audio/qsound.cpp b/src/multimedia/audio/qsound.cpp
deleted file mode 100644
index cbd336457..000000000
--- a/src/multimedia/audio/qsound.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsound.h"
-#include "qsoundeffect.h"
-#include "qcoreapplication.h"
-
-
-/*!
- \class QSound
- \brief The QSound class provides a method to play .wav sound files.
- \inmodule QtMultimedia
- \ingroup multimedia
- \ingroup multimedia_audio
-
- Qt provides the most commonly required audio operation in GUI
- applications: asynchronously playing a sound file. This is most
- easily accomplished using the static play() function:
-
- \snippet multimedia-snippets/qsound.cpp 0
-
- Alternatively, create a QSound object from the sound file first
- and then call the play() slot:
-
- \snippet multimedia-snippets/qsound.cpp 1
-
- In both cases, the file may either be a local file or in a
- \l{The Qt Resource System}{resource}.
-
- Once created a QSound object can be queried for its fileName() and
- total number of loops() (i.e. the number of times the sound will
- play). The number of repetitions can be altered using the
- setLoops() function. While playing the sound, the loopsRemaining()
- function returns the remaining number of repetitions. Use the
- isFinished() function to determine whether the sound has finished
- playing.
-
- Sounds played using a QSound object may use more memory than the
- static play() function, but it may also play more immediately
- (depending on the underlying platform audio facilities).
-
- If you require finer control over playing sounds, consider the
- \l QSoundEffect or \l QAudioOutput classes.
-
- \sa QSoundEffect
-*/
-
-/*!
- \enum QSound::Loop
-
- \value Infinite Can be used as a parameter to \l setLoops() to loop infinitely.
-*/
-
-
-/*!
- Plays the sound stored in the file specified by the given \a filename.
-
- The file can either be a local file or in a \l{The Qt Resource System}{resource}.
-
- \sa stop(), loopsRemaining(), isFinished()
-*/
-void QSound::play(const QString &filename)
-{
- // Object destruction is generally handled via deleteOnComplete
- // Unexpected cases will be handled via parenting of QSound objects to qApp
- QSound *sound = new QSound(filename, qApp);
- sound->connect(sound->m_soundEffect, &QSoundEffect::playingChanged,
- sound, &QSound::deleteOnComplete);
- sound->play();
-}
-
-/*!
- Constructs a QSound object from the file specified by the given \a
- filename and with the given \a parent.
-
- The file can either be a local file or in a \l{The Qt Resource System}{resource}.
-
- \sa play()
-*/
-QSound::QSound(const QString &filename, QObject *parent)
- : QObject(parent)
-{
- m_soundEffect = new QSoundEffect(this);
- const bool isQrc = filename.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive);
- const QUrl url = isQrc ? QUrl(filename) : QUrl::fromLocalFile(filename);
- m_soundEffect->setSource(url);
-}
-
-/*!
- Destroys this sound object. If the sound is not finished playing,
- the stop() function is called before the sound object is
- destroyed.
-
- \sa stop(), isFinished()
-*/
-QSound::~QSound()
-{
- if (!isFinished())
- stop();
-}
-
-/*!
- Returns true if the sound has finished playing; otherwise returns false.
-*/
-bool QSound::isFinished() const
-{
- return !m_soundEffect->isPlaying();
-}
-
-/*!
- \overload
-
- Starts playing the sound specified by this QSound object.
-
- The function returns immediately. Depending on the platform audio
- facilities, other sounds may stop or be mixed with the new
- sound. The sound can be played again at any time, possibly mixing
- or replacing previous plays of the sound.
-
- \sa fileName()
-*/
-void QSound::play()
-{
- m_soundEffect->play();
-}
-
-/*!
- Returns the number of times the sound will play.
- Return value of \c QSound::Infinite indicates infinite number of loops
-
- \sa loopsRemaining(), setLoops()
-*/
-int QSound::loops() const
-{
- // retain old API value for infinite loops
- int loopCount = m_soundEffect->loopCount();
- if (loopCount == QSoundEffect::Infinite)
- loopCount = Infinite;
-
- return loopCount;
-}
-
-/*!
- Returns the remaining number of times the sound will loop (for all
- positive values this value decreases each time the sound is played).
- Return value of \c QSound::Infinite indicates infinite number of loops
-
- \sa loops(), isFinished()
-*/
-int QSound::loopsRemaining() const
-{
- // retain old API value for infinite loops
- int loopsRemaining = m_soundEffect->loopsRemaining();
- if (loopsRemaining == QSoundEffect::Infinite)
- loopsRemaining = Infinite;
-
- return loopsRemaining;
-}
-
-/*!
- \fn void QSound::setLoops(int number)
-
- Sets the sound to repeat the given \a number of times when it is
- played.
-
- Note that passing the value \c QSound::Infinite will cause the sound to loop
- indefinitely.
-
- \sa loops()
-*/
-void QSound::setLoops(int n)
-{
- if (n == Infinite)
- n = QSoundEffect::Infinite;
-
- m_soundEffect->setLoopCount(n);
-}
-
-/*!
- Returns the filename associated with this QSound object.
-
- \sa QSound()
-*/
-QString QSound::fileName() const
-{
- return m_soundEffect->source().toLocalFile();
-}
-
-/*!
- Stops the sound playing.
-
- \sa play()
-*/
-void QSound::stop()
-{
- m_soundEffect->stop();
-}
-
-/*!
- \internal
-*/
-void QSound::deleteOnComplete()
-{
- if (!m_soundEffect->isPlaying())
- deleteLater();
-}
-
-#include "moc_qsound.cpp"
diff --git a/src/multimedia/audio/qsound.h b/src/multimedia/audio/qsound.h
deleted file mode 100644
index 972847c37..000000000
--- a/src/multimedia/audio/qsound.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSOUND_H
-#define QSOUND_H
-
-#include <QtMultimedia/qtmultimediaglobal.h>
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QSoundEffect;
-
-class Q_MULTIMEDIA_EXPORT QSound : public QObject
-{
- Q_OBJECT
-public:
- enum Loop
- {
- Infinite = -1
- };
-
- static void play(const QString &filename);
-
- explicit QSound(const QString &filename, QObject *parent = nullptr);
- ~QSound();
-
- int loops() const;
- int loopsRemaining() const;
- void setLoops(int);
- QString fileName() const;
-
- bool isFinished() const;
-
-public Q_SLOTS:
- void play();
- void stop();
-
-private Q_SLOTS:
- void deleteOnComplete();
-
-private:
- QSoundEffect *m_soundEffect = nullptr;
-};
-
-QT_END_NAMESPACE
-
-
-#endif // QSOUND_H