1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

Make VLC event handling a member function

This commit is contained in:
Uwe L. Korn
2014-10-22 18:51:18 +02:00
parent 6bb0d88df5
commit 215b43b27b
2 changed files with 21 additions and 13 deletions

View File

@@ -447,22 +447,17 @@ AudioOutput::setVolume(qreal vol)
void
AudioOutput::vlcEventCallback( const libvlc_event_t* event, void* opaque )
AudioOutput::onVlcEvent( const libvlc_event_t* event )
{
// tDebug() << Q_FUNC_INFO;
AudioOutput* that = reinterpret_cast < AudioOutput * > ( opaque );
Q_ASSERT( that );
switch (event->type) {
switch ( event->type ) {
case libvlc_MediaPlayerTimeChanged:
that->setCurrentTime( event->u.media_player_time_changed.new_time );
setCurrentTime( event->u.media_player_time_changed.new_time );
break;
case libvlc_MediaPlayerSeekableChanged:
// tDebug() << Q_FUNC_INFO << " : seekable changed : " << event->u.media_player_seekable_changed.new_seekable;
break;
case libvlc_MediaDurationChanged:
that->setTotalTime( event->u.media_duration_changed.new_duration );
setTotalTime( event->u.media_duration_changed.new_duration );
break;
case libvlc_MediaPlayerLengthChanged:
// tDebug() << Q_FUNC_INFO << " : length changed : " << event->u.media_player_length_changed.new_length;
@@ -475,14 +470,14 @@ AudioOutput::vlcEventCallback( const libvlc_event_t* event, void* opaque )
case libvlc_MediaPlayerStopped:
break;
case libvlc_MediaPlayerEndReached:
that->setState(Stopped);
setState( Stopped );
break;
case libvlc_MediaPlayerEncounteredError:
tDebug() << "LibVLC error : MediaPlayerEncounteredError. Stopping";
if ( that->m_vlcPlayer != 0 ) {
that->stop();
if ( m_vlcPlayer != nullptr ) {
stop();
}
that->setState( Error );
setState( Error );
break;
case libvlc_MediaPlayerVout:
case libvlc_MediaPlayerMediaChanged:
@@ -498,6 +493,18 @@ AudioOutput::vlcEventCallback( const libvlc_event_t* event, void* opaque )
}
void
AudioOutput::vlcEventCallback( const libvlc_event_t* event, void* opaque )
{
// tDebug() << Q_FUNC_INFO;
AudioOutput* that = reinterpret_cast < AudioOutput * > ( opaque );
Q_ASSERT( that );
that->onVlcEvent( event );
}
void
AudioOutput::s_dspCallback( int frameNumber, float* samples, int nb_channels, int nb_samples )
{

View File

@@ -79,6 +79,7 @@ private:
void setCurrentTime( qint64 time );
void setTotalTime( qint64 time );
void onVlcEvent( const libvlc_event_t* event );
static void vlcEventCallback( const libvlc_event_t *event, void *opaque );
static void s_dspCallback( int frameNumber, float* samples, int nb_channels, int nb_samples );