mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-18 03:14:06 +00:00
9aa3c44d4e
* add config and GUI support for internal player back end switching; * make FFmpeg player disabling option consistent with other similar qmake options by using CONFIG; * add a new qmake option that disables Qt Multimedia player. This is useful for GNU/Linux distributions where Qt WebKit and Qt Multimedia packages depend on different GStreamer versions and don't work correctly when combined in one application. The existing FFmpeg+libao internal player back end has a relatively low-level implementation, which is difficult to understand and improve. There are at least 3 open internal player issues: 1) many GNU/Linux users have to edit their libao configuration file to make Goldendict's internal player work (issue #412); 2) libao's pulseaudio plugin does not support 32-bit audio, which means that many MediaWiki pronunciations don't work with the most popular GNU/Linux audio driver (issue #949); 3) Ffmpeg::DecoderContext uses deprecated FFmpeg APIs, which causes compiler warnings and means that this internal player back end may not compile with a future FFmpeg library version (issue #978). The Qt Multimedia back end implementation uses the highest-level Qt audio API and is very simple. This new back end works flawlessly on my GNU/Linux machine. I'm not making it the default back end because I don't know how well it will work on other platforms with different configurations.
58 lines
961 B
C++
58 lines
961 B
C++
#ifndef __FFMPEGAUDIO_HH_INCLUDED__
|
|
#define __FFMPEGAUDIO_HH_INCLUDED__
|
|
|
|
#ifdef MAKE_FFMPEG_PLAYER
|
|
|
|
#include <QObject>
|
|
#include <QMutex>
|
|
#include <QAtomicInt>
|
|
#include <QByteArray>
|
|
#include <QThread>
|
|
|
|
namespace Ffmpeg
|
|
{
|
|
|
|
class AudioService : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static AudioService & instance();
|
|
void playMemory( const char * ptr, int size );
|
|
void stop();
|
|
|
|
signals:
|
|
void cancelPlaying( bool waitUntilFinished );
|
|
void error( QString const & message );
|
|
|
|
private:
|
|
AudioService();
|
|
~AudioService();
|
|
};
|
|
|
|
class DecoderThread: public QThread
|
|
{
|
|
Q_OBJECT
|
|
|
|
static QMutex deviceMutex_;
|
|
QAtomicInt isCancelled_;
|
|
QByteArray audioData_;
|
|
|
|
public:
|
|
DecoderThread( QByteArray const & audioData, QObject * parent );
|
|
virtual ~DecoderThread();
|
|
|
|
public slots:
|
|
void run();
|
|
void cancel( bool waitUntilFinished );
|
|
|
|
signals:
|
|
void error( QString const & message );
|
|
};
|
|
|
|
}
|
|
|
|
#endif // MAKE_FFMPEG_PLAYER
|
|
|
|
#endif // __FFMPEGAUDIO_HH_INCLUDED__
|