Skip to content

Commit

Permalink
Remove lines to rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
AXDOOMER committed Jul 26, 2022
1 parent ebf595b commit e92032e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 80 deletions.
19 changes: 0 additions & 19 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@ import (
)

type CLIOpts struct {
doLog bool
setcap bool
sinkName string
unload bool
loadInput bool
loadOutput bool
threshold int
list bool
checkUpdate bool
}

func parseCLIOpts() CLIOpts {
var opt CLIOpts
flag.BoolVar(&opt.doLog, "log", false, "Print debugging output to stdout")
flag.BoolVar(&opt.setcap, "setcap", false, "for internal use only")
flag.StringVar(&opt.sinkName, "s", "", "Use the specified source/sink device ID")
flag.BoolVar(&opt.loadInput, "i", false, "Load supressor for input. If no source device ID is specified the default pulse audio source is used.")
Expand Down Expand Up @@ -58,13 +48,6 @@ func doCLI(opt CLIOpts, config *config, librnnoise string) {
cleanupExit(librnnoise, 0)
}

if opt.setcap {
err := makeBinarySetcapped()
if err != nil {
cleanupExit(librnnoise, 1)
}
cleanupExit(librnnoise, 0)
}

paClient, err := pulseaudio.NewClient()
if err != nil {
Expand Down Expand Up @@ -176,6 +159,4 @@ func doCLI(opt CLIOpts, config *config, librnnoise string) {
}

func cleanupExit(librnnoise string, exitCode int) {
removeLib(librnnoise)
os.Exit(exitCode)
}
5 changes: 0 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ func main() {

opt := parseCLIOpts()

if opt.doLog {
log.SetOutput(os.Stdout)
} else {
log.SetOutput(ioutil.Discard)
}
log.Printf("Application starting. Version: %s (%s)\n", version, distribution)
log.Printf("CAP_SYS_RESOURCE: %t\n", hasCapSysResource(getCurrentCaps()))

Expand Down
8 changes: 0 additions & 8 deletions module.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ func loadSupressor(ctx *ntcontext, inp *device, out *device) error {
}

func loadModule(ctx *ntcontext, module, args string) (uint32, error) {
idx, err := ctx.paClient.LoadModule(module, args)

//14 = module initialisation failed
if paErr, ok := err.(*pulseaudio.Error); ok && paErr.Code == 14 {
resetUI(ctx)
ctx.views.Push(makeErrorView(ctx, fmt.Sprintf("Could not load module '%s'. This is likely a problem with your system or distribution.", module)))
}
return idx, err
}

func loadPipeWireInput(ctx *ntcontext, inp *device) error {
Expand Down
48 changes: 0 additions & 48 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ var lightBlue = color.RGBA{173, 216, 230, 255}
const notice = "NoiseTorch Next Gen (stylized NoiseTorch-ng) is a continuation of the NoiseTorch\nproject after it was abandoned by its original author. Please do not confuse\nboth programs. You may convey modified versions of this program under its name."

func updatefn(ctx *ntcontext, w *nucular.Window) {
currView := ctx.views.Peek()
currView(ctx, w)
}

func mainView(ctx *ntcontext, w *nucular.Window) {

Expand Down Expand Up @@ -435,66 +432,21 @@ func capabilitiesView(ctx *ntcontext, w *nucular.Window) {

func makeErrorView(ctx *ntcontext, errorMsg string) ViewFunc {
return func(ctx *ntcontext, w *nucular.Window) {
w.Row(15).Dynamic(1)
w.Label("Error", "CB")
w.Row(15).Dynamic(1)
w.Label(errorMsg, "CB")
w.Row(40).Dynamic(1)
w.Row(25).Dynamic(1)
if w.ButtonText("OK") {
ctx.views.Pop()
return
}
}
}

func makeFatalErrorView(ctx *ntcontext, errorMsg string) ViewFunc {
return func(ctx *ntcontext, w *nucular.Window) {
w.Row(15).Dynamic(1)
w.Label("Fatal Error", "CB")
w.Row(15).Dynamic(1)
w.Label(errorMsg, "CB")
w.Row(40).Dynamic(1)
w.Row(25).Dynamic(1)
if w.ButtonText("Quit") {
os.Exit(1)
return
}
}
}

func makeConfirmView(ctx *ntcontext, title, text, confirmText, denyText string, confirmfunc, denyfunc func()) ViewFunc {
return func(ctx *ntcontext, w *nucular.Window) {
w.Row(15).Dynamic(1)
w.Label(title, "CB")
w.Row(15).Dynamic(1)
w.Label(text, "CB")
w.Row(40).Dynamic(1)
w.Row(25).Dynamic(2)
if w.ButtonText(denyText) {
ctx.views.Pop()
go denyfunc()
return
}
if w.ButtonText(confirmText) {
ctx.views.Pop()
go confirmfunc()
return
}
}
}

func resetUI(ctx *ntcontext) {
ctx.views = NewViewStack()
ctx.views.Push(mainView)

if !ctx.haveCapabilities {
ctx.views.Push(capabilitiesView)
}

if ctx.serverInfo.outdatedPipeWire {
ctx.views.Push(makeFatalErrorView(ctx,
fmt.Sprintf("Your PipeWire version is too old. Detected %d.%d.%d. Require at least 0.3.28.",
ctx.serverInfo.major, ctx.serverInfo.minor, ctx.serverInfo.patch)))
}
}

0 comments on commit e92032e

Please sign in to comment.