Added stream finalizer so the last bit gets sent.

This commit is contained in:
Thulinma 2013-07-18 15:39:14 +02:00
parent 82b5f9ef59
commit ddd0445f0e

View file

@ -64,7 +64,6 @@ namespace Buffer {
Stream::get()->dropReadLock(); Stream::get()->dropReadLock();
while (usr->S.connected()){ while (usr->S.connected()){
Util::sleep(5); //sleep 5ms
if ( !usr->myRing->playCount || !usr->Send(newSelect)){ if ( !usr->myRing->playCount || !usr->Send(newSelect)){
if (usr->S.spool()){ if (usr->S.spool()){
while (usr->S.Received().size()){ while (usr->S.Received().size()){
@ -154,6 +153,7 @@ namespace Buffer {
} }
} }
} }
Util::sleep(5); //sleep 5ms
} }
} }
usr->Disconnect("Socket closed."); usr->Disconnect("Socket closed.");
@ -202,11 +202,13 @@ namespace Buffer {
///\brief A function running a thread to handle input data through rtmp push. ///\brief A function running a thread to handle input data through rtmp push.
///\param empty A null pointer. ///\param empty A null pointer.
void handlePushin(void * empty){ void handlePushin(void * empty){
bool connected = false;
if (empty != 0){ if (empty != 0){
return; return;
} }
while (buffer_running){ while (buffer_running){
if (thisStream->getIPInput().connected()){ if (thisStream->getIPInput().connected()){
connected = true;
if (thisStream->getIPInput().spool()){ if (thisStream->getIPInput().spool()){
while (true){ while (true){
thisStream->getWriteLock(); thisStream->getWriteLock();
@ -222,6 +224,12 @@ namespace Buffer {
Util::sleep(10); //10ms wait Util::sleep(10); //10ms wait
} }
}else{ }else{
if (connected){
connected = false;
thisStream->getWriteLock();
thisStream->getStream()->endStream();
thisStream->dropWriteLock(true);
}
Util::sleep(1000); //1s wait Util::sleep(1000); //1s wait
} }
} }