Remove dead analyzer code from VLC engine

This commit is contained in:
Jonas Kvinge 2018-07-28 00:09:39 +02:00
parent c3e916d945
commit 73029ab7a2
3 changed files with 23 additions and 74 deletions

View File

@ -1,6 +1,7 @@
/* /*
* Strawberry Music Player * Strawberry Music Player
* This file was part of Clementine * This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2017-2018, Jonas Kvinge <jonas@jkvinge.net> * Copyright 2017-2018, Jonas Kvinge <jonas@jkvinge.net>
* *
* Strawberry is free software: you can redistribute it and/or modify * Strawberry is free software: you can redistribute it and/or modify
@ -24,7 +25,6 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <QtGlobal> #include <QtGlobal>
#include <QMutex>
#include <QByteArray> #include <QByteArray>
#include <QUrl> #include <QUrl>
@ -37,14 +37,11 @@
#include "vlcengine.h" #include "vlcengine.h"
#include "vlcscopedref.h" #include "vlcscopedref.h"
VLCEngine *VLCEngine::sInstance = nullptr;
VLCEngine::VLCEngine(TaskManager *task_manager) VLCEngine::VLCEngine(TaskManager *task_manager)
: EngineBase(), : EngineBase(),
instance_(nullptr), instance_(nullptr),
player_(nullptr), player_(nullptr),
state_(Engine::Empty), state_(Engine::Empty) {
scope_data_(4096) {
type_ = Engine::VLC; type_ = Engine::VLC;
ReloadSettings(); ReloadSettings();
@ -62,30 +59,16 @@ VLCEngine::~VLCEngine() {
bool VLCEngine::Init() { bool VLCEngine::Init() {
/* FIXME: Do we need this? const char *args[] = {
static const char *const args[] = { //"--verbose=3",
"-I", "dummy", // Don't use any interface "--ignore-config",
"--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",
"--no-plugins-cache", "--no-plugins-cache",
"--no-xlib",
// Try to stop audio stuttering "--no-video",
"--file-caching=500", // msec
"--http-caching=500",
#ifdef HAVE_ALSA_
"--aout=alsa", // The default, pulseaudio, is buggy
#endif
}; };
*/
// Create the VLC instance // Create the VLC instance
instance_ = libvlc_new(0, nullptr); instance_ = libvlc_new(sizeof(args) / sizeof(*args), args);
//instance_ = libvlc_new(sizeof(args) / sizeof(args[0]), args);
HandleErrors(); HandleErrors();
// Create the media player // Create the media player
@ -106,8 +89,6 @@ bool VLCEngine::Init() {
AttachCallback(player_em, libvlc_MediaPlayerEndReached, StateChangedCallback); AttachCallback(player_em, libvlc_MediaPlayerEndReached, StateChangedCallback);
HandleErrors(); HandleErrors();
sInstance = this;
return true; 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) { bool VLCEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) {
if (!Initialised()) return false; if (!Initialised()) return false;
// Create the media object // Create the media object
VlcScopedRef<libvlc_media_t> media(libvlc_media_new_location(instance_, url.toEncoded().constData())); VlcScopedRef<libvlc_media_t> 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) { bool VLCEngine::Play(quint64 offset_nanosec) {
if (!Initialised()) return false; if (!Initialised()) return false;
// Set audio output // Set audio output
if (!output_.isEmpty() || output_ != "auto") { if (!output_.isEmpty() || output_ != "auto") {
int result = libvlc_audio_output_set(player_, output_.toUtf8().constData()); int result = libvlc_audio_output_set(player_, output_.toUtf8().constData());
@ -150,10 +135,10 @@ bool VLCEngine::Play(quint64 offset_nanosec) {
return true; return true;
} }
void VLCEngine::Stop(bool stop_after) { void VLCEngine::Stop(bool stop_after) {
if (!Initialised()) return; if (!Initialised()) return;
libvlc_media_player_stop(player_); libvlc_media_player_stop(player_);
HandleErrors(); HandleErrors();
@ -161,6 +146,7 @@ void VLCEngine::Stop(bool stop_after) {
} }
void VLCEngine::Pause() { void VLCEngine::Pause() {
if (!Initialised()) return; if (!Initialised()) return;
libvlc_media_player_pause(player_); libvlc_media_player_pause(player_);
HandleErrors(); HandleErrors();
@ -168,6 +154,7 @@ void VLCEngine::Pause() {
} }
void VLCEngine::Unpause() { void VLCEngine::Unpause() {
if (!Initialised()) return; if (!Initialised()) return;
libvlc_media_player_play(player_); libvlc_media_player_play(player_);
HandleErrors(); HandleErrors();
@ -178,7 +165,7 @@ void VLCEngine::Seek(quint64 offset_nanosec) {
if (!Initialised()) return; if (!Initialised()) return;
int offset = (offset_nanosec / kNsecPerMsec); int offset = (offset_nanosec / kNsecPerMsec);
uint len = length(); uint len = length();
if (len == 0) return; 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 ; i<uint(kScopeSize) ; ++i)
scope_[i] = scope_data_[i] * (1 << 15);
// Remove the samples from the buffer. Unfortunately I think this is O(n) :(
scope_data_.rresize(qMax(0, int(scope_data_.size()) - kScopeSize*2));
return scope_;
}
EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const { EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const {
OutputDetailsList ret; OutputDetailsList ret;
@ -308,19 +276,6 @@ bool VLCEngine::CanDecode(const QUrl &url) {
return true; return true;
} }
void VLCEngine::SetScopeData(float *data, int size) {
if (!sInstance) return;
QMutexLocker l(&sInstance->scope_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 ; i<size ; ++i) {
sInstance->scope_data_.push_back(data[i]);
}
}
void VLCEngine::HandleErrors() const { void VLCEngine::HandleErrors() const {
} }

View File

@ -1,6 +1,7 @@
/* /*
* Strawberry Music Player * Strawberry Music Player
* This file was part of Clementine * This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2017-2018, Jonas Kvinge <jonas@jkvinge.net> * Copyright 2017-2018, Jonas Kvinge <jonas@jkvinge.net>
* *
* Strawberry is free software: you can redistribute it and/or modify * Strawberry is free software: you can redistribute it and/or modify
@ -29,7 +30,6 @@
#include <QtGlobal> #include <QtGlobal>
#include <QObject> #include <QObject>
#include <QMutex>
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
@ -60,7 +60,6 @@ class VLCEngine : public Engine::Base {
public: public:
virtual qint64 position_nanosec() const; virtual qint64 position_nanosec() const;
virtual qint64 length_nanosec() const; virtual qint64 length_nanosec() const;
const Engine::Scope& Scope();
OutputDetailsList GetOutputsList() const; OutputDetailsList GetOutputsList() const;
bool ValidOutput(const QString &output); bool ValidOutput(const QString &output);
@ -71,16 +70,11 @@ class VLCEngine : public Engine::Base {
libvlc_instance_t *instance_; libvlc_instance_t *instance_;
libvlc_media_player_t *player_; libvlc_media_player_t *player_;
Engine::State state_; Engine::State state_;
boost::circular_buffer<float> scope_data_;
static VLCEngine *sInstance;
QMutex scope_mutex_;
bool Initialised() const; bool Initialised() const;
uint position() const; uint position() const;
uint length() const; uint length() const;
bool CanDecode(const QUrl &url); bool CanDecode(const QUrl &url);
static void SetScopeData(float* data, int size);
void HandleErrors() const; void HandleErrors() const;
void AttachCallback(libvlc_event_manager_t* em, libvlc_event_type_t type, libvlc_callback_t callback); 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); static void StateChangedCallback(const libvlc_event_t* e, void* data);

View File

@ -1,7 +1,7 @@
/* /*
* Strawberry Music Player * Strawberry Music Player
* This file was part of Clementine * This file was part of Clementine.
* Copyright 2017-2018, Jonas Kvinge <jonas@jkvinge.net> * Copyright 2010, David Sansome <me@davidsansome.com>
* *
* Strawberry is free software: you can redistribute it and/or modify * Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by