mirror of https://bitbucket.org/ausocean/av.git
rtmp: simplify recv call in C_RTMPSockBuf_Fill
This commit is contained in:
parent
b9fcb2202f
commit
bb6ee2a3ce
19
rtmp/rtmp.go
19
rtmp/rtmp.go
|
@ -615,10 +615,9 @@ func C_ReadN(r *C_RTMP, buffer *byte, n int) int {
|
|||
}
|
||||
|
||||
if nRead > 0 {
|
||||
memmove(unsafe.Pointer(ptr), unsafe.Pointer(r.m_sb.sb_start), uintptr(nRead))
|
||||
r.m_sb.sb_start = (*byte)(incBytePtr(unsafe.Pointer(r.m_sb.sb_start),
|
||||
nRead))
|
||||
r.m_sb.sb_size -= int32(nRead)
|
||||
memmove(unsafe.Pointer(ptr), unsafe.Pointer(&r.m_sb.sb_buf[r.m_sb.sb_start]), uintptr(nRead))
|
||||
r.m_sb.sb_start += nRead
|
||||
r.m_sb.sb_size -= nRead
|
||||
nBytes = nRead
|
||||
r.m_nBytesIn += int32(nRead)
|
||||
if r.m_bSendCounter && r.m_nBytesIn > (r.m_nBytesInSent+r.m_nClientBW/10) {
|
||||
|
@ -1797,15 +1796,11 @@ func C_CloseInternal(r *C_RTMP, reconnect int32) {
|
|||
// rtmp.c +4253
|
||||
func C_RTMPSockBuf_Fill(sb *C_RTMPSockBuf) int {
|
||||
if sb.sb_size == 0 {
|
||||
sb.sb_start = &sb.sb_buf[0]
|
||||
sb.sb_start = 0
|
||||
}
|
||||
|
||||
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])))
|
||||
|
||||
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)
|
||||
nBytes := C.long((len(sb.sb_buf) - 1) - (sb.sb_size + sb.sb_start))
|
||||
nBytes, err := C.recv(C.int(sb.sb_socket), unsafe.Pointer(&sb.sb_buf[sb.sb_start+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 {
|
||||
|
@ -1813,7 +1808,7 @@ func C_RTMPSockBuf_Fill(sb *C_RTMPSockBuf) int {
|
|||
nBytes = 0
|
||||
}
|
||||
} else {
|
||||
sb.sb_size += int32(nBytes)
|
||||
sb.sb_size += int(nBytes)
|
||||
}
|
||||
|
||||
return int(nBytes)
|
||||
|
|
|
@ -137,8 +137,8 @@ type C_RTMPPacket struct {
|
|||
// rtmp.h +127
|
||||
type C_RTMPSockBuf struct {
|
||||
sb_socket int32
|
||||
sb_size int32
|
||||
sb_start *byte
|
||||
sb_size int
|
||||
sb_start int
|
||||
sb_buf [RTMP_BUFFER_CACHE_SIZE]byte // port const
|
||||
sb_timedout bool
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue