Skip to content

Commit

Permalink
Remove not needed code and rewrita vector usage in STL C++ style
Browse files Browse the repository at this point in the history
  • Loading branch information
firewall1110 committed Feb 8, 2025
1 parent 4dc773d commit 5672e7c
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions plugins/Sid/SidInstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,7 @@ SidInstrument::SidInstrument( InstrumentTrack * _instrument_track ) :
auto sid = new reSID::SID();
if (sid)
{
struct SIDElement el = { false, sid };
sid->set_sampling_parameters(
C64_PAL_CYCLES_PER_SEC,
reSID::SAMPLE_FAST,
Engine::audioEngine()->outputSampleRate());
sid->set_chip_model(reSID::MOS8580);
sid->enable_filter( true );
sid->reset();
m_sidStorage.push_back(el);
m_sidStorage.push_back(SIDElement{ false, sid });
}
else
{
Expand Down Expand Up @@ -492,19 +484,17 @@ gui::PluginView* SidInstrument::instantiateView( QWidget * _parent )
reSID::SID *SidInstrument::getSID()
{
spin();
for (unsigned n = 0; n < m_sidStorage.size(); ++n)
auto el = m_sidStorage.begin();
auto elEnd = m_sidStorage.end();
for (; el != elEnd; ++el)
{
if (m_sidStorage[n].sid)
if ((el->sid) && (!el->used))
{
if (!m_sidStorage[n].used)
{
m_sidStorage[n].used = true;
m_lockGet.clear(std::memory_order_release);
return m_sidStorage[n].sid;
}
el->used = true;
m_lockGet.clear(std::memory_order_release);
return el->sid;
}
}

m_lockGet.clear(std::memory_order_release);
return nullptr;
}
Expand All @@ -514,11 +504,13 @@ reSID::SID *SidInstrument::getSID()

bool SidInstrument::freeSID(reSID::SID *sid)
{
for (unsigned n = 0; n < m_sidStorage.size(); ++n)
auto el = m_sidStorage.begin();
auto elEnd = m_sidStorage.end();
for (; el != elEnd; ++el)
{
if (sid == m_sidStorage[n].sid)
if (sid == el->sid)
{
m_sidStorage[n].used = false;
el->used = false;
return true;
}
}
Expand Down

0 comments on commit 5672e7c

Please sign in to comment.