mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-18 09:24: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"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
@ -66,6 +67,13 @@ func WriteWavFile(filename string, data []byte, sampleRate int, channels int, bi
|
||||||
}
|
}
|
||||||
defer f.Close()
|
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)
|
err = writeWavHeader(f, data, sampleRate, channels, bitsPerSample)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue