goldendict-ng/ffmpegaudioplayer.hh
Igor Kushnir fb71eb4ce1 Stop Ffmpeg::AudioService in Ffmpeg::~AudioPlayer()
When the current audio player instance changes, the destroyed player's
playback must be stopped for consistency between implementations and to
avoid surprises. Note that this residual playback could be stopped only
by switching back to the Ffmpeg player or by exiting the application.
2018-04-16 18:12:41 +03:00

47 lines
856 B
C++

/* This file is (c) 2018 Igor Kushnir <igorkuo@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef FFMPEGAUDIOPLAYER_HH_INCLUDED
#define FFMPEGAUDIOPLAYER_HH_INCLUDED
#include "audioplayerinterface.hh"
#include "ffmpegaudio.hh"
#ifdef MAKE_FFMPEG_PLAYER
namespace Ffmpeg
{
class AudioPlayer : public AudioPlayerInterface
{
Q_OBJECT
public:
AudioPlayer()
{
connect( &AudioService::instance(), SIGNAL( error( QString ) ),
this, SIGNAL( error( QString ) ) );
}
~AudioPlayer()
{
stop();
}
virtual QString play( const char * data, int size )
{
AudioService::instance().playMemory( data, size );
return QString();
}
virtual void stop()
{
AudioService::instance().stop();
}
};
}
#endif // MAKE_FFMPEG_PLAYER
#endif // FFMPEGAUDIOPLAYER_HH_INCLUDED