Skip to content

Commit

Permalink
treat card entry as locked; fixed card profile indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
patroclos committed Dec 31, 2017
1 parent cb5596f commit aed87dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/cardentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ void CardEntry::cycleSwitch(bool increment) {
if (m_Profiles.empty())
return;

m_Profile = (m_Profile + increment ? 1 : -1) % (unsigned) m_Profiles.size();
m_Profile = (m_Profile + (increment ? 1 : -1)) % (int) m_Profiles.size();
if (m_Profile < 0)
m_Profile += m_Profiles.size();

pa_operation *op = pa_context_set_card_profile_by_index(interface->getPAContext(), m_Index,
m_Profiles[m_Profile].name.c_str(), &PAInterface::cb_success,
Expand Down
7 changes: 4 additions & 3 deletions src/pamix_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,11 @@ void pamix_ui::selectEntries(entry_type type) {
}
m_EntriesType = type;

if (m_SelectedEntry >= m_Entries->size())
if (m_SelectedEntry > 0 && m_SelectedEntry >= m_Entries->size())
m_SelectedEntry = (unsigned) m_Entries->size() - 1;
auto currentEntry = getSelectedEntryIterator();
if (currentEntry != m_Entries->end() && m_SelectedChannel >= currentEntry->second->m_PAVolume.channels)
if (currentEntry != m_Entries->end() && m_SelectedChannel > 0 &&
m_SelectedChannel >= currentEntry->second->m_PAVolume.channels)
m_SelectedChannel = (unsigned) currentEntry->second->m_PAVolume.channels - 1;
}

Expand Down Expand Up @@ -311,7 +312,7 @@ void pamix_ui::moveSelection(int delta, bool includeChannels) {
for (int i = 0, numSteps = delta < 0 ? -delta : delta; i < numSteps; i++) {
auto entryThresh = static_cast<int>(delta < 0 ? 0 : m_Entries->size() - 1);

if (includeChannels) {
if (includeChannels && m_EntriesType != ENTRY_CARDS) {
bool isLocked = it->second->m_Lock;
int channelThresh = it->second->m_PAVolume.channels - 1;
if (delta < 0)
Expand Down

0 comments on commit aed87dc

Please sign in to comment.