~marcustomlinson/dspatch/component_params

« back to all changes in this revision

Viewing changes to src/DspComponent.cpp

  • Committer: Marcus Tomlinson
  • Date: 2014-06-15 07:45:37 UTC
  • Revision ID: marcus.tomlinson@canonical.com-20140615074537-ubzmyv2rtj6xrngg
Return pointers from DspParameter get methods to be compared with NULL.
ParameterUpdated_() replaced with ParameterUpdating_() for components to first validate the new value.

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
 
233
233
//-------------------------------------------------------------------------------------------------
234
234
 
235
 
bool DspComponent::GetParameter( std::string const& paramName, DspParameter& returnParam )
 
235
DspParameter const* DspComponent::GetParameter( std::string const& paramName )
236
236
{
237
237
  PauseAutoTick();
238
 
  bool result = GetParameter_( paramName, returnParam );
 
238
  DspParameter const* result = GetParameter_( paramName );
239
239
  ResumeAutoTick();
240
240
  return result;
241
241
}
244
244
 
245
245
bool DspComponent::SetParameter( std::string const& paramName, DspParameter const& param )
246
246
{
 
247
  bool result = false;
247
248
  PauseAutoTick();
248
 
  bool result = SetParameter_( paramName, param );
 
249
  if( ParameterUpdating_( paramName, param ) )
 
250
  {
 
251
    result = SetParameter_( paramName, param );
 
252
  }
249
253
  ResumeAutoTick();
250
254
  return result;
251
255
}
274
278
    _outputBus.ClearAllValues();
275
279
 
276
280
    // 4. call Process_() with newly aquired inputs
277
 
    Process_( _inputBus, _outputBus, _parameters );
 
281
    Process_( _inputBus, _outputBus );
278
282
  }
279
283
}
280
284
 
393
397
 
394
398
//=================================================================================================
395
399
 
396
 
void DspComponent::Process_( DspSignalBus& inputs, DspSignalBus& outputs, std::map< std::string, DspParameter >& )
397
 
{
398
 
  Process_( inputs, outputs );
399
 
}
400
 
 
401
 
//-------------------------------------------------------------------------------------------------
402
 
 
403
400
bool DspComponent::AddInput_( std::string const& inputName )
404
401
{
405
402
  for( unsigned short i = 0; i < _inputBuses.size(); i++ )
562
559
 
563
560
//-------------------------------------------------------------------------------------------------
564
561
 
565
 
bool DspComponent::GetParameter_( std::string const& paramName, DspParameter& returnParam )
 
562
DspParameter const* DspComponent::GetParameter_( std::string const& paramName ) const
566
563
{
567
564
  if( _parameters.find( paramName ) != _parameters.end() )
568
565
  {
569
 
    return returnParam.SetParam( _parameters.at( paramName ) );
 
566
    return &_parameters.at( paramName );
570
567
  }
571
 
  return false;
 
568
  return NULL;
572
569
}
573
570
 
574
571
//-------------------------------------------------------------------------------------------------
579
576
  {
580
577
    if( _parameters.at( paramName ).SetParam( param ) )
581
578
    {
582
 
      ParameterUpdated_( paramName, param );
583
579
      if( _callback )
584
580
      {
585
581
        _callback( this, ParameterUpdated, std::distance( _parameters.begin(), _parameters.find( paramName ) ) );
744
740
    _WaitForRelease( threadNo );
745
741
 
746
742
    // 5. call Process_() with newly aquired inputs
747
 
    Process_( _inputBuses[threadNo], _outputBuses[threadNo], _parameters );
 
743
    Process_( _inputBuses[threadNo], _outputBuses[threadNo] );
748
744
 
749
745
    // 6. signal that you're done processing.
750
746
    _ReleaseThread( threadNo );