From 73029ab7a2032b8f99cf0e293dd76fcdb2ca6533 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 28 Jul 2018 00:09:39 +0200 Subject: [PATCH] Remove dead analyzer code from VLC engine --- src/engine/vlcengine.cpp | 83 +++++++++------------------------------ src/engine/vlcengine.h | 10 +---- src/engine/vlcscopedref.h | 4 +- 3 files changed, 23 insertions(+), 74 deletions(-) diff --git a/src/engine/vlcengine.cpp b/src/engine/vlcengine.cpp index 0802881d2..8c2f2963a 100644 --- a/src/engine/vlcengine.cpp +++ b/src/engine/vlcengine.cpp @@ -1,6 +1,7 @@ /* * Strawberry Music Player - * This file was part of Clementine + * This file was part of Clementine. + * Copyright 2010, David Sansome * Copyright 2017-2018, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify @@ -24,7 +25,6 @@ #include #include -#include #include #include @@ -37,14 +37,11 @@ #include "vlcengine.h" #include "vlcscopedref.h" -VLCEngine *VLCEngine::sInstance = nullptr; - VLCEngine::VLCEngine(TaskManager *task_manager) : EngineBase(), instance_(nullptr), player_(nullptr), - state_(Engine::Empty), - scope_data_(4096) { + state_(Engine::Empty) { type_ = Engine::VLC; ReloadSettings(); @@ -62,30 +59,16 @@ VLCEngine::~VLCEngine() { bool VLCEngine::Init() { -/* FIXME: Do we need this? - static const char *const args[] = { - "-I", "dummy", // Don't use any interface - "--ignore-config", // Don't use VLC's config - "--extraintf=logger", // log anything - "--verbose=2", // be much more verbose then normal for debugging purpose - - // Our scope plugin - "--audio-filter=strawberry_scope", + const char *args[] = { + //"--verbose=3", + "--ignore-config", "--no-plugins-cache", - - // Try to stop audio stuttering - "--file-caching=500", // msec - "--http-caching=500", - -#ifdef HAVE_ALSA_ - "--aout=alsa", // The default, pulseaudio, is buggy -#endif + "--no-xlib", + "--no-video", }; -*/ // Create the VLC instance - instance_ = libvlc_new(0, nullptr); - //instance_ = libvlc_new(sizeof(args) / sizeof(args[0]), args); + instance_ = libvlc_new(sizeof(args) / sizeof(*args), args); HandleErrors(); // Create the media player @@ -106,8 +89,6 @@ bool VLCEngine::Init() { AttachCallback(player_em, libvlc_MediaPlayerEndReached, StateChangedCallback); HandleErrors(); - sInstance = this; - return true; } @@ -120,7 +101,9 @@ bool VLCEngine::Initialised() const { } bool VLCEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) { + if (!Initialised()) return false; + // Create the media object VlcScopedRef media(libvlc_media_new_location(instance_, url.toEncoded().constData())); @@ -131,7 +114,9 @@ bool VLCEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool forc } bool VLCEngine::Play(quint64 offset_nanosec) { + if (!Initialised()) return false; + // Set audio output if (!output_.isEmpty() || output_ != "auto") { int result = libvlc_audio_output_set(player_, output_.toUtf8().constData()); @@ -149,11 +134,11 @@ bool VLCEngine::Play(quint64 offset_nanosec) { Seek(offset_nanosec); return true; - } void VLCEngine::Stop(bool stop_after) { + if (!Initialised()) return; libvlc_media_player_stop(player_); HandleErrors(); @@ -161,6 +146,7 @@ void VLCEngine::Stop(bool stop_after) { } void VLCEngine::Pause() { + if (!Initialised()) return; libvlc_media_player_pause(player_); HandleErrors(); @@ -168,6 +154,7 @@ void VLCEngine::Pause() { } void VLCEngine::Unpause() { + if (!Initialised()) return; libvlc_media_player_play(player_); HandleErrors(); @@ -175,10 +162,10 @@ void VLCEngine::Unpause() { } void VLCEngine::Seek(quint64 offset_nanosec) { - + if (!Initialised()) return; - int offset = (offset_nanosec / kNsecPerMsec); + int offset = (offset_nanosec / kNsecPerMsec); uint len = length(); if (len == 0) return; @@ -215,25 +202,6 @@ qint64 VLCEngine::length_nanosec() const { } } -const Engine::Scope &VLCEngine::Scope() { - - QMutexLocker l(&scope_mutex_); - - // Leave the scope unchanged if there's not enough data - if (scope_data_.size() < uint(kScopeSize)) - return scope_; - - // Take the samples off the front of the circular buffer - for (uint i=0 ; iscope_mutex_); - - // This gets called by our VLC plugin. Just push the data on to the end of the circular buffer and let it get consumed by scope() - for (int i=0 ; iscope_data_.push_back(data[i]); - } - -} - void VLCEngine::HandleErrors() const { } void VLCEngine::AttachCallback(libvlc_event_manager_t *em, libvlc_event_type_t type, libvlc_callback_t callback) { - + libvlc_event_attach(em, type, callback, this); HandleErrors(); diff --git a/src/engine/vlcengine.h b/src/engine/vlcengine.h index 2a9eee358..25339207c 100644 --- a/src/engine/vlcengine.h +++ b/src/engine/vlcengine.h @@ -1,6 +1,7 @@ /* * Strawberry Music Player - * This file was part of Clementine + * This file was part of Clementine. + * Copyright 2010, David Sansome * Copyright 2017-2018, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify @@ -29,7 +30,6 @@ #include #include -#include #include #include @@ -60,7 +60,6 @@ class VLCEngine : public Engine::Base { public: virtual qint64 position_nanosec() const; virtual qint64 length_nanosec() const; - const Engine::Scope& Scope(); OutputDetailsList GetOutputsList() const; bool ValidOutput(const QString &output); @@ -71,16 +70,11 @@ class VLCEngine : public Engine::Base { libvlc_instance_t *instance_; libvlc_media_player_t *player_; Engine::State state_; - boost::circular_buffer scope_data_; - - static VLCEngine *sInstance; - QMutex scope_mutex_; bool Initialised() const; uint position() const; uint length() const; bool CanDecode(const QUrl &url); - static void SetScopeData(float* data, int size); void HandleErrors() const; void AttachCallback(libvlc_event_manager_t* em, libvlc_event_type_t type, libvlc_callback_t callback); static void StateChangedCallback(const libvlc_event_t* e, void* data); diff --git a/src/engine/vlcscopedref.h b/src/engine/vlcscopedref.h index 881c70ce3..43d4cf29b 100644 --- a/src/engine/vlcscopedref.h +++ b/src/engine/vlcscopedref.h @@ -1,7 +1,7 @@ /* * Strawberry Music Player - * This file was part of Clementine - * Copyright 2017-2018, Jonas Kvinge + * This file was part of Clementine. + * Copyright 2010, David Sansome * * Strawberry is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by