当前位置: 首页>>代码示例>>C++>>正文


C++ sio_open函数代码示例

本文整理汇总了C++中sio_open函数的典型用法代码示例。如果您正苦于以下问题:C++ sio_open函数的具体用法?C++ sio_open怎么用?C++ sio_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sio_open函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init_netifs

static void
init_netifs(void)
{
#if PPP_SUPPORT
  pppInit();
#if PPP_PTY_TEST
  ppp_sio = sio_open(2);
#else
  ppp_sio = sio_open(0);
#endif
  if(!ppp_sio)
  {
      perror("Error opening device: ");
      exit(1);
  }

#ifdef LWIP_PPP_CHAP_TEST
  pppSetAuth(PPPAUTHTYPE_CHAP, "lwip", "mysecret");
#endif

  pppOpen(ppp_sio, pppLinkStatusCallback, NULL);
#endif /* PPP_SUPPORT */
  
#if LWIP_DHCP
  {
    IP4_ADDR(&gw, 0,0,0,0);
    IP4_ADDR(&ipaddr, 0,0,0,0);
    IP4_ADDR(&netmask, 0,0,0,0);

    netif_add(&netif, &ipaddr, &netmask, &gw, NULL, tapif_init,
              tcpip_input);
    netif_set_default(&netif);
    dhcp_start(&netif);
  }
#else
  
  netif_set_default(netif_add(&netif,&ipaddr, &netmask, &gw, NULL, tapif_init,
                  tcpip_input));
  netif_set_up(&netif);

#endif

#if 0
  /* Only used for testing purposes: */
  netif_add(&ipaddr, &netmask, &gw, NULL, pcapif_init, tcpip_input);
#endif
  
#if LWIP_TCP  
  //tcpecho_init();
  //shell_init();
  httpd_init();
#endif
#if LWIP_UDP  
  //udpecho_init();
#endif  
  /*  sys_timeout(5000, tcp_debug_timeout, NULL);*/
}
开发者ID:carriercomm,项目名称:LWIPDPDK,代码行数:57,代码来源:simhost.c

示例2: open_audio

unsigned long open_audio(unsigned long f, int s)
   {
	struct sio_par par;
	int buf_max;

	hdl = sio_open(NULL, SIO_PLAY, 0);
	if (hdl == NULL)
		end_all("Error opening audio device");

	realpos = 0;
	sio_onmove(hdl, movecb, NULL);

	sio_initpar(&par);
	if (f)
		par.rate = f;
	par.pchan = 2;
	if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) || !sio_start(hdl) ||
	    (par.bits != 8 && par.bits != 16) || par.pchan > 2)
		end_all("Sorry, no audio format supported by this binary is available");

	buf_max = par.appbufsz * par.bps * par.pchan;
	current_freq = par.rate;
	stereo = par.pchan == 2 ? 1 : 0;

	dsp_samplesize = par.bits;
	dsize = par.bps;
	buffer = malloc(buf_max);
	buffer16 = (short *)buffer;

	idx = 0;
	samples_max = buf_max / dsize / par.pchan;
	set_watched_scalar(FREQUENCY, current_freq);
	total = 0;
	return current_freq;
   }
开发者ID:Bluerise,项目名称:bitrig-ports,代码行数:35,代码来源:audio.c

示例3: Initialize

bool CAESinkSNDIO::Initialize(AEAudioFormat &format, std::string &device)
{
  if ((m_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0)) == nullptr)
  {
    CLog::Log(LOGERROR, "CAESinkSNDIO::Initialize - Failed to open device");
    return false;
  }

  AudioFormatToPar(format);
  if (!sio_setpar(m_hdl, &m_par) ||
      !sio_getpar(m_hdl, &m_par) ||
      !ParToAudioFormat(format))
  {
    CLog::Log(LOGERROR, "CAESinkSNDIO::Initialize - could not negotiate parameters");
    return false;
  }

  m_played = m_written = 0;

  sio_onmove(m_hdl, CAESinkSNDIO::OnmoveCb, this);

  if (!sio_start(m_hdl))
  {
    CLog::Log(LOGERROR, "CAESinkSNDIO::Initialize - sio_start failed");
    return false;
  }

  return true;
}
开发者ID:anaconda,项目名称:xbmc,代码行数:29,代码来源:AESinkSNDIO.cpp

示例4: sndio_open_playback

