Chore: linter complaints
This commit is contained in:
@@ -49,20 +49,24 @@ func (w *WhisperBinary) StartRecording() error {
|
||||
return errors.New("recording is already in progress")
|
||||
}
|
||||
// Temporarily redirect stderr to suppress ALSA warnings during PortAudio init
|
||||
origStderr, err := syscall.Dup(syscall.Stderr)
|
||||
origStderr, errDup := syscall.Dup(syscall.Stderr)
|
||||
if errDup != nil {
|
||||
return fmt.Errorf("failed to dup stderr: %w", errDup)
|
||||
}
|
||||
nullFD, err := syscall.Open("/dev/null", syscall.O_WRONLY, 0)
|
||||
if err != nil {
|
||||
_ = syscall.Close(origStderr) // Close the dup'd fd if open fails
|
||||
return fmt.Errorf("failed to open /dev/null: %w", err)
|
||||
}
|
||||
// redirect stderr
|
||||
syscall.Dup2(nullFD, syscall.Stderr)
|
||||
_ = syscall.Dup2(nullFD, syscall.Stderr)
|
||||
// Initialize PortAudio (this is where ALSA warnings occur)
|
||||
portaudioErr := portaudio.Initialize()
|
||||
defer func() {
|
||||
// Restore stderr
|
||||
syscall.Dup2(origStderr, syscall.Stderr)
|
||||
syscall.Close(origStderr)
|
||||
syscall.Close(nullFD)
|
||||
_ = syscall.Dup2(origStderr, syscall.Stderr)
|
||||
_ = syscall.Close(origStderr)
|
||||
_ = syscall.Close(nullFD)
|
||||
}()
|
||||
if portaudioErr != nil {
|
||||
return fmt.Errorf("portaudio init failed: %w", portaudioErr)
|
||||
|
||||
Reference in New Issue
Block a user