From d9b5fdf0b11436070cdf0b8e1d345caf89373f85 Mon Sep 17 00:00:00 2001 From: dridri Date: Mon, 20 Oct 2014 19:56:05 +0200 Subject: [PATCH] removed too unstable dsp, done remaning TODOs for vlc --- src/libtomahawk/CMakeLists.txt | 1 - src/libtomahawk/audio/AudioEngine.cpp | 10 ++--- src/libtomahawk/audio/AudioOutput.cpp | 28 +++++++----- src/libtomahawk/audio/VlcDsp.cpp | 38 ---------------- src/libtomahawk/audio/VlcDsp.h | 47 -------------------- src/libtomahawk/audio/VlcDsp_p.h | 62 --------------------------- src/libtomahawk/utils/MediaStream.cpp | 6 +-- 7 files changed, 24 insertions(+), 168 deletions(-) delete mode 100644 src/libtomahawk/audio/VlcDsp.cpp delete mode 100644 src/libtomahawk/audio/VlcDsp.h delete mode 100644 src/libtomahawk/audio/VlcDsp_p.h diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index a110b024d..33079a431 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -215,7 +215,6 @@ list(APPEND libSources audio/AudioEngine.cpp audio/AudioOutput.cpp - audio/VlcDsp.cpp collection/Collection.cpp collection/ArtistsRequest.cpp diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index 8db3a599f..2ab83fb3f 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -31,7 +31,7 @@ #include "playlist/SingleTrackPlaylistInterface.h" #include "utils/Closure.h" #include "utils/Logger.h" -#include "utils/Qnr_IoDeviceStream.h" +#include "utils/Qnr_IoDeviceSFtream.h" #include "Album.h" #include "Artist.h" @@ -75,9 +75,7 @@ AudioEnginePrivate::onStateChanged( AudioOutput::AudioState newState, AudioOutpu if ( newState == AudioOutput::Error ) { q_ptr->stop( AudioEngine::UnknownError ); - -//TODO tDebug() << "AudioOutput Error:" << audioOutput->errorString() << audioOutput->errorType(); - + tDebug() << "AudioOutput Error"; emit q_ptr->error( AudioEngine::UnknownError ); q_ptr->setState( AudioEngine::Error ); } @@ -1244,8 +1242,8 @@ AudioEngine::currentTime() const qint64 AudioEngine::currentTrackTotalTime() const { - // TODO : This is too hacky. The problem is that I don't know why - // libVLC doesn't report total duration for stream data (imem://) + // FIXME : This is too hacky. The problem is that I don't know why + // libVLC doesn't report total duration for stream data (imem://) // But it's not a real problem for playback, since EndOfStream is emitted by libVLC itself // This value is only used by AudioOutput to evaluate if it's close to end of stream if ( d_func()->audioOutput->totalTime() <= 0 && d_func()->currentTrack && d_func()->currentTrack->track() ) { diff --git a/src/libtomahawk/audio/AudioOutput.cpp b/src/libtomahawk/audio/AudioOutput.cpp index 10dfe45fc..3fe7d91e2 100644 --- a/src/libtomahawk/audio/AudioOutput.cpp +++ b/src/libtomahawk/audio/AudioOutput.cpp @@ -21,7 +21,6 @@ #include "AudioEngine.h" #include "AudioOutput.h" -#include "VlcDsp.h" #include "utils/Logger.h" @@ -91,10 +90,6 @@ AudioOutput::AudioOutput( QObject* parent ) */ args << "--no-video"; args << "--no-xlib"; -#ifdef VLC_DSP_PLUGIN_ENABLED - args << "--audio-filter=dsp"; - args << QString("--dsp-callback=%1").arg((quint64)&AudioOutput::s_dspCallback, 0, 16).toAscii(); -#endif QVarLengthArray< const char * , 64 > vlcArgs( args.size() ); for ( int i = 0 ; i < args.size() ; ++i ) { @@ -145,7 +140,18 @@ AudioOutput::~AudioOutput() { tDebug() << Q_FUNC_INFO; - // TODO + if ( vlcPlayer != 0 ) { + libvlc_media_player_stop( vlcPlayer ); + libvlc_media_player_release( vlcPlayer ); + vlcPlayer = 0; + } + if ( vlcMedia != 0 ) { + libvlc_media_release( vlcMedia ); + vlcMedia = 0; + } + if ( vlcInstance != 0 ) { + libvlc_release( vlcInstance ); + } } @@ -227,10 +233,6 @@ AudioOutput::setCurrentSource(MediaStream* stream) libvlc_media_player_set_media( vlcPlayer, vlcMedia ); -#ifdef VLC_DSP_PLUGIN_ENABLED - VlcDspSetup( vlcPlayer ); -#endif - if ( stream->type() == MediaStream::Url ) { m_totalTime = libvlc_media_get_duration( vlcMedia ); } @@ -475,7 +477,11 @@ AudioOutput::vlcEventCallback( const libvlc_event_t* event, void* opaque ) that->setState(Stopped); break; case libvlc_MediaPlayerEncounteredError: - // TODO emit Error + tDebug() << "LibVLC error : MediaPlayerEncounteredError. Stopping"; + if ( that->vlcPlayer != 0 ) { + that->stop(); + } + that->setState( Error ); break; case libvlc_MediaPlayerVout: case libvlc_MediaPlayerMediaChanged: diff --git a/src/libtomahawk/audio/VlcDsp.cpp b/src/libtomahawk/audio/VlcDsp.cpp deleted file mode 100644 index b5ebeaf6f..000000000 --- a/src/libtomahawk/audio/VlcDsp.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "VlcDsp_p.h" - -#ifdef VLC_DSP_PLUGIN_ENABLED - -void -VlcDspSetup( libvlc_media_player_t* vlcPlayer ) -{ - vlc_value_t val; - - if ( vlcPlayer->input.p_resource != 0 ) { - audio_output_t *aout = input_resource_GetAout( vlcPlayer->input.p_resource ); - if ( aout != 0 ) { - var_Create( ( vlc_object_t* )aout, "audio-filter", VLC_VAR_STRING ); - val.psz_string = (char*)"dsp"; - var_SetChecked( ( vlc_object_t* )aout, "audio-filter", VLC_VAR_STRING, val ); - aout->event.restart_request( aout, AOUT_RESTART_FILTERS ); - input_resource_PutAout( vlcPlayer->input.p_resource, aout ); - } - } -} - -#endif // VLC_DSP_PLUGIN_ENABLED diff --git a/src/libtomahawk/audio/VlcDsp.h b/src/libtomahawk/audio/VlcDsp.h deleted file mode 100644 index a57c85394..000000000 --- a/src/libtomahawk/audio/VlcDsp.h +++ /dev/null @@ -1,47 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef VLCDSP_H -#define VLCDSP_H - -/* - * Very tricky technique to enable DSP plugin support - * There is no other way to do this with libvlc for the moment - * - * A VLC audio filter plugin specificaly made for Tomahawk - * is necessary to get it functionning - * - * TODO : Check thoroughly if libvlc_media_player_t - * structure is identical to the one in running libvlccore.so - * (checking if libVLC version is >= than the one used to compile Tomahawk - * and verifying pointers integrity should be enough. - * + check if audio filter "dsp" is present in libVLC plugins list) - * - * The define 'VLC_DSP_PLUGIN_ENABLED' better should be a CMake option -*/ - -// Maybe later :) -//#define VLC_DSP_PLUGIN_ENABLED - -#ifdef VLC_DSP_PLUGIN_ENABLED - -struct libvlc_media_player_t; - -void VlcDspSetup( libvlc_media_player_t* vlcPlayer ); - -#endif // VLC_DSP_PLUGIN_ENABLED - -#endif // VLCDSP_H diff --git a/src/libtomahawk/audio/VlcDsp_p.h b/src/libtomahawk/audio/VlcDsp_p.h deleted file mode 100644 index 67e8a6482..000000000 --- a/src/libtomahawk/audio/VlcDsp_p.h +++ /dev/null @@ -1,62 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef VLCDSP_P_H -#define VLCDSP_P_H - -#include "VlcDsp.h" - -#ifdef VLC_DSP_PLUGIN_ENABLED - -#include - -#include -#include -#include -#include -#include - -#define restrict -#define _(s) s - -#include -#include - -typedef struct libvlc_media_player_t -{ - const char *psz_object_type; - char *psz_header; - int i_flags; - bool b_force; - void *p_libvlc; - void *p_parent; - int i_refcount; - vlc_mutex_t object_lock; - struct - { - void *p_thread; - input_resource_t *p_resource; - vlc_mutex_t lock; - } input; - void *p_libvlc_instance; - void *p_md; - void *p_event_manager; - int state; -} libvlc_media_player_t; - -#endif // VLC_DSP_PLUGIN_ENABLED - -#endif // VLCDSP_P_H diff --git a/src/libtomahawk/utils/MediaStream.cpp b/src/libtomahawk/utils/MediaStream.cpp index c5c1335b9..dde1147f9 100644 --- a/src/libtomahawk/utils/MediaStream.cpp +++ b/src/libtomahawk/utils/MediaStream.cpp @@ -45,7 +45,7 @@ MediaStream::MediaStream( QObject* parent ) MediaStream::MediaStream( const QUrl &url ) : QObject( 0 ) - , m_type(Url) + , m_type( Url ) , m_ioDevice ( 0 ) , m_started( false ) , m_bufferingFinished( false ) @@ -61,7 +61,7 @@ MediaStream::MediaStream( const QUrl &url ) MediaStream::MediaStream( QIODevice* device ) : QObject( 0 ) - , m_type(IODevice) + , m_type( IODevice ) , m_url( QUrl() ) , m_ioDevice ( 0 ) , m_started( false ) @@ -202,7 +202,7 @@ MediaStream::readDoneCallback ( void *data, const char *cookie, size_t bufferSiz MediaStream* that = static_cast < MediaStream * > ( data ); if ( ( that->m_type == Stream ) && buffer != 0 && bufferSize > 0 ) { - delete static_cast(buffer); + delete static_cast< char* >( buffer ); } return 0;