Beispiel #1
0
int main (int argc, char * argv [])

{
	extern char const * program_name;
	static char const * optv [] =
	{
		"example command line program",
		"[< stdin] [> stdout]",
		"",
		(char const *) (0)
	};
	signed c;
	optind = 1;
	opterr = 1;
	program_name = basename (* argv);
	while (~ (c = getopt (argc, argv, optv [2])))
	{
		switch (c)
		{
		default: 
			break;
		}
	}
	argc -= optind;
	argv += optind;
	while (~ (c = CMDRead ()))
	{
		TREE * node = CMDLine ();
		CMDTree (node);
		CMDFree (node);
	}
	return (0);
}
Beispiel #2
0
bool SndSysDriverOSS::Initialize (iObjectRegistry *obj_reg)
{
  /// Interface to the Configuration file
  csConfigAccess Config;

  // copy the system pointer
  m_pObjectRegistry=obj_reg;

  // Get an interface for event recorder (if present)
  m_EventRecorder = csQueryRegistry<iSndSysEventRecorder> (m_pObjectRegistry);

  // Critical because you really want to log this.  Trust me.  Really.
  RecordEvent(SSEL_CRITICAL, "OSS sound driver for software sound renderer initialized.");

  // read the config file
  Config.AddConfig(m_pObjectRegistry, "/config/sound.cfg");

  // check for optional output device name from the commandline
  csRef<iCommandLineParser> CMDLine (
    csQueryRegistry<iCommandLineParser> (m_pObjectRegistry));
  const char *OutputDeviceName = CMDLine->GetOption ("ossdevice");
  if (!OutputDeviceName)
    OutputDeviceName = Config->GetStr("SndSys.Driver.OSS.Device", "/dev/dsp");

  strcpy(m_OutputDeviceName, OutputDeviceName);


  // The 'buffer length' here is not a real buffer allocation, but
  //  is instead the maximum amount of data we will send ahead to OSS.
  m_BufferLengthms=0;
  if (CMDLine)
  {
    const char *BufferLengthStr = CMDLine->GetOption("soundbufferms");
    if (BufferLengthStr) m_BufferLengthms=atoi(BufferLengthStr);
  }

  // Check for sound config file option. Default to 20 ms if no option is found.
  if (m_BufferLengthms<=0)
    m_BufferLengthms = Config->GetInt("SndSys.Driver.OSS.SoundBufferms", 20);

  // The number of underbuffer events before the buffer size is automatically increased
  m_UnderBuffersAllowed=5;

  return true;
}