static ALCenum sndio_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
    sndio_data *data;

    if(!deviceName)
        deviceName = sndio_device;
    else if(strcmp(deviceName, sndio_device) != 0)
        return ALC_INVALID_VALUE;

    data = calloc(1, sizeof(*data));
    data->killNow = 0;

    data->sndHandle = sio_open(NULL, SIO_PLAY, 0);
    if(data->sndHandle == NULL)
    {
        free(data);
        ERR("Could not open device\n");
        return ALC_INVALID_VALUE;
    }

    device->DeviceName = strdup(deviceName);
    device->ExtraData = data;

    return ALC_NO_ERROR;
}
开发者ID:BitPuffin,项目名称:NeoEditor,代码行数:25,代码来源:sndio.c

示例5: slipif_init

/**
 * SLIP netif initialization
 *
 * Call the arch specific sio_open and remember
 * the opened device in the state field of the netif.
 *
 * @param netif the lwip network interface structure for this slipif
 * @return ERR_OK if serial line could be opened,
 *         ERR_IF is serial line couldn't be opened
 *
 * @note netif->num must contain the number of the serial port to open
 *       (0 by default)
 */
err_t
slipif_init(struct netif *netif)
{

  LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)netif->num));

  netif->name[0] = 's';
  netif->name[1] = 'l';
  netif->output = slipif_output;
  netif->mtu = MAX_SIZE;
  netif->flags = NETIF_FLAG_POINTTOPOINT;

  /* Try to open the serial port (netif->num contains the port number). */
  netif->state = sio_open(netif->num);
  if (!netif->state) {
    /* Opening the serial port failed. */
    return ERR_IF;
  }

  /* initialize the snmp variables and counters inside the struct netif
   * ifSpeed: no assumption can be made without knowing more about the
   * serial line!
   */
  NETIF_INIT_SNMP(netif, snmp_ifType_slip, 0);

  /* Create a thread to poll the serial line. */
  sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop, netif, SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO);
  return ERR_OK;
}
开发者ID:EnricoGiordano1992,项目名称:Tesi,代码行数:42,代码来源:slipif.c

示例6: audio_open

static int
audio_open(void)
{
 hdl = sio_open(NULL, SIO_PLAY, 0);
 if (hdl == NULL)
  {
   fprintf(stderr, "sio_open failed\n");
   return 0;
  }
 return 1;
}
开发者ID:Bluerise,项目名称:bitrig-ports,代码行数:11,代码来源:openbsdplay.c

示例7: audioOpen

int
audioOpen()
{
	hdl = sio_open(NULL, SIO_PLAY, 0);
	if (hdl == NULL) {
		fprintf(stderr, "unable to open audio device\n");
		return 0;
	}

	return true;
}
开发者ID:acamari,项目名称:openbsd-wip,代码行数:11,代码来源:audioIO_sndio.cpp

示例8: open_sndio_device

/* used to probe and to configure the device.  don't use sio_start() here. */
static int
open_sndio_device(int input)
{
	hdl = sio_open(NULL, (input ? SIO_REC : SIO_PLAY), 0);
	if (hdl == NULL) {
		uszprintf(allegro_error, ALLEGRO_ERROR_SIZE,
		    get_config_text("sio_opn failed"));
		return -1;
	}

	sio_initpar(&par);
	par.bits = (_sound_bits == 8) ? 8 : 16;
	par.sig = (_sound_bits == 8) ? 0 : 1;
	if (input)
		par.rchan = (_sound_stereo) ? 2 : 1;
	else
		par.pchan = (_sound_stereo) ? 2 : 1;
	par.rate = (_sound_freq > 0) ? _sound_freq : 48000;
	par.le = SIO_LE_NATIVE;
	/* allegro wants small blocks */
	par.round = 512;
	par.appbufsz = par.rate / 10;

	if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
	    (par.bits != 8 && par.bits != 16) ||
	    (par.bits == 8 && par.sig) ||
	    (par.bits == 16 && !par.sig) ||
	    (par.bits == 16 && par.le != SIO_LE_NATIVE) ||
	    (input && (par.rchan != 1 && par.rchan != 2)) ||
	    (!input && (par.pchan != 1 && par.pchan != 2))) {
		ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
		    get_config_text("could not set sndio parameters"));
		sio_close(hdl);
		return -1;
	}

	_sound_bits = par.bits;
	_sound_stereo = input ? par.rchan == 2 : par.pchan == 2;
	_sound_freq = par.rate;

	if (input) {
		sndio_rec_round = par.round; 
		sndio_rec_appbufsz = par.appbufsz;
		sndio_rec_bufsize = par.round * par.bps * par.rchan;
	} else {
		sndio_play_round = par.round;
		sndio_play_appbufsz = par.appbufsz;
		sndio_play_bufsize = sndio_play_round * par.bps * par.pchan;
	}
	sndio_signed = par.sig ? 1 : 0;

	return 0;
}
开发者ID:DragonFlyBSD,项目名称:DPorts,代码行数:54,代码来源:sndio.c

示例9: Audio_Available

static int Audio_Available(void)
{
	struct sio_hdl *this_hdl;
	int available = 0;

	if ( (this_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0)) != NULL ) {
		sio_close(this_hdl);
		available = 1;
	}

	return available;
}
开发者ID:Ptr-mat,项目名称:bitrig-ports,代码行数:12,代码来源:SDL_sndioaudio.c

示例10: open_output

static int open_output(void)
{
  static struct sio_par par, newpar;

  sndio_ctx = sio_open(NULL, SIO_PLAY, 0);
  if (sndio_ctx == NULL) {
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_open() failed");
    return -1;
  }

  sio_initpar(&par);

  par.sig = 1;
  par.pchan = (dpm.encoding & PE_MONO) ? 1 : 2;
  par.le = SIO_LE_NATIVE;
  par.rate = dpm.rate;
  if (dpm.encoding & PE_24BIT) {
    par.bits = 24;
    par.bps = 3;
  } else if (dpm.encoding & PE_16BIT) {
    par.bits = 16;
    par.bps = 2;
  } else {
    par.bits = 8;
    par.bps = 1;
  }

  if (!sio_setpar(sndio_ctx, &par)) {
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_setpar() failed");
    return -1;
  }

  if (sio_getpar(sndio_ctx, &newpar) == 0) {
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_getpar() failed");
    return -1;
  }
  if (newpar.sig != par.sig ||
      newpar.le != par.le ||
      newpar.pchan != par.pchan ||
      newpar.bits != par.bits ||
      newpar.bps != par.bps ||
      newpar.rate * 1000 > par.rate * 1005 ||
      newpar.rate * 1000 < par.rate *  995) {
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "couldn't set output play parameters");
    return -1;
  }

  if (!sio_start(sndio_ctx)) {
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_start() failed");
    return -1;
  }
  return 0;
}
开发者ID:Bluerise,项目名称:bitrig-ports,代码行数:53,代码来源:sndio_a.c

示例11: ai_sndio_init

int ai_sndio_init(audio_in_t *ai)
{
    int err;

    if ((ai->sndio.hdl = sio_open(ai->sndio.device, SIO_REC, 0)) == NULL) {
	mp_msg(MSGT_TV, MSGL_ERR, "could not open sndio audio");
	return -1;
    }

    err = ai_sndio_setup(ai);

    return err;
}
开发者ID:avsm,项目名称:openbsd-ports,代码行数:13,代码来源:ai_sndio.c

示例12: sndio_play

static void
sndio_play (int argc, char *argv [])
{	struct sio_hdl	*hdl ;
	struct sio_par	par ;
	short	 	buffer [BUFFER_LEN] ;
	SNDFILE	*sndfile ;
	SF_INFO	sfinfo ;
	int		k, readcount ;

	for (k = 1 ; k < argc ; k++)
	{	printf ("Playing %s\n", argv [k]) ;
		if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
		{	puts (sf_strerror (NULL)) ;
			continue ;
			} ;

		if (sfinfo.channels < 1 || sfinfo.channels > 2)
		{	printf ("Error : channels = %d.\n", sfinfo.channels) ;
			continue ;
			} ;

		if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL)
		{	fprintf (stderr, "open sndio device failed") ;
			return ;
			} ;

		sio_initpar (&par) ;
		par.rate = sfinfo.samplerate ;
		par.pchan = sfinfo.channels ;
		par.bits = 16 ;
		par.sig = 1 ;
		par.le = SIO_LE_NATIVE ;

		if (! sio_setpar (hdl, &par) || ! sio_getpar (hdl, &par))
		{	fprintf (stderr, "set sndio params failed") ;
			return ;
			} ;

		if (! sio_start (hdl))
		{	fprintf (stderr, "sndio start failed") ;
			return ;
			} ;

		while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
			sio_write (hdl, buffer, readcount * sizeof (short)) ;

		sio_close (hdl) ;
		} ;

	return ;
} /* sndio_play */
开发者ID:5in4,项目名称:libsox.dll,代码行数:51,代码来源:sndfile-play.c

示例13: swfdec_playback_stream_open

static void
swfdec_playback_stream_open (SwfdecPlayback *sound, SwfdecAudio *audio)
{
  Stream *stream;
  struct sio_hdl *hdl;
  struct sio_par par;

  hdl = sio_open (NULL, SIO_PLAY, 0);
  if (hdl == NULL) {
    g_printerr ("Could not open sndio\n");
    return;
  }

  sio_initpar (&par);

  par.bits = 16;
  par.sig = 1;
  par.pchan = 2;
  par.rate = 44100;
  par.appbufsz = 8192;

  if (!sio_setpar (hdl, &par)) {
    g_printerr ("\n\nCould not set sndio hardware parameters\n");
    goto fail;
  }
  if (!sio_getpar (hdl, &par)) {
    g_printerr ("\n\nCould not get sndio hardware parameters\n");
    goto fail;
  }

  stream = g_new0 (Stream, 1);
  stream->write = try_write;
  stream->sound = sound;
  stream->audio = g_object_ref (audio);
  stream->hdl = hdl;
  stream->par = par;
  sound->streams = g_list_prepend (sound->streams, stream);

  sio_onmove (hdl, sndio_movecb, stream);
  stream->f_written = stream->f_played = 0;

  g_signal_connect (stream->audio, "changed", 
      G_CALLBACK (swfdec_playback_stream_changed), stream);
  g_signal_connect (stream->audio, "new-data", 
      G_CALLBACK (swfdec_playback_stream_new_data), stream);
  swfdec_playback_stream_start (stream);
  return;

fail:
  sio_close (hdl);
}
开发者ID:aharri,项目名称:ports,代码行数:51,代码来源:swfdec_playback_sndio.c

示例14: Open

//---------------------------------------------------------------------------
bool __fastcall CSerialPort::Open(int nPort,int nBaudRate,int nMode)
{
        m_nPortNo=nPort;
  if(sio_open(nPort)!=SIO_OK)
    return false;

  //if(sio_ioctl(nPort,B9600,BIT_8|STOP_1|P_NONE)!=SIO_OK)
        if( sio_ioctl(nPort,nBaudRate,nMode) != SIO_OK )
                return false;

  //sio_SetReadTimeouts(nPort,MAXDWORD,2000);

	return true;
}
开发者ID:Raxtion,项目名称:CT74,代码行数:15,代码来源:SerialPort.cpp

示例15: slipif_init

/**
 * SLIP netif initialization
 *
 * Call the arch specific sio_open and remember
 * the opened device in the state field of the netif.
 *
 * @param netif the lwip network interface structure for this slipif
 * @return ERR_OK if serial line could be opened,
 *         ERR_MEM if no memory could be allocated,
 *         ERR_IF is serial line couldn't be opened
 *
 * @note netif->num must contain the number of the serial port to open
 *       (0 by default)
 */
err_t
slipif_init(struct netif *netif)
{
  struct slipif_priv *priv;

  LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)netif->num));

  /* Allocate private data */
  priv = mem_malloc(sizeof(struct slipif_priv));
  if (!priv) {
    return ERR_MEM;
  }

  netif->name[0] = 's';
  netif->name[1] = 'l';
  netif->output = slipif_output;
  netif->mtu = SLIP_MAX_SIZE;
  netif->flags |= NETIF_FLAG_POINTTOPOINT;

  /* Try to open the serial port (netif->num contains the port number). */
  priv->sd = sio_open(netif->num);
  if (!priv->sd) {
    /* Opening the serial port failed. */
    mem_free(priv);
    return ERR_IF;
  }

  /* Initialize private data */
  priv->p = NULL;
  priv->q = NULL;
  priv->state = SLIP_RECV_NORMAL;
  priv->i = 0;
  priv->recved = 0;

  netif->state = priv;

  /* initialize the snmp variables and counters inside the struct netif
   * ifSpeed: no assumption can be made without knowing more about the
   * serial line!
   */
  NETIF_INIT_SNMP(netif, snmp_ifType_slip, 0);

#if !NO_SYS
  /* Create a thread to poll the serial line. */
  sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop_thread, netif,
    SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO);
#endif
  return ERR_OK;
}
开发者ID:B-Rich,项目名称:NUL,代码行数:63,代码来源:slipif.c


注:本文中的sio_open函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。