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
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"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
|
* returns a bool indicating whether the program should keep running and an
|
||||||
* error, if any.
|
* 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() {
|
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
|
||||||
keepRunning := handleEvent(event, m)
|
keepRunning := handleEvent(event, m)
|
||||||
if !keepRunning {
|
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 {
|
if err == io.ErrUnexpectedEOF {
|
||||||
return false, nil
|
return false, nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
@ -159,11 +158,9 @@ func milkbucket(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
m.loadPreset(false)
|
m.loadPreset(false)
|
||||||
|
|
||||||
r := bufio.NewReader(os.Stdin)
|
|
||||||
|
|
||||||
running := true
|
running := true
|
||||||
for running {
|
for running {
|
||||||
running, err = update(r, m)
|
running, err = update(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue