mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-06 02:09:04 +02:00
fix uint64 and cursors on 32bit systems.
This commit is contained in:
parent
d42165a5fd
commit
bbefb393f8
2 changed files with 10 additions and 9 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
@ -26,7 +25,7 @@ type StreamSinkManagerCtx struct {
|
||||||
// wait for a keyframe before sending samples
|
// wait for a keyframe before sending samples
|
||||||
waitForKf bool
|
waitForKf bool
|
||||||
|
|
||||||
bitrate uint64 // atomic
|
bitrate uint64
|
||||||
brBuckets map[int]float64
|
brBuckets map[int]float64
|
||||||
|
|
||||||
logger zerolog.Logger
|
logger zerolog.Logger
|
||||||
|
@ -144,7 +143,7 @@ func (manager *StreamSinkManagerCtx) ID() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *StreamSinkManagerCtx) Bitrate() uint64 {
|
func (manager *StreamSinkManagerCtx) Bitrate() uint64 {
|
||||||
return atomic.LoadUint64(&manager.bitrate)
|
return manager.bitrate
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *StreamSinkManagerCtx) Codec() codec.RTPCodec {
|
func (manager *StreamSinkManagerCtx) Codec() codec.RTPCodec {
|
||||||
|
@ -361,8 +360,8 @@ func (manager *StreamSinkManagerCtx) saveSampleBitrate(timestamp time.Time, delt
|
||||||
next := int((sec + 1) % 3)
|
next := int((sec + 1) % 3)
|
||||||
|
|
||||||
if manager.brBuckets[next] != 0 {
|
if manager.brBuckets[next] != 0 {
|
||||||
// atomic update bitrate
|
// update bitrate, TODO: atomic?
|
||||||
atomic.StoreUint64(&manager.bitrate, uint64(manager.brBuckets[last]))
|
manager.bitrate = uint64(manager.brBuckets[last])
|
||||||
// empty next bucket
|
// empty next bucket
|
||||||
manager.brBuckets[next] = 0
|
manager.brBuckets[next] = 0
|
||||||
}
|
}
|
||||||
|
@ -410,5 +409,5 @@ func (manager *StreamSinkManagerCtx) DestroyPipeline() {
|
||||||
manager.pipelinesActive.Set(0)
|
manager.pipelinesActive.Set(0)
|
||||||
|
|
||||||
manager.brBuckets = make(map[int]float64)
|
manager.brBuckets = make(map[int]float64)
|
||||||
atomic.StoreUint64(&manager.bitrate, 0)
|
manager.bitrate = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -279,13 +280,14 @@ func GetCursorImage() *types.CursorImage {
|
||||||
width := int(cur.width)
|
width := int(cur.width)
|
||||||
height := int(cur.height)
|
height := int(cur.height)
|
||||||
|
|
||||||
// Xlib stores 32-bit data in longs, even if longs are 64-bits long.
|
// Xlib stores 32-bit data in longs, even if longs are 64-bits on 64-bit systems.
|
||||||
pixels := C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width*height*8))
|
ptrSize := strconv.IntSize / 8
|
||||||
|
pixels := C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width*height*ptrSize))
|
||||||
|
|
||||||
img := image.NewRGBA(image.Rect(0, 0, width, height))
|
img := image.NewRGBA(image.Rect(0, 0, width, height))
|
||||||
for y := 0; y < height; y++ {
|
for y := 0; y < height; y++ {
|
||||||
for x := 0; x < width; x++ {
|
for x := 0; x < width; x++ {
|
||||||
pos := ((y * width) + x) * 8
|
pos := ((y * width) + x) * ptrSize
|
||||||
|
|
||||||
img.SetRGBA(x, y, color.RGBA{
|
img.SetRGBA(x, y, color.RGBA{
|
||||||
A: pixels[pos+3],
|
A: pixels[pos+3],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue