1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-10 16:14:40 +02:00

Prefix member objects with m_

This commit is contained in:
Uwe L. Korn
2014-10-22 18:41:08 +02:00
parent 7526422be6
commit 5298640f63
2 changed files with 71 additions and 75 deletions

View File

@@ -51,10 +51,10 @@ AudioOutput::instance()
AudioOutput::AudioOutput( QObject* parent ) AudioOutput::AudioOutput( QObject* parent )
: QObject( parent ) : QObject( parent )
, currentState( Stopped ) , m_currentState( Stopped )
, currentStream( nullptr ) , m_currentStream( nullptr )
, seekable( true ) , m_seekable( true )
, muted( false ) , m_muted( false )
, m_autoDelete ( true ) , m_autoDelete ( true )
, m_volume( 1.0 ) , m_volume( 1.0 )
, m_currentTime( 0 ) , m_currentTime( 0 )
@@ -62,9 +62,9 @@ AudioOutput::AudioOutput( QObject* parent )
, m_aboutToFinish( false ) , m_aboutToFinish( false )
, m_justSeeked( false ) , m_justSeeked( false )
, dspPluginCallback( nullptr ) , dspPluginCallback( nullptr )
, vlcInstance( nullptr ) , m_vlcInstance( nullptr )
, vlcPlayer( nullptr ) , m_vlcPlayer( nullptr )
, vlcMedia( nullptr ) , m_vlcMedia( nullptr )
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
@@ -88,15 +88,15 @@ AudioOutput::AudioOutput( QObject* parent )
}; };
// Create and initialize a libvlc instance (it should be done only once) // Create and initialize a libvlc instance (it should be done only once)
vlcInstance = libvlc_new( sizeof(vlcArgs) / sizeof(*vlcArgs), vlcArgs ); m_vlcInstance = libvlc_new( sizeof(vlcArgs) / sizeof(*vlcArgs), vlcArgs );
if ( !vlcInstance ) { if ( !m_vlcInstance ) {
tDebug() << "libVLC: could not initialize"; tDebug() << "libVLC: could not initialize";
} }
vlcPlayer = libvlc_media_player_new( vlcInstance ); m_vlcPlayer = libvlc_media_player_new( m_vlcInstance );
libvlc_event_manager_t* manager = libvlc_media_player_event_manager( vlcPlayer ); libvlc_event_manager_t* manager = libvlc_media_player_event_manager( m_vlcPlayer );
libvlc_event_type_t events[] = { libvlc_event_type_t events[] = {
libvlc_MediaPlayerMediaChanged, libvlc_MediaPlayerMediaChanged,
libvlc_MediaPlayerNothingSpecial, libvlc_MediaPlayerNothingSpecial,
@@ -131,17 +131,17 @@ AudioOutput::~AudioOutput()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
if ( vlcPlayer != nullptr ) { if ( m_vlcPlayer != nullptr ) {
libvlc_media_player_stop( vlcPlayer ); libvlc_media_player_stop( m_vlcPlayer );
libvlc_media_player_release( vlcPlayer ); libvlc_media_player_release( m_vlcPlayer );
vlcPlayer = nullptr; m_vlcPlayer = nullptr;
} }
if ( vlcMedia != nullptr ) { if ( m_vlcMedia != nullptr ) {
libvlc_media_release( vlcMedia ); libvlc_media_release( m_vlcMedia );
vlcMedia = nullptr; m_vlcMedia = nullptr;
} }
if ( vlcInstance != nullptr ) { if ( m_vlcInstance != nullptr ) {
libvlc_release( vlcInstance ); libvlc_release( m_vlcInstance );
} }
} }
@@ -174,21 +174,21 @@ AudioOutput::setCurrentSource( MediaStream* stream )
setState(Loading); setState(Loading);
if ( vlcMedia != nullptr ) { if ( m_vlcMedia != nullptr ) {
// Ensure playback is stopped, then release media // Ensure playback is stopped, then release media
libvlc_media_player_stop( vlcPlayer ); libvlc_media_player_stop( m_vlcPlayer );
libvlc_media_release( vlcMedia ); libvlc_media_release( m_vlcMedia );
vlcMedia = nullptr; m_vlcMedia = nullptr;
} }
if ( m_autoDelete && currentStream != nullptr ) { if ( m_autoDelete && m_currentStream != nullptr ) {
delete currentStream; delete m_currentStream;
} }
currentStream = stream; m_currentStream = stream;
m_totalTime = 0; m_totalTime = 0;
m_currentTime = 0; m_currentTime = 0;
m_justSeeked = false; m_justSeeked = false;
seekable = true; m_seekable = true;
QByteArray url; QByteArray url;
switch (stream->type()) { switch (stream->type()) {
@@ -220,9 +220,9 @@ AudioOutput::setCurrentSource( MediaStream* stream )
tDebug() << "MediaStream::Final Url:" << url; tDebug() << "MediaStream::Final Url:" << url;
vlcMedia = libvlc_media_new_location( vlcInstance, url.constData() ); m_vlcMedia = libvlc_media_new_location( m_vlcInstance, url.constData() );
libvlc_event_manager_t* manager = libvlc_media_event_manager( vlcMedia ); libvlc_event_manager_t* manager = libvlc_media_event_manager( m_vlcMedia );
libvlc_event_type_t events[] = { libvlc_event_type_t events[] = {
libvlc_MediaDurationChanged, libvlc_MediaDurationChanged,
}; };
@@ -231,23 +231,23 @@ AudioOutput::setCurrentSource( MediaStream* stream )
libvlc_event_attach( manager, events[ i ], &AudioOutput::vlcEventCallback, this ); libvlc_event_attach( manager, events[ i ], &AudioOutput::vlcEventCallback, this );
} }
libvlc_media_player_set_media( vlcPlayer, vlcMedia ); libvlc_media_player_set_media( m_vlcPlayer, m_vlcMedia );
if ( stream->type() == MediaStream::Url ) if ( stream->type() == MediaStream::Url )
{ {
m_totalTime = libvlc_media_get_duration( vlcMedia ); m_totalTime = libvlc_media_get_duration( m_vlcMedia );
} }
else if ( stream->type() == MediaStream::Stream || stream->type() == MediaStream::IODevice ) else if ( stream->type() == MediaStream::Stream || stream->type() == MediaStream::IODevice )
{ {
libvlc_media_add_option_flag(vlcMedia, "imem-cat=4", libvlc_media_option_trusted); libvlc_media_add_option_flag(m_vlcMedia, "imem-cat=4", libvlc_media_option_trusted);
const char* imemData = QString( "imem-data=%1" ).arg( (uintptr_t)stream ).toLatin1().constData(); const char* imemData = QString( "imem-data=%1" ).arg( (uintptr_t)stream ).toLatin1().constData();
libvlc_media_add_option_flag(vlcMedia, imemData, libvlc_media_option_trusted); libvlc_media_add_option_flag(m_vlcMedia, imemData, libvlc_media_option_trusted);
const char* imemGet = QString( "imem-get=%1" ).arg( (uintptr_t)&MediaStream::readCallback ).toLatin1().constData(); const char* imemGet = QString( "imem-get=%1" ).arg( (uintptr_t)&MediaStream::readCallback ).toLatin1().constData();
libvlc_media_add_option_flag(vlcMedia, imemGet, libvlc_media_option_trusted); libvlc_media_add_option_flag(m_vlcMedia, imemGet, libvlc_media_option_trusted);
const char* imemRelease = QString( "imem-release=%1" ).arg( (uintptr_t)&MediaStream::readDoneCallback ).toLatin1().constData(); const char* imemRelease = QString( "imem-release=%1" ).arg( (uintptr_t)&MediaStream::readDoneCallback ).toLatin1().constData();
libvlc_media_add_option_flag(vlcMedia, imemRelease, libvlc_media_option_trusted); libvlc_media_add_option_flag(m_vlcMedia, imemRelease, libvlc_media_option_trusted);
const char* imemSeek = QString( "imem-seek=%1" ).arg( (uintptr_t)&MediaStream::seekCallback ).toLatin1().constData(); const char* imemSeek = QString( "imem-seek=%1" ).arg( (uintptr_t)&MediaStream::seekCallback ).toLatin1().constData();
libvlc_media_add_option_flag(vlcMedia, imemSeek, libvlc_media_option_trusted); libvlc_media_add_option_flag(m_vlcMedia, imemSeek, libvlc_media_option_trusted);
} }
m_aboutToFinish = false; m_aboutToFinish = false;
@@ -259,7 +259,7 @@ AudioOutput::AudioState
AudioOutput::state() AudioOutput::state()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
return currentState; return m_currentState;
} }
@@ -267,8 +267,8 @@ void
AudioOutput::setState( AudioState state ) AudioOutput::setState( AudioState state )
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
AudioState last = currentState; AudioState last = m_currentState;
currentState = state; m_currentState = state;
emit stateChanged ( state, last ); emit stateChanged ( state, last );
} }
@@ -287,7 +287,7 @@ AudioOutput::setCurrentTime( qint64 time )
// if we are about to finish // if we are about to finish
if ( m_totalTime == 0 ) { if ( m_totalTime == 0 ) {
m_totalTime = AudioEngine::instance()->currentTrackTotalTime(); m_totalTime = AudioEngine::instance()->currentTrackTotalTime();
seekable = true; m_seekable = true;
} }
m_currentTime = time; m_currentTime = time;
@@ -325,10 +325,10 @@ AudioOutput::setTotalTime( qint64 time )
tDebug() << Q_FUNC_INFO << " " << time; tDebug() << Q_FUNC_INFO << " " << time;
if ( time <= 0 ) { if ( time <= 0 ) {
seekable = false; m_seekable = false;
} else { } else {
m_totalTime = time; m_totalTime = time;
seekable = true; m_seekable = true;
// emit current time to refresh total time // emit current time to refresh total time
emit tick( time ); emit tick( time );
} }
@@ -340,10 +340,10 @@ AudioOutput::play()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
if ( libvlc_media_player_is_playing ( vlcPlayer ) ) { if ( libvlc_media_player_is_playing ( m_vlcPlayer ) ) {
libvlc_media_player_set_pause ( vlcPlayer, 0 ); libvlc_media_player_set_pause ( m_vlcPlayer, 0 );
} else { } else {
libvlc_media_player_play ( vlcPlayer ); libvlc_media_player_play ( m_vlcPlayer );
} }
setState( Playing ); setState( Playing );
@@ -355,7 +355,7 @@ AudioOutput::pause()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
libvlc_media_player_set_pause ( vlcPlayer, 1 ); libvlc_media_player_set_pause ( m_vlcPlayer, 1 );
setState( Paused ); setState( Paused );
} }
@@ -365,7 +365,7 @@ void
AudioOutput::stop() AudioOutput::stop()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
libvlc_media_player_stop ( vlcPlayer ); libvlc_media_player_stop ( m_vlcPlayer );
setState( Stopped ); setState( Stopped );
} }
@@ -382,7 +382,7 @@ AudioOutput::seek( qint64 milliseconds )
// return; // return;
// } // }
switch ( currentState ) { switch ( m_currentState ) {
case Playing: case Playing:
case Paused: case Paused:
case Loading: case Loading:
@@ -395,26 +395,22 @@ AudioOutput::seek( qint64 milliseconds )
// tDebug() << "AudioOutput:: seeking" << milliseconds << "msec"; // tDebug() << "AudioOutput:: seeking" << milliseconds << "msec";
m_justSeeked = true; m_justSeeked = true;
libvlc_media_player_set_time ( vlcPlayer, milliseconds ); libvlc_media_player_set_time ( m_vlcPlayer, milliseconds );
setCurrentTime( milliseconds ); setCurrentTime( milliseconds );
} }
bool bool
AudioOutput::isSeekable() AudioOutput::isSeekable() const
{ {
tDebug() << Q_FUNC_INFO; return m_seekable;
return seekable;
} }
bool bool
AudioOutput::isMuted() AudioOutput::isMuted() const
{ {
tDebug() << Q_FUNC_INFO; return m_muted;
return muted;
} }
@@ -423,11 +419,11 @@ AudioOutput::setMuted(bool m)
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
muted = m; m_muted = m;
if ( muted == true ) { if ( m_muted == true ) {
libvlc_audio_set_volume( vlcPlayer, 0 ); libvlc_audio_set_volume( m_vlcPlayer, 0 );
} else { } else {
libvlc_audio_set_volume( vlcPlayer, m_volume * 100.0 ); libvlc_audio_set_volume( m_vlcPlayer, m_volume * 100.0 );
} }
} }
@@ -437,7 +433,7 @@ AudioOutput::volume()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
return muted ? 0 : m_volume; return m_muted ? 0 : m_volume;
} }
@@ -447,8 +443,8 @@ AudioOutput::setVolume(qreal vol)
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
m_volume = vol; m_volume = vol;
if ( !muted ) { if ( !m_muted ) {
libvlc_audio_set_volume( vlcPlayer, m_volume * 100.0 ); libvlc_audio_set_volume( m_vlcPlayer, m_volume * 100.0 );
} }
} }
@@ -486,7 +482,7 @@ AudioOutput::vlcEventCallback( const libvlc_event_t* event, void* opaque )
break; break;
case libvlc_MediaPlayerEncounteredError: case libvlc_MediaPlayerEncounteredError:
tDebug() << "LibVLC error : MediaPlayerEncounteredError. Stopping"; tDebug() << "LibVLC error : MediaPlayerEncounteredError. Stopping";
if ( that->vlcPlayer != 0 ) { if ( that->m_vlcPlayer != 0 ) {
that->stop(); that->stop();
} }
that->setState( Error ); that->setState( Error );

View File

@@ -54,8 +54,8 @@ public:
void stop(); void stop();
void seek( qint64 milliseconds ); void seek( qint64 milliseconds );
bool isSeekable(); bool isSeekable() const;
bool isMuted(); bool isMuted() const;
void setMuted( bool m ); void setMuted( bool m );
void setVolume( qreal vol ); void setVolume( qreal vol );
qreal volume(); qreal volume();
@@ -83,10 +83,10 @@ private:
static void s_dspCallback( int frameNumber, float* samples, int nb_channels, int nb_samples ); static void s_dspCallback( int frameNumber, float* samples, int nb_channels, int nb_samples );
static AudioOutput* s_instance; static AudioOutput* s_instance;
AudioState currentState; AudioState m_currentState;
MediaStream* currentStream; MediaStream* m_currentStream;
bool seekable; bool m_seekable;
bool muted; bool m_muted;
bool m_autoDelete; bool m_autoDelete;
qreal m_volume; qreal m_volume;
qint64 m_currentTime; qint64 m_currentTime;
@@ -96,9 +96,9 @@ private:
std::function< void( int state, int frameNumber, float* samples, int nb_channels, int nb_samples ) > dspPluginCallback; std::function< void( int state, int frameNumber, float* samples, int nb_channels, int nb_samples ) > dspPluginCallback;
libvlc_instance_t* vlcInstance; libvlc_instance_t* m_vlcInstance;
libvlc_media_player_t* vlcPlayer; libvlc_media_player_t* m_vlcPlayer;
libvlc_media_t* vlcMedia; libvlc_media_t* m_vlcMedia;
}; };
#endif // AUDIOOUTPUT_H #endif // AUDIOOUTPUT_H