AudioPlayer::AudioPlayer(Library* library, Backend backend, bool testing, QObject* parent) : QObject(parent) , library_(library) , mainWindow_(nullptr) , replaygain_(ReplayGainMode::None) , preamp_with_rg_(10) , playbackOrder_(PlaybackOrder::Default) , lengthHack_(false) , testing_(testing) { if (backend == Backend::mpv) audioOutput_.reset(new MpvAudioOutput); else audioOutput_.reset(new PhononAudioOutput); QObject::connect(audioOutput_.get(), SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish())); QObject::connect(audioOutput_.get(), SIGNAL(currentSourceChanged()), this, SLOT(currentSourceChanged())); QObject::connect(audioOutput_.get(), SIGNAL(tick(qint64)), this, SLOT(slotTick(qint64))); QObject::connect(audioOutput_.get(), SIGNAL(stateChanged(AudioState)), this, SLOT(slotAudioStateChanged(AudioState))); QObject::connect(audioOutput_.get(), SIGNAL(finished()), this, SLOT(slotFinished())); QObject::connect(audioOutput_.get(), SIGNAL(durationChanged(double)), this, SLOT(durationChanged(double))); QObject::connect(audioOutput_.get(), SIGNAL(metadataChanged(QString, QString, int)), this, SLOT(metadataChanged(QString, QString, int))); // Not using Phono totalTimeChanged() signal because it returns 0 when used with enqueue() // TODO: report bug to phonon // QObject::connect(audioOutput_, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); readSettings(); instance = this; }
GlobalTimer::GlobalTimer() : QObject(nullptr), timer(new QTimer()), tickCount(0) { timer->setInterval(1000); timer->setSingleShot(false); connect(timer.get(), SIGNAL(timeout()), this, SLOT(slotTick())); timer->start(); }
void EngineController::initializePhonon() { DEBUG_BLOCK delete m_media; delete m_audio; delete m_preamp; PERF_LOG( "EngineController: loading phonon objects" ) m_media = new Phonon::MediaObject( this ); m_audio = new Phonon::AudioOutput( Phonon::MusicCategory, this ); m_path = Phonon::createPath( m_media, m_audio ); // HACK we turn off replaygain manually on OSX, until the phonon coreaudio backend is fixed. // as the default is specified in the .cfg file, we can't just tell it to be a different default on OSX #ifdef Q_WS_MAC AmarokConfig::setReplayGainMode( AmarokConfig::EnumReplayGainMode::Off ); #endif // only create pre-amp if we have replaygain on, preamp can cause phonon issues if( AmarokConfig::replayGainMode() != AmarokConfig::EnumReplayGainMode::Off ) { m_preamp = new Phonon::VolumeFaderEffect( this ); m_path.insertEffect( m_preamp ); } m_media->setTickInterval( 100 ); debug() << "Tick Interval (actual): " << m_media->tickInterval(); PERF_LOG( "EngineController: loaded phonon objects" ) // Get the next track when there is 2 seconds left on the current one. m_media->setPrefinishMark( 2000 ); connect( m_media, SIGNAL( finished() ), SLOT( slotQueueEnded() ) ); connect( m_media, SIGNAL( aboutToFinish()), SLOT( slotAboutToFinish() ) ); connect( m_media, SIGNAL( metaDataChanged() ), SLOT( slotMetaDataChanged() ) ); connect( m_media, SIGNAL( stateChanged( Phonon::State, Phonon::State ) ), SLOT( slotStateChanged( Phonon::State, Phonon::State ) ) ); connect( m_media, SIGNAL( tick( qint64 ) ), SLOT( slotTick( qint64 ) ) ); connect( m_media, SIGNAL( totalTimeChanged( qint64 ) ), SLOT( slotTrackLengthChanged( qint64 ) ) ); connect( m_media, SIGNAL( currentSourceChanged( const Phonon::MediaSource & ) ), SLOT( slotNewTrackPlaying( const Phonon::MediaSource & ) ) ); //TODO: The xine engine does not support crossfading. Cannot get the gstreamer engine to work, will test this once I do. #if 0 if( AmarokConfig::trackDelayLength() > -1 ) m_media->setTransitionTime( AmarokConfig::trackDelayLength() ); // Also Handles gapless. else if( AmarokConfig::crossfadeLength() > 0 ) // TODO: Handle the possible options on when to crossfade.. the values are not documented anywhere however m_media->setTransitionTime( -AmarokConfig::crossfadeLength() ); #endif }