From 94094640e63fc5c0e3f3c696daf112870afb4629 Mon Sep 17 00:00:00 2001 From: TonyChyi Date: Tue, 20 Mar 2018 10:08:53 +0800 Subject: [PATCH] fix FUCK! Well --- backend/alsa_wrapper/alsa_wrapper.go | 9 ++++++--- backend/midiDevice_linux.go | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/alsa_wrapper/alsa_wrapper.go b/backend/alsa_wrapper/alsa_wrapper.go index c84c20d..e4260da 100644 --- a/backend/alsa_wrapper/alsa_wrapper.go +++ b/backend/alsa_wrapper/alsa_wrapper.go @@ -30,6 +30,7 @@ func NewClient(name string) error { return fmt.Errorf("Error while setting sequencer name. %d", errCode) } } + return nil } // NewPort to reigister new MIDI port. @@ -40,6 +41,7 @@ func NewPort(name string) error { if status != 0 { return fmt.Errorf("Error while createing sequencer port. %d", status) } + return nil } // SendData to ALSA @@ -51,13 +53,14 @@ func SendData(p []byte) error { stage, errCode := resolveErrCode(status) switch stage { case 1: - return 0, fmt.Errorf("Error while creating MIDI event. %d", errCode) + return fmt.Errorf("Error while creating MIDI event. %d", errCode) case 2: - return 0, fmt.Errorf("Error while encoding MIDI event. %d", errCode) + return fmt.Errorf("Error while encoding MIDI event. %d", errCode) case 3: - return 0, fmt.Errorf("Error while sending data. %d", errCode) + return fmt.Errorf("Error while sending data. %d", errCode) } } + return nil } func resolveErrCode(code int) (int, int) { diff --git a/backend/midiDevice_linux.go b/backend/midiDevice_linux.go index 4cc9e6a..e6bc1ff 100644 --- a/backend/midiDevice_linux.go +++ b/backend/midiDevice_linux.go @@ -36,7 +36,10 @@ func (midiDev *MIDIDevice) Init() error { func (midiDev *MIDIDevice) Write(p []byte) (int, error) { midiDev.Signal <- 1 - alsa.SendData(p) + err := alsa.SendData(p) + if err != nil { + return 0, err + } return len(p), nil }