Merge pull request #997 from vedgy/small-audio-player-fixes

Small audio player fixes
This commit is contained in:
Abs62 2018-04-17 20:30:56 +03:00 committed by GitHub
commit d9980bf662
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -60,14 +60,14 @@ void AudioPlayerFactory::reset()
if( !internalPlayerBackend.isQtmultimedia() ) if( !internalPlayerBackend.isQtmultimedia() )
{ {
if( qobject_cast< Ffmpeg::AudioPlayer * >( playerPtr.data() ) == 0 ) if( !playerPtr || !qobject_cast< Ffmpeg::AudioPlayer * >( playerPtr.data() ) )
playerPtr.reset( new Ffmpeg::AudioPlayer ); playerPtr.reset( new Ffmpeg::AudioPlayer );
return; return;
} }
#endif #endif
#ifdef MAKE_QTMULTIMEDIA_PLAYER #ifdef MAKE_QTMULTIMEDIA_PLAYER
if( qobject_cast< MultimediaAudioPlayer * >( playerPtr.data() ) == 0 ) if( !playerPtr || !qobject_cast< MultimediaAudioPlayer * >( playerPtr.data() ) )
playerPtr.reset( new MultimediaAudioPlayer ); playerPtr.reset( new MultimediaAudioPlayer );
return; return;
#endif #endif

View file

@ -22,6 +22,11 @@ public:
this, SIGNAL( error( QString ) ) ); this, SIGNAL( error( QString ) ) );
} }
~AudioPlayer()
{
stop();
}
virtual QString play( const char * data, int size ) virtual QString play( const char * data, int size )
{ {
AudioService::instance().playMemory( data, size ); AudioService::instance().playMemory( data, size );