remove bufio

This commit is contained in:
filifa 2024-09-05 23:16:14 -05:00
parent 6f5f8b1818
commit afb198052e
1 changed files with 4 additions and 7 deletions

View File

@ -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)
}