Update CI script
This commit is contained in:
parent
c5a38c0fd6
commit
37e26dd841
4 changed files with 40 additions and 14 deletions
|
@ -1,9 +1,35 @@
|
|||
stages:
|
||||
- test
|
||||
image: golang:latest
|
||||
|
||||
test:
|
||||
image: golang:latest
|
||||
stage: test
|
||||
stages:
|
||||
- validate
|
||||
- build
|
||||
|
||||
fmt:
|
||||
stage: validate
|
||||
script:
|
||||
- gofmt -l -s -e .
|
||||
- exit $(gofmt -l -s -e . | wc -l)
|
||||
|
||||
lint:
|
||||
stage: validate
|
||||
script:
|
||||
- go get -u golang.org/x/lint/golint
|
||||
- golint -set_exit_status
|
||||
|
||||
vet:
|
||||
stage: validate
|
||||
script:
|
||||
- apt-get update && apt-get install -y libasound2-dev
|
||||
- go test -v ./...
|
||||
- go vet -composites=false ./...
|
||||
|
||||
test:
|
||||
stage: validate
|
||||
script:
|
||||
- apt-get update && apt-get install -y libasound2-dev
|
||||
- go test -race -v ./...
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- apt-get update && apt-get install -y libasound2-dev
|
||||
- go build -race
|
||||
|
|
2
audio.go
2
audio.go
|
@ -151,7 +151,7 @@ func play(audioFile *audioFile) {
|
|||
streamFd = os.NewFile(uintptr(streamFdInt), "out")
|
||||
|
||||
go func() {
|
||||
rateLimitedStreamer := NewRateLimitedStreamer(ctrl, bufferSize/64)
|
||||
rateLimitedStreamer := newRateLimitedStreamer(ctrl, bufferSize/64)
|
||||
for {
|
||||
_ = wav.Encode(streamFd, rateLimitedStreamer, playingFormat)
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
|
|
|
@ -110,9 +110,9 @@ func listToggleHidden() {
|
|||
showHiddenFolders = !showHiddenFolders
|
||||
|
||||
if showHiddenFolders {
|
||||
statusText = "Hidden folders: show"
|
||||
statusText = "Hidden folders: shown"
|
||||
} else {
|
||||
statusText = "Hidden folders: hide"
|
||||
statusText = "Hidden folders: hidden"
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(3 * time.Second)
|
||||
|
|
10
streamer.go
10
streamer.go
|
@ -6,18 +6,18 @@ import (
|
|||
"github.com/faiface/beep"
|
||||
)
|
||||
|
||||
type RateLimitedStreamer struct {
|
||||
type rateLimitedStreamer struct {
|
||||
streamer beep.Streamer
|
||||
rate time.Duration
|
||||
last time.Time
|
||||
}
|
||||
|
||||
func NewRateLimitedStreamer(streamer beep.Streamer, rate time.Duration) *RateLimitedStreamer {
|
||||
s := RateLimitedStreamer{streamer: streamer, rate: rate}
|
||||
func newRateLimitedStreamer(streamer beep.Streamer, rate time.Duration) *rateLimitedStreamer {
|
||||
s := rateLimitedStreamer{streamer: streamer, rate: rate}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s *RateLimitedStreamer) Stream(samples [][2]float64) (n int, ok bool) {
|
||||
func (s *rateLimitedStreamer) Stream(samples [][2]float64) (n int, ok bool) {
|
||||
if time.Since(s.last) < s.rate {
|
||||
time.Sleep(time.Until(s.last.Add(s.rate)))
|
||||
}
|
||||
|
@ -26,6 +26,6 @@ func (s *RateLimitedStreamer) Stream(samples [][2]float64) (n int, ok bool) {
|
|||
return s.streamer.Stream(samples)
|
||||
}
|
||||
|
||||
func (s *RateLimitedStreamer) Err() error {
|
||||
func (s *rateLimitedStreamer) Err() error {
|
||||
return s.streamer.Err()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue