Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for broken DSP volume control #49

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions hifiberrydsp/alsa/alsasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def set_volume_register(self, volume_register):
def set_alsa_control(self, alsa_control):
from alsaaudio import Mixer
try:
self.mixer = Mixer(alsa_control)
self.mixer = self.get_dsp_mixer(alsa_control)
logging.debug("using existing ALSA control %s", alsa_control)
except:
try:
Expand Down Expand Up @@ -147,7 +147,7 @@ def update_dsp(self, value):

def read_alsa_data(self):
from alsaaudio import Mixer
volumes = Mixer(self.mixername).getvolume()
volumes = self.get_dsp_mixer(self.mixername).getvolume()
channels = 0
vol = 0
for i in range(len(volumes)):
Expand Down Expand Up @@ -193,6 +193,21 @@ def read_dsp_data(self):
else:
return False

def get_dsp_mixer(self, mixername):
import alsaaudio
find_card = True
i=0
while(find_card):
try:
mixers = alsaaudio.mixers(cardindex=i)
if [match for match in mixers if mixername in match]:
hw_dev = "hw:{0}".format(str(i))
return alsaaudio.Mixer(mixername,device=hw_dev)
except:
find_card = False
i+=1
return None

def check_sync(self):
alsa_changed = self.read_alsa_data()
dsp_changed = self.read_dsp_data()
Expand Down