remove bufio
This commit is contained in:
parent
6f5f8b1818
commit
afb198052e
11
cmd/root.go
11
cmd/root.go
|
@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
|
@ -110,7 +109,7 @@ func handleEvent(event sdl.Event, m *milkDropWindow) bool {
|
|||
* returns a bool indicating whether the program should keep running and an
|
||||
* error, if any.
|
||||
*/
|
||||
func update(r *bufio.Reader, m *milkDropWindow) (bool, error) {
|
||||
func update(m *milkDropWindow) (bool, error) {
|
||||
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
|
||||
keepRunning := handleEvent(event, m)
|
||||
if !keepRunning {
|
||||
|
@ -118,9 +117,9 @@ func update(r *bufio.Reader, m *milkDropWindow) (bool, error) {
|
|||
}
|
||||
}
|
||||
|
||||
audioData := make([]int16, r.Size()/2)
|
||||
audioData := make([]int16, 2048)
|
||||
|
||||
err := binary.Read(r, binary.LittleEndian, audioData)
|
||||
err := binary.Read(os.Stdin, binary.LittleEndian, audioData)
|
||||
if err == io.ErrUnexpectedEOF {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
|
@ -159,11 +158,9 @@ func milkbucket(cmd *cobra.Command, args []string) {
|
|||
|
||||
m.loadPreset(false)
|
||||
|
||||
r := bufio.NewReader(os.Stdin)
|
||||
|
||||
running := true
|
||||
for running {
|
||||
running, err = update(r, m)
|
||||
running, err = update(m)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue