Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
246 user(s) are online (133 user(s) are browsing Forums)

Members: 0
Guests: 246

more...

Headlines

 
  Register To Post  

how to detect if overlay is present in few strings ?
Home away from home
Home away from home


See User information
I need to detect if overlay is present or not , and in case if yes, return true, in case if not, return false.

That how it done on morphos's mplayer to have fallback if overlay not present (by return -1):

static int preinit(const char *arg)
{
    
extern int fullscreen;
    
mp_msg(MSGT_VOMSGL_INFO"VO: [cgx_overlay] Hello!\n");
    if(!
CGXVideoBase)
    {
        if ( ! (
CGXVideoBase = (struct Library *) OpenLibrary("cgxvideo.library" 0L) ) )
        {
            return -
1;
        }
    }

    
/* common arguments  */
    
if (!Cgx_GiveArg(arg))
    {
        
CloseLibrary(CGXVideoBase);
        
CGXVideoBase NULL;
        return -
1;    
    }

    
/* common arguments  */
    
if (!Cgx_Overlay_GiveArg(arg))
    {
        
Cgx_ReleaseArg();
        
CloseLibrary(CGXVideoBase);
        
CGXVideoBase NULL;
        return -
1;
    }

    if(!
fullscreen)
    {
        
ULONG available FALSE;
        
struct Screen *screen LockPubScreen PubScreenName[0] ? PubScreenName NULL);
        if(
screen)
        {
            
APTR VLHandle CreateVLayerHandleTags(screenVOA_SrcTypeSRCFMT_RGB16VOA_SrcWidth320VOA_SrcHeight240TAG_DONE);

            if(
VLHandle)
            {
                
available TRUE;
                
DeleteVLayerHandle(VLHandle);
                
VLHandle NULL;
            }

            
UnlockPubScreen(NULL,screen);
        }

        if(!
available)
        {
            
Cgx_ReleaseArg();
            
CloseLibrary(CGXVideoBase);
            
CGXVideoBase NULL;
            return -
1;
        }
    }

    
Cgx_Message();

    return 
0;
}


Need same by logic, but just for p96 overlay check. The less by code and cleaner solution will be the better of course

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: how to detect if overlay is present in few strings ?
Home away from home
Home away from home


See User information
@kas1e

You basically just try to open an overlay window. Use the P96PIP_ErrorCode tag to get more information about why it failed.

struct Window *pipWindow;
  
LONG error 0;

  
pipWindow p96PIP_OpenTags (P96PIP_SourceFormatRGBFORMAT,     /* Pixel format of overlay */
                               
P96PIP_SourceWidth,  256,           /* Width of overlay surface */
                               
P96PIP_SourceHeight256,           /* Height of overlay surface */
                               
P96PIP_ErrorCode,    (LONG) &error,

                               
WA_Title,         "Overlay Window",
                               
WA_Activate,      TRUE,
                               
WA_RMBTrap,       TRUE,
                               
WA_DragBar,       TRUE,
                               
WA_DepthGadget,   TRUE,
                               
WA_SimpleRefreshTRUE,
                               
WA_SizeGadget,    TRUE,
                               
WA_CloseGadget,   TRUE,
                               
WA_IDCMP,         IDCMP_CLOSEWINDOW,

                               
WA_Width,         400,
                               
WA_Height,        400,

                               
WA_PubScreenName"Workbench",
                               
TAG_DONE);

  if (
pipWindow)
  {
    
// Yay, we have overlay!
  
}
  else
  {
    switch (
error)
    {
      case 
PIPERR_NOMEMORY:
        
printf("PIPERR_NOMEMORY\n");
        break; 
/* couldn't get normal memory */
      
case PIPERR_ATTACHFAIL:
        
printf("PIPERR_ATTACHFAIL\n");
        break; 
/* Failed to attach to a screen */
      
case PIPERR_NOTAVAILABLE:
        
printf("PIPERR_NOTAVAILABLE\n");
        break; 
/* PIP not available for other reason   */
      
case PIPERR_OUTOFPENS:
        
printf("PIPERR_OUTOFPENS\n");
        break; 
/* couldn't get a free pen for occlusion */
      
case PIPERR_BADDIMENSIONS:
        
printf("PIPERR_BADDIMENSIONS\n");
        break; 
/* type, width, height or format invalid */
      
case PIPERR_NOWINDOW:
        
printf("PIPERR_NOWINDOW\n");
        break; 
/* couldn't open window */
      
case PIPERR_BADALIGNMENT:
        
printf("PIPERR_BADALIGNMENT\n");
        break; 
/* specified alignment is not ok */
      
case PIPERR_CROPPED:
        
printf("PIPERR_CROPPED\n");
        break;
    }


Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
Go to top
Re: how to detect if overlay is present in few strings ?
Home away from home
Home away from home


See User information
@Hans
Thanks !

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: how to detect if overlay is present in few strings ?
Just popping in
Just popping in


See User information
@kas1e

Perhaps you should set WA_Activate to FALSE and WA_Hidden to TRUE to avoid that the window becomes visible and takes away the focus of another active window if the function is just there to check if overlay is possible at all.

Go to top
Re: how to detect if overlay is present in few strings ?
Home away from home
Home away from home


See User information
@Thore
Yep, added

@All
Do test case based on Hans's code and something weird happens. Test case are:

// compile: gcc test.c -lauto

#define __USE_INLINE__ 
#include <stdio.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/Picasso96API.h>
#include <libraries/Picasso96.h>

int main()
{
  
struct Window *pipWindow
  
LONG error 0

  if (!(
P96Base OpenLibrary(P96NAME,2)))
  {
     
quit();
  }
  
  if (!(
IP96 = (struct P96IFace *)GetInterface(P96Base,"main",1,NULL)))
  {
     
quit();
  }   

  
pipWindow p96PIP_OpenTags (P96PIP_SourceFormatRGBFB_YUV422CGX,   /* Pixel format of overlay */ 
                               
P96PIP_SourceWidth,  256,           /* Width of overlay surface */ 
                               
P96PIP_SourceHeight256,           /* Height of overlay surface */ 
                               
P96PIP_ErrorCode,    (LONG) &error

                               
WA_Title,         "Overlay Window"
                               
WA_Activate,      FALSE
                               
WA_Hidden,        TRUE,
                               
                               
WA_Width,         400
                               
WA_Height,        400
                               
                               
WA_PubScreenName"Workbench",
                               
                               
TAG_DONE); 

  if (
pipWindow
  {     
     
printf("Yeah, we have overlay!\n");
     
CloseWindow(pipWindow);
     
quit();
  } 
  
  else 
  { 
    switch (
error
    { 
      case 
PIPERR_NOMEMORY
        
printf("PIPERR_NOMEMORYn"); 
        break; 
/* couldn't get normal memory */ 
      
case PIPERR_ATTACHFAIL
        
printf("PIPERR_ATTACHFAILn"); 
        break; 
/* Failed to attach to a screen */ 
      
case PIPERR_NOTAVAILABLE
        
printf("PIPERR_NOTAVAILABLEn"); 
        break; 
/* PIP not available for other reason   */ 
      
case PIPERR_OUTOFPENS
        
printf("PIPERR_OUTOFPENSn"); 
        break; 
/* couldn't get a free pen for occlusion */ 
      
case PIPERR_BADDIMENSIONS
        
printf("PIPERR_BADDIMENSIONSn"); 
        break; 
/* type, width, height or format invalid */ 
      
case PIPERR_NOWINDOW
        
printf("PIPERR_NOWINDOWn"); 
        break; 
/* couldn't open window */ 
      
case PIPERR_BADALIGNMENT
        
printf("PIPERR_BADALIGNMENTn"); 
        break; 
/* specified alignment is not ok */ 
      
case PIPERR_CROPPED
        
printf("PIPERR_CROPPEDn"); 
        break; 
    }
  }
  
}


int quit()
{  
  if (
P96Base) {
     
DropInterface((struct Interface*)IP96);
     
CloseLibrary(P96Base);
     
P96Base NULL;  
  }
  
  return 
0;
}


Once i run it first time, i have "yeah, we have overlay!", but if i just run it second (or third, or does not matter how many times since first run) i have "PIERR_NOTAVAILABLE". If i reboot, and run it again, then first run all is fine, and all other ones again the same.

Did i miss something obvious there ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: how to detect if overlay is present in few strings ?
Just popping in
Just popping in


See User information
@kas1e

You can one overlay window at most only. Thus you must close the (invisible) window again after a successful check.

Go to top
Re: how to detect if overlay is present in few strings ?
Home away from home
Home away from home


See User information
@Thore
Right :) Just was in hope CloseWindow(pipWindow) will deal with p96_pip one as well. Replaced with p96_Close(pipWindow) and all works now. Thanks for tip!

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project