mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-17 08:54:19 +00:00
Exit with an error if any parameter is <= 0
This commit is contained in:
parent
c4768d3c76
commit
ac370f31ce
1 changed files with 8 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
|
@ -66,6 +67,13 @@ func WriteWavFile(filename string, data []byte, sampleRate int, channels int, bi
|
|||
}
|
||||
defer f.Close()
|
||||
|
||||
if sampleRate <= 0 || channels <= 0 || bitsPerSample <= 0 {
|
||||
return fmt.Errorf(
|
||||
"values must be greater than zero (sampleRate: %d, channels: %d, bitsPerSample: %d)",
|
||||
sampleRate, channels, bitsPerSample,
|
||||
)
|
||||
}
|
||||
|
||||
err = writeWavHeader(f, data, sampleRate, channels, bitsPerSample)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue