Skip to content

Commit

Permalink
Factor out common code
Browse files Browse the repository at this point in the history
  • Loading branch information
pljones committed Oct 2, 2024
1 parent 4cb01e3 commit 2ade0ca
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/audiomixerboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,22 +1335,16 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf

void CAudioMixerBoard::SetFaderLevel ( const int iChannelIdx, const int iValue )
{
// only apply new fader level if channel index is valid and the fader is visible
if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) )
{
if ( vecpChanFader[static_cast<size_t> ( iChannelIdx )]->IsVisible() )
{
vecpChanFader[static_cast<size_t> ( iChannelIdx )]->SetFaderLevel ( iValue );
}
}
// Proposed change: if iChannelIdx is -1 and our own channel ID is a valid index
// then we adjust our own fader level:
if((iChannelIdx == -1) && iMyChannelID != INVALID_INDEX)
const int iTheChannelIdx = ( iChannelIdx == INVALID_INDEX ) ? iMyChannelID : iChannelIdx;

// only apply new fader level if channel index is valid and the fader is visible
if ( ( iTheChannelIdx >= 0 ) && ( iTheChannelIdx < MAX_NUM_CHANNELS ) )
{
if ( vecpChanFader[static_cast<size_t> ( iMyChannelID )]->IsVisible() )
if ( vecpChanFader[static_cast<size_t> ( iTheChannelIdx )]->IsVisible() )
{
//printf("debug: set our own fader(%d) level to %d\n", iMyChannelID, iValue);
vecpChanFader[static_cast<size_t> ( iMyChannelID )]->SetFaderLevel ( iValue );
vecpChanFader[static_cast<size_t> ( iTheChannelIdx )]->SetFaderLevel ( iValue );
}
}
}
Expand Down

0 comments on commit 2ade0ca

Please sign in to comment.