Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-03-18 16:50:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fbd722bf76d176ca2fadb547cf9897eda330117b
fbd722bf
1 parent
f36e4a44
refine the fast buffer to more readable.
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
17 行增加
和
12 行删除
trunk/src/protocol/srs_rtmp_buffer.cpp
trunk/src/protocol/srs_rtmp_buffer.cpp
查看文件 @
fbd722b
...
...
@@ -82,17 +82,21 @@ char* SrsFastBuffer::bytes()
void
SrsFastBuffer
::
set_buffer
(
int
buffer_size
)
{
// the user-space buffer size limit to a max value.
int
nb_resize_buf
=
srs_min
(
buffer_size
,
SRS_MAX_SOCKET_BUFFER
);
// never exceed the max size.
if
(
buffer_size
>
SRS_MAX_SOCKET_BUFFER
)
{
srs_warn
(
"limit the user-space buffer from %d to %d"
,
buffer_size
,
SRS_MAX_SOCKET_BUFFER
);
srs_warn
(
"limit the user-space buffer from %d to %d"
,
buffer_size
,
SRS_MAX_SOCKET_BUFFER
);
}
// the user-space buffer size limit to a max value.
int
nb_resize_buf
=
srs_min
(
buffer_size
,
SRS_MAX_SOCKET_BUFFER
);
// only realloc when buffer changed bigger
if
(
nb_resize_buf
<=
nb_buffer
)
{
return
;
}
// realloc for buffer change bigger.
int
start
=
p
-
buffer
;
int
nb_bytes
=
end
-
p
;
...
...
@@ -148,6 +152,7 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
srs_assert
(
nb_exists_bytes
>=
0
);
srs_verbose
(
"move fast buffer %d bytes"
,
nb_exists_bytes
);
// reset or move to get more space.
if
(
!
nb_exists_bytes
)
{
// reset when buffer is empty.
p
=
end
=
buffer
;
...
...
@@ -159,15 +164,15 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
p
=
buffer
;
end
=
p
+
nb_exists_bytes
;
}
}
// check whether enough free space in buffer.
nb_free_space
=
buffer
+
nb_buffer
-
end
;
if
(
nb_free_space
<
required_size
)
{
ret
=
ERROR_READER_BUFFER_OVERFLOW
;
srs_error
(
"buffer overflow, required=%d, max=%d, left=%d, ret=%d"
,
required_size
,
nb_buffer
,
nb_free_space
,
ret
);
return
ret
;
// check whether enough free space in buffer.
nb_free_space
=
buffer
+
nb_buffer
-
end
;
if
(
nb_free_space
<
required_size
)
{
ret
=
ERROR_READER_BUFFER_OVERFLOW
;
srs_error
(
"buffer overflow, required=%d, max=%d, left=%d, ret=%d"
,
required_size
,
nb_buffer
,
nb_free_space
,
ret
);
return
ret
;
}
}
// buffer is ok, read required size of bytes.
...
...
请
注册
或
登录
后发表评论