fix FUCK! Well

This commit is contained in:
TonyChyi 2018-03-20 10:08:53 +08:00
parent 7bc1a238ed
commit 94094640e6
2 changed files with 10 additions and 4 deletions

View File

@ -30,6 +30,7 @@ func NewClient(name string) error {
return fmt.Errorf("Error while setting sequencer name. %d", errCode) return fmt.Errorf("Error while setting sequencer name. %d", errCode)
} }
} }
return nil
} }
// NewPort to reigister new MIDI port. // NewPort to reigister new MIDI port.
@ -40,6 +41,7 @@ func NewPort(name string) error {
if status != 0 { if status != 0 {
return fmt.Errorf("Error while createing sequencer port. %d", status) return fmt.Errorf("Error while createing sequencer port. %d", status)
} }
return nil
} }
// SendData to ALSA // SendData to ALSA
@ -51,13 +53,14 @@ func SendData(p []byte) error {
stage, errCode := resolveErrCode(status) stage, errCode := resolveErrCode(status)
switch stage { switch stage {
case 1: 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: 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: 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) { func resolveErrCode(code int) (int, int) {

View File

@ -36,7 +36,10 @@ func (midiDev *MIDIDevice) Init() error {
func (midiDev *MIDIDevice) Write(p []byte) (int, error) { func (midiDev *MIDIDevice) Write(p []byte) (int, error) {
midiDev.Signal <- 1 midiDev.Signal <- 1
alsa.SendData(p) err := alsa.SendData(p)
if err != nil {
return 0, err
}
return len(p), nil return len(p), nil
} }