Martin Wache schrieb:
> Hi List,
> 
> I'm posting a patch for testing which moves the setupStore into shared
> memory. This enables some more features, like changing brightness, hue
> and contrast for the ShmClient.
> This patch is quite intrusive, but most of the changes are trivial
> because the variable setupStore is now a pointer. If this patch works
> and is merged into the CVS we can start introducing parameters for the
> ShmClient.
> Comments and failure/success reports are welcome!
> 
And here comes the patch ;-)
Index: Makefile
===================================================================
RCS file: /cvsroot/softdevice/softdevice/Makefile,v
retrieving revision 1.34
diff -u -r1.34 Makefile
--- Makefile    18 Sep 2006 10:06:38 -0000      1.34
+++ Makefile    19 Sep 2006 08:13:04 -0000
@@ -236,7 +236,7 @@
   
 ifdef DFB_SUPPORT
   ifdef USE_SUBPLUGINS
-    DFB_OBJS  = utils.o video.o video-dfb.o PicBuffer.o
+    DFB_OBJS  = utils.o video.o video-dfb.o PicBuffer.o setup-softdevice.o
     ALL_OBJS += $(DFB_OBJS)
     LIBS     += $(CLE266_LIBS)
     DFB_LIBS += $(CLE266_LIBS)
@@ -261,7 +261,7 @@
 
 ifdef XV_SUPPORT
   ifdef USE_SUBPLUGINS
-    XV_OBJS   = utils.o video.o video-xv.o xscreensaver.o PicBuffer.o
+    XV_OBJS   = utils.o video.o video-xv.o xscreensaver.o PicBuffer.o 
setup-softdevice.o
     ALL_OBJS  += $(XV_OBJS)
     TARGETS   += lib$(PLUGIN)-xv.so
   else
Index: ShmClient.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/ShmClient.c,v
retrieving revision 1.16
diff -u -r1.16 ShmClient.c
--- ShmClient.c 4 Sep 2006 20:25:17 -0000       1.16
+++ ShmClient.c 19 Sep 2006 08:13:05 -0000
@@ -65,10 +65,7 @@
 };
 
 int main(int argc, char **argv) {
-        cSetupStore SetupStore;
-        SetupStore.xvFullscreen=0;
-        cXvVideoOut *vout=new cXvVideoOut(&SetupStore);
-        xvRemote= new cShmRemote("softdevice-xv");
+        cSetupStore *SetupStore=NULL;
 
         signal(SIGINT,sig_handler);
         signal(SIGQUIT,sig_handler);
@@ -92,15 +89,26 @@
                 fprintf(stderr,"ctl_shmid error attatching shm ctl!\n");
                 exit(-1);
         };
+        
+        if ( (SetupStore = (cSetupStore *) shmat(ctl->setup_shmid,NULL,0))
+                        == (cSetupStore *) -1 ) {
+                fprintf(stderr,"Error attatching to setupStore shm!\n");
+                exit(-1);
+        };
+
+        cXvVideoOut *vout=new cXvVideoOut(SetupStore);
+        xvRemote= new cShmRemote("softdevice-xv");
+        //SetupStore.InitSetupStore();
+        SetupStore->xvFullscreen=0;
 
         if ( !vout->Initialize()  ) {
                 fprintf(stderr,"Could not init video out!\n");
                 exit(-1);
         };
        
-        while (!vout->Reconfigure(SetupStore.pixelFormat) 
-                        && SetupStore.pixelFormat < 3 )
-                SetupStore.pixelFormat++;
+        while (!vout->Reconfigure(SetupStore->pixelFormat) 
+                        && SetupStore->pixelFormat < 3 )
+                SetupStore->pixelFormat++;
         
         if ( vout->useShm && vout->xv_image ) {
                 ctl->pict_shmid= vout->shminfo.shmid;
Index: VideoFilter.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/VideoFilter.c,v
retrieving revision 1.3
diff -u -r1.3 VideoFilter.c
--- VideoFilter.c       30 May 2006 18:57:21 -0000      1.3
+++ VideoFilter.c       19 Sep 2006 08:13:06 -0000
@@ -89,7 +89,7 @@
             fprintf(stderr,
                 "[softdevice] no picture buffer is allocated for mirroring !\n"
                 "[softdevice] switching mirroring off !\n");
-            setupStore.mirror = 0;
+            setupStore->mirror = 0;
             return;
     }
 
@@ -158,7 +158,7 @@
             fprintf(stderr,
                 "[softdevice] no picture buffer is allocated for 
deinterlacing!\n"
                 "[softdevice] switching deinterlacing off !\n");
-            setupStore.deintMethod = 0;
+            setupStore->deintMethod = 0;
             return;
     }
 
@@ -189,7 +189,7 @@
             fprintf(stderr,
                             "[softdevice] error, libavcodec deinterlacer 
failure\n"
                             "[softdevice] switching deinterlacing off !\n");
-            setupStore.deintMethod = 0;
+            setupStore->deintMethod = 0;
             return;
     }
     CopyPicBufferContext(dest,orig);
@@ -303,7 +303,7 @@
                 fprintf(stderr,
                                 "[softdevice] no picture buffer is allocated 
for post processing!\n"
                                 "[softdevice] switching post processing off 
!\n");
-                setupStore.deintMethod = setupStore.ppMethod = 0;
+                setupStore->deintMethod = setupStore->ppMethod = 0;
                 return;
         }
 
@@ -342,26 +342,26 @@
         }
         
         if ( ppmode == NULL 
-                        || currentDeintMethod != setupStore.deintMethod 
-                        || currentppMethod != setupStore.ppMethod
-                        || currentppQuality != setupStore.ppQuality ) {
+                        || currentDeintMethod != setupStore->deintMethod 
+                        || currentppMethod != setupStore->ppMethod
+                        || currentppQuality != setupStore->ppQuality ) {
                 // reallocate ppmode if method or quality changed
-                currentDeintMethod = setupStore.deintMethod;
-                currentppMethod = setupStore.ppMethod;
-                currentppQuality = setupStore.ppQuality;
+                currentDeintMethod = setupStore->deintMethod;
+                currentppMethod = setupStore->ppMethod;
+                currentppQuality = setupStore->ppQuality;
 
                 if (ppmode)  {
                         pp_free_mode (ppmode);
                         ppmode = NULL;
                 }
                 char mode[60]="";
-                if (setupStore.getPPdeintValue() && setupStore.getPPValue())
-                        sprintf(mode,"%s,%s",setupStore.getPPdeintValue(),
-                                        setupStore.getPPValue());
-                else if (setupStore.getPPdeintValue() )
-                        sprintf(mode,"%s",setupStore.getPPdeintValue());
-                else if (setupStore.getPPValue() )
-                        sprintf(mode,"%s",setupStore.getPPValue());
+                if (setupStore->getPPdeintValue() && setupStore->getPPValue())
+                        sprintf(mode,"%s,%s",setupStore->getPPdeintValue(),
+                                        setupStore->getPPValue());
+                else if (setupStore->getPPdeintValue() )
+                        sprintf(mode,"%s",setupStore->getPPdeintValue());
+                else if (setupStore->getPPValue() )
+                        sprintf(mode,"%s",setupStore->getPPValue());
 
                 ppmode = pp_get_mode_by_name_and_quality(mode, 
currentppQuality);
         }
@@ -370,8 +370,8 @@
                 fprintf(stderr,
                         "[softdevice] pp-filter %s couldn't be initialized,\n"
                         "[softdevice] switching postprocessing off !\n",
-                        setupStore.getPPValue());
-                setupStore.deintMethod = setupStore.ppMethod = 0;
+                        setupStore->getPPValue());
+                setupStore->deintMethod = setupStore->ppMethod = 0;
                 return;
         }
 
Index: mpeg2decoder.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/mpeg2decoder.c,v
retrieving revision 1.68
diff -u -r1.68 mpeg2decoder.c
--- mpeg2decoder.c      16 Sep 2006 20:26:24 -0000      1.68
+++ mpeg2decoder.c      19 Sep 2006 08:13:08 -0000
@@ -136,7 +136,7 @@
 // --- cStreamDecoder ---------------------------------------------------------
 
 cStreamDecoder::cStreamDecoder(AVCodecContext *Context, bool packetMode)
-        : PacketQueue(packet_buf_size[setupStore.bufferMode])
+        : PacketQueue(packet_buf_size[setupStore->bufferMode])
 {
   context=Context;
   if (context)
@@ -334,7 +334,7 @@
 uint64_t cAudioStreamDecoder::GetPTS()
 {
   MPGDEB("pts %lld aDelay: %d ",pts,audioOut->GetDelay());
-  uint64_t PTS= pts - audioOut->GetDelay() + setupStore.avOffset*10;
+  uint64_t PTS= pts - audioOut->GetDelay() + setupStore->avOffset*10;
  return PTS;
 };
 
@@ -375,7 +375,7 @@
 
   if (context->codec_id == CODEC_ID_AC3)
   {
-    switch(setupStore.ac3Mode)
+    switch(setupStore->ac3Mode)
     {
       case 0:
         // get the AC3 -> 2CH stereo data
@@ -405,7 +405,7 @@
           pts = pkt->pts;
           pkt->pts=AV_NOPTS_VALUE;
         }
-        PTS = pts - audioOut->GetDelay() + setupStore.avOffset*10;
+        PTS = pts - audioOut->GetDelay() + setupStore->avOffset*10;
 #if AC3_PTS_TRACE
         fprintf (stderr, "audio pts offset %lld %d\n",
                  cClock::GetTime()-PTS, delta_pts);
@@ -480,7 +480,7 @@
       pts = pkt->pts;
       pkt->pts=AV_NOPTS_VALUE;
     }
-    uint64_t PTS= pts - audioOut->GetDelay() + setupStore.avOffset*10;
+    uint64_t PTS= pts - audioOut->GetDelay() + setupStore->avOffset*10;
 
     MPGDEB("audio pts offset %lld\n",cClock::GetTime()-PTS);
     cClock::AdjustAudioPTS(PTS);
@@ -596,7 +596,7 @@
   offset=0;
   delay=0;
   hurry_up=0;
-  syncTimer = new cSyncTimer ((eSyncMode) setupStore.syncTimerMode);
+  syncTimer = new cSyncTimer ((eSyncMode) setupStore->syncTimerMode);
   syncTimer->Reset();
 
   default_frametime = DEFAULT_FRAMETIME;
@@ -819,7 +819,7 @@
     BUFDEB("start decode video stream %d data: %p size: %d \n",
         pkt->stream_index,data,size);
 #ifdef HAVE_CLE266_MPEG_DECODER
-    if (setupStore.cle266HWdecode && context->codec_id == CODEC_ID_MPEG2VIDEO)
+    if (setupStore->cle266HWdecode && context->codec_id == CODEC_ID_MPEG2VIDEO)
             len = DecodePicture_cle266(pic, got_picture,
                                 data, size, pkt->pts);
     else
@@ -864,17 +864,17 @@
       continue;
 
     // postproc stuff....
-    if (setupStore.mirror == 1)
+    if (setupStore->mirror == 1)
       Mirror.Filter(pic,pic);
 
-    if (setupStore.deintMethod == 1)
+    if (setupStore->deintMethod == 1)
       DeintLibav.Filter(pic,pic);
 
 #ifdef PP_LIBAVCODEC
 #ifdef FB_SUPPORT
-    if (setupStore.deintMethod > 2 || setupStore.ppMethod!=0 )
+    if (setupStore->deintMethod > 2 || setupStore->ppMethod!=0 )
 #else
-    if (setupStore.deintMethod > 1 || setupStore.ppMethod!=0 )
+    if (setupStore->deintMethod > 1 || setupStore->ppMethod!=0 )
 #endif //FB_SUPPORT
       LibAvPostProc.Filter(pic,pic);
 #endif //PP_LIBAVCODEC
@@ -1118,7 +1118,7 @@
        printf("Failed to open input stream.Error %d\n",err);
    };
 
-   init_put_byte(&ic->pb, NULL,dvb_buf_size[setupStore.bufferMode]/2, 0, this,
+   init_put_byte(&ic->pb, NULL,dvb_buf_size[setupStore->bufferMode]/2, 0, this,
        read_packet_RingBuffer,NULL,seek_RingBuffer);
    ic->pb.buf_end=NULL;
    CMDDEB("init put byte finished\n");
@@ -1326,7 +1326,7 @@
        delete StreamBuffer;
        StreamBuffer=NULL;
   };
-  StreamBuffer=new 
cSoftRingBufferLinear(dvb_buf_size[setupStore.bufferMode],0);
+  StreamBuffer=new 
cSoftRingBufferLinear(dvb_buf_size[setupStore->bufferMode],0);
   StreamBuffer->Clear();
   initStream();
 
@@ -1357,14 +1357,14 @@
   if (!videoOut->Resume()) {
         fprintf(stderr,"Could not open video out! Sleeping again...\n");
         videoOut->Suspend();
-        setupStore.shouldSuspend=true;
+        setupStore->shouldSuspend=true;
         IsSuspended=true;
         return;
   };
 
   if (!audioOut->Resume()) {
         fprintf(stderr,"Could not open audio out! Sleeping again...\n");
-        setupStore.shouldSuspend=true;
+        setupStore->shouldSuspend=true;
         IsSuspended=true;
         videoOut->Suspend();
         return;
@@ -1633,11 +1633,11 @@
 {
   BUFDEB("Decode %p, Length %d\n",Data,Length);
 
-  if (running && !IsSuspended && setupStore.shouldSuspend)
+  if (running && !IsSuspended && setupStore->shouldSuspend)
      // still running and should suspend
      Suspend();
 
-  if (!running && IsSuspended && !setupStore.shouldSuspend)
+  if (!running && IsSuspended && !setupStore->shouldSuspend)
      // not running and should resume
      Resume();
 
Index: setup-softdevice-menu.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/setup-softdevice-menu.c,v
retrieving revision 1.8
diff -u -r1.8 setup-softdevice-menu.c
--- setup-softdevice-menu.c     9 Sep 2006 10:35:37 -0000       1.8
+++ setup-softdevice-menu.c     19 Sep 2006 08:13:08 -0000
@@ -13,8 +13,8 @@
  */
 cMenuSetupVideoParm::cMenuSetupVideoParm(const char *name) : cOsdMenu(name, 33)
 {
-  copyData = setupStore;
-  data = &setupStore;
+  copyData = *setupStore;
+  data = setupStore;
 
   if (data->vidCaps & CAP_BRIGHTNESS)
   {
@@ -72,7 +72,7 @@
       }
       break;
     case osBack:
-      setupStore = copyData;
+      *setupStore = copyData;
       fprintf (stderr, "[setup-videoparm] restoring setup state\n");
       break;
     default:
@@ -85,8 +85,8 @@
  */
 cMenuSetupCropping::cMenuSetupCropping(const char *name) : cOsdMenu(name, 33)
 {
-  copyData = setupStore;
-  data = &setupStore;
+  copyData = *setupStore;
+  data = setupStore;
 
   crop_str[0] = tr("none");
   Add(new cMenuEditStraItem(tr("CropMode"),
@@ -184,7 +184,7 @@
       }
       break;
     case osBack:
-      setupStore = copyData;
+      *setupStore = copyData;
       fprintf (stderr, "[setup-cropping] restoring setup state\n");
       break;
     default:
@@ -197,8 +197,8 @@
  */
 cMenuSetupPostproc::cMenuSetupPostproc(const char *name) : cOsdMenu(name, 33)
 {
-  copyData = setupStore;
-  data = &setupStore;
+  copyData = *setupStore;
+  data = setupStore;
 
   deint_str[0] = tr("none");
   if (data->outputMethod == VOUT_FB)
@@ -258,7 +258,7 @@
       }
       break;
     case osBack:
-      setupStore = copyData;
+      *setupStore = copyData;
       fprintf (stderr, "[setup-postproc] restoring setup state\n");
       break;
     default:
@@ -274,8 +274,8 @@
   if (plugin)
     SetPlugin(plugin);
 
-  copyData = setupStore;
-  data = &setupStore;
+  copyData = *setupStore;
+  data = setupStore;
 
   Add(new cOsdItem(tr("Cropping")));
   Add(new cOsdItem(tr("Post processing")));
@@ -416,7 +416,7 @@
       }
       break;
     case osBack:
-      setupStore = copyData;
+      *setupStore = copyData;
       fprintf (stderr, "[setup-softdevice] restoring setup state\n");
       break;
     default:
@@ -430,7 +430,7 @@
 void cMenuSetupSoftdevice::Store(void)
 {
 #if 0
-  if (setupStore.deintMethod != data.deintMethod) {
+  if (setupStore->deintMethod != data.deintMethod) {
     fprintf(stderr,
             "[setup-softdevice] deinterlace method changed to (%d) %s\n",
             data.deintMethod, deint_str [data.deintMethod]);
@@ -440,33 +440,33 @@
 
   fprintf (stderr, "[setup-softdevice] storing data\n");
 //  setupStore = data;
-  SetupStore ("Xv-Aspect",          setupStore.xvAspect);
+  SetupStore ("Xv-Aspect",          setupStore->xvAspect);
   // don't save max area value as it is ignored on load
-  //SetupStore ("Xv-MaxArea",         setupStore.xvMaxArea);
-  SetupStore ("CropMode",           setupStore.cropMode);
-  SetupStore ("CropModeToggleKey",     setupStore.cropModeToggleKey);
-  SetupStore ("CropTopLines",        setupStore.cropTopLines);
-  SetupStore ("CropBottomLines",     setupStore.cropBottomLines);
-  SetupStore ("CropLeftCols",        setupStore.cropLeftCols);
-  SetupStore ("CropRightCols",       setupStore.cropRightCols);
-  SetupStore ("Deinterlace Method", setupStore.deintMethod);
-  SetupStore ("Postprocess Method", setupStore.ppMethod);
-  SetupStore ("Postprocess Quality", setupStore.ppQuality);
-  SetupStore ("PixelFormat",        setupStore.pixelFormat);
-  SetupStore ("UseStretchBlit",     setupStore.useStretchBlit);
-  SetupStore ("Picture mirroring",  setupStore.mirror);
-  SetupStore ("avOffset",           setupStore.avOffset);
-  SetupStore ("AlsaDevice",         setupStore.alsaDevice);
-  SetupStore ("AlsaAC3Device",      setupStore.alsaAC3Device);
-  SetupStore ("PixelAspect",        setupStore.screenPixelAspect);
-  SetupStore ("Suspend",            setupStore.shouldSuspend);
-  SetupStore ("OSDalphablend",      setupStore.osdMode);
-  SetupStore ("AC3Mode",            setupStore.ac3Mode);
-  SetupStore ("bufferMode",           setupStore.bufferMode);
-  SetupStore ("mainMenu",             setupStore.mainMenu);
-  SetupStore ("syncTimerMode",        setupStore.syncTimerMode);
-  SetupStore ("vidBrightness",        setupStore.vidBrightness);
-  SetupStore ("vidContrast",          setupStore.vidContrast);
-  SetupStore ("vidHue",               setupStore.vidHue);
-  SetupStore ("vidSaturation",        setupStore.vidSaturation);
+  //SetupStore ("Xv-MaxArea",         setupStore->xvMaxArea);
+  SetupStore ("CropMode",           setupStore->cropMode);
+  SetupStore ("CropModeToggleKey",     setupStore->cropModeToggleKey);
+  SetupStore ("CropTopLines",        setupStore->cropTopLines);
+  SetupStore ("CropBottomLines",     setupStore->cropBottomLines);
+  SetupStore ("CropLeftCols",        setupStore->cropLeftCols);
+  SetupStore ("CropRightCols",       setupStore->cropRightCols);
+  SetupStore ("Deinterlace Method", setupStore->deintMethod);
+  SetupStore ("Postprocess Method", setupStore->ppMethod);
+  SetupStore ("Postprocess Quality", setupStore->ppQuality);
+  SetupStore ("PixelFormat",        setupStore->pixelFormat);
+  SetupStore ("UseStretchBlit",     setupStore->useStretchBlit);
+  SetupStore ("Picture mirroring",  setupStore->mirror);
+  SetupStore ("avOffset",           setupStore->avOffset);
+  SetupStore ("AlsaDevice",         setupStore->alsaDevice);
+  SetupStore ("AlsaAC3Device",      setupStore->alsaAC3Device);
+  SetupStore ("PixelAspect",        setupStore->screenPixelAspect);
+  SetupStore ("Suspend",            setupStore->shouldSuspend);
+  SetupStore ("OSDalphablend",      setupStore->osdMode);
+  SetupStore ("AC3Mode",            setupStore->ac3Mode);
+  SetupStore ("bufferMode",           setupStore->bufferMode);
+  SetupStore ("mainMenu",             setupStore->mainMenu);
+  SetupStore ("syncTimerMode",        setupStore->syncTimerMode);
+  SetupStore ("vidBrightness",        setupStore->vidBrightness);
+  SetupStore ("vidContrast",          setupStore->vidContrast);
+  SetupStore ("vidHue",               setupStore->vidHue);
+  SetupStore ("vidSaturation",        setupStore->vidSaturation);
 }
Index: setup-softdevice.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/setup-softdevice.c,v
retrieving revision 1.46
diff -u -r1.46 setup-softdevice.c
--- setup-softdevice.c  25 Jul 2006 19:58:12 -0000      1.46
+++ setup-softdevice.c  19 Sep 2006 08:13:09 -0000
@@ -85,9 +85,10 @@
 
 /* ----------------------------------------------------------------------------
  */
-cSetupStore setupStore;
+cSetupStore *setupStore=NULL;
+int setupStoreShmId=-1;
 
-cSetupStore::cSetupStore ()
+void cSetupStore::InitSetupStore()
 {
   xvAspect      = 1;   // XV_FORMAT_NORMAL;
   xvMaxArea     = 0;
@@ -135,7 +136,6 @@
 
   strcpy (alsaDevice, "");
   strcpy (alsaAC3Device, "");
-  voArgs = aoArgs = NULL;
 
   xv_startup_aspect[0] = tr("16:9 wide");
   xv_startup_aspect[1] = tr("4:3 normal");
Index: setup-softdevice.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/setup-softdevice.h,v
retrieving revision 1.34
diff -u -r1.34 setup-softdevice.h
--- setup-softdevice.h  9 Sep 2006 10:35:37 -0000       1.34
+++ setup-softdevice.h  19 Sep 2006 08:13:09 -0000
@@ -112,16 +112,17 @@
 
 /* ---------------------------------------------------------------------------
  */
-class cSetupStore {
+    
+
+struct cSetupStore {
   public:
-                  cSetupStore ();
-    virtual       ~cSetupStore () {};
+    void InitSetupStore();
     bool          SetupParse(const char *Name, const char *Value);
     char          *getPPdeintValue(void);
     char          *getPPValue(void);
     void          CropModeNext(void);
 
-    virtual bool  CatchRemoteKey(const char *remoteName, uint64 key);
+    bool  CatchRemoteKey(const char *remoteName, uint64 key);
 
     int   xvAspect;
     int   xvMaxArea;
@@ -169,13 +170,12 @@
           vidCaps;
     char  alsaDevice [ALSA_DEVICE_NAME_LENGTH];
     char  alsaAC3Device [ALSA_DEVICE_NAME_LENGTH];
-    char  *voArgs;
-    char  *aoArgs;
 };
 
 #define OSDMODE_PSEUDO    0
 #define OSDMODE_SOFTWARE  1
 
-extern cSetupStore setupStore;
+extern cSetupStore *setupStore;
+extern int setupStoreShmId;
 
 #endif //__SETUP_SOFTDEVICE_H
Index: shm-common.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/shm-common.h,v
retrieving revision 1.6
diff -u -r1.6 shm-common.h
--- shm-common.h        4 Sep 2006 20:25:17 -0000       1.6
+++ shm-common.h        19 Sep 2006 08:13:09 -0000
@@ -18,7 +18,7 @@
 #include <sys/sem.h> 
 
 
-#define CTL_KEY 5679 
+#define CTL_KEY 5680 
 
 union semun {
         int val;                  
@@ -74,6 +74,9 @@
 
         /* keypress events */
         uint64_t key;
+
+        /* setupStore shm id */
+        int setup_shmid;
 };
 
 inline void sem_wait_lock(int semid, int idx, int flag=0) 
Index: softdevice.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/softdevice.c,v
retrieving revision 1.71
diff -u -r1.71 softdevice.c
--- softdevice.c        16 Sep 2006 09:30:19 -0000      1.71
+++ softdevice.c        19 Sep 2006 08:13:11 -0000
@@ -192,7 +192,7 @@
     fprintf(stderr,
             "[softdevice] ffmpeg build(%d)\n",
              LIBAVCODEC_BUILD);
-    setupStore.outputMethod = method;
+    setupStore->outputMethod = method;
 #ifdef USE_SUBPLUGINS
     switch (method) {
       case VOUT_XV:
@@ -222,7 +222,7 @@
 #endif
         break;
       case VOUT_DUMMY:
-        videoOut=new cDummyVideoOut(&setupStore);
+        videoOut=new cDummyVideoOut(setupStore);
         break;
       default:
         esyslog("[softdevice] NO video out specified exiting\n");
@@ -233,18 +233,18 @@
     switch (method) {
       case VOUT_XV:
 #ifdef XV_SUPPORT
-        videoOut = new cXvVideoOut (&setupStore);
+        videoOut = new cXvVideoOut(setupStore);
         if ( videoOut->Initialize() ) {
 
           if (!videoOut->Reconfigure()) {
                   // XVideo intialization failed, try different pix formats
-                  setupStore.pixelFormat=0;
-                  while (!videoOut->Reconfigure(setupStore.pixelFormat)
-                                  && setupStore.pixelFormat < 3)
-                          setupStore.pixelFormat++;
+                  setupStore->pixelFormat=0;
+                  while (!videoOut->Reconfigure(setupStore->pixelFormat)
+                                  && setupStore->pixelFormat < 3)
+                          setupStore->pixelFormat++;
                   // reset to default if all failed...
-                  if (setupStore.pixelFormat == 3)
-                          setupStore.pixelFormat = 0;
+                  if (setupStore->pixelFormat == 3)
+                          setupStore->pixelFormat = 0;
           };
 
           fprintf (stderr, "[softdevice] Xv out OK !\n");
@@ -256,30 +256,30 @@
         break;
       case VOUT_FB:
 #ifdef FB_SUPPORT
-        videoOut=new cFBVideoOut(&setupStore);
+        videoOut=new cFBVideoOut(setupStore);
         videoOut->Initialize();
 #endif
         break;
       case VOUT_SHM:
 #ifdef SHM_SUPPORT
-        videoOut=new cShmVideoOut(&setupStore);
+        videoOut=new cShmVideoOut(setupStore);
         videoOut->Initialize();
 #endif
         break;
       case VOUT_DFB:
 #ifdef DFB_SUPPORT
-        videoOut=new cDFBVideoOut(&setupStore);
+        videoOut=new cDFBVideoOut(setupStore);
         videoOut->Initialize();
 #endif
         break;
       case VOUT_VIDIX:
 #ifdef VIDIX_SUPPORT
-        videoOut=new cVidixVideoOut(&setupStore);
+        videoOut=new cVidixVideoOut(setupStore);
         videoOut->Initialize();
 #endif
         break;
       case VOUT_DUMMY:
-        videoOut=new cDummyVideoOut(&setupStore);
+        videoOut=new cDummyVideoOut(setupStore);
         videoOut->Initialize();
         break;
       default:
@@ -296,13 +296,13 @@
     switch (audioMethod) {
       case AOUT_ALSA:
 #ifdef ALSA_SUPPORT
-        audioOut=new cAlsaAudioOut(&setupStore);
+        audioOut=new cAlsaAudioOut(setupStore);
         break;
 #else
         fprintf(stderr,"[softdevice] No alsa support compiled in. Using 
dummy-audio\n");
 #endif
       case AOUT_DUMMY:
-        audioOut=new cDummyAudioOut(&setupStore);
+        audioOut=new cDummyAudioOut(setupStore);
         break;
     }
     fprintf(stderr,"[softdevice] Audio out seems to be OK\n");
@@ -352,7 +352,7 @@
     err = dlerror();
     if (!err)
     {
-      videoOut = (cVideoOut *) creator (&setupStore);
+      videoOut = (cVideoOut *) creator(setupStore);
     }
     else
     {
@@ -686,6 +686,70 @@
   aoutMethod = AOUT_ALSA;
   pluginPath = PLUGINLIBDIR;
   runtimePluginPath = GetLibPath();
+
+#ifndef VOUT_SHM 
+  setupStore = (cSetupStore *) malloc( sizeof(cSetupStore) );
+  setupStore->InitSetupStore();
+#else
+  int ctl_shmid;
+  ShmCtlBlock *ctl=NULL;
+  key_t ctl_key=CTL_KEY;
+
+  // try to get an existing ShmCltBlock
+  if  ( (ctl_shmid = shmget(ctl_key,sizeof(ShmCtlBlock), 0666)) >= 0 ) {
+          fprintf(stderr,"softdevice: Got ctl_shmid %d shm ctl!\n",ctl_shmid);
+  }; 
+
+  // attach to the control block
+  if ( ctl_shmid>0 && ( (ctl = (ShmCtlBlock*)shmat(ctl_shmid,NULL,0)) 
+                          == (ShmCtlBlock*) -1 )) {
+          fprintf(stderr,"softdevice: Error attatching shm ctl!\n");
+          ctl=NULL;
+  };
+
+  if ( ctl && ctl->setup_shmid>0 ) {
+          setupStoreShmId=ctl->setup_shmid;
+          // try to attach to an existing setupStore
+          if ( (setupStore = (cSetupStore*)shmat(setupStoreShmId,NULL,0)) 
+                          == (cSetupStore*) -1 ) {
+                  fprintf(stderr,"softdevice: Error attatching existing 
setupStore shm!\n");
+                  setupStoreShmId=-1;
+                  setupStore=NULL;
+                  printf("setupStoreShmId %d setupStore %p\n",
+                                  setupStoreShmId,setupStore);
+          } else fprintf(stderr,"softdevice: Attatched to setupStore %d at 
%p\n",
+                          setupStoreShmId,setupStore);
+                                 
+  };
+
+  if ( !setupStore ) {
+          if ( (setupStoreShmId = shmget(IPC_PRIVATE,sizeof(cSetupStore), 
+                                          IPC_CREAT | 0666)) >= 0 ) {
+                  fprintf(stderr,"softdevice: Created setupStoreId %d!\n",
+                                  setupStoreShmId);
+          };
+          // try to attach to the new setupStore
+          if ( (setupStore = (cSetupStore*)shmat(setupStoreShmId,NULL,0)) 
+                          == (cSetupStore*) -1 ) {
+                  fprintf(stderr,"softdevice: Error attatching setupStore 
shm!\n");
+                  exit(-1);
+          } else 
+                  fprintf(stderr,"softdevice: Attatched to setupStoreId %d at 
%p.\n",
+                          setupStoreShmId,setupStore);
+          
+          if (ctl>0)
+                  ctl->setup_shmid=setupStoreShmId;
+                          // request removing after detaching
+          if ( setupStoreShmId > 0)
+                        shmctl(setupStoreShmId, IPC_RMID, 0);
+
+  };
+  if ( ctl>0 ) {
+          shmdt(ctl);
+          ctl=NULL;
+  };
+  setupStore->InitSetupStore();
+#endif
 }
 
 cPluginSoftDevice::~cPluginSoftDevice()
@@ -701,7 +765,7 @@
 
 const char *cPluginSoftDevice::MainMenuEntry(void)
 {
-  if (setupStore.mainMenu)
+  if (setupStore->mainMenu)
     return tr(MAINMENUENTRY);
   return NULL;
 }
@@ -769,7 +833,6 @@
          printf("vo_argv: %s \n",vo_argv);
         if (!strncmp (vo_argv, "xv:", 3)) {
           vo_argv += 3;
-          setupStore.voArgs = vo_argv;
 #ifdef XV_SUPPORT
           voutMethod = VOUT_XV;
           while (strlen(vo_argv) > 1) {
@@ -781,12 +844,12 @@
               if (!strncmp (vo_argv, "wide", 4)) {
                 fprintf (stderr,
                          "[ProcessArgs] xv: startup aspect ratio set to wide 
(16:9)\n");
-                setupStore. xvAspect = XV_FORMAT_WIDE;
+                setupStore->xvAspect = XV_FORMAT_WIDE;
                 vo_argv += 4;
               } else if (!strncmp (vo_argv, "normal", 6)) {
                 fprintf (stderr,
                          "[ProcessArgs] xv: startup aspect ratio set to normal 
(4:3)\n");
-                setupStore. xvAspect = XV_FORMAT_NORMAL;
+                setupStore->xvAspect = XV_FORMAT_NORMAL;
                 vo_argv += 6;
               } else {
                 fprintf (stderr,
@@ -796,19 +859,19 @@
                 break;
               }
             } else if (!strncmp (vo_argv, "max-area", 8)) {
-              setupStore.xvMaxArea = 1;
+              setupStore->xvMaxArea = 1;
               fprintf (stderr,
                        "[ProcessArgs] xv: using max available area\n");
               vo_argv += 8;
             } else if (!strncmp (vo_argv, "full", 4)) {
-              setupStore.xvFullscreen = 1;
+              setupStore->xvFullscreen = 1;
               fprintf (stderr,
                        "[ProcessArgs] xv: start up fullscreen\n");
               vo_argv += 4;
             } else if (!strncmp (vo_argv, "use-defaults", 12)) {
               fprintf (stderr,
                        "[ProcessArgs] xv: don't change brigtness etc on 
startup\n");
-              setupStore.xvUseDefaults=true;
+              setupStore->xvUseDefaults=true;
               vo_argv += 12;
             } else {
                fprintf(stderr,"[softdevice] ignoring unrecognized option 
\"%s\"!\n",argv[i]);
@@ -823,7 +886,6 @@
 #endif
         } else if (!strncmp (vo_argv, "fb:", 3)) {
           vo_argv += 3;
-          setupStore.voArgs = vo_argv;
 #ifdef FB_SUPPORT
           voutMethod = VOUT_FB;
 #else
@@ -831,7 +893,6 @@
 #endif
         } else if (!strncmp (vo_argv, "shm:", 3)) {
           vo_argv += 4;
-          setupStore.voArgs = vo_argv;
 #ifdef SHM_SUPPORT
           voutMethod = VOUT_SHM;
 #else
@@ -839,7 +900,6 @@
 #endif
         } else if (!strncmp (vo_argv, "dfb:", 4)) {
           vo_argv += 4;
-          setupStore.voArgs = vo_argv;
 #ifdef DFB_SUPPORT
           voutMethod = VOUT_DFB;
           while (strlen(vo_argv) > 1) {
@@ -847,20 +907,20 @@
                ++vo_argv;
 
             if (!strncmp (vo_argv, "mgatv", 5)) {
-              setupStore.useMGAtv = 1;
+              setupStore->useMGAtv = 1;
               vo_argv += 5;
             } else if (!strncmp (vo_argv, "viatv", 5)) {
-              setupStore.viaTv = 1;
+              setupStore->viaTv = 1;
               fprintf(stderr,"[softdevice] enabling field parity\n");
               vo_argv += 5;
 #ifdef HAVE_CLE266_MPEG_DECODER
             } else if (!strncmp (vo_argv, "cle266", 6)) {
-              setupStore.cle266HWdecode = 1;
+              setupStore->cle266HWdecode = 1;
               vo_argv += 6;
               fprintf(stderr,"[softdevice] enabling CLE266 HW decoding\n");
 #endif // HAVE_CLE266_MPEG_DECODER
             } else if (!strncmp (vo_argv, "triple", 6)) {
-              setupStore.tripleBuffering = 1;
+              setupStore->tripleBuffering = 1;
               vo_argv += 6;
               fprintf(stderr,"[softdevice] enabling triple buffering\n");
             } else {
@@ -876,7 +936,6 @@
 #endif
         } else if (!strncmp (vo_argv, "vidix:", 6)) {
           vo_argv += 6;
-          setupStore.voArgs = vo_argv;
 #ifdef VIDIX_SUPPORT
           voutMethod = VOUT_VIDIX;
 #else
@@ -885,7 +944,6 @@
 #endif
         } else if (!strncmp (vo_argv, "dummy:", 6)) {
           vo_argv += 6;
-          setupStore.voArgs = vo_argv;
           voutMethod = VOUT_DUMMY;
           fprintf(stderr,"[softdevice] using dummy video out\n");
         } else {
@@ -902,7 +960,6 @@
           char *ao_argv = argv[i];
         if (!strncmp(ao_argv, "alsa:", 5)) {
           ao_argv += 5;
-          setupStore.aoArgs = ao_argv;
           aoutMethod = AOUT_ALSA;
           while (strlen(ao_argv) > 1) {
               char  *sep;
@@ -923,10 +980,10 @@
               len = (len > ALSA_DEVICE_NAME_LENGTH) ?
                       ALSA_DEVICE_NAME_LENGTH : len;
               if (len) {
-                strncpy(setupStore.alsaDevice, ao_argv, len);
-                setupStore.alsaDevice [len] = 0;
+                strncpy(setupStore->alsaDevice, ao_argv, len);
+                setupStore->alsaDevice[len]= 0;
                 fprintf (stderr, "[softdevice] using PCM alsa device %s\n",
-                         setupStore.alsaDevice);
+                         setupStore->alsaDevice);
               }
               ao_argv += len;
             } else if (!strncmp(ao_argv, "ac3=", 4)) {
@@ -935,22 +992,22 @@
               len = (len > ALSA_DEVICE_NAME_LENGTH) ?
                       ALSA_DEVICE_NAME_LENGTH : len;
               if (len) {
-                strncpy(setupStore.alsaAC3Device, ao_argv, len);
-                setupStore.alsaAC3Device [len] = 0;
+                strncpy(setupStore->alsaAC3Device, ao_argv, len);
+                setupStore->alsaAC3Device[len] = 0;
                 fprintf (stderr, "[softdevice] using AC3 alsa device %s\n",
-                         setupStore.alsaAC3Device);
+                         setupStore->alsaAC3Device);
               }
               ao_argv += len;
             } else {
               fprintf(stderr, "[softdevice] using alsa device %s\n", ao_argv);
-              strncpy(setupStore.alsaDevice, ao_argv, ALSA_DEVICE_NAME_LENGTH);
+              strncpy(setupStore->alsaDevice, ao_argv, 
ALSA_DEVICE_NAME_LENGTH);
+              setupStore->alsaDevice[ALSA_DEVICE_NAME_LENGTH-1]=0;  
               ao_argv += strlen(ao_argv);
             }
 
           }
         } else if (!strncmp(ao_argv, "dummy:", 6)) {
           ao_argv += 6;
-          setupStore.aoArgs = ao_argv;
           aoutMethod = AOUT_DUMMY;
         } else {
           fprintf(stderr,"[softdevice] ignoring unrecognized option 
\"%s\"!\n",argv[i]);
@@ -1062,7 +1119,7 @@
 bool cPluginSoftDevice::SetupParse(const char *Name, const char *Value)
 {
   // Parse your own setup parameters and store their values.
-  return setupStore.SetupParse(Name, Value);
+  return setupStore->SetupParse(Name, Value);
 }
 
 VDRPLUGINCREATOR(cPluginSoftDevice); // Don't touch this!

_______________________________________________
Softdevice-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/softdevice-devel

Reply via email to