[vlmc-devel] Backend: VLC: Remove EventWaiter class

Hugo Beauzée-Luyssen git at videolan.org
Thu Mar 24 13:22:29 CET 2016


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Mar 21 19:57:04 2016 +0100| [d16bd9db2f15b1c72aac0e5de92c1754f765d2e8] | committer: Hugo Beauzée-Luyssen

Backend: VLC: Remove EventWaiter class

> https://code.videolan.org/videolan/vlmc/commit/d16bd9db2f15b1c72aac0e5de92c1754f765d2e8
---

 src/Backend/VLC/EventWaiter.cpp | 89 -----------------------------------------
 src/Backend/VLC/EventWaiter.h   | 86 ---------------------------------------
 src/CMakeLists.txt              |  1 -
 3 files changed, 176 deletions(-)

diff --git a/src/Backend/VLC/EventWaiter.cpp b/src/Backend/VLC/EventWaiter.cpp
deleted file mode 100644
index 480990a..0000000
--- a/src/Backend/VLC/EventWaiter.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*****************************************************************************
- * EventWaiter.cpp: Helper to wait on a LibVLC event
- *****************************************************************************
- * Copyright (C) 2008-2014 VideoLAN
- *
- * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
- *
- * This program 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 2
- * of the License, or (at your option) any later version.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#include "EventWaiter.h"
-
-using namespace Backend::VLC;
-
-EventWaiter::EventWaiter( LibVLCpp::MediaPlayer* mediaPlayer, bool startLocked )
-    : m_mediaPlayer( mediaPlayer )
-    , m_validationCallback( NULL )
-    , m_found( true )
-    , m_startLocked( startLocked )
-{
-    if ( startLocked == true )
-        m_mutex.lock();
-    m_mediaPlayer->registerEvents( &EventWaiter::eventsCallback, this );
-}
-
-EventWaiter::~EventWaiter()
-{
-    m_mediaPlayer->unregisterEvents( &EventWaiter::eventsCallback, this );
-}
-
-void
-EventWaiter::add(libvlc_event_type_t event)
-{
-    m_events.push_back( event );
-}
-
-EventWaiter::Result
-EventWaiter::wait(unsigned long timeoutMs)
-{
-    if ( m_startLocked == false )
-        m_mutex.lock();
-    if ( m_waitCond.wait( &m_mutex, timeoutMs ) == false )
-    {
-        m_mutex.unlock();
-        return Timeout;
-    }
-    m_mutex.unlock();
-    return m_found == true ? Success : Canceled;
-}
-
-void
-EventWaiter::setValidationCallback(EventWaiter::ValidationCallback callback)
-{
-    m_validationCallback = callback;
-}
-
-void EventWaiter::eventsCallback( const libvlc_event_t* event, void *data )
-{
-    EventWaiter* self = reinterpret_cast<EventWaiter*>( data );
-    QMutexLocker lock( &self->m_mutex );
-
-    if ( self->m_events.contains( event->type ) == true )
-    {
-        if ( self->m_validationCallback != NULL && self->m_validationCallback( event ) == false )
-            return;
-        self->m_found = true;
-        self->m_waitCond.wakeAll();
-        return;
-    }
-
-    if ( event->type == libvlc_MediaPlayerEncounteredError ||
-         event->type == libvlc_MediaPlayerEndReached )
-    {
-        self->m_waitCond.wakeAll();
-    }
-}
-
diff --git a/src/Backend/VLC/EventWaiter.h b/src/Backend/VLC/EventWaiter.h
deleted file mode 100644
index a6634fc..0000000
--- a/src/Backend/VLC/EventWaiter.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*****************************************************************************
- * EventWaiter.h: Helper to wait on a LibVLC event
- *****************************************************************************
- * Copyright (C) 2008-2014 VideoLAN
- *
- * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
- *
- * This program 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 2
- * of the License, or (at your option) any later version.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef EVENTWAITER_H
-#define EVENTWAITER_H
-
-#include "VLCMediaPlayer.h"
-
-#include <QList>
-#include <QMutex>
-#include <QWaitCondition>
-
-namespace Backend
-{
-namespace VLC
-{
-
-class EventWaiter
-{
-public:
-    /**
-     * @brief initialize the EventWaiter
-     *
-     * This method will lock a mutex, preventing any further event processing.
-     * Basic use scheme is
-     * \li EventWaiter* ew = new EventWaiter( mediaPlayer );
-     * \li ev->add( <event> );
-     * \li <whatever action that will lead to an asynchronous event>
-     * \li we->wait(...);
-     *
-     * @param startLocked   Specify if the EventWaiter should immediatly lock the mutex
-     * If this is false, mutex will be locked when wait() is called. This should
-     * be set to false when the function leading to the event might process synchronously
-     * and if the event will be triggered again (for instance, time & position events)
-     *
-     */
-    EventWaiter(LibVLCpp::MediaPlayer* mediaPlayer , bool startLocked);
-    ~EventWaiter();
-
-    enum    Result
-    {
-        Success, ///The event has been emited.
-        Canceled,///A cancelation event has been emited first.
-        Timeout  ///Timeout has been reached.
-    };
-    void            add( libvlc_event_type_t event );
-    Result          wait( unsigned long timeoutMs );
-
-    typedef bool    (*ValidationCallback)( const libvlc_event_t* event );
-    void            setValidationCallback( ValidationCallback callback );
-
-private:
-    static void     eventsCallback( const libvlc_event_t *event, void* data );
-
-private:
-    LibVLCpp::MediaPlayer*      m_mediaPlayer;
-    QList<libvlc_event_type_t>  m_events;
-    QWaitCondition              m_waitCond;
-    QMutex                      m_mutex;
-    ValidationCallback          m_validationCallback;
-    bool                        m_found;
-    bool                        m_startLocked;
-};
-
-} //VLC
-} //Backend
-#endif // EVENTWAITER_H
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0a9ba0c..104ce15 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,6 @@ SET(VLMC_SRCS
     Backend/IBackend.h
     Backend/ISourceRenderer.h
     Backend/ISource.h
-    Backend/VLC/EventWaiter.cpp
     Backend/VLC/VLCBackend.cpp
     Backend/VLC/VLCSourceRenderer.cpp
     Backend/VLC/VLCVmemRenderer.cpp



More information about the Vlmc-devel mailing list