SASC
DVBSoftCAM

cScDevices Class Reference

#include <device.h>

Inheritance diagram for cScDevices:

List of all members.

Public Member Functions

 cScDevices (void)
 cScDevices (void)

Static Public Member Functions

static void OnPluginLoad (void)
static void OnPluginUnload (void)
static bool Initialize (void)
static void Startup (void)
static void Shutdown (void)
static void SetForceBudget (int n)
static bool ForceBudget (int n)
static void DvbName (const char *Name, int a, int f, char *buffer, int len)
static int DvbOpen (const char *Name, int a, int f, int Mode, bool ReportError=false)
static void OnPluginLoad (void)
static void OnPluginUnload (void)
static bool Initialize (void)
static void Startup (void)
static void Shutdown (void)
static void SetForceBudget (int n)
static bool ForceBudget (int n)
static void DvbName (const char *Name, int a, int f, char *buffer, int len)
static int DvbOpen (const char *Name, int a, int f, int Mode, bool ReportError=false)

Detailed Description

Definition at line 69 of file device.h.


Constructor & Destructor Documentation

cScDevices::cScDevices ( void  ) [inline]

Definition at line 76 of file device.h.

:cDvbDevice(0) {}
cScDevices::cScDevices ( void  ) [inline]

Definition at line 76 of file device.h.

:cDvbDevice(0) {}

Member Function Documentation

void cScDevices::DvbName ( const char *  Name,
int  a,
int  f,
char *  buffer,
int  len 
) [static]

Definition at line 288 of file device.c.

References DEV_DVB_ADAPTER.

Referenced by DvbOpen(), and Initialize().

{
  snprintf(buffer,len,"%s%d/%s%d",DEV_DVB_ADAPTER,a,Name,f);
}
static void cScDevices::DvbName ( const char *  Name,
int  a,
int  f,
char *  buffer,
int  len 
) [static]
int cScDevices::DvbOpen ( const char *  Name,
int  a,
int  f,
int  Mode,
bool  ReportError = false 
) [static]

Definition at line 293 of file device.c.

References DvbName(), fd, LOG_ERROR_STR, and open().

Referenced by cScDvbDevicePlugin::Probe().

{
  char FileName[128];
  DvbName(Name,a,f,FileName,sizeof(FileName));
  int fd=open(FileName,Mode);
  if(fd<0 && ReportError) LOG_ERROR_STR(FileName);
  return fd;
}
static int cScDevices::DvbOpen ( const char *  Name,
int  a,
int  f,
int  Mode,
bool  ReportError = false 
) [static]
static bool cScDevices::ForceBudget ( int  n) [static]
bool cScDevices::ForceBudget ( int  n) [static]

Definition at line 417 of file device.c.

Referenced by SCDEVICE::LateInit().

{
   return budget && (budget&(1<<n));
}
bool cScDevices::Initialize ( void  ) [static]

Initializes the DVB devices. Must be called before accessing any DVB functions.

Returns:
True if any devices are available.

Reimplemented from cDvbDevice.

Definition at line 344 of file device.c.

References DEV_DVB_FRONTEND, DvbName(), cSimpleList< T >::First(), i, L_GEN_DEBUG, L_GEN_ERROR, L_GEN_INFO, MAXDVBDEVICES, cDevice::NextCardIndex(), cDevice::NumDevices(), open(), PRINTF, cScDevicePlugin::Probe(), cDevice::UseDevice(), vdr_save_ud, and vdr_ud.

{
#if APIVERSNUM >= 10711
  return true;
#else
  if(!vdr_nci || !vdr_ud) {
    PRINTF(L_GEN_ERROR,"Failed to locate VDR symbols. Plugin not operable");
    return false;
    }
  if(NumDevices()>0) {
    PRINTF(L_GEN_ERROR,"Number of devices != 0 on init. Put SC plugin first on VDR commandline! Aborting.");
    return false;
    }
  *vdr_nci=0; *vdr_ud=vdr_save_ud;

  int i, found=0;
  for(i=0; i<MAXDVBDEVICES; i++) {
    if(UseDevice(NextCardIndex())) {
      char name[128];
      cScDevices::DvbName(DEV_DVB_FRONTEND,i,0,name,sizeof(name));
      if(access(name,F_OK)==0) {
        PRINTF(L_GEN_DEBUG,"probing %s",name);
        int f=open(name,O_RDONLY);
        if(f>=0) {
          close(f);
          PRINTF(L_GEN_DEBUG,"capturing device %d",i);
          devplugins.First()->Probe(i,0,0);
          found++;
          }
        else {
          if(errno!=ENODEV && errno!=EINVAL) PRINTF(L_GEN_ERROR,"open %s failed: %s",name,strerror(errno));
          break;
          }
        }
      else {
        if(errno!=ENOENT) PRINTF(L_GEN_ERROR,"access %s failed: %s",name,strerror(errno));
        break;
        }
      }
    else NextCardIndex(1);
    }
  NextCardIndex(MAXDVBDEVICES-i);
  if(found>0) PRINTF(L_GEN_INFO,"captured %d video device%s",found,found>1 ? "s" : "");
  else PRINTF(L_GEN_INFO,"no DVB device captured");
  return found>0;
#endif
}
static bool cScDevices::Initialize ( void  ) [static]

Initializes the DVB devices. Must be called before accessing any DVB functions.

Returns:
True if any devices are available.

Reimplemented from cDvbDevice.

static void cScDevices::OnPluginLoad ( void  ) [static]
void cScDevices::OnPluginLoad ( void  ) [static]

Definition at line 308 of file device.c.

References dlsym(), L_GEN_DEBUG, PRINTF, vdr_save_ud, and vdr_ud.

Referenced by cScPlugin::cScPlugin().

{
#if APIVERSNUM >= 10711
  PRINTF(L_GEN_DEBUG,"using new 1.7.11+ capture code");
  cScDeviceProbe::Install();
#else
  PRINTF(L_GEN_DEBUG,"using old pre1.7.11 capture code");
/*
  This is an extremly ugly hack to access VDRs device scan parameters, which are
  protected in this context. Heavily dependant on the actual symbol names
  created by the compiler. May fail in any future version!

  To get the actual symbol names of your VDR binary you may use the command:
  objdump -T <path-to-vdr>/vdr | grep -E "(useDevice|nextCardIndex)"
  Insert the symbol names below.
*/
#if __GNUC__ >= 3
  vdr_nci=(int *)dlsym(RTLD_DEFAULT,"_ZN7cDevice13nextCardIndexE");
  vdr_ud =(int *)dlsym(RTLD_DEFAULT,"_ZN7cDevice9useDeviceE");
#else
  vdr_nci=(int *)dlsym(RTLD_DEFAULT,"_7cDevice.nextCardIndex");
  vdr_ud =(int *)dlsym(RTLD_DEFAULT,"_7cDevice.useDevice");
#endif
  if(vdr_nci && vdr_ud) { vdr_save_ud=*vdr_ud; *vdr_ud=1<<30; }
#endif
  // default device plugin must be last in the list
  new cScDvbDevicePlugin;
}
void cScDevices::OnPluginUnload ( void  ) [static]

Definition at line 337 of file device.c.

Referenced by cScPlugin::~cScPlugin().

{
#if APIVERSNUM >= 10711
  cScDeviceProbe::Remove();
#endif
}
static void cScDevices::OnPluginUnload ( void  ) [static]
static void cScDevices::SetForceBudget ( int  n) [static]
void cScDevices::SetForceBudget ( int  n) [static]

Definition at line 412 of file device.c.

References MAXDVBDEVICES.

Referenced by cScPlugin::ProcessArgs().

{
   if(n>=0 && n<MAXDVBDEVICES) budget|=(1<<n);
}
static void cScDevices::Shutdown ( void  ) [static]

Closes down all devices. Must be called at the end of the program.

Reimplemented from cDevice.

void cScDevices::Shutdown ( void  ) [static]

Closes down all devices. Must be called at the end of the program.

Reimplemented from cDevice.

Definition at line 403 of file device.c.

References cSimpleList< T >::First(), cDevice::GetDevice(), cSimpleList< T >::Next(), and cDevice::NumDevices().

Referenced by cScPlugin::Stop().

{
  for(int n=cDevice::NumDevices(); --n>=0;) {
    cDevice *dev=cDevice::GetDevice(n);
    for(cScDevicePlugin *dp=devplugins.First(); dp; dp=devplugins.Next(dp))
      if(dp->EarlyShutdown(dev)) break;
    }
}
void cScDevices::Startup ( void  ) [static]
static void cScDevices::Startup ( void  ) [static]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines