Skip to content

Commit

Permalink
for bug #249, simplify the macro, 0 to disable chunk stream cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 4, 2014
1 parent 159ef38 commit 57f844b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions trunk/src/core/srs_core_performance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* how many chunk stream to cache, [0, N].
* to imporove about 10% performance when chunk size small, and 5% for large chunk.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/249
* @remark 0 to disable the chunk stream cache.
*/
#define SRS_PERF_CHUNK_STREAM_CACHE 16

Expand Down
8 changes: 7 additions & 1 deletion trunk/src/rtmp/srs_protocol_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io)
warned_c0c3_cache_dry = false;
auto_response_when_recv = true;

cs_cache = new SrsChunkStream*[SRS_PERF_CHUNK_STREAM_CACHE];
cs_cache = NULL;
if (SRS_PERF_CHUNK_STREAM_CACHE > 0) {
cs_cache = new SrsChunkStream*[SRS_PERF_CHUNK_STREAM_CACHE];
}
for (int cid = 0; cid < SRS_PERF_CHUNK_STREAM_CACHE; cid++) {
SrsChunkStream* cs = new SrsChunkStream(cid);
// set the perfer cid of chunk,
Expand Down Expand Up @@ -1102,6 +1105,9 @@ int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg)
}
srs_verbose("read basic header success. fmt=%d, cid=%d", fmt, cid);

// the cid must not negative.
srs_assert(cid >= 0);

// once we got the chunk message header,
// that is there is a real message in cache,
// increase the timeout to got it.
Expand Down

0 comments on commit 57f844b

Please sign in to comment.