qtbase: Remove QSound.
Which currently causes tests not to compile on Windows due to missing symbols in QtWidgets (QSound::QSound() ,etc). Change-Id: I87f0a403e61c3a67f9a758f114e33db1012e33e8 Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
2757a5fe8c
commit
ebfdb73b75
2
dist/changes-5.0.0
vendored
2
dist/changes-5.0.0
vendored
@ -85,6 +85,8 @@ information about a particular change.
|
||||
* Refactored to be based on action names. All functions have been changed from using
|
||||
int parameters to strings.
|
||||
|
||||
- QSound has been moved from QtGui to QtMultimedia
|
||||
|
||||
****************************************************************************
|
||||
* General *
|
||||
****************************************************************************
|
||||
|
@ -820,7 +820,6 @@ QT_CLASS_LIB(QPlatformWindowFormat, QtGui, qplatformwindowformat_qpa.h)
|
||||
QT_CLASS_LIB(QSessionManager, QtGui, qsessionmanager.h)
|
||||
QT_CLASS_LIB(QShortcut, QtWidgets, qshortcut.h)
|
||||
QT_CLASS_LIB(QSizePolicy, QtWidgets, qsizepolicy.h)
|
||||
QT_CLASS_LIB(QSound, QtWidgets, qsound.h)
|
||||
QT_CLASS_LIB(QStackedLayout, QtWidgets, qstackedlayout.h)
|
||||
QT_CLASS_LIB(QToolTip, QtWidgets, qtooltip.h)
|
||||
QT_CLASS_LIB(QWhatsThis, QtWidgets, qwhatsthis.h)
|
||||
|
@ -107,7 +107,6 @@ false:!x11:mac {
|
||||
OBJECTIVE_SOURCES += \
|
||||
kernel/qcursor_mac.mm \
|
||||
kernel/qdnd_mac.mm \
|
||||
kernel/qsound_mac.mm \
|
||||
kernel/qapplication_mac.mm \
|
||||
kernel/qwidget_mac.mm \
|
||||
kernel/qcocoapanel_mac.mm \
|
||||
|
@ -1,367 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** 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.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qsound.h"
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
|
||||
#include "qlist.h"
|
||||
#include <private/qobject_p.h>
|
||||
#include "qsound_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static QList<QAuServer*> *servers=0;
|
||||
|
||||
QAuServer::QAuServer(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
if (!servers)
|
||||
servers = new QList<QAuServer*>;
|
||||
servers->prepend(this);
|
||||
}
|
||||
|
||||
QAuServer::~QAuServer()
|
||||
{
|
||||
servers->removeAll(this);
|
||||
if (servers->count() == 0) {
|
||||
delete servers;
|
||||
servers = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QAuServer::play(const QString& filename)
|
||||
{
|
||||
QSound s(filename);
|
||||
play(&s);
|
||||
}
|
||||
|
||||
extern QAuServer* qt_new_audio_server();
|
||||
|
||||
static QAuServer& server()
|
||||
{
|
||||
if (!servers) qt_new_audio_server();
|
||||
return *servers->first();
|
||||
}
|
||||
|
||||
class QSoundPrivate : public QObjectPrivate
|
||||
{
|
||||
public:
|
||||
QSoundPrivate(const QString& fname)
|
||||
: filename(fname), bucket(0), looprem(0), looptotal(1)
|
||||
{
|
||||
}
|
||||
|
||||
~QSoundPrivate()
|
||||
{
|
||||
delete bucket;
|
||||
}
|
||||
|
||||
QString filename;
|
||||
QAuBucket* bucket;
|
||||
int looprem;
|
||||
int looptotal;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QSound
|
||||
\brief The QSound class provides access to the platform audio facilities.
|
||||
|
||||
\ingroup multimedia
|
||||
\inmodule QtWidgets
|
||||
|
||||
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 doc/src/snippets/code/src_gui_kernel_qsound.cpp 0
|
||||
|
||||
Alternatively, create a QSound object from the sound file first
|
||||
and then call the play() slot:
|
||||
|
||||
\snippet doc/src/snippets/code/src_gui_kernel_qsound.cpp 1
|
||||
|
||||
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). Use the
|
||||
static isAvailable() function to determine whether sound
|
||||
facilities exist on the platform. Which facilities that are
|
||||
actually used varies:
|
||||
|
||||
\table
|
||||
\header \o Platform \o Audio Facility
|
||||
\row
|
||||
\o Microsoft Windows
|
||||
\o The underlying multimedia system is used; only WAVE format sound files
|
||||
are supported.
|
||||
\row
|
||||
\o X11
|
||||
\o The \l{ftp://ftp.x.org/contrib/audio/nas/}{Network Audio System}
|
||||
is used if available, otherwise all operations work silently. NAS
|
||||
supports WAVE and AU files.
|
||||
\row
|
||||
\o Mac OS X
|
||||
\o NSSound is used. All formats that NSSound supports, including QuickTime formats,
|
||||
are supported by Qt for Mac OS X.
|
||||
\row
|
||||
\o Qt for Embedded Linux
|
||||
\o A built-in mixing sound server is used, accessing \c /dev/dsp
|
||||
directly. Only the WAVE format is supported.
|
||||
\row
|
||||
\o Symbian
|
||||
\o CMdaAudioPlayerUtility is used. All formats that Symbian OS or devices support
|
||||
are supported also by Qt.
|
||||
\endtable
|
||||
|
||||
Note that QSound does not support \l{resources.html}{resources}.
|
||||
This might be fixed in a future Qt version.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Plays the sound stored in the file specified by the given \a filename.
|
||||
|
||||
\sa stop(), loopsRemaining(), isFinished()
|
||||
*/
|
||||
void QSound::play(const QString& filename)
|
||||
{
|
||||
server().play(filename);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a QSound object from the file specified by the given \a
|
||||
filename and with the given \a parent.
|
||||
|
||||
This may use more memory than the static play() function, but it
|
||||
may also play more immediately (depending on the underlying
|
||||
platform audio facilities).
|
||||
|
||||
\sa play()
|
||||
*/
|
||||
QSound::QSound(const QString& filename, QObject* parent)
|
||||
: QObject(*new QSoundPrivate(filename), parent)
|
||||
{
|
||||
server().init(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this sound object. If the sound is not finished playing,
|
||||
the stop() function is called before the sound object is
|
||||
destructed.
|
||||
|
||||
\sa stop(), isFinished()
|
||||
*/
|
||||
QSound::~QSound()
|
||||
{
|
||||
if (!isFinished())
|
||||
stop();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the sound has finished playing; otherwise returns false.
|
||||
|
||||
\warning On Windows this function always returns true for unlooped sounds.
|
||||
*/
|
||||
bool QSound::isFinished() const
|
||||
{
|
||||
Q_D(const QSound);
|
||||
return d->looprem == 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\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()
|
||||
{
|
||||
Q_D(QSound);
|
||||
d->looprem = d->looptotal;
|
||||
server().play(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of times the sound will play.
|
||||
|
||||
\sa loopsRemaining(), setLoops()
|
||||
*/
|
||||
int QSound::loops() const
|
||||
{
|
||||
Q_D(const QSound);
|
||||
return d->looptotal;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the remaining number of times the sound will loop (this
|
||||
value decreases each time the sound is played).
|
||||
|
||||
\sa loops(), isFinished()
|
||||
*/
|
||||
int QSound::loopsRemaining() const
|
||||
{
|
||||
Q_D(const QSound);
|
||||
return d->looprem;
|
||||
}
|
||||
|
||||
/*!
|
||||
\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 -1 will cause the sound to loop
|
||||
indefinitely.
|
||||
|
||||
\sa loops()
|
||||
*/
|
||||
void QSound::setLoops(int n)
|
||||
{
|
||||
Q_D(QSound);
|
||||
d->looptotal = n;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the filename associated with this QSound object.
|
||||
|
||||
\sa QSound()
|
||||
*/
|
||||
QString QSound::fileName() const
|
||||
{
|
||||
Q_D(const QSound);
|
||||
return d->filename;
|
||||
}
|
||||
|
||||
/*!
|
||||
Stops the sound playing.
|
||||
|
||||
Note that on Windows the current loop will finish if a sound is
|
||||
played in a loop.
|
||||
|
||||
\sa play()
|
||||
*/
|
||||
void QSound::stop()
|
||||
{
|
||||
Q_D(QSound);
|
||||
server().stop(this);
|
||||
d->looprem = 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns true if sound facilities exist on the platform; otherwise
|
||||
returns false.
|
||||
|
||||
If no sound is available, all QSound operations work silently and
|
||||
quickly. An application may choose either to notify the user if
|
||||
sound is crucial to the application or to operate silently without
|
||||
bothering the user.
|
||||
|
||||
Note: On Windows this always returns true because some sound card
|
||||
drivers do not implement a way to find out whether it is available
|
||||
or not.
|
||||
*/
|
||||
bool QSound::isAvailable()
|
||||
{
|
||||
return server().okay();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the internal bucket record of sound \a s to \a b, deleting
|
||||
any previous setting.
|
||||
*/
|
||||
void QAuServer::setBucket(QSound* s, QAuBucket* b)
|
||||
{
|
||||
delete s->d_func()->bucket;
|
||||
s->d_func()->bucket = b;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the internal bucket record of sound \a s.
|
||||
*/
|
||||
QAuBucket* QAuServer::bucket(QSound* s)
|
||||
{
|
||||
return s->d_func()->bucket;
|
||||
}
|
||||
|
||||
/*!
|
||||
Decrements the QSound::loopRemaining() value for sound \a s,
|
||||
returning the result.
|
||||
*/
|
||||
int QAuServer::decLoop(QSound* s)
|
||||
{
|
||||
if (s->d_func()->looprem > 0)
|
||||
--s->d_func()->looprem;
|
||||
return s->d_func()->looprem;
|
||||
}
|
||||
|
||||
/*!
|
||||
Initializes the sound. The default implementation does nothing.
|
||||
*/
|
||||
void QAuServer::init(QSound*)
|
||||
{
|
||||
}
|
||||
|
||||
QAuBucket::~QAuBucket()
|
||||
{
|
||||
}
|
||||
/*!
|
||||
\fn bool QSound::available()
|
||||
|
||||
Use the isAvailable() function instead.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_SOUND
|
@ -1,90 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** 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.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSOUND_H
|
||||
#define QSOUND_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
|
||||
class QSoundPrivate;
|
||||
|
||||
class Q_WIDGETS_EXPORT QSound : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static bool isAvailable();
|
||||
static void play(const QString& filename);
|
||||
|
||||
explicit QSound(const QString& filename, QObject* parent = 0);
|
||||
~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_DECLARE_PRIVATE(QSound)
|
||||
friend class QAuServer;
|
||||
};
|
||||
|
||||
#endif // QT_NO_SOUND
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSOUND_H
|
@ -1,100 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** 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.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSOUND_P_H
|
||||
#define QSOUND_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtCore/qobject.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
|
||||
class QSound;
|
||||
/*
|
||||
QAuServer is an INTERNAL class. If you wish to provide support for
|
||||
additional audio servers, you can make a subclass of QAuServer to do
|
||||
so, HOWEVER, your class may need to be re-engineered to some degree
|
||||
with each new Qt release, including minor releases.
|
||||
|
||||
QAuBucket is whatever you want.
|
||||
*/
|
||||
|
||||
class QAuBucket {
|
||||
public:
|
||||
virtual ~QAuBucket();
|
||||
};
|
||||
|
||||
class QAuServer : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QAuServer(QObject* parent);
|
||||
~QAuServer();
|
||||
|
||||
virtual void init(QSound*);
|
||||
virtual void play(const QString& filename);
|
||||
virtual void play(QSound*)=0;
|
||||
virtual void stop(QSound*)=0;
|
||||
virtual bool okay()=0;
|
||||
|
||||
protected:
|
||||
void setBucket(QSound*, QAuBucket*);
|
||||
QAuBucket* bucket(QSound*);
|
||||
int decLoop(QSound*);
|
||||
};
|
||||
|
||||
#endif // QT_NO_SOUND
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QSOUND_P_H
|
@ -1,190 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** 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.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <qapplication.h>
|
||||
#include "qsound.h"
|
||||
#include "qsound_p.h"
|
||||
#include <private/qt_mac_p.h>
|
||||
#include <qhash.h>
|
||||
#include <qdebug.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include <AppKit/NSSound.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
void qt_mac_beep()
|
||||
{
|
||||
NSBeep();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef QHash<QSound *, NSSound const *> Sounds;
|
||||
static Sounds sounds;
|
||||
|
||||
class QAuServerMac : public QAuServer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QAuServerMac(QObject* parent) : QAuServer(parent) { }
|
||||
void play(const QString& filename);
|
||||
void play(QSound *s);
|
||||
void stop(QSound*);
|
||||
bool okay() { return true; }
|
||||
using QAuServer::decLoop; // promote to public.
|
||||
protected:
|
||||
NSSound *createNSSound(const QString &filename, QSound *qSound);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
|
||||
@protocol NSSoundDelegate <NSObject>
|
||||
-(void)sound:(NSSound *)sound didFinishPlaying:(BOOL)aBool;
|
||||
@end
|
||||
#endif
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(QMacSoundDelegate) : NSObject<NSSoundDelegate> {
|
||||
QSound *qSound; // may be null.
|
||||
QAuServerMac* server;
|
||||
}
|
||||
-(id)initWithQSound:(QSound*)sound:(QAuServerMac*)server;
|
||||
@end
|
||||
|
||||
@implementation QT_MANGLE_NAMESPACE(QMacSoundDelegate)
|
||||
-(id)initWithQSound:(QSound*)s:(QAuServerMac*)serv {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
qSound = s;
|
||||
server = serv;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// Delegate function that gets called each time a sound finishes.
|
||||
-(void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finishedOk
|
||||
{
|
||||
// qSound is null if this sound was started by play(QString),
|
||||
// in which case there is no corresponding QSound object.
|
||||
if (qSound == 0) {
|
||||
[sound release];
|
||||
[self release];
|
||||
return;
|
||||
}
|
||||
|
||||
// finishedOk is false if the sound cold not be played or
|
||||
// if it was interrupted by stop().
|
||||
if (finishedOk == false) {
|
||||
sounds.remove(qSound);
|
||||
[sound release];
|
||||
[self release];
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the sound should loop "forever" (until stop).
|
||||
if (qSound->loops() == -1) {
|
||||
[sound play];
|
||||
return;
|
||||
}
|
||||
|
||||
const int remainingIterations = server->decLoop(qSound);
|
||||
if (remainingIterations > 0) {
|
||||
[sound play];
|
||||
} else {
|
||||
sounds.remove(qSound);
|
||||
[sound release];
|
||||
[self release];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
void QAuServerMac::play(const QString &fileName)
|
||||
{
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
NSSound * const nsSound = createNSSound(fileName, 0);
|
||||
[nsSound play];
|
||||
}
|
||||
|
||||
void QAuServerMac::play(QSound *qSound)
|
||||
{
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
NSSound * const nsSound = createNSSound(qSound->fileName(), qSound);
|
||||
[nsSound play];
|
||||
// Keep track of the nsSound object so we can find it again in stop().
|
||||
sounds[qSound] = nsSound;
|
||||
}
|
||||
|
||||
void QAuServerMac::stop(QSound *qSound)
|
||||
{
|
||||
Sounds::const_iterator it = sounds.constFind(qSound);
|
||||
if (it != sounds.constEnd())
|
||||
[*it stop];
|
||||
}
|
||||
|
||||
// Creates an NSSound object and installs a "sound finished" callack delegate on it.
|
||||
NSSound *QAuServerMac::createNSSound(const QString &fileName, QSound *qSound)
|
||||
{
|
||||
NSString *nsFileName = const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(fileName)));
|
||||
NSSound * const nsSound = [[NSSound alloc] initWithContentsOfFile: nsFileName byReference:YES];
|
||||
QT_MANGLE_NAMESPACE(QMacSoundDelegate) * const delegate = [[QT_MANGLE_NAMESPACE(QMacSoundDelegate) alloc] initWithQSound:qSound:this];
|
||||
[nsSound setDelegate:delegate];
|
||||
[nsFileName release];
|
||||
return nsSound;
|
||||
}
|
||||
|
||||
QAuServer* qt_new_audio_server()
|
||||
{
|
||||
return new QAuServerMac(qApp);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qsound_mac.moc"
|
||||
|
||||
#endif // QT_NO_SOUND
|
@ -9,7 +9,6 @@ SUBDIRS=\
|
||||
qgridlayout \
|
||||
qinputcontext \
|
||||
qlayout \
|
||||
qsound \
|
||||
qstackedlayout \
|
||||
qtooltip \
|
||||
qwidget \
|
||||
|
1
tests/auto/widgets/kernel/qsound/.gitignore
vendored
1
tests/auto/widgets/kernel/qsound/.gitignore
vendored
@ -1 +0,0 @@
|
||||
tst_qsound
|
Binary file not shown.
@ -1,12 +0,0 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qsound
|
||||
SOURCES += tst_qsound.cpp
|
||||
QT += testlib widgets
|
||||
|
||||
wince* {
|
||||
deploy.files += 4.wav
|
||||
DEPLOYMENT += deploy
|
||||
DEFINES += SRCDIR=\\\"\\\"
|
||||
} else {
|
||||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** 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.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtWidgets>
|
||||
|
||||
class tst_QSound : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QSound( QObject* parent=0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
void checkFinished();
|
||||
|
||||
// Manual tests
|
||||
void staticPlay();
|
||||
};
|
||||
|
||||
void tst_QSound::checkFinished()
|
||||
{
|
||||
QSKIP("QSound is not implemented on Lighthouse");
|
||||
QSound sound(SRCDIR"4.wav");
|
||||
sound.setLoops(3);
|
||||
sound.play();
|
||||
QTest::qWait(5000);
|
||||
|
||||
#if defined(Q_WS_QWS)
|
||||
QEXPECT_FAIL("", "QSound buggy on embedded (task QTBUG-157)", Abort);
|
||||
#endif
|
||||
QVERIFY(sound.isFinished() );
|
||||
}
|
||||
|
||||
void tst_QSound::staticPlay()
|
||||
{
|
||||
QSKIP("Test disabled -- only for manual purposes");
|
||||
// Check that you hear sound with static play also.
|
||||
QSound::play(SRCDIR"4.wav");
|
||||
QTest::qWait(2000);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QSound);
|
||||
#include "tst_qsound.moc"
|
Loading…
Reference in New Issue
Block a user