[debian-edu-commits] debian-edu/pkg-team/ 03/04: Restored old implementation for non-Linux systems
Javier Serrano Polo
jasp00-guest at moszumanska.debian.org
Wed Apr 20 19:05:03 UTC 2016
This is an automated email from the git hooks/post-receive script.
jasp00-guest pushed a commit to branch master
in repository lmms.
commit 8b3055804a21e6be02967c1ea854e029d705ad25
Author: Javier Serrano Polo <javier at jasp.net>
Date: Wed Apr 20 17:52:42 2016 +0200
Restored old implementation for non-Linux systems
---
debian/patches/sync-socket.patch | 891 +++++++++++++++++----------------------
1 file changed, 395 insertions(+), 496 deletions(-)
diff --git a/debian/patches/sync-socket.patch b/debian/patches/sync-socket.patch
index 5e9250d..444dbbf 100644
--- a/debian/patches/sync-socket.patch
+++ b/debian/patches/sync-socket.patch
@@ -5,35 +5,26 @@ Author: Javier Serrano Polo <javier at jasp.net>
Index: lmms-1.1.3/include/RemotePlugin.h
===================================================================
---- lmms-1.1.3.orig/include/RemotePlugin.h 2016-04-09 01:09:22.000000000 +0200
-+++ lmms-1.1.3/include/RemotePlugin.h 2016-04-14 21:10:40.000000000 +0200
-@@ -37,41 +37,9 @@
+--- lmms-1.1.3.orig/include/RemotePlugin.h 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/include/RemotePlugin.h 2016-04-20 01:38:51.000000000 +0200
+@@ -37,11 +37,13 @@
#include <cassert>
#ifdef LMMS_BUILD_WIN32
--#define USE_QT_SEMAPHORES
++#define SYNC_WITH_SHM_FIFO
+ #define USE_QT_SEMAPHORES
#define USE_QT_SHMEM
#endif
--#ifdef LMMS_BUILD_APPLE
--#define USE_QT_SEMAPHORES
--#endif
--
--
--#ifdef USE_QT_SEMAPHORES
--
--#ifdef LMMS_HAVE_PROCESS_H
--#include <process.h>
--#endif
--
--#include <QtCore/QtGlobal>
--
--#if QT_VERSION >= 0x040400
--#include <QtCore/QSystemSemaphore>
--#else
--#error building LMMS on this platform requires at least Qt 4.4.0
--#endif
--
+ #ifdef LMMS_BUILD_APPLE
++#define SYNC_WITH_SHM_FIFO
+ #define USE_QT_SEMAPHORES
+ #endif
+
+@@ -60,16 +62,6 @@
+ #error building LMMS on this platform requires at least Qt 4.4.0
+ #endif
+
-#else /* USE_QT_SEMAPHORES */
-
-#ifdef LMMS_HAVE_SYS_IPC_H
@@ -44,99 +35,70 @@ Index: lmms-1.1.3/include/RemotePlugin.h
-#include <semaphore.h>
-#endif
-
--#endif
--
+ #endif
- #ifdef USE_QT_SHMEM
-@@ -108,385 +76,15 @@
+@@ -108,12 +100,24 @@
#undef EXPORT
#define EXPORT
#define COMPILE_REMOTE_PLUGIN_BASE
++
++#ifndef SYNC_WITH_SHM_FIFO
+#include <sys/socket.h>
+#include <sys/un.h>
++#endif
++
#else
-+#include <poll.h>
#include <QtCore/QMutex>
#include <QtCore/QProcess>
#include <QtCore/QThread>
++
++#ifndef SYNC_WITH_SHM_FIFO
++#include <poll.h>
#endif
--// sometimes we need to exchange bigger messages (e.g. for VST parameter dumps)
--// so set a usable value here
--const int SHM_FIFO_SIZE = 512*1024;
--
--
--// implements a FIFO inside a shared memory segment
--class shmFifo
--{
-- // need this union to handle different sizes of sem_t on 32 bit
-- // and 64 bit platforms
-- union sem32_t
-- {
++#endif
++
++#ifdef SYNC_WITH_SHM_FIFO
+ // sometimes we need to exchange bigger messages (e.g. for VST parameter dumps)
+ // so set a usable value here
+ const int SHM_FIFO_SIZE = 512*1024;
+@@ -126,9 +130,6 @@
+ // and 64 bit platforms
+ union sem32_t
+ {
-#ifndef USE_QT_SEMAPHORES
- sem_t sem;
-#endif
-- int semKey;
-- char fill[32];
-- } ;
-- struct shmData
-- {
-- sem32_t dataSem; // semaphore for locking this
-- // FIFO management data
-- sem32_t messageSem; // semaphore for incoming messages
-- volatile int32_t startPtr; // current start of FIFO in memory
-- volatile int32_t endPtr; // current end of FIFO in memory
-- char data[SHM_FIFO_SIZE]; // actual data
-- } ;
--
--public:
-- // constructor for master-side
-- shmFifo() :
-- m_invalid( false ),
-- m_master( true ),
-- m_shmKey( 0 ),
--#ifdef USE_QT_SHMEM
-- m_shmObj(),
--#else
-- m_shmID( -1 ),
--#endif
-- m_data( NULL ),
+ int semKey;
+ char fill[32];
+ } ;
+@@ -154,13 +155,8 @@
+ m_shmID( -1 ),
+ #endif
+ m_data( NULL ),
-#ifdef USE_QT_SEMAPHORES
-- m_dataSem( QString::null ),
-- m_messageSem( QString::null ),
+ m_dataSem( QString::null ),
+ m_messageSem( QString::null ),
-#else
- m_dataSem( NULL ),
- m_messageSem( NULL ),
-#endif
-- m_lockDepth( 0 )
-- {
--#ifdef USE_QT_SHMEM
-- do
-- {
-- m_shmObj.setKey( QString( "%1" ).arg( ++m_shmKey ) );
-- m_shmObj.create( sizeof( shmData ) );
-- } while( m_shmObj.error() != QSharedMemory::NoError );
--
-- m_data = (shmData *) m_shmObj.data();
--#else
-- while( ( m_shmID = shmget( ++m_shmKey, sizeof( shmData ),
-- IPC_CREAT | IPC_EXCL | 0600 ) ) == -1 )
-- {
-- }
-- m_data = (shmData *) shmat( m_shmID, 0, 0 );
--#endif
-- assert( m_data != NULL );
-- m_data->startPtr = m_data->endPtr = 0;
+ m_lockDepth( 0 )
+ {
+ #ifdef USE_QT_SHMEM
+@@ -180,7 +176,6 @@
+ #endif
+ assert( m_data != NULL );
+ m_data->startPtr = m_data->endPtr = 0;
-#ifdef USE_QT_SEMAPHORES
-- static int k = 0;
-- m_data->dataSem.semKey = ( getpid()<<10 ) + ++k;
-- m_data->messageSem.semKey = ( getpid()<<10 ) + ++k;
-- m_dataSem.setKey( QString::number( m_data->dataSem.semKey ),
-- 1, QSystemSemaphore::Create );
-- m_messageSem.setKey( QString::number(
-- m_data->messageSem.semKey ),
-- 0, QSystemSemaphore::Create );
+ static int k = 0;
+ m_data->dataSem.semKey = ( getpid()<<10 ) + ++k;
+ m_data->messageSem.semKey = ( getpid()<<10 ) + ++k;
+@@ -189,20 +184,6 @@
+ m_messageSem.setKey( QString::number(
+ m_data->messageSem.semKey ),
+ 0, QSystemSemaphore::Create );
-#else
- m_dataSem = &m_data->dataSem.sem;
- m_messageSem = &m_data->messageSem.sem;
@@ -151,324 +113,192 @@ Index: lmms-1.1.3/include/RemotePlugin.h
- "m_messageSem\n" );
- }
-#endif
-- }
--
-- // constructor for remote-/client-side - use _shm_key for making up
-- // the connection to master
-- shmFifo( key_t _shm_key ) :
-- m_invalid( false ),
-- m_master( false ),
-- m_shmKey( 0 ),
--#ifdef USE_QT_SHMEM
-- m_shmObj( QString::number( _shm_key ) ),
--#else
-- m_shmID( shmget( _shm_key, 0, 0 ) ),
--#endif
-- m_data( NULL ),
+ }
+
+ // constructor for remote-/client-side - use _shm_key for making up
+@@ -217,13 +198,8 @@
+ m_shmID( shmget( _shm_key, 0, 0 ) ),
+ #endif
+ m_data( NULL ),
-#ifdef USE_QT_SEMAPHORES
-- m_dataSem( QString::null ),
-- m_messageSem( QString::null ),
+ m_dataSem( QString::null ),
+ m_messageSem( QString::null ),
-#else
- m_dataSem( NULL ),
- m_messageSem( NULL ),
-#endif
-- m_lockDepth( 0 )
-- {
--#ifdef USE_QT_SHMEM
-- if( m_shmObj.attach() )
-- {
-- m_data = (shmData *) m_shmObj.data();
-- }
--#else
-- if( m_shmID != -1 )
-- {
-- m_data = (shmData *) shmat( m_shmID, 0, 0 );
-- }
--#endif
-- assert( m_data != NULL );
+ m_lockDepth( 0 )
+ {
+ #ifdef USE_QT_SHMEM
+@@ -238,14 +214,9 @@
+ }
+ #endif
+ assert( m_data != NULL );
-#ifdef USE_QT_SEMAPHORES
-- m_dataSem.setKey( QString::number( m_data->dataSem.semKey ) );
-- m_messageSem.setKey( QString::number(
-- m_data->messageSem.semKey ) );
+ m_dataSem.setKey( QString::number( m_data->dataSem.semKey ) );
+ m_messageSem.setKey( QString::number(
+ m_data->messageSem.semKey ) );
-#else
- m_dataSem = &m_data->dataSem.sem;
- m_messageSem = &m_data->messageSem.sem;
-#endif
-- }
--
-- ~shmFifo()
-- {
--#ifndef USE_QT_SHMEM
-- shmdt( m_data );
--#endif
-- // master?
-- if( m_master )
-- {
--#ifndef USE_QT_SHMEM
-- shmctl( m_shmID, IPC_RMID, NULL );
--#endif
+ }
+
+ ~shmFifo()
+@@ -259,10 +230,6 @@
+ #ifndef USE_QT_SHMEM
+ shmctl( m_shmID, IPC_RMID, NULL );
+ #endif
-#ifndef USE_QT_SEMAPHORES
- sem_destroy( m_dataSem );
- sem_destroy( m_messageSem );
-#endif
-- }
-- }
--
-- inline bool isInvalid() const
-- {
-- return m_invalid;
-- }
--
-- void invalidate()
-- {
-- m_invalid = true;
-- }
--
-- // do we act as master (i.e. not as remote-process?)
-- inline bool isMaster() const
-- {
-- return m_master;
-- }
--
-- // recursive lock
-- inline void lock()
-- {
-- if( !isInvalid() && __sync_add_and_fetch( &m_lockDepth, 1 ) == 1 )
-- {
+ }
+ }
+
+@@ -287,11 +254,7 @@
+ {
+ if( !isInvalid() && __sync_add_and_fetch( &m_lockDepth, 1 ) == 1 )
+ {
-#ifdef USE_QT_SEMAPHORES
-- m_dataSem.acquire();
+ m_dataSem.acquire();
-#else
- sem_wait( m_dataSem );
-#endif
-- }
-- }
--
-- // recursive unlock
-- inline void unlock()
-- {
-- if( __sync_sub_and_fetch( &m_lockDepth, 1) <= 0 )
-- {
+ }
+ }
+
+@@ -300,11 +263,7 @@
+ {
+ if( __sync_sub_and_fetch( &m_lockDepth, 1) <= 0 )
+ {
-#ifdef USE_QT_SEMAPHORES
-- m_dataSem.release();
+ m_dataSem.release();
-#else
- sem_post( m_dataSem );
-#endif
-- }
-- }
--
-- // wait until message-semaphore is available
-- inline void waitForMessage()
-- {
-- if( !isInvalid() )
-- {
+ }
+ }
+
+@@ -313,22 +272,14 @@
+ {
+ if( !isInvalid() )
+ {
-#ifdef USE_QT_SEMAPHORES
-- m_messageSem.acquire();
+ m_messageSem.acquire();
-#else
- sem_wait( m_messageSem );
-#endif
-- }
-- }
--
-- // increase message-semaphore
-- inline void messageSent()
-- {
+ }
+ }
+
+ // increase message-semaphore
+ inline void messageSent()
+ {
-#ifdef USE_QT_SEMAPHORES
-- m_messageSem.release();
+ m_messageSem.release();
-#else
- sem_post( m_messageSem );
-#endif
-- }
--
--
-- inline int32_t readInt()
-- {
-- int32_t i;
-- read( &i, sizeof( i ) );
-- return i;
-- }
--
-- inline void writeInt( const int32_t & _i )
-- {
-- write( &_i, sizeof( _i ) );
-- }
--
-- inline std::string readString()
-- {
-- const int len = readInt();
-- if( len )
-- {
-- char * sc = new char[len + 1];
-- read( sc, len );
-- sc[len] = 0;
-- std::string s( sc );
-- delete[] sc;
-- return s;
-- }
-- return std::string();
-- }
--
--
-- inline void writeString( const std::string & _s )
-- {
-- const int len = _s.size();
-- writeInt( len );
-- write( _s.c_str(), len );
-- }
--
--
-- inline bool messagesLeft()
-- {
-- if( isInvalid() )
-- {
-- return false;
-- }
+ }
+
+
+@@ -374,16 +325,10 @@
+ {
+ return false;
+ }
-#ifdef USE_QT_SEMAPHORES
-- lock();
-- const bool empty = ( m_data->startPtr == m_data->endPtr );
-- unlock();
-- return !empty;
+ lock();
+ const bool empty = ( m_data->startPtr == m_data->endPtr );
+ unlock();
+ return !empty;
-#else
- int v;
- sem_getvalue( m_messageSem, &v );
- return v > 0;
-#endif
-- }
--
--
-- inline int shmKey() const
-- {
-- return m_shmKey;
-- }
--
--
--private:
-- static inline void fastMemCpy( void * _dest, const void * _src,
-- const int _len )
-- {
-- // calling memcpy() for just an integer is obsolete overhead
-- if( _len == 4 )
-- {
-- *( (int32_t *) _dest ) = *( (int32_t *) _src );
-- }
-- else
-- {
-- memcpy( _dest, _src, _len );
-- }
-- }
--
-- void read( void * _buf, int _len )
-- {
-- if( isInvalid() )
-- {
-- memset( _buf, 0, _len );
-- return;
-- }
-- lock();
-- while( isInvalid() == false &&
-- _len > m_data->endPtr - m_data->startPtr )
-- {
-- unlock();
--#ifndef LMMS_BUILD_WIN32
-- usleep( 5 );
--#endif
-- lock();
-- }
-- fastMemCpy( _buf, m_data->data + m_data->startPtr, _len );
-- m_data->startPtr += _len;
-- // nothing left?
-- if( m_data->startPtr == m_data->endPtr )
-- {
-- // then reset to 0
-- m_data->startPtr = m_data->endPtr = 0;
-- }
-- unlock();
-- }
--
-- void write( const void * _buf, int _len )
-- {
-- if( isInvalid() || _len > SHM_FIFO_SIZE )
-- {
-- return;
-- }
-- lock();
-- while( _len > SHM_FIFO_SIZE - m_data->endPtr )
-- {
-- // if no space is left, try to move data to front
-- if( m_data->startPtr > 0 )
-- {
-- memmove( m_data->data,
-- m_data->data + m_data->startPtr,
-- m_data->endPtr - m_data->startPtr );
-- m_data->endPtr = m_data->endPtr -
-- m_data->startPtr;
-- m_data->startPtr = 0;
-- }
-- unlock();
--#ifndef LMMS_BUILD_WIN32
-- usleep( 5 );
--#endif
-- lock();
-- }
-- fastMemCpy( m_data->data + m_data->endPtr, _buf, _len );
-- m_data->endPtr += _len;
-- unlock();
-- }
--
-- volatile bool m_invalid;
-- bool m_master;
-- key_t m_shmKey;
--#ifdef USE_QT_SHMEM
-- QSharedMemory m_shmObj;
--#else
-- int m_shmID;
--#endif
-- shmData * m_data;
+ }
+
+
+@@ -475,16 +420,12 @@
+ int m_shmID;
+ #endif
+ shmData * m_data;
-#ifdef USE_QT_SEMAPHORES
-- QSystemSemaphore m_dataSem;
-- QSystemSemaphore m_messageSem;
+ QSystemSemaphore m_dataSem;
+ QSystemSemaphore m_messageSem;
-#else
- sem_t * m_dataSem;
- sem_t * m_messageSem;
-#endif
-- volatile int m_lockDepth;
--
--} ;
--
--
+ volatile int m_lockDepth;
- enum RemoteMessageIDs
- {
-@@ -596,30 +194,51 @@
+ } ;
++#endif
+
+
+
+@@ -596,9 +537,14 @@
} ;
-- RemotePluginBase( shmFifo * _in, shmFifo * _out );
++#ifdef SYNC_WITH_SHM_FIFO
+ RemotePluginBase( shmFifo * _in, shmFifo * _out );
++#else
+ RemotePluginBase();
++#endif
virtual ~RemotePluginBase();
-- void reset( shmFifo *in, shmFifo *out )
-+ inline int32_t readInt()
++#ifdef SYNC_WITH_SHM_FIFO
+ void reset( shmFifo *in, shmFifo *out )
+ {
+ delete m_in;
+@@ -606,21 +552,20 @@
+ m_in = in;
+ m_out = out;
+ }
++#endif
+
+ int sendMessage( const message & _m );
+ message receiveMessage();
+
+ inline bool isInvalid() const
{
-- delete m_in;
-- delete m_out;
-- m_in = in;
-- m_out = out;
++#ifdef SYNC_WITH_SHM_FIFO
+ return m_in->isInvalid() || m_out->isInvalid();
++#else
++ return m_invalid;
++#endif
+ }
+
+- inline bool messagesLeft()
+- {
+- return m_in->messagesLeft();
+- }
+-
+-
+ message waitForMessage( const message & _m,
+ bool _busy_waiting = false );
+
+@@ -631,6 +576,61 @@
+ return m;
+ }
+
++#ifndef SYNC_WITH_SHM_FIFO
++ inline int32_t readInt()
++ {
+ int32_t i;
+ read( &i, sizeof( i ) );
+ return i;
- }
-
-- int sendMessage( const message & _m );
-- message receiveMessage();
++ }
++
+ inline void writeInt( const int32_t & _i )
+ {
+ write( &_i, sizeof( _i ) );
+ }
-
-- inline bool isInvalid() const
++
+ inline std::string readString()
- {
-- return m_in->isInvalid() || m_out->isInvalid();
++ {
+ const int len = readInt();
+ if( len )
+ {
@@ -480,42 +310,23 @@ Index: lmms-1.1.3/include/RemotePlugin.h
+ return s;
+ }
+ return std::string();
- }
-
-- inline bool messagesLeft()
++ }
++
+
+ inline void writeString( const std::string & _s )
- {
-- return m_in->messagesLeft();
++ {
+ const int len = _s.size();
+ writeInt( len );
+ write( _s.c_str(), len );
- }
-
-+ int sendMessage( const message & _m );
-+ message receiveMessage();
-+
-+ inline bool isInvalid() const
-+ {
-+ return m_invalid;
+ }
-
- message waitForMessage( const message & _m,
- bool _busy_waiting = false );
-@@ -631,6 +250,7 @@
- return m;
- }
-
++#endif
++
+#ifndef BUILD_REMOTE_PLUGIN_CLIENT
- inline void fetchAndProcessAllMessages()
- {
- while( messagesLeft() )
-@@ -639,31 +259,96 @@
- }
- }
-
+ inline bool messagesLeft()
+ {
++#ifdef SYNC_WITH_SHM_FIFO
++ return m_in->messagesLeft();
++#else
+ struct pollfd pollin;
+ pollin.fd = m_socket;
+ pollin.events = POLLIN;
@@ -525,29 +336,56 @@ Index: lmms-1.1.3/include/RemotePlugin.h
+ qWarning( "Unexpected poll error." );
+ }
+ return pollin.revents & POLLIN;
-+ }
+#endif
++ }
+
+ inline void fetchAndProcessAllMessages()
+ {
+ while( messagesLeft() )
+@@ -638,11 +638,13 @@
+ fetchAndProcessNextMessage();
+ }
+ }
++#endif
+
virtual bool processMessage( const message & _m ) = 0;
protected:
-- inline const shmFifo * in() const
-+ void invalidate()
++#ifdef SYNC_WITH_SHM_FIFO
+ inline const shmFifo * in() const
+ {
+ return m_in;
+@@ -652,18 +654,93 @@
{
-- return m_in;
+ return m_out;
+ }
++#endif
+
+ inline void invalidate()
+ {
++#ifdef SYNC_WITH_SHM_FIFO
+ m_in->invalidate();
+ m_out->invalidate();
+ m_in->messageSent();
++#else
+ m_invalid = true;
++#endif
}
-- inline const shmFifo * out() const
-+
+
++#ifndef SYNC_WITH_SHM_FIFO
+ int m_socket;
++#endif
+
+
-+private:
+ private:
++#ifdef SYNC_WITH_SHM_FIFO
+ shmFifo * m_in;
+ shmFifo * m_out;
++#else
+ void read( void * _buf, int _len )
- {
-- return m_out;
++ {
+ if( isInvalid() )
+ {
+ memset( _buf, 0, _len );
@@ -575,14 +413,10 @@ Index: lmms-1.1.3/include/RemotePlugin.h
+ sched_yield();
+ }
+ }
- }
-
-- inline void invalidate()
++ }
++
+ void write( const void * _buf, int _len )
- {
-- m_in->invalidate();
-- m_out->invalidate();
-- m_in->messageSent();
++ {
+ if( isInvalid() )
+ {
+ return;
@@ -608,17 +442,15 @@ Index: lmms-1.1.3/include/RemotePlugin.h
+ sched_yield();
+ }
+ }
- }
-
-
--private:
-- shmFifo * m_in;
-- shmFifo * m_out;
++ }
++
++
+ bool m_invalid;
++#endif
} ;
-@@ -697,8 +382,9 @@
+@@ -697,8 +774,9 @@
} ;
@@ -629,12 +461,14 @@ Index: lmms-1.1.3/include/RemotePlugin.h
public:
RemotePlugin();
virtual ~RemotePlugin();
-@@ -797,7 +483,14 @@
+@@ -797,7 +875,16 @@
int m_inputCount;
int m_outputCount;
++#ifndef SYNC_WITH_SHM_FIFO
+ int m_server;
+ QString m_socketFile;
++#endif
+
friend class ProcessWatcher;
+
@@ -644,94 +478,114 @@ Index: lmms-1.1.3/include/RemotePlugin.h
} ;
#endif
-@@ -808,7 +501,7 @@
+@@ -808,7 +895,11 @@
class RemotePluginClient : public RemotePluginBase
{
public:
-- RemotePluginClient( key_t _shm_in, key_t _shm_out );
++#ifdef SYNC_WITH_SHM_FIFO
+ RemotePluginClient( key_t _shm_in, key_t _shm_out );
++#else
+ RemotePluginClient( const char * socketPath );
++#endif
virtual ~RemotePluginClient();
#ifdef USE_QT_SHMEM
VstSyncData * getQtVSTshm();
-@@ -905,9 +598,9 @@
+@@ -905,9 +996,15 @@
#endif
--RemotePluginBase::RemotePluginBase( shmFifo * _in, shmFifo * _out ) :
-- m_in( _in ),
-- m_out( _out )
++#ifdef SYNC_WITH_SHM_FIFO
+ RemotePluginBase::RemotePluginBase( shmFifo * _in, shmFifo * _out ) :
+ m_in( _in ),
+ m_out( _out )
++#else
+RemotePluginBase::RemotePluginBase() :
+ m_socket( -1 ),
+ m_invalid( false )
++#endif
{
#ifdef LMMS_HAVE_LOCALE_H
// make sure, we're using common ways to print/scan
-@@ -921,8 +614,6 @@
+@@ -921,8 +1018,10 @@
RemotePluginBase::~RemotePluginBase()
{
-- delete m_in;
-- delete m_out;
++#ifdef SYNC_WITH_SHM_FIFO
+ delete m_in;
+ delete m_out;
++#endif
}
-@@ -930,17 +621,14 @@
+@@ -930,6 +1029,7 @@
int RemotePluginBase::sendMessage( const message & _m )
{
-- m_out->lock();
-- m_out->writeInt( _m.id );
-- m_out->writeInt( _m.data.size() );
++#ifdef SYNC_WITH_SHM_FIFO
+ m_out->lock();
+ m_out->writeInt( _m.id );
+ m_out->writeInt( _m.data.size() );
+@@ -941,6 +1041,16 @@
+ }
+ m_out->unlock();
+ m_out->messageSent();
++#else
+ writeInt( _m.id );
+ writeInt( _m.data.size() );
- int j = 8;
- for( unsigned int i = 0; i < _m.data.size(); ++i )
- {
-- m_out->writeString( _m.data[i] );
++ int j = 8;
++ for( unsigned int i = 0; i < _m.data.size(); ++i )
++ {
+ writeString( _m.data[i] );
- j += 4 + _m.data[i].size();
- }
-- m_out->unlock();
-- m_out->messageSent();
++ j += 4 + _m.data[i].size();
++ }
++#endif
return j;
}
-@@ -950,16 +638,13 @@
+@@ -950,6 +1060,7 @@
RemotePluginBase::message RemotePluginBase::receiveMessage()
{
-- m_in->waitForMessage();
-- m_in->lock();
++#ifdef SYNC_WITH_SHM_FIFO
+ m_in->waitForMessage();
+ m_in->lock();
message m;
-- m.id = m_in->readInt();
-- const int s = m_in->readInt();
+@@ -960,6 +1071,15 @@
+ m.data.push_back( m_in->readString() );
+ }
+ m_in->unlock();
++#else
++ message m;
+ m.id = readInt();
+ const int s = readInt();
- for( int i = 0; i < s; ++i )
- {
-- m.data.push_back( m_in->readString() );
++ for( int i = 0; i < s; ++i )
++ {
+ m.data.push_back( readString() );
- }
-- m_in->unlock();
++ }
++#endif
return m;
}
-@@ -1005,8 +690,8 @@
+@@ -1005,8 +1125,13 @@
#ifdef BUILD_REMOTE_PLUGIN_CLIENT
--RemotePluginClient::RemotePluginClient( key_t _shm_in, key_t _shm_out ) :
-- RemotePluginBase( new shmFifo( _shm_in ), new shmFifo( _shm_out ) ),
++#ifdef SYNC_WITH_SHM_FIFO
+ RemotePluginClient::RemotePluginClient( key_t _shm_in, key_t _shm_out ) :
+ RemotePluginBase( new shmFifo( _shm_in ), new shmFifo( _shm_out ) ),
++#else
+RemotePluginClient::RemotePluginClient( const char * socketPath ) :
+ RemotePluginBase(),
++#endif
#ifdef USE_QT_SHMEM
m_shmObj(),
m_shmQtID( "/usr/bin/lmms" ),
-@@ -1062,6 +747,26 @@
+@@ -1062,6 +1187,28 @@
}
}
#endif
+
++#ifndef SYNC_WITH_SHM_FIFO
+ struct sockaddr_un sa;
+ sa.sun_family = AF_LOCAL;
+
@@ -750,26 +604,29 @@ Index: lmms-1.1.3/include/RemotePlugin.h
+ {
+ fprintf( stderr, "Could not connect to local server.\n" );
+ }
++#endif
+
// if attaching shared memory fails
sendMessage( IdSampleRateInformation );
sendMessage( IdBufferSizeInformation );
-@@ -1080,6 +785,11 @@
+@@ -1080,6 +1227,13 @@
#ifndef USE_QT_SHMEM
shmdt( m_shm );
#endif
+
++#ifndef SYNC_WITH_SHM_FIFO
+ if ( close( m_socket ) == -1)
+ {
+ fprintf( stderr, "Error freeing resources.\n" );
+ }
++#endif
}
Index: lmms-1.1.3/plugins/vst_base/RemoteVstPlugin.cpp
===================================================================
---- lmms-1.1.3.orig/plugins/vst_base/RemoteVstPlugin.cpp 2016-04-09 00:44:21.000000000 +0200
-+++ lmms-1.1.3/plugins/vst_base/RemoteVstPlugin.cpp 2016-04-14 21:09:56.000000000 +0200
+--- lmms-1.1.3.orig/plugins/vst_base/RemoteVstPlugin.cpp 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/plugins/vst_base/RemoteVstPlugin.cpp 2016-04-20 01:43:34.000000000 +0200
@@ -56,6 +56,7 @@
#endif
@@ -778,27 +635,33 @@ Index: lmms-1.1.3/plugins/vst_base/RemoteVstPlugin.cpp
#include <windows.h>
#ifdef LMMS_BUILD_WIN32
-@@ -121,7 +122,7 @@
+@@ -121,7 +122,11 @@
class RemoteVstPlugin : public RemotePluginClient
{
public:
-- RemoteVstPlugin( key_t _shm_in, key_t _shm_out );
++#ifdef SYNC_WITH_SHM_FIFO
+ RemoteVstPlugin( key_t _shm_in, key_t _shm_out );
++#else
+ RemoteVstPlugin( const char * socketPath );
++#endif
virtual ~RemoteVstPlugin();
virtual bool processMessage( const message & _m );
-@@ -332,8 +333,8 @@
+@@ -332,8 +337,13 @@
--RemoteVstPlugin::RemoteVstPlugin( key_t _shm_in, key_t _shm_out ) :
-- RemotePluginClient( _shm_in, _shm_out ),
++#ifdef SYNC_WITH_SHM_FIFO
+ RemoteVstPlugin::RemoteVstPlugin( key_t _shm_in, key_t _shm_out ) :
+ RemotePluginClient( _shm_in, _shm_out ),
++#else
+RemoteVstPlugin::RemoteVstPlugin( const char * socketPath ) :
+ RemotePluginClient( socketPath ),
++#endif
m_shortName( "" ),
m_libInst( NULL ),
m_plugin( NULL ),
-@@ -1014,7 +1015,7 @@
+@@ -1014,7 +1024,7 @@
if( len > 0 )
{
int fd = open( _file.c_str(), O_WRONLY | O_BINARY );
@@ -807,7 +670,7 @@ Index: lmms-1.1.3/plugins/vst_base/RemoteVstPlugin.cpp
close( fd );
}
}
-@@ -1331,7 +1332,7 @@
+@@ -1331,7 +1341,7 @@
}
const int fd = open( _file.c_str(), O_RDONLY | O_BINARY );
@@ -816,28 +679,34 @@ Index: lmms-1.1.3/plugins/vst_base/RemoteVstPlugin.cpp
close( fd );
pluginDispatch( 24, 0, _len, chunk );
-@@ -1853,7 +1854,7 @@
+@@ -1853,7 +1863,11 @@
int main( int _argc, char * * _argv )
{
-- if( _argc < 3 )
++#ifdef SYNC_WITH_SHM_FIFO
+ if( _argc < 3 )
++#else
+ if( _argc < 2 )
++#endif
{
fprintf( stderr, "not enough arguments\n" );
return -1;
-@@ -1879,7 +1880,7 @@
+@@ -1879,7 +1893,11 @@
// constructor automatically will process messages until it receives
// a IdVstLoadPlugin message and processes it
-- __plugin = new RemoteVstPlugin( atoi( _argv[1] ), atoi( _argv[2] ) );
++#ifdef SYNC_WITH_SHM_FIFO
+ __plugin = new RemoteVstPlugin( atoi( _argv[1] ), atoi( _argv[2] ) );
++#else
+ __plugin = new RemoteVstPlugin( _argv[1] );
++#endif
if( __plugin->isInitialized() )
{
Index: lmms-1.1.3/plugins/vst_base/VstPlugin.cpp
===================================================================
---- lmms-1.1.3.orig/plugins/vst_base/VstPlugin.cpp 2016-04-09 12:55:05.000000000 +0200
-+++ lmms-1.1.3/plugins/vst_base/VstPlugin.cpp 2016-04-13 22:02:05.000000000 +0200
+--- lmms-1.1.3.orig/plugins/vst_base/VstPlugin.cpp 2016-04-15 00:26:50.000000000 +0200
++++ lmms-1.1.3/plugins/vst_base/VstPlugin.cpp 2016-04-15 00:26:50.000000000 +0200
@@ -78,9 +78,8 @@
@@ -851,8 +720,8 @@ Index: lmms-1.1.3/plugins/vst_base/VstPlugin.cpp
m_pluginWindowID( 0 ),
Index: lmms-1.1.3/plugins/vst_base/VstPlugin.h
===================================================================
---- lmms-1.1.3.orig/plugins/vst_base/VstPlugin.h 2016-04-10 18:53:28.000000000 +0200
-+++ lmms-1.1.3/plugins/vst_base/VstPlugin.h 2016-04-10 19:03:28.000000000 +0200
+--- lmms-1.1.3.orig/plugins/vst_base/VstPlugin.h 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/plugins/vst_base/VstPlugin.h 2016-04-15 00:26:50.000000000 +0200
@@ -37,8 +37,7 @@
#include "communication.h"
@@ -865,42 +734,51 @@ Index: lmms-1.1.3/plugins/vst_base/VstPlugin.h
public:
Index: lmms-1.1.3/plugins/zynaddsubfx/RemoteZynAddSubFx.cpp
===================================================================
---- lmms-1.1.3.orig/plugins/zynaddsubfx/RemoteZynAddSubFx.cpp 2016-04-10 21:05:46.000000000 +0200
-+++ lmms-1.1.3/plugins/zynaddsubfx/RemoteZynAddSubFx.cpp 2016-04-13 23:34:46.000000000 +0200
-@@ -44,8 +44,8 @@
+--- lmms-1.1.3.orig/plugins/zynaddsubfx/RemoteZynAddSubFx.cpp 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/plugins/zynaddsubfx/RemoteZynAddSubFx.cpp 2016-04-20 01:48:10.000000000 +0200
+@@ -44,8 +44,13 @@
class RemoteZynAddSubFx : public RemotePluginClient, public LocalZynAddSubFx
{
public:
-- RemoteZynAddSubFx( int _shm_in, int _shm_out ) :
-- RemotePluginClient( _shm_in, _shm_out ),
++#ifdef SYNC_WITH_SHM_FIFO
+ RemoteZynAddSubFx( int _shm_in, int _shm_out ) :
+ RemotePluginClient( _shm_in, _shm_out ),
++#else
+ RemoteZynAddSubFx( const char * socketPath ) :
+ RemotePluginClient( socketPath ),
++#endif
LocalZynAddSubFx(),
m_guiSleepTime( 100 ),
m_guiExit( false )
-@@ -261,7 +261,7 @@
+@@ -261,7 +266,11 @@
int main( int _argc, char * * _argv )
{
-- if( _argc < 3 )
++#ifdef SYNC_WITH_SHM_FIFO
+ if( _argc < 3 )
++#else
+ if( _argc < 2 )
++#endif
{
fprintf( stderr, "not enough arguments\n" );
return -1;
-@@ -276,8 +276,7 @@
+@@ -276,8 +285,12 @@
#endif
-- RemoteZynAddSubFx * remoteZASF =
-- new RemoteZynAddSubFx( atoi( _argv[1] ), atoi( _argv[2] ) );
++#ifdef SYNC_WITH_SHM_FIFO
+ RemoteZynAddSubFx * remoteZASF =
+ new RemoteZynAddSubFx( atoi( _argv[1] ), atoi( _argv[2] ) );
++#else
+ RemoteZynAddSubFx * remoteZASF = new RemoteZynAddSubFx( _argv[1] );
++#endif
remoteZASF->run();
Index: lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.cpp
===================================================================
---- lmms-1.1.3.orig/plugins/zynaddsubfx/ZynAddSubFx.cpp 2016-04-10 19:05:45.000000000 +0200
-+++ lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.cpp 2016-04-10 19:05:57.000000000 +0200
+--- lmms-1.1.3.orig/plugins/zynaddsubfx/ZynAddSubFx.cpp 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.cpp 2016-04-15 00:26:50.000000000 +0200
@@ -74,7 +74,6 @@
@@ -911,8 +789,8 @@ Index: lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.cpp
init( "RemoteZynAddSubFx", false );
Index: lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.h
===================================================================
---- lmms-1.1.3.orig/plugins/zynaddsubfx/ZynAddSubFx.h 2016-04-10 19:05:10.000000000 +0200
-+++ lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.h 2016-04-10 19:05:35.000000000 +0200
+--- lmms-1.1.3.orig/plugins/zynaddsubfx/ZynAddSubFx.h 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.h 2016-04-15 00:26:50.000000000 +0200
@@ -44,7 +44,7 @@
class ledCheckBox;
@@ -924,38 +802,45 @@ Index: lmms-1.1.3/plugins/zynaddsubfx/ZynAddSubFx.h
public:
Index: lmms-1.1.3/src/core/RemotePlugin.cpp
===================================================================
---- lmms-1.1.3.orig/src/core/RemotePlugin.cpp 2016-04-09 19:17:15.000000000 +0200
-+++ lmms-1.1.3/src/core/RemotePlugin.cpp 2016-04-14 21:11:40.000000000 +0200
-@@ -34,6 +34,9 @@
- #include "config_mgr.h"
+--- lmms-1.1.3.orig/src/core/RemotePlugin.cpp 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/src/core/RemotePlugin.cpp 2016-04-20 17:25:13.000000000 +0200
+@@ -39,6 +39,12 @@
+ #include <unistd.h>
+ #endif
- #include <QtCore/QDir>
++#ifndef SYNC_WITH_SHM_FIFO
+#include <QtCore/QUuid>
+#include <sys/socket.h>
+#include <sys/un.h>
++#endif
++
- #ifdef LMMS_HAVE_UNISTD_H
- #include <unistd.h>
-@@ -69,7 +72,8 @@
+ // simple helper thread monitoring our RemotePlugin - if process terminates
+ // unexpectedly invalidate plugin so LMMS doesn't lock up
+@@ -69,7 +75,12 @@
RemotePlugin::RemotePlugin() :
-- RemotePluginBase( new shmFifo(), new shmFifo() ),
+ QObject(),
++#ifdef SYNC_WITH_SHM_FIFO
+ RemotePluginBase( new shmFifo(), new shmFifo() ),
++#else
+ RemotePluginBase(),
++#endif
m_failed( true ),
m_process(),
m_watcher( this ),
-@@ -85,6 +89,28 @@
+@@ -85,6 +96,30 @@
m_inputCount( DEFAULT_CHANNELS ),
m_outputCount( DEFAULT_CHANNELS )
{
++#ifndef SYNC_WITH_SHM_FIFO
+ struct sockaddr_un sa;
+ sa.sun_family = AF_LOCAL;
+
+ m_socketFile = QDir::tempPath() + QDir::separator() +
+ QUuid::createUuid().toString();
-+ const char * path = m_socketFile.toUtf8().data();
++ const char * path = m_socketFile.toUtf8().constData();
+ if ( strlen( path ) >= sizeof sa.sun_path )
+ {
+ qWarning( "Socket path too long." );
@@ -972,47 +857,56 @@ Index: lmms-1.1.3/src/core/RemotePlugin.cpp
+ {
+ qWarning( "Unable to start the server." );
+ }
++#endif
}
-@@ -116,6 +142,12 @@
+@@ -116,6 +151,14 @@
shmctl( m_shmID, IPC_RMID, NULL );
#endif
}
+
++#ifndef SYNC_WITH_SHM_FIFO
+ if ( close( m_server ) == -1)
+ {
+ qWarning( "Error freeing resources." );
+ }
-+ remove( m_socketFile.toUtf8().data() );
++ remove( m_socketFile.toUtf8().constData() );
++#endif
}
-@@ -127,16 +159,13 @@
+@@ -127,16 +170,22 @@
lock();
if( m_failed )
{
-- reset( new shmFifo(), new shmFifo() );
++#ifdef SYNC_WITH_SHM_FIFO
+ reset( new shmFifo(), new shmFifo() );
++#endif
m_failed = false;
}
QString exec = configManager::inst()->pluginDir() +
QDir::separator() + pluginExecutable;
QStringList args;
-- // swap in and out for bidirectional communication
-- args << QString::number( out()->shmKey() );
-- args << QString::number( in()->shmKey() );
++#ifdef SYNC_WITH_SHM_FIFO
+ // swap in and out for bidirectional communication
+ args << QString::number( out()->shmKey() );
+ args << QString::number( in()->shmKey() );
++#else
+ args << m_socketFile;
++#endif
#ifndef DEBUG_REMOTE_PLUGIN
m_process.setProcessChannelMode( QProcess::ForwardedChannels );
m_process.setWorkingDirectory( QCoreApplication::applicationDirPath() );
-@@ -146,6 +175,28 @@
+@@ -146,6 +195,30 @@
qDebug() << exec << args;
#endif
+ connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
+ this, SLOT( processFinished( int, QProcess::ExitStatus ) ) );
+
++#ifndef SYNC_WITH_SHM_FIFO
+ struct pollfd pollin;
+ pollin.fd = m_server;
+ pollin.events = POLLIN;
@@ -1031,11 +925,12 @@ Index: lmms-1.1.3/src/core/RemotePlugin.cpp
+ {
+ qWarning( "Unexpected socket error." );
+ }
++#endif
+
resizeSharedProcessingMemory();
if( waitForInitDoneMsg )
-@@ -337,6 +388,15 @@
+@@ -337,6 +410,17 @@
}
@@ -1044,7 +939,9 @@ Index: lmms-1.1.3/src/core/RemotePlugin.cpp
+void RemotePlugin::processFinished( int exitCode,
+ QProcess::ExitStatus exitStatus )
+{
++#ifndef SYNC_WITH_SHM_FIFO
+ invalidate();
++#endif
+}
+
+
@@ -1053,8 +950,8 @@ Index: lmms-1.1.3/src/core/RemotePlugin.cpp
bool RemotePlugin::processMessage( const message & _m )
Index: lmms-1.1.3/src/core/main.cpp
===================================================================
---- lmms-1.1.3.orig/src/core/main.cpp 2016-04-13 20:33:13.000000000 +0200
-+++ lmms-1.1.3/src/core/main.cpp 2016-04-13 20:43:35.000000000 +0200
+--- lmms-1.1.3.orig/src/core/main.cpp 2016-04-14 22:36:18.000000000 +0200
++++ lmms-1.1.3/src/core/main.cpp 2016-04-20 16:35:32.000000000 +0200
@@ -64,6 +64,8 @@
#include <unistd.h>
#endif
@@ -1064,10 +961,11 @@ Index: lmms-1.1.3/src/core/main.cpp
#include "config_mgr.h"
#include "embed.h"
#include "engine.h"
-@@ -408,6 +410,18 @@
+@@ -408,6 +410,20 @@
#endif
#endif
++#if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
+ struct sigaction sa;
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = SA_SIGINFO;
@@ -1079,6 +977,7 @@ Index: lmms-1.1.3/src/core/main.cpp
+ {
+ fprintf( stderr, "Signal initialization failed.\n" );
+ }
++#endif
+
configManager::inst()->loadConfigFile();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/lmms.git
More information about the debian-edu-commits
mailing list