mirror of
https://github.com/LX3JL/xlxd.git
synced 2025-12-06 07:42:01 +01:00
Merge pull request #222 from narspt/patch-20
fix ambed openstream timeout issue
This commit is contained in:
commit
8428d1ef40
|
|
@ -32,6 +32,7 @@ CSemaphore::CSemaphore()
|
||||||
{
|
{
|
||||||
// Initialized as locked.
|
// Initialized as locked.
|
||||||
m_Count = 0;
|
m_Count = 0;
|
||||||
|
m_WaitingCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -66,7 +67,21 @@ bool CSemaphore::WaitFor(uint ms)
|
||||||
{
|
{
|
||||||
m_Count--;
|
m_Count--;
|
||||||
}
|
}
|
||||||
|
if ( m_WaitingCount > 0 )
|
||||||
|
{
|
||||||
|
m_WaitingCount--;
|
||||||
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSemaphore::PreWaitFor(void)
|
||||||
|
{
|
||||||
|
std::unique_lock<decltype(m_Mutex)> lock(m_Mutex);
|
||||||
|
// discard timedout notify(s) count
|
||||||
|
if ( m_Count > m_WaitingCount )
|
||||||
|
{
|
||||||
|
m_Count = m_WaitingCount;
|
||||||
|
}
|
||||||
|
// pre flag waiting notify
|
||||||
|
m_WaitingCount++;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,14 @@ public:
|
||||||
void Notify(void);
|
void Notify(void);
|
||||||
void Wait(void);
|
void Wait(void);
|
||||||
bool WaitFor(uint);
|
bool WaitFor(uint);
|
||||||
|
void PreWaitFor(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// data
|
// data
|
||||||
std::mutex m_Mutex;
|
std::mutex m_Mutex;
|
||||||
std::condition_variable m_Condition;
|
std::condition_variable m_Condition;
|
||||||
size_t m_Count;
|
size_t m_Count;
|
||||||
|
size_t m_WaitingCount;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ CCodecStream *CTranscoder::GetStream(CPacketStream *PacketStream, uint8 uiCodecI
|
||||||
{
|
{
|
||||||
// yes, post openstream request
|
// yes, post openstream request
|
||||||
EncodeOpenstreamPacket(&Buffer, uiCodecIn, (uiCodecIn == CODEC_AMBEPLUS) ? CODEC_AMBE2PLUS : CODEC_AMBEPLUS);
|
EncodeOpenstreamPacket(&Buffer, uiCodecIn, (uiCodecIn == CODEC_AMBEPLUS) ? CODEC_AMBE2PLUS : CODEC_AMBEPLUS);
|
||||||
|
m_SemaphoreOpenStream.PreWaitFor(); // pre flag waiting notify and discard timedout notify(s) count
|
||||||
m_Socket.Send(Buffer, m_Ip, TRANSCODER_PORT);
|
m_Socket.Send(Buffer, m_Ip, TRANSCODER_PORT);
|
||||||
|
|
||||||
// wait relpy here
|
// wait relpy here
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue