Skip to content

Commit

Permalink
Merge pull request PlayCover#82 from IsaacMarovitz/sound-fix
Browse files Browse the repository at this point in the history
Fixes SoundDeviceService, a deprecation, changes error alert title
  • Loading branch information
Depal1 authored Jul 22, 2022
2 parents 7433e6b + 95e699f commit d06f04d
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 20 deletions.
24 changes: 12 additions & 12 deletions PlayCover/Services/SoundDeviceService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// PlayCover
//

import Foundation
import SimplyCoreAudio
import SwiftUI

class SoundDeviceService {

Expand All @@ -20,18 +20,18 @@ class SoundDeviceService {
if let sampleRate = device?.nominalSampleRate {
if sampleRate == 48000.0 || sampleRate == 44100.0 { return }
}

for device in simplyCA.allOutputDevices {
if let sampleRate = device.nominalSampleRate {
if sampleRate == 48000.0 || sampleRate == 44100.0 {
device.isDefaultOutputDevice = true
return
}
DispatchQueue.main.async {
let alert = NSAlert()
alert.messageText = NSLocalizedString("soundAlert.messageText", comment: "")
alert.informativeText = NSLocalizedString("soundAlert.informativeText", comment: "")
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
alert.alertStyle = .critical
let response: NSApplication.ModalResponse = alert.runModal()
if response == NSApplication.ModalResponse.alertFirstButtonReturn {
device?.setNominalSampleRate(48000.0)
Log.shared.msg(NSLocalizedString("soundAlert.successText", comment: ""))
}
}

Log.shared.msg("No device with sample rate of 48 / 44.1 ghz found! " +
"Please lower sample rate in Audio settings or connect another output audio device." +
" Otherwise crashes are possible!")
}
}
12 changes: 9 additions & 3 deletions PlayCover/View/AppsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Foundation

import SwiftUI
import Cocoa
import AppKit

struct AppsView: View {
@Binding public var bottomPadding: CGFloat
Expand Down Expand Up @@ -270,9 +271,14 @@ struct ExportView: View {
Installer.exportForSideloadly(ipaUrl: uif.ipaUrl!, returnCompletion: { (ipa) in
DispatchQueue.main.async {
ipa?.showInFinder()
NSWorkspace.shared.open([ipa!], withAppBundleIdentifier: "com.sideloadly.sideloadly",
options: NSWorkspace.LaunchOptions.withErrorPresentation,
additionalEventParamDescriptor: nil, launchIdentifiers: nil)
let configuration = NSWorkspace.OpenConfiguration()
configuration.promptsUserIfNeeded = true
let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.sideloadly.sideloadly")
if url != nil {
NSWorkspace.shared.open([ipa!], withApplicationAt: url.unsafelyUnwrapped, configuration: configuration)
} else {
Log.shared.error("Could not find Sideloadly!")
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion PlayCover/ViewModel/Log.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Log: ObservableObject {

func error(_ err: Error) {
DispatchQueue.main.async {
self.dialog(question: NSLocalizedString("Some error happened!", comment: ""),
self.dialog(question: NSLocalizedString("An Error Occurred!", comment: ""),
text: err.localizedDescription, style: NSAlert.Style.critical)
}
}
Expand Down
3 changes: 3 additions & 0 deletions PlayCover/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@
"This .IPA is courrupted.Try to use another .ipa" = "Diese .IPA ist beschädigt.Versuch, eine andere .ipa . zu verwenden";
"You have not performed all instructions! Please, perform all instructions in 'Settings' or watch video in pinned messages." = "Du hast nicht alle Anweisungen ausgeführt! Bitte führe alle Anweisungen unter 'Einstellungen' aus oder schau Dir das Video in den angepinnten Nachrichten an..";
"Get" = "Herunterladen";
"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
3 changes: 3 additions & 0 deletions PlayCover/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,6 @@
"It is the one you use to unlock your Mac" = "It is the one you use to unlock your Mac";
"Now, restart the Mac and all is done!" = "Now, restart the Mac and all is done!";
"Important news and announcements" = "Important news and announcements";
"soundAlert.messageText" = "Incorrect Audio Settings Detected!";
"soundAlert.informativeText" = "Your current output device does not have a sample rate of 48 or 44.1 KHz! Crashes may occur. Would you like to change your current output device's sample rate to 48 KHz?";
"soundAlert.successText" = "Current output device sample rate set to 48 KHz";
4 changes: 3 additions & 1 deletion PlayCover/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@
"Screen refresh rate" = "Tasa de refresco de la pantalla";
"Mouse sensivity: %.f" = "Sensibilidad del ratón: %.f";
"Settings reseted to default!" = "¡Se han restablecido los ajustes por defecto!";
"No device with sample rate of 48 / 44.1 ghz found! Please, lower sample rate in Audio settings or connect another output audio device. Otherwise crashes possible!" = "¡No se ha encontrado ningún dispositivo con una frecuencia de muestreo de 48 / 44.1 ghz! Por favor, baje la frecuencia de muestreo en la configuración de audio o conecte otro dispositivo de salida de audio. De lo contrario, puede que se produzcan errores!";
"Copy logs" = "Copiar logs";
"Notices" = "Notificaciones";
"Having problems logging into apps?" = "¿Tienes problemas para iniciar sesión en las aplicaciones?";
"PlayCover must be inside Applications folder. Press button to move it." = "PlayCover debe estar dentro de la carpeta de aplicaciones. Pulse el botón para moverlo.";
"If you encounter any errors, restart and repeat the whole process again" = "Si encuentra algún error, reinicie y repita el proceso de nuevo";
"Please, wait current install to finish!" = "Por favor, espere a que la instalación termine!";
"You'll receive ban on this PlayCover version! Call of Duty supported on 0.9.2-0.9.4. PUBG requires higher PlayCover version. Free Fire status is not confirmed. There is one message of ban." = "Su cuenta sera banneada si utiliza esta versión de PlayCover! Call of duty funciona correctamente en las versiones 0.9.2-0.9.4. Mientas que PUBG requiere una versión más reciente. Sobre Free Fire aún no tenemos datos suficientes sin embargo hay una prueba de banneo";
"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
3 changes: 3 additions & 0 deletions PlayCover/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@
"If you encounter any errors, restart and repeat the whole process again" = "Si vous avez des erreurs, redémarrez et répétez le processus encore une fois.";
"Please, wait current install to finish!" = "Veuillez attendre que l'installation se termine!";
"You'll receive ban on this PlayCover version! Call of Duty supported on 0.9.2-0.9.4. PUBG requires higher PlayCover version. Free Fire status is not confirmed. There is one message of ban." = "Vous risquez d'être banni sur cette version de PlayCover! Call of Duty est supporté sur les versions 0.9.2-0.9.4. PUBG requiert une version plus récente. Free Fire n'est pas encore confirmé. Il y a un message de ban.";
"soundAlert.messageText" = "Paramètres Audio Incorrects Détectés!";
"soundAlert.informativeText" = "Votre sortie audio actuelle n'a pas un taux d'échantillonnage de 48 ou 44.1 KHz! Des erreurs peuvent survenir. Voulez-vous changer le taux d'échantillonnage de votre sortie audio actuelle à 48 KHz?";
"soundAlert.successText" = "Définir le taux d'échantillonnage de votre sortie audio à 48 KHz";
3 changes: 3 additions & 0 deletions PlayCover/id.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@
"Make sure you don't disallowed PlayCover to access files in Settings - Secuirity & Privacy" = "Pastikan sudah memberikan ijin akses file untuk Playcover pada Settings - Security & Privacy";
"This .IPA is courrupted.Try to use another .ipa" = ".IPA rusak. Coba gunakan .ipa lain";
"You have not performed all instructions! Please, perform all instructions in 'Settings' or watch video in pinned messages." = "Kamu belum mengikuti semua instruksi, tolong ikuti semua instruksi dengan benar pada 'Settings' atau tonton video tutorial yang kami pin";
"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
4 changes: 3 additions & 1 deletion PlayCover/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@
"To do this you need to reboot, enter into Recovery mode, open Terminal and type" = "Per fare questo hai bisogno di riavviare, entrare in Recovery mode, aprire il Terminale e scrivere";
"App is installed!" = "App installata!";
"Please, check it out in 'My Apps'" = "Per favore, controlla in 'Le mie Apps'";

"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
3 changes: 3 additions & 0 deletions PlayCover/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@
"Make sure you don't disallowed PlayCover to access files in Settings - Security & Privacy" = "PlayCoverにファイルのアクセスが許可されているか 設定ーセキュリティとプライバシーで確認してください";
"This .IPA is courrupted.Try to use another .ipa" = "この.ipaファイルは壊れています。他の.ipaファイルを使ってみてください。";
"You not performed all instructions! Please, perform all instructions in 'Settings' or watch video in pinned messages." = "マニュアルのすべてのステップが実行されていません。設定にある説明ステップをすべて実行してください。またはディスコードの固定メッセージの動画を観てください。";
"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
3 changes: 3 additions & 0 deletions PlayCover/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@
"Make sure you don't disallowed PlayCover to access files in Settings - Secuirity & Privacy" = "설정 - 보안 및 개인 정보 보호 에서 PlayCover의 파일 엑세스 권한을 막지 않았는지 확인해주세요.";
"This .IPA is courrupted.Try to use another .ipa" = "이 .ipa 파일은 손상되었습니다. 다른 .ipa 파일을 사용해 주세요.";
"You not performed all instructions! Please, perform all instructions in 'Settings' or watch video in pinned messages." = "이 시스템은 설치 가이드를 모두 수행하지 않았습니다! '설정' 탭에 있는 가이드를 보거나, 고정된 메세지의 비디오를 확인 후 모두 수행해 주세요.";
"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
3 changes: 3 additions & 0 deletions PlayCover/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@
"You have not performed all instructions! Please, perform all instructions in 'Settings' or watch video in pinned messages." = "Вы не выполнили все инструкции! Пожалуйста, выполните все инструкции в “Настройках” или посмотрите видео в закрепленных сообщениях.";
"Get" = "Скачать";
"To do this you need to reboot, enter into Recovery mode, open Terminal and type" = "Чтобы это сделать, перейдите в режим восстановления, откройте Терминал и введите";
"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
4 changes: 3 additions & 1 deletion PlayCover/vi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@
"To do this you need to reboot, enter into Recovery mode, open Terminal and type" = "Để thực hiện bước này, khởi động máy Mac của bạn vào chế độ Phục hồi, mở Terminal và gõ";
"App is installed!" = "Ứng dụng đã được cài đặt!";
"Please, check it out in 'My Apps'" = "Vui lòng kiểm tra tại 'Ứng dụng của tôi'";

"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";
4 changes: 3 additions & 1 deletion PlayCover/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@
"Reset settings and keymapping" = "恢复默认设置";
"Settings reseted to default!" = "已重置设置到默认值!";
"Ok" = "OK";
"No device with sample rate of 48 / 44.1 ghz found! Please, lower sample rate in Audio settings or connect another output audio device. Otherwise crashes possible!" = "No device with sample rate of 48 / 44.1 ghz found! Please, lower sample rate in Audio settings or connect another output audio device. Otherwise crashes possible!";
"Copy logs" = "拷贝日志";
"Notices" = "注意事项";
"PlayCover must be inside Applications folder. Press button to move it." = "PlayCover 必须被放入“应用程序”文件夹中。按下按钮以移动。";
"Please, wait current install to finish!" = "请等待当前应用安装完成!";
"You'll receive ban on this PlayCover version! Call of Duty supported on 0.9.2-0.9.4. PUBG requires higher PlayCover version. Free Fire status is not confirmed. There is one message of ban." = "You'll receive ban on this PlayCover version! Call of Duty supported on 0.9.2-0.9.4. PUBG requires higher PlayCover version. Free Fire status is not confirmed. There is one message of ban.";
"soundAlert.messageText" = "";
"soundAlert.informativeText" = "";
"soundAlert.successText" = "";

0 comments on commit d06f04d

Please sign in to comment.