diff --git a/cmd/audio-player/looper/main.go b/cmd/audio-player/looper/main.go index da48434c..1a5043d8 100644 --- a/cmd/audio-player/looper/main.go +++ b/cmd/audio-player/looper/main.go @@ -69,6 +69,7 @@ func main() { // Infinite loop that outputs audio and gathers debug information. var numPlays int + var fatal bool for { numPlays++ log.Log(logger.Debug, "playing audio", "play number", numPlays) @@ -91,7 +92,8 @@ func main() { err = cmd.Start() if err != nil { - log.Log(logger.Fatal, "cmd.Start() for 'play' failed", "error", err.Error()) + log.Log(logger.Error, "cmd.Start() failed", "error", err.Error()) + fatal = true } var wg sync.WaitGroup @@ -107,13 +109,19 @@ func main() { err = cmd.Wait() if err != nil { - log.Log(logger.Fatal, "cmd.Run() for 'play' failed", "error", err.Error()) + log.Log(logger.Error, "cmd.Run() failed", "error", err.Error()) + fatal = true } if errStdout != nil || errStderr != nil { - log.Log(logger.Fatal, "failed to capture stdout or stderr") + log.Log(logger.Error, "failed to capture stdout or stderr") + fatal = true } outStr, errStr := string(stdoutBuf.Bytes()), string(stderrBuf.Bytes()) log.Log(logger.Debug, "stdout received", "stdout", outStr) log.Log(logger.Debug, "stderr received", "stderr", errStr) + + if fatal == true { + log.Log(logger.Fatal, "a fatal error has occured while trying to play (see above)") + } } } diff --git a/cmd/audio-player/looper/rc.local b/cmd/audio-player/looper/rc.local index 962b0166..e08fc6cf 100644 --- a/cmd/audio-player/looper/rc.local +++ b/cmd/audio-player/looper/rc.local @@ -10,6 +10,6 @@ set -x # tell sh to display commands before execution PLAYERPATH=/home/pi/go/src/bitbucket.org/ausocean/av/cmd/audio-player/looper cd $PLAYERPATH -./looper & +sudo ./looper -path=/home/pi/example.mp3 & -exit 0 \ No newline at end of file +exit 0