From 72a9a97564165e09ece706de579e8cfd558ba10a Mon Sep 17 00:00:00 2001 From: deva Date: Sun, 22 May 2005 16:34:44 +0000 Subject: Fix: Connection is now taken down when taking a sanpshot without recording. --- src/encoder.cc | 17 +++++++++++++++++ src/server.cc | 26 +++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/encoder.cc b/src/encoder.cc index 6568578..f0b3324 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -39,6 +39,10 @@ /* * $Log$ + * Revision 1.27 2005/05/22 16:34:44 deva + * + * Fix: Connection is now taken down when taking a sanpshot without recording. + * * Revision 1.26 2005/05/03 08:31:59 deva * Removed the error object, and replaced it with a more generic info object. * @@ -167,6 +171,19 @@ void Encoder::encode() } } } + + if(frame->shoot && !frozen && !frame->record) { + // FIXME: This is ugly! + // Bugfix... connection not cleared, when an 'unfrozen' snapshot is taken, + // and no recording is done. + if(s) { + if(n) delete n; + delete s; + s = NULL; + n = NULL; + } + } + if(frame) delete frame; } } diff --git a/src/server.cc b/src/server.cc index a79f463..f13d8df 100644 --- a/src/server.cc +++ b/src/server.cc @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.19 2005/05/22 16:34:44 deva + * + * Fix: Connection is now taken down when taking a sanpshot without recording. + * * Revision 1.18 2005/05/22 15:49:22 deva * Added multithreaded encoding support. * @@ -334,21 +338,20 @@ void newConnection(Socket *socket) } } - if(h.header.h_data.record) { - if(!enc) enc = newMovEncoder(cpr); - enc->encode(frame); - } - if(h.header.h_data.savestate) { savestate = h.header.h_data.savestate; } if(h.header.h_data.freeze) { if(freeze_frame) delete freeze_frame; - freeze_frame = frame; - } else { - // Never delete the frames here! - //delete frame; + // copy the frame into another temporary one. + freeze_frame = new Frame(frame->data, frame->size); + } + + // This one must be last! + if(h.header.h_data.record) { + if(!enc) enc = newMovEncoder(cpr); + enc->encode(frame); } frame = new Frame(NULL, DVPACKAGE_SIZE); @@ -356,9 +359,10 @@ void newConnection(Socket *socket) // TODO: Use save state + fprintf(stderr, "Closing connection...\n"); fflush(stderr); + if(enc) delete enc; - fprintf(stderr, "Connection end[pid: %d]...\n", getpid()); - fflush(stderr); + fprintf(stderr, "Connection closed [pid: %d]...\n", getpid()); fflush(stderr); } -- cgit v1.2.3