Skip to content

Commit f0cf4fa

Browse files
committed
Merge branch 'albayan_beta' of https://github.com/tecwindow/albayan into albayan_beta
2 parents 10febbd + 9a8136a commit f0cf4fa

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

ui/dialogs/settings_dialog.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,6 @@ def set_current_settings(self):
427427
self.speech_checkbox.setChecked(Config.audio.speak_actions_enabled)
428428
self.volume.setValue(Config.audio.volume_level)
429429
self.athkar_volume.setValue(Config.audio.athkar_volume_level)
430-
self.ayah_device_combo.setCurrentIndex(Config.audio.ayah_device)
431-
self.surah_device_combo.setCurrentIndex(Config.audio.surah_device)
432-
self.volume_device_combo.setCurrentIndex(Config.audio.volume_device)
433-
self.athkar_device_combo.setCurrentIndex(Config.audio.athkar_device)
434430
self.ayah_volume.setValue(Config.audio.ayah_volume_level)
435431
self.surah_volume.setValue(Config.audio.surah_volume_level)
436432
self.run_in_background_checkbox.setChecked(Config.general.run_in_background_enabled)
@@ -450,6 +446,10 @@ def set_current_settings(self):
450446
(self.action_combo, Config.listening.action_after_listening),
451447
(self.font_type_combo, QuranFontType.from_int(Config.reading.font_type)),
452448
(self.marks_type_combo, MarksType.from_int(Config.reading.marks_type)),
449+
(self.ayah_device_combo, Config.audio.ayah_device),
450+
(self.surah_device_combo, Config.audio.surah_device),
451+
( self.volume_device_combo, Config.audio.volume_device),
452+
(self.athkar_device_combo, Config.audio.athkar_device)
453453
]
454454

455455
for combo, value in combo_config:

utils/audio_player/bass_init.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class BassFlag(IntFlag):
1515
MUSIC_NOSAMPLE = 0x100000
1616
STREAM_STATUS = 0x800000
1717
STREAM_RESTRATE = 0x80000
18+
BASS_DEVICE_DEFAULT = 0x2
19+
BASS_DEVICE_ENABLED = 0x1
20+
1821

1922
class BASS_DEVICEINFO(ctypes.Structure):
2023
_fields_ = [
@@ -23,13 +26,21 @@ class BASS_DEVICEINFO(ctypes.Structure):
2326
("flags", c_uint),
2427
]
2528

26-
@dataclass(frozen=True)
29+
@dataclass(eq=True, frozen=True)
2730
class SoundCard:
2831
index: int
2932
name: str
3033
driver: str
3134
flag: int
3235

36+
@property
37+
def is_default(self) -> bool:
38+
return bool(self.flag & BassFlag.BASS_DEVICE_DEFAULT)
39+
40+
@property
41+
def is_enabled(self) -> bool:
42+
return bool(self.flag & BassFlag.BASS_DEVICE_ENABLED)
43+
3344

3445
class BassInitializer:
3546
def __init__(self, bass_library_path: str = "bass.dll"):
@@ -90,20 +101,26 @@ def get_sound_cards(self) -> List[SoundCard]:
90101
"""Retrieve a list of available sound cards."""
91102
logger.debug("Retrieving available sound cards.")
92103
devices = []
93-
index = 0
104+
index = 1
94105

95106
while True:
96107
info = BASS_DEVICEINFO()
97108
if not self.bass.BASS_GetDeviceInfo(index, ctypes.byref(info)):
98109
break
110+
111+
name=info.name.decode() if info.name else "Unknown"
112+
if name.strip().lower() == "default":
113+
name = "الافتراضي"
114+
99115
devices.append(SoundCard(
100116
index=index,
101-
name=info.name.decode() if info.name else "Unknown",
117+
name=name,
102118
driver=info.driver.decode() if info.driver else "Unknown",
103119
flag=info.flags
104120
))
105121
logger.debug(f"Found sound card: {devices[-1]}")
106122
index += 1
123+
107124
logger.debug(f"Found {len(devices)} sound cards.")
108125
return devices
109126

0 commit comments

Comments
 (0)