| 273 | |
| 274 | |
| 275 | bool RemotePlugin::process( const sampleFrame * _in_buf, |
| 276 | sampleFrame * _out_buf ) |
| 277 | { |
| 278 | const fpp_t frames = Engine::mixer()->framesPerPeriod(); |
| 279 | |
| 280 | if( m_failed || !isRunning() ) |
| 281 | { |
| 282 | if( _out_buf != NULL ) |
| 283 | { |
| 284 | BufferManager::clear( _out_buf, frames ); |
| 285 | } |
| 286 | return false; |
| 287 | } |
| 288 | |
| 289 | if( m_shm == NULL ) |
| 290 | { |
| 291 | // m_shm being zero means we didn't initialize everything so |
| 292 | // far so process one message each time (and hope we get |
| 293 | // information like SHM-key etc.) until we process messages |
| 294 | // in a later stage of this procedure |
| 295 | if( m_shmSize == 0 ) |
| 296 | { |
| 297 | lock(); |
| 298 | fetchAndProcessAllMessages(); |
| 299 | unlock(); |
| 300 | } |
| 301 | if( _out_buf != NULL ) |
| 302 | { |
| 303 | BufferManager::clear( _out_buf, frames ); |
| 304 | } |
| 305 | return false; |
| 306 | } |
| 307 | |
| 308 | memset( m_shm, 0, m_shmSize ); |
| 309 | |
| 310 | ch_cnt_t inputs = qMin<ch_cnt_t>( m_inputCount, DEFAULT_CHANNELS ); |
| 311 | |
| 312 | if( _in_buf != NULL && inputs > 0 ) |
| 313 | { |
| 314 | if( m_splitChannels ) |
| 315 | { |
| 316 | for( ch_cnt_t ch = 0; ch < inputs; ++ch ) |
| 317 | { |
| 318 | for( fpp_t frame = 0; frame < frames; ++frame ) |
| 319 | { |
| 320 | m_shm[ch * frames + frame] = |
| 321 | _in_buf[frame][ch]; |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | else if( inputs == DEFAULT_CHANNELS ) |
| 326 | { |
| 327 | memcpy( m_shm, _in_buf, frames * BYTES_PER_FRAME ); |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | sampleFrame * o = (sampleFrame *) m_shm; |
| 332 | for( ch_cnt_t ch = 0; ch < inputs; ++ch ) |