From 39e6a785eff932f2f9af5953e3d5194ce9db6309 Mon Sep 17 00:00:00 2001 From: Saxon1 Date: Sun, 6 May 2018 00:26:02 +0930 Subject: [PATCH] removed bad free and added better to clean output chan --- revid/Revid.go | 10 +++++++--- rtmp/RTMPWrapper.c | 3 --- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/revid/Revid.go b/revid/Revid.go index 6faefacc..e269530d 100644 --- a/revid/Revid.go +++ b/revid/Revid.go @@ -64,7 +64,6 @@ const ( ringBufferElementSize = 150000 httpTimeOut = 5 // s packetsPerFrame = 7 - h264BufferSize = 1000000 bitrateTime = 60 // s mjpegParserInChanLen = 100000 ffmpegPath = "/usr/local/bin/ffmpeg" @@ -298,9 +297,14 @@ func (r *revid) getFramePacketization() []byte { // flushDataPacketization removes data from the revid inst's coutput chan func (r *revid) flushData() { - for len(r.outputChan) > 0 { - <-(r.outputChan) + for { + select { + case <-r.outputChan: + default: + goto done + } } + done: } // packClips takes data segments; whether that be tsPackets or mjpeg frames and diff --git a/rtmp/RTMPWrapper.c b/rtmp/RTMPWrapper.c index f63e76d7..1919a8ab 100644 --- a/rtmp/RTMPWrapper.c +++ b/rtmp/RTMPWrapper.c @@ -70,17 +70,14 @@ unsigned int RTMP_write_frame(char* data, uint data_length){ if (!RTMP_IsConnected(rtmp)) { printf("RTMP is not connected!\n"); free(dataForC); - free(data); return 0; } if (!RTMP_Write(rtmp, (const char*)data, data_length)) { printf("RTMP write error!\n"); free(dataForC); - free(data); return 0; } free(dataForC); - free(data); return 1; }