Code review cleanup

pull/71/head
Nicu Reut 4 years ago
parent 078d5776dd
commit 551ca2a813

@ -137,7 +137,6 @@ func main() {
fmt.Fprintf(os.Stderr, "No source specified to load and failed to load default source: %+v\n", err) fmt.Fprintf(os.Stderr, "No source specified to load and failed to load default source: %+v\n", err)
os.Exit(1) os.Exit(1)
} }
fmt.Printf("No source specified to load, loading default source with Device ID %s\n\n", defaultSource)
sourceName = defaultSource sourceName = defaultSource
} }
for i := range sources { for i := range sources {
@ -235,7 +234,7 @@ func paConnectionWatchdog(ctx *ntcontext) {
ctx.paClient = paClient ctx.paClient = paClient
go updateNoiseSupressorLoaded(paClient, &ctx.noiseSupressorState) go updateNoiseSupressorLoaded(paClient, &ctx.noiseSupressorState)
ctx.inputList = getSourcesWithPreSelectedInput(paClient, ctx.config) ctx.inputList = getSourcesWithPreSelectedInput(ctx)
resetUI(ctx) resetUI(ctx)
@ -243,17 +242,17 @@ func paConnectionWatchdog(ctx *ntcontext) {
} }
} }
func getSourcesWithPreSelectedInput(client *pulseaudio.Client, config *config) []input { func getSourcesWithPreSelectedInput(ctx *ntcontext) []input {
inputs := getSources(client) inputs := getSources(ctx.paClient)
preselectedInputId := config.LastUsedInput preselectedInputId := ctx.config.LastUsedInput
inputExists := false inputExists := false
for _, input := range inputs { for _, input := range inputs {
inputExists = inputExists || input.ID == *preselectedInputId inputExists = inputExists || input.ID == *preselectedInputId
} }
if !inputExists { if !inputExists {
defaultSource, err := getDefaultSourceID(client) defaultSource, err := getDefaultSourceID(ctx.paClient)
if err != nil { if err != nil {
log.Printf("Failed to load default source\n") log.Printf("Failed to load default source: %+v\n", err)
} else { } else {
preselectedInputId = &defaultSource preselectedInputId = &defaultSource
} }

Loading…
Cancel
Save