mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 11:54:22 -04:00
fixed sound on linux using phonon. This should be extensible to all unix systems
This commit is contained in:
parent
fc3606c18e
commit
e25787bcd5
3 changed files with 32 additions and 4 deletions
|
@ -37,6 +37,14 @@
|
||||||
#define GROUP_ENABLE "Enable"
|
#define GROUP_ENABLE "Enable"
|
||||||
#define GROUP_SOUNDFILE "SoundFilePath"
|
#define GROUP_SOUNDFILE "SoundFilePath"
|
||||||
|
|
||||||
|
#ifdef UBUNTU
|
||||||
|
#include <phonon/audiooutput.h>
|
||||||
|
#include <phonon/mediaobject.h>
|
||||||
|
#include <phonon/mediasource.h>
|
||||||
|
|
||||||
|
Phonon::MediaObject *SoundManager::mediaObject = NULL ;
|
||||||
|
#endif
|
||||||
|
|
||||||
SoundManager *soundManager = NULL;
|
SoundManager *soundManager = NULL;
|
||||||
|
|
||||||
SoundEvents::SoundEvents()
|
SoundEvents::SoundEvents()
|
||||||
|
@ -234,12 +242,24 @@ void SoundManager::playFile(const QString &filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString playFilename = realFilename(filename);
|
QString playFilename = realFilename(filename);
|
||||||
|
|
||||||
|
#ifdef UBUNTU
|
||||||
|
// The media object is only deleted before being used, so as to avoid a memory leak. We cannot delete it after calling play() because the
|
||||||
|
// playing is asynchronous. The way to do this properly would be to connect the finish() signal of the player to some slot that delete it,
|
||||||
|
// assuming it's not done in a static method like now.
|
||||||
|
|
||||||
|
if(mediaObject != NULL)
|
||||||
|
delete mediaObject ;
|
||||||
|
|
||||||
|
mediaObject = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(QUrl::fromLocalFile(filename)));
|
||||||
|
mediaObject->play();
|
||||||
|
#else
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
|
||||||
if (!QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).isEmpty()) {
|
if (!QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).isEmpty())
|
||||||
#else
|
#else
|
||||||
if (QSound::isAvailable()) {
|
if (QSound::isAvailable())
|
||||||
#endif
|
#endif
|
||||||
QSound::play(playFilename);
|
QSound::play(playFilename);
|
||||||
}
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#define SOUND_MESSAGE_ARRIVED "MessageArrived"
|
#define SOUND_MESSAGE_ARRIVED "MessageArrived"
|
||||||
#define SOUND_DOWNLOAD_COMPLETE "DownloadComplete"
|
#define SOUND_DOWNLOAD_COMPLETE "DownloadComplete"
|
||||||
|
|
||||||
|
#ifdef UBUNTU
|
||||||
|
#include <phonon/mediaobject.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class SoundEvents
|
class SoundEvents
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -84,9 +88,12 @@ public:
|
||||||
|
|
||||||
static QString eventFilename(const QString &event);
|
static QString eventFilename(const QString &event);
|
||||||
static void setEventFilename(const QString &event, const QString &filename);
|
static void setEventFilename(const QString &event, const QString &filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SoundManager();
|
SoundManager();
|
||||||
|
#ifdef UBUNTU
|
||||||
|
static Phonon::MediaObject *mediaObject ;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SoundManager *soundManager;
|
extern SoundManager *soundManager;
|
||||||
|
|
|
@ -66,6 +66,7 @@ linux-* {
|
||||||
|
|
||||||
PKGCONFIG *= x11 xscrnsaver
|
PKGCONFIG *= x11 xscrnsaver
|
||||||
|
|
||||||
|
LIBS *= -lphonon
|
||||||
LIBS *= -rdynamic
|
LIBS *= -rdynamic
|
||||||
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
||||||
DEFINES *= UBUNTU
|
DEFINES *= UBUNTU
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue