mirror of https://bitbucket.org/ausocean/av.git
rtmp: clarify C_RTMPSockBuf_Fill
The while loop in the C is only there to allow sigint to be caught and ignored when user interupts are not allowed.
This commit is contained in:
parent
0cfabbbad0
commit
9b5d62a99a
29
rtmp/rtmp.go
29
rtmp/rtmp.go
|
@ -54,6 +54,7 @@ import (
|
|||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
|
@ -1795,29 +1796,27 @@ func C_CloseInternal(r *C_RTMP, reconnect int32) {
|
|||
// int RTMPSockBuf_Fill(RTMPSockBuf* sb);
|
||||
// rtmp.c +4253
|
||||
func C_RTMPSockBuf_Fill(sb *C_RTMPSockBuf) int {
|
||||
var nBytes int
|
||||
|
||||
if sb.sb_size == 0 {
|
||||
sb.sb_start = &sb.sb_buf[0]
|
||||
}
|
||||
|
||||
for {
|
||||
nBytes = int(unsafe.Sizeof(sb.sb_buf)) - 1 - int(sb.sb_size) -
|
||||
int(uintptr(unsafe.Pointer(sb.sb_start))-uintptr(unsafe.Pointer(
|
||||
nBytes := C.long(unsafe.Sizeof(sb.sb_buf)) - 1 - C.long(sb.sb_size) -
|
||||
C.long(uintptr(unsafe.Pointer(sb.sb_start))-uintptr(unsafe.Pointer(
|
||||
&sb.sb_buf[0])))
|
||||
|
||||
// TODO: figure out what to do with recv
|
||||
nBytes = int(C.recv(C.int(sb.sb_socket), unsafe.Pointer(uintptr(unsafe.Pointer(
|
||||
sb.sb_start))+uintptr(int(sb.sb_size))), C.size_t(nBytes), 0))
|
||||
|
||||
if nBytes != -1 {
|
||||
sb.sb_size += int32(nBytes)
|
||||
nBytes, err := C.recv(C.int(sb.sb_socket), unsafe.Pointer(uintptr(unsafe.Pointer(
|
||||
sb.sb_start))+uintptr(int(sb.sb_size))), C.size_t(nBytes), 0)
|
||||
if nBytes == -1 {
|
||||
log.Printf("C_RTMPSockBuf_Fill: recv error: %v", err)
|
||||
if err == syscall.EWOULDBLOCK || err == syscall.EAGAIN {
|
||||
sb.sb_timedout = 1
|
||||
nBytes = 0
|
||||
}
|
||||
} else {
|
||||
log.Println("C_RTMPSockBuf_Fill: recv error!")
|
||||
sb.sb_size += int32(nBytes)
|
||||
}
|
||||
break
|
||||
}
|
||||
return nBytes
|
||||
|
||||
return int(nBytes)
|
||||
}
|
||||
|
||||
// int RTMPSockBuf_Send(RTMPSockBuf* sb, const char* buf, int len);
|
||||
|
|
Loading…
Reference in New Issue