diff --git a/Scripts/Python/xIniAudio.py b/Scripts/Python/xIniAudio.py index e93091ea22..af0198819d 100644 --- a/Scripts/Python/xIniAudio.py +++ b/Scripts/Python/xIniAudio.py @@ -323,9 +323,9 @@ def SetAudioMode(init, device, eax): PtDebugPrint(device) if entryDev: - entryDev.setValue(0, "\"" + device + "\"") + entryDev.setValue(0, "\"" + device.encode("utf-8") + "\"") else: - gIniFile.addEntry("Audio.SetDeviceName \"" + device + "\"") + gIniFile.addEntry("Audio.SetDeviceName \"" + device.encode("utf-8") + "\"") if eax: val = kBeTrue diff --git a/Scripts/Python/xOptionsMenu.py b/Scripts/Python/xOptionsMenu.py index a0aa1206a1..ef690034b6 100644 --- a/Scripts/Python/xOptionsMenu.py +++ b/Scripts/Python/xOptionsMenu.py @@ -89,6 +89,7 @@ kDemoMovieName = "avi/UruPreview.webm" gPreviewStarted = 0 prevAudioDeviceName = None +gAudioDevices = () # ===================================== # Aspect Ratios @@ -1244,7 +1245,7 @@ def OnGUINotify(self,id,control,event): if self.restartAudio: audio = ptAudioControl() audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeID)) - audModeNum = audio.getNumAudioDevices() - 1 + audModeNum = len(gAudioDevices) - 1 curSelection = round(audioField.getValue() * audModeNum) intCurSelection = int(curSelection) @@ -1252,7 +1253,7 @@ def OnGUINotify(self,id,control,event): EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03)) audio.useEAXAcceleration(EAXcheckbox.isChecked()) - audio.setDeviceName(audio.getAudioDeviceName(intCurSelection), 1) + audio.setPlaybackDevice(gAudioDevices[intCurSelection], 1) self.WriteAudioControls() elif event == kAction or event == kValueChanged: @@ -1310,23 +1311,21 @@ def OnGUINotify(self,id,control,event): self.restartAudio = 1 audio = ptAudioControl() #~ PtDebugPrint("Number of Audio Devices: %d" % (audio.getNumAudioDevices())) - audModeNum = audio.getNumAudioDevices() - 1 + audModeNum = len(gAudioDevices) - 1 curSelection = round(control.getValue() * audModeNum) intCurSelection = int(curSelection) control.setValue(curSelection/audModeNum) - audioDeviceName = audio.getAudioDeviceName(intCurSelection) + audioDeviceName = gAudioDevices[intCurSelection] audioModeCtrlTextBox = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeTextID)) - curText = audioModeCtrlTextBox.getString() - if curText != audio.getAudioDeviceName(intCurSelection): - audioModeCtrlTextBox.setString(audioDeviceName) + audioModeCtrlTextBox.setStringW(audio.getFriendlyDeviceName(audioDeviceName)) if audioDeviceName != prevAudioDeviceName: #Only update the EAX checkbox when the mouse has been let up... PtDebugPrint("Audio Device Name changed!") prevAudioDeviceName = audioDeviceName EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03)) - if not audio.supportsEAX(audioDeviceName): + if not audio.isEAXSupported(): PtDebugPrint("Disabling EAX checkbox") #Disable EAX checkbox EAXcheckbox.disable() @@ -1670,7 +1669,7 @@ def WriteAudioControls(self): EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03)) - xIniAudio.SetAudioMode( True, audio.getDeviceName(), EAXcheckbox.isChecked() ) + xIniAudio.SetAudioMode( True, audio.getPlaybackDevice(), EAXcheckbox.isChecked() ) #xIniAudio.SetAudioMode( audio.isEnabled(), audio.getDeviceName(), EAXcheckbox.isChecked() ) #xIniAudio.SetAudioMode( audio.isEnabled(), audio.getDeviceName(), audio.isUsingEAXAcceleration() ) #xIniAudio.SetMicLevel( audio.getMicLevel() ) @@ -1679,11 +1678,14 @@ def WriteAudioControls(self): xIniAudio.WriteIni() def InitAudioControlsGUI(self): + global gAudioDevices global prevAudioDeviceName xIniAudio.ReadIni() audio = ptAudioControl() + gAudioDevices = audio.getPlaybackDevices() + audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioNumberOfSoundsSliderTag)) audioField.setValue( audio.getPriorityCutoff() ) @@ -1714,12 +1716,12 @@ def InitAudioControlsGUI(self): respDisableItems.run(self.key, state="enableEAX") audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeID)) - numAudioDevices = audio.getNumAudioDevices() - 1.0 + numAudioDevices = len(gAudioDevices) - 1.0 if numAudioDevices > 0: - for num in range(audio.getNumAudioDevices()): - if audio.getAudioDeviceName(num) == audio.getDeviceName(): - if not audio.supportsEAX(audio.getDeviceName()): + for num, device in enumerate(gAudioDevices): + if gAudioDevices[num] == audio.getPlaybackDevice(): + if not audio.isEAXSupported(): EAXcheckbox.disable() respDisableItems.run(self.key, state="disableEAX") EAXcheckbox.setChecked(False) @@ -1727,8 +1729,8 @@ def InitAudioControlsGUI(self): audioField.setValue(num/numAudioDevices) audioModeCtrlTextBox = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeTextID)) - audioDeviceName = prevAudioDeviceName = audio.getAudioDeviceName(num) - audioModeCtrlTextBox.setString(audioDeviceName) + audioDeviceName = prevAudioDeviceName = audio.getPlaybackDevice() + audioModeCtrlTextBox.setStringW(audio.getFriendlyDeviceName(device)) else: EAXcheckbox.disable() respDisableItems.run(self.key, state="disableEAX")