1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix signal bug, break for gmc. fix SrsMessage leak, use common message to free payload. to 0.9.88

This commit is contained in:
winlin 2014-05-02 12:29:56 +08:00
parent ac3d0d5bc2
commit d74f01e2d1
5 changed files with 90 additions and 54 deletions

View file

@ -759,7 +759,7 @@ int SrsProtocol::send_and_free_packet(SrsPacket* packet, int stream_id)
}
// to message
SrsMessage* msg = new SrsMessage();
SrsMessage* msg = new SrsCommonMessage();
msg->payload = (int8_t*)payload;
msg->size = (int32_t)size;
@ -975,7 +975,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
bool is_first_chunk_of_msg = false;
if (!chunk->msg) {
is_first_chunk_of_msg = true;
chunk->msg = new SrsMessage();
chunk->msg = new SrsCommonMessage();
srs_verbose("create message for new chunk, fmt=%d, cid=%d", fmt, chunk->cid);
}
@ -1532,7 +1532,16 @@ SrsMessage::SrsMessage()
}
SrsMessage::~SrsMessage()
{
{
}
SrsCommonMessage::SrsCommonMessage()
{
}
SrsCommonMessage::~SrsCommonMessage()
{
srs_freepa(payload);
}
SrsSharedPtrMessage::__SrsSharedPtr::__SrsSharedPtr()

View file

@ -325,6 +325,12 @@ public:
* message is raw data RTMP message, bytes oriented,
* protcol always recv RTMP message, and can send RTMP message or RTMP packet.
* the shared-ptr message is a special RTMP message, use ref-count for performance issue.
*
* @remark, never directly new SrsMessage, the constructor is protected,
* for in the SrsMessage, we never know whether we should free the message,
* for SrsCommonMessage, we should free the payload,
* while for SrsSharedPtrMessage, we should use ref-count to free it.
* so, use these two concrete message, SrsCommonMessage or SrsSharedPtrMessage instread.
*/
class SrsMessage
{
@ -341,11 +347,22 @@ public:
*/
int32_t size;
int8_t* payload;
public:
protected:
SrsMessage();
public:
virtual ~SrsMessage();
};
/**
* the common message used free the payload in common way.
*/
class SrsCommonMessage : public SrsMessage
{
public:
SrsCommonMessage();
virtual ~SrsCommonMessage();
};
/**
* shared ptr message.
* for audio/video/data message that need less memory copy.