|
@@ -237,19 +237,14 @@ class RemoteVstPlugin : public RemotePluginClient |
|
|
// has to be called as soon as input- or output-count changes |
|
|
void updateInOutCount(); |
|
|
|
|
|
inline void lock() |
|
|
{ |
|
|
pthread_mutex_lock( &m_pluginLock ); |
|
|
} |
|
|
|
|
|
inline void unlock() |
|
|
inline void lockShm() |
|
|
{ |
|
|
pthread_mutex_unlock( &m_pluginLock ); |
|
|
pthread_mutex_lock( &m_shmLock ); |
|
|
} |
|
|
|
|
|
inline void lockShm() |
|
|
inline bool tryLockShm() |
|
|
{ |
|
|
pthread_mutex_lock( &m_shmLock ); |
|
|
return pthread_mutex_trylock( &m_shmLock ) == 0; |
|
|
} |
|
|
|
|
|
inline void unlockShm() |
|
@@ -318,22 +313,8 @@ class RemoteVstPlugin : public RemotePluginClient |
|
|
|
|
|
bool load( const std::string & _plugin_file ); |
|
|
|
|
|
// thread-safe dispatching of plugin |
|
|
int pluginDispatch( int cmd, int param1 = 0, int param2 = 0, |
|
|
void * p = NULL, float f = 0 ) |
|
|
{ |
|
|
int ret = 0; |
|
|
lock(); |
|
|
if( m_plugin ) |
|
|
{ |
|
|
ret = m_plugin->dispatcher( m_plugin, cmd, param1, param2, p, f ); |
|
|
} |
|
|
unlock(); |
|
|
return ret; |
|
|
} |
|
|
|
|
|
// thread-safe dispatching of plugin |
|
|
int pluginDispatchNoLocking( int cmd, int param1 = 0, int param2 = 0, void * p = NULL, float f = 0 ) |
|
|
{ |
|
|
if( m_plugin ) |
|
|
{ |
|
@@ -356,7 +337,6 @@ class RemoteVstPlugin : public RemotePluginClient |
|
|
bool m_initialized; |
|
|
bool m_registeredWindowClass; |
|
|
|
|
|
pthread_mutex_t m_pluginLock; |
|
|
bool m_processing; |
|
|
|
|
|
std::queue<message> m_messageList; |
|
@@ -408,7 +388,6 @@ RemoteVstPlugin::RemoteVstPlugin( const char * socketPath ) : |
|
|
m_windowHeight( 0 ), |
|
|
m_initialized( false ), |
|
|
m_registeredWindowClass( false ), |
|
|
m_pluginLock(), |
|
|
m_processing( false ), |
|
|
m_messageList(), |
|
|
m_shouldGiveIdle( false ), |
|
@@ -424,7 +403,6 @@ RemoteVstPlugin::RemoteVstPlugin( const char * socketPath ) : |
|
|
m_shmID( -1 ), |
|
|
m_vstSyncData( NULL ) |
|
|
{ |
|
|
pthread_mutex_init( &m_pluginLock, NULL ); |
|
|
pthread_mutex_init( &m_shmLock, NULL ); |
|
|
|
|
|
__plugin = this; |
|
@@ -518,7 +496,6 @@ RemoteVstPlugin::~RemoteVstPlugin() |
|
|
delete[] m_outputs; |
|
|
|
|
|
pthread_mutex_destroy( &m_shmLock ); |
|
|
pthread_mutex_destroy( &m_pluginLock ); |
|
|
} |
|
|
|
|
|
|
|
@@ -623,9 +600,7 @@ bool RemoteVstPlugin::processMessage( const message & _m ) |
|
|
break; |
|
|
|
|
|
case IdVstSetParameter: |
|
|
lock(); |
|
|
m_plugin->setParameter( m_plugin, _m.getInt( 0 ), _m.getFloat( 1 ) ); |
|
|
unlock(); |
|
|
//sendMessage( IdVstSetParameter ); |
|
|
break; |
|
|
|
|
@@ -906,13 +881,14 @@ void RemoteVstPlugin::process( const sampleFrame * _in, sampleFrame * _out ) |
|
|
|
|
|
// now we're ready to fetch sound from VST-plugin |
|
|
|
|
|
lock(); |
|
|
lockShm(); |
|
|
if( !tryLockShm() ) |
|
|
{ |
|
|
return; |
|
|
} |
|
|
|
|
|
if( !isShmValid() ) |
|
|
{ |
|
|
unlockShm(); |
|
|
unlock(); |
|
|
return; |
|
|
} |
|
|
|
|
@@ -943,7 +919,6 @@ void RemoteVstPlugin::process( const sampleFrame * _in, sampleFrame * _out ) |
|
|
#endif |
|
|
|
|
|
unlockShm(); |
|
|
unlock(); |
|
|
|
|
|
m_currentSamplePos += bufferSize(); |
|
|
} |
|
@@ -1050,25 +1025,21 @@ void RemoteVstPlugin::sendCurrentProgramName() |
|
|
|
|
|
void RemoteVstPlugin::getParameterDump() |
|
|
{ |
|
|
lock(); |
|
|
|
|
|
message m( IdVstParameterDump ); |
|
|
m.addInt( m_plugin->numParams ); |
|
|
|
|
|
for( int i = 0; i < m_plugin->numParams; ++i ) |
|
|
{ |
|
|
char paramName[32]; |
|
|
memset( paramName, 0, sizeof( paramName ) ); |
|
|
pluginDispatchNoLocking( effGetParamName, i, 0, paramName ); |
|
|
pluginDispatch( effGetParamName, i, 0, paramName ); |
|
|
paramName[sizeof(paramName)-1] = 0; |
|
|
|
|
|
m.addInt( i ); |
|
|
m.addString( paramName ); |
|
|
m.addFloat( m_plugin->getParameter( m_plugin, i ) ); |
|
|
} |
|
|
|
|
|
unlock(); |
|
|
|
|
|
sendMessage( m ); |
|
|
} |
|
|
|
|
@@ -1077,7 +1048,6 @@ void RemoteVstPlugin::getParameterDump() |
|
|
|
|
|
void RemoteVstPlugin::setParameterDump( const message & _m ) |
|
|
{ |
|
|
lock(); |
|
|
const int n = _m.getInt( 0 ); |
|
|
const int params = ( n > m_plugin->numParams ) ? |
|
|
m_plugin->numParams : n; |
|
@@ -1090,7 +1060,6 @@ void RemoteVstPlugin::setParameterDump( const message & _m ) |
|
|
item.value = _m.getFloat( ++p ); |
|
|
m_plugin->setParameter( m_plugin, item.index, item.value ); |
|
|
} |
|
|
unlock(); |
|
|
} |
|
|
|
|
|
|
|
@@ -1243,14 +1212,12 @@ void RemoteVstPlugin::savePreset( const std::string & _file ) |
|
|
chunk_size = m_plugin->numParams * sizeof( float ); |
|
|
data = new char[ chunk_size ]; |
|
|
unsigned int* toUIntArray = reinterpret_cast<unsigned int*>( data ); |
|
|
lock(); |
|
|
for ( int i = 0; i < m_plugin->numParams; i++ ) |
|
|
{ |
|
|
float value = m_plugin->getParameter( m_plugin, i ); |
|
|
unsigned int * pValue = ( unsigned int * ) &value; |
|
|
toUIntArray[ i ] = endian_swap( *pValue ); |
|
|
} |
|
|
unlock(); |
|
|
} else chunk_size = (((m_plugin->numParams * sizeof( float )) + 56)*m_plugin->numPrograms); |
|
|
} |
|
|
|
|
@@ -1296,14 +1263,12 @@ void RemoteVstPlugin::savePreset( const std::string & _file ) |
|
|
pluginDispatch( effSetProgram, 0, j ); |
|
|
pluginDispatch( effGetProgramName, 0, 0, pBank->prgName ); |
|
|
fwrite ( pBank, 1, 56, stream ); |
|
|
lock(); |
|
|
for ( int i = 0; i < m_plugin->numParams; i++ ) |
|
|
{ |
|
|
value = m_plugin->getParameter( m_plugin, i ); |
|
|
pValue = ( unsigned int * ) &value; |
|
|
toUIntArray[ i ] = endian_swap( *pValue ); |
|
|
} |
|
|
unlock(); |
|
|
fwrite ( data, 1, chunk_size, stream ); |
|
|
} |
|
|
pluginDispatch( effSetProgram, 0, currProgram ); |
|
@@ -1370,15 +1335,13 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) |
|
|
pluginDispatch( 24, 1, len, chunk ); |
|
|
else |
|
|
{ |
|
|
lock(); |
|
|
unsigned int* toUIntArray = reinterpret_cast<unsigned int*>( chunk ); |
|
|
for (int i = 0; i < pBank->numPrograms; i++ ) |
|
|
{ |
|
|
toUInt = endian_swap( toUIntArray[ i ] ); |
|
|
pFloat = ( float* ) &toUInt; |
|
|
m_plugin->setParameter( m_plugin, i, *pFloat ); |
|
|
} |
|
|
unlock(); |
|
|
} |
|
|
} else { |
|
|
if(pBank->fxMagic != 0x6B427846) { |
|
@@ -1389,7 +1352,6 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) |
|
|
int currProgram = pluginDispatch( effGetProgram ); |
|
|
chunk = new char[ len = sizeof(float)*m_plugin->numParams ]; |
|
|
toUIntArray = reinterpret_cast<unsigned int *>( chunk ); |
|
|
lock(); |
|
|
for (int i =0; i < numPrograms; i++) { |
|
|
if ( fread (pBank, 1, 56, stream) != 56 ) |
|
|
{ |
|
@@ -1410,7 +1372,6 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) |
|
|
m_plugin->setParameter( m_plugin, j, *pFloat ); |
|
|
} |
|
|
} |
|
|
unlock(); |
|
|
pluginDispatch( effSetProgram, 0, currProgram ); |
|
|
fclose( stream ); |
|
|
} |
|
|