From 177ef988ab1f22e889a8994cf1e7c107c3adae6d Mon Sep 17 00:00:00 2001
From: iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>
Date: Thu, 26 Oct 2006 03:25:44 +0000
Subject: incorporated caching into main, no proccessing yet

git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@119 f606c939-3180-4ac9-a4b8-4b8779d57d0a
---
 rMD-exp/src/recordmydesktop.c | 57 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 14 deletions(-)

(limited to 'rMD-exp')

diff --git a/rMD-exp/src/recordmydesktop.c b/rMD-exp/src/recordmydesktop.c
index c02ecdf..1946a37 100644
--- a/rMD-exp/src/recordmydesktop.c
+++ b/rMD-exp/src/recordmydesktop.c
@@ -185,15 +185,20 @@ int main(int argc,char **argv){
         if(!pdata.args.full_shots)
             pthread_create(&poll_damage_t,NULL,PollDamage,(void *)&pdata);
         pthread_create(&image_capture_t,NULL,GetFrame,(void *)&pdata);
-//         pthread_create(&image_encode_t,NULL,EncodeImageBuffer,(void *)&pdata);
-        pthread_create(&image_cache_t,NULL,CacheImageBuffer,(void *)&pdata);
+        if(pdata.args.encOnTheFly)
+            pthread_create(&image_encode_t,NULL,EncodeImageBuffer,(void *)&pdata);
+        else
+            pthread_create(&image_cache_t,NULL,CacheImageBuffer,(void *)&pdata);
 
         if(!pdata.args.nosound){
             pthread_create(&sound_capture_t,NULL,CaptureSound,(void *)&pdata);
-            pthread_create(&sound_cache_t,NULL,CacheSoundBuffer,(void *)&pdata);
-//             pthread_create(&sound_encode_t,NULL,EncodeSoundBuffer,(void *)&pdata);
+            if(pdata.args.encOnTheFly)
+                pthread_create(&sound_encode_t,NULL,EncodeSoundBuffer,(void *)&pdata);
+            else
+                pthread_create(&sound_cache_t,NULL,CacheSoundBuffer,(void *)&pdata);
         }
-//         pthread_create(&flush_to_ogg_t,NULL,FlushToOgg,(void *)&pdata);
+        if(pdata.args.encOnTheFly)
+            pthread_create(&flush_to_ogg_t,NULL,FlushToOgg,(void *)&pdata);
         
 
         RegisterCallbacks(&pdata.args);
@@ -203,23 +208,43 @@ int main(int argc,char **argv){
         
         pthread_join(image_capture_t,NULL);
         fprintf(stderr,"Shutting down.");
-//         pthread_join(image_encode_t,NULL);
+        if(pdata.args.encOnTheFly)
+            pthread_join(image_encode_t,NULL);
+        else
+            pthread_join(image_cache_t,NULL);
+
+
         fprintf(stderr,".");
         if(!pdata.args.nosound){
             int *snd_exit;
             pthread_join(sound_capture_t,(void *)(&snd_exit));
             fprintf(stderr,".");
-//             if(!(*snd_exit))
-//                 pthread_join(sound_encode_t,NULL);
-//             else{
-//                 pthread_cancel(sound_encode_t);
-//                 exit_status=*snd_exit;
-//             }
-            fprintf(stderr,".");
+
+            if(pdata.args.encOnTheFly){
+                if(!(*snd_exit))
+                    pthread_join(sound_encode_t,NULL);
+                else{
+                    pthread_cancel(sound_encode_t);
+                    exit_status=*snd_exit;
+                }
+            }
+            else{
+                if(!(*snd_exit))
+                    pthread_join(sound_cache_t,NULL);
+                else{
+                    pthread_cancel(sound_cache_t);
+                    exit_status=*snd_exit;
+                }
+            }
         }
         else
             fprintf(stderr,"..");
-//         pthread_join(flush_to_ogg_t,NULL);
+
+
+        if(pdata.args.encOnTheFly)
+            pthread_join(flush_to_ogg_t,NULL);
+
+
         fprintf(stderr,".");
         if(!pdata.args.full_shots)
             pthread_join(poll_damage_t,NULL);
@@ -231,6 +256,10 @@ int main(int argc,char **argv){
         }
         fprintf(stderr,"\n");
         XCloseDisplay(pdata.dpy);
+
+
+
+
         if(Aborted){
             if(remove(pdata.args.filename)){
                 perror("Error while removing file:\n");
-- 
cgit v1.2.3