Use exp/slice Remove, bump Kirika, cleanup go inspection
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f8eb6de4c1
commit
68e7cfca07
3
go.mod
3
go.mod
|
@ -3,9 +3,10 @@ module git.gammaspectra.live/S.O.N.G/MeteorLight
|
|||
go 1.19
|
||||
|
||||
require (
|
||||
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220915065938-f487b8f0b04a
|
||||
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20221003095030-2222e280fc82
|
||||
github.com/BurntSushi/toml v1.2.0
|
||||
github.com/dhowden/tag v0.0.0-20220618230019-adf36e896086
|
||||
golang.org/x/exp v0.0.0-20221002003631-540bb7301a08
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
6
go.sum
6
go.sum
|
@ -1,5 +1,5 @@
|
|||
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220915065938-f487b8f0b04a h1:kYlTnwESq8w0FbyXgLnKNI9/iJvi2C2g7ZYv/Bh/v8c=
|
||||
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220915065938-f487b8f0b04a/go.mod h1:y3dAETc57qpC0HbqmNzke7GOg4/IpPjx3PwYU87Zkjk=
|
||||
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20221003095030-2222e280fc82 h1:cqFfhiY0t+qCfGXgjyMTd0neZKPhYXBzla+egdLEM3Q=
|
||||
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20221003095030-2222e280fc82/go.mod h1:4fg7Jk1vISqJViN0hKTlqmtf46/rzWZSFuPGH+gI/Nw=
|
||||
git.gammaspectra.live/S.O.N.G/flacgo v0.0.0-20220726151057-28f458bc5391 h1:us3yKKsnMe0FZVHRSFZCw113ddiNrZgKf5M5PNr3SQ4=
|
||||
git.gammaspectra.live/S.O.N.G/flacgo v0.0.0-20220726151057-28f458bc5391/go.mod h1:ZVHB/7Vrs9xxK1j98+SJ5TRYBc7Q9dIUaNJHEmysZcI=
|
||||
git.gammaspectra.live/S.O.N.G/go-alac v0.0.0-20220421115623-d0b3bfe57e0f h1:CxN7zlk5FdAieyRKQSbwBGBsvQ2cDF8JVCODZpzcRkA=
|
||||
|
@ -61,6 +61,8 @@ github.com/youpy/go-wav v0.3.2 h1:NLM8L/7yZ0Bntadw/0h95OyUsen+DQIVf9gay+SUsMU=
|
|||
github.com/zaf/g711 v0.0.0-20220109202201-cf0017bf0359 h1:P9yeMx2iNJxJqXEwLtMjSwWcD2a0AlFmFByeosMZhLM=
|
||||
github.com/zaf/g711 v0.0.0-20220109202201-cf0017bf0359/go.mod h1:ySLGJD8AQluMQuu5JDvfJrwsBra+8iX1jFsKS8KfB2I=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20221002003631-540bb7301a08 h1:LtBIgSqNhkuC9gA3BFjGy5obHQT1lnmNsMDFSqWzQ5w=
|
||||
golang.org/x/exp v0.0.0-20221002003631-540bb7301a08/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
|
||||
golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
|
|
|
@ -30,9 +30,9 @@ func NewListener(info listener.Information, writer listener.WriterFunc, samplesT
|
|||
|
||||
headerBytes := new(bytes.Buffer)
|
||||
|
||||
binary.Write(headerBytes, binary.LittleEndian, int64(channels))
|
||||
binary.Write(headerBytes, binary.LittleEndian, int64(sampleRate))
|
||||
binary.Write(headerBytes, binary.LittleEndian, int32(len(mimeType)))
|
||||
_ = binary.Write(headerBytes, binary.LittleEndian, int64(channels))
|
||||
_ = binary.Write(headerBytes, binary.LittleEndian, int64(sampleRate))
|
||||
_ = binary.Write(headerBytes, binary.LittleEndian, int32(len(mimeType)))
|
||||
headerBytes.Write([]byte(mimeType))
|
||||
|
||||
return &Listener{
|
||||
|
@ -147,7 +147,7 @@ func (l *Listener) Write(packet packetizer.Packet) error {
|
|||
}
|
||||
|
||||
func (l *Listener) Close() {
|
||||
l.writer(nil)
|
||||
_ = l.writer(nil)
|
||||
close(l.waiter)
|
||||
}
|
||||
|
||||
|
|
|
@ -151,6 +151,6 @@ func (l *Listener) Write(packet packetizer.Packet) error {
|
|||
}
|
||||
|
||||
func (l *Listener) Close() {
|
||||
l.writer(nil)
|
||||
_ = l.writer(nil)
|
||||
close(l.waiter)
|
||||
}
|
||||
|
|
|
@ -85,6 +85,6 @@ func (l *Listener) Write(packet packetizer.Packet) error {
|
|||
}
|
||||
|
||||
func (l *Listener) Close() {
|
||||
l.writer(nil)
|
||||
_ = l.writer(nil)
|
||||
close(l.waiter)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"git.gammaspectra.live/S.O.N.G/MeteorLight/queue/track"
|
||||
"git.gammaspectra.live/S.O.N.G/MeteorLight/stream"
|
||||
"git.gammaspectra.live/S.O.N.G/MeteorLight/util"
|
||||
"golang.org/x/exp/slices"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -179,8 +180,7 @@ func (q *Queue) GetQueue() (result []*track.Entry) {
|
|||
defer q.mutex.RUnlock()
|
||||
|
||||
if len(q.queue) > 1 {
|
||||
result = make([]*track.Entry, len(q.queue)-1)
|
||||
copy(result, q.queue[1:])
|
||||
result = slices.Clone(q.queue[1:])
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -247,7 +247,7 @@ func (q *Queue) Remove(identifier queue.Identifier) bool {
|
|||
|
||||
for i, e := range q.queue {
|
||||
if e.Identifier == identifier {
|
||||
q.queue = append(q.queue[:i], q.queue[i+1:]...)
|
||||
q.queue = slices.Delete(q.queue, i, i+1)
|
||||
entry = e
|
||||
return
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ func (q *Queue) HandleRadioRequest(writer http.ResponseWriter, request *http.Req
|
|||
jsonBytes, _ := json.MarshalIndent(mounts, "", " ")
|
||||
|
||||
writer.WriteHeader(http.StatusOK)
|
||||
writer.Write(jsonBytes)
|
||||
_, _ = writer.Write(jsonBytes)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ func (q *Queue) HandleRadioRequest(writer http.ResponseWriter, request *http.Req
|
|||
writer.Header().Set("Content-Range", fmt.Sprintf("bytes 0-1/%d", safariLargeFileValue)) //64 TiB max fake size
|
||||
writer.Header().Set("Content-Length", "2")
|
||||
writer.WriteHeader(http.StatusPartialContent)
|
||||
writer.Write([]byte{'f', 'L'})
|
||||
_, _ = writer.Write([]byte{'f', 'L'})
|
||||
return
|
||||
} else if rangeHeader == fmt.Sprintf("bytes=0-%d", safariLargeFileValue-1) {
|
||||
//second request, serve status 200 to keep retries to a minimum
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"git.gammaspectra.live/S.O.N.G/MeteorLight/config"
|
||||
"git.gammaspectra.live/S.O.N.G/MeteorLight/listener"
|
||||
"git.gammaspectra.live/S.O.N.G/MeteorLight/queue/metadata"
|
||||
"golang.org/x/exp/slices"
|
||||
"io"
|
||||
"log"
|
||||
"sync"
|
||||
|
@ -191,7 +192,7 @@ func NewStreamMount(source audio.Source, config *config.StreamConfig) *Mount {
|
|||
func (m *Mount) removeDiscard(sampleNumber int64) {
|
||||
for i, p := range m.keepBuffer {
|
||||
if p.KeepMode() == packetizer.Discard && p.GetEndSampleNumber() <= sampleNumber {
|
||||
m.keepBuffer = append(m.keepBuffer[:i], m.keepBuffer[i+1:]...)
|
||||
m.keepBuffer = slices.Delete(m.keepBuffer, i, i+1)
|
||||
m.removeDiscard(sampleNumber)
|
||||
break
|
||||
} else if p.GetEndSampleNumber() > sampleNumber {
|
||||
|
@ -204,7 +205,7 @@ func (m *Mount) removeDiscard(sampleNumber int64) {
|
|||
func (m *Mount) removeKeepLast(category int64) {
|
||||
for i, p := range m.keepBuffer {
|
||||
if p.Category() == category && p.KeepMode() == packetizer.KeepLast {
|
||||
m.keepBuffer = append(m.keepBuffer[:i], m.keepBuffer[i+1:]...)
|
||||
m.keepBuffer = slices.Delete(m.keepBuffer, i, i+1)
|
||||
m.removeKeepLast(category)
|
||||
break
|
||||
}
|
||||
|
@ -214,7 +215,7 @@ func (m *Mount) removeKeepLast(category int64) {
|
|||
func (m *Mount) removeGroupKeep(category int64) {
|
||||
for i, p := range m.keepBuffer {
|
||||
if p.Category() == category && p.KeepMode() == packetizer.GroupKeep {
|
||||
m.keepBuffer = append(m.keepBuffer[:i], m.keepBuffer[i+1:]...)
|
||||
m.keepBuffer = slices.Delete(m.keepBuffer, i, i+1)
|
||||
m.removeGroupKeep(category)
|
||||
break
|
||||
}
|
||||
|
@ -243,7 +244,7 @@ func (m *Mount) RemoveListener(identifier string, direct ...bool) bool {
|
|||
for i := range m.listeners {
|
||||
l := m.listeners[i]
|
||||
if l.Identifier() == identifier {
|
||||
m.listeners = append(m.listeners[:i], m.listeners[i+1:]...)
|
||||
m.listeners = slices.Delete(m.listeners, i, i+1)
|
||||
l.Close()
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -79,20 +79,20 @@ func (r *RangeReadSeekCloser) retryConnect() error {
|
|||
r.body = response.Body
|
||||
|
||||
if response.StatusCode != http.StatusPartialContent {
|
||||
r.body.Close()
|
||||
_ = r.body.Close()
|
||||
r.body = nil
|
||||
return fmt.Errorf("response status code %d != %d", response.StatusCode, http.StatusPartialContent)
|
||||
}
|
||||
|
||||
contentLength, err := strconv.ParseInt(response.Header.Get("content-length"), 10, 0)
|
||||
if err != nil {
|
||||
r.body.Close()
|
||||
_ = r.body.Close()
|
||||
r.body = nil
|
||||
return errors.New("server response does not have a valid Content-Length")
|
||||
}
|
||||
|
||||
if contentLength != expectedLength {
|
||||
r.body.Close()
|
||||
_ = r.body.Close()
|
||||
r.body = nil
|
||||
return fmt.Errorf("server returned %d bytes, expected %d", contentLength, expectedLength)
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ func (r *RangeReadSeekCloser) Seek(offset int64, whence int) (int64, error) {
|
|||
|
||||
if oldOffset != r.readOffset {
|
||||
if r.body != nil {
|
||||
r.body.Close()
|
||||
_ = r.body.Close()
|
||||
}
|
||||
r.body = nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue