• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ slock_new函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: rarch_main_data_thread_init

static void rarch_main_data_thread_init(void)
{
   data_runloop_t *runloop  = rarch_main_data_get_ptr();

   if (!runloop)
      return;

   runloop->lock            = slock_new();
   runloop->cond_lock       = slock_new();
   runloop->cond            = scond_new();

#ifdef HAVE_OVERLAY
   rarch_main_data_overlay_thread_init();
#endif

   runloop->thread    = sthread_create(data_thread_loop, runloop);

   if (!runloop->thread)
      goto error;

   slock_lock(runloop->lock);
   runloop->thread_inited   = true;
   runloop->alive           = true;
   runloop->thread_code     = THREAD_CODE_ALIVE;
   slock_unlock(runloop->lock);

   return;

error:
   data_runloop_thread_deinit(runloop);
}
开发者ID:aldatsa,项目名称:RetroArch,代码行数:31,代码来源:runloop_data.c


示例2: thread_init

static bool thread_init(thread_video_t *thr, const video_info_t *info, const input_driver_t **input,
                        void **input_data)
{
    thr->lock = slock_new();
    thr->frame.lock = slock_new();
    thr->cond_cmd = scond_new();
    thr->cond_thread = scond_new();
    thr->input = input;
    thr->input_data = input_data;
    thr->info = *info;
    thr->alive = true;
    thr->focus = true;

    size_t max_size = info->input_scale * RARCH_SCALE_BASE;
    max_size *= max_size;
    max_size *= info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
    thr->frame.buffer = (uint8_t*)malloc(max_size);
    if (!thr->frame.buffer)
        return false;

    memset(thr->frame.buffer, 0x80, max_size);

    thr->target_frame_time = (rarch_time_t)roundf(1000000LL / g_settings.video.refresh_rate);
    thr->last_time = rarch_get_time_usec();

    thr->thread = sthread_create(thread_loop, thr);
    if (!thr->thread)
        return false;
    thread_send_cmd(thr, CMD_INIT);
    thread_wait_reply(thr, CMD_INIT);

    return thr->cmd_data.b;
}
开发者ID:CatalystG,项目名称:RetroArch,代码行数:33,代码来源:thread_wrapper.c


示例3: rarch_main_data_thread_init

static void rarch_main_data_thread_init(void)
{
   g_data_runloop.lock            = slock_new();
   g_data_runloop.cond_lock       = slock_new();
   g_data_runloop.cond            = scond_new();

#ifdef HAVE_OVERLAY
   rarch_main_data_overlay_thread_init();
#endif

   g_data_runloop.thread    = sthread_create(data_thread_loop, &g_data_runloop);

   if (!g_data_runloop.thread)
      goto error;

   slock_lock(g_data_runloop.lock);
   g_data_runloop.thread_inited   = true;
   g_data_runloop.alive           = true;
   g_data_runloop.thread_code     = THREAD_CODE_ALIVE;
   slock_unlock(g_data_runloop.lock);

   return;

error:
   data_runloop_thread_deinit();
}
开发者ID:brianblakely,项目名称:RetroArch,代码行数:26,代码来源:runloop_data.c


示例4: sizeof

autosave_t *autosave_new(const char *path, const void *data, size_t size, unsigned interval)
{
    autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
    if (!handle)
        return NULL;

    handle->bufsize = size;
    handle->interval = interval;
    handle->path = path;
    handle->buffer = malloc(size);
    handle->snes_buffer = data;

    if (!handle->buffer)
    {
        free(handle);
        return NULL;
    }
    memcpy(handle->buffer, handle->snes_buffer, handle->bufsize);

    handle->lock = slock_new();
    handle->cond_lock = slock_new();
    handle->cond = scond_new();

    handle->thread = sthread_create(autosave_thread, handle);

    return handle;
}
开发者ID:magicseb,项目名称:RetroArch,代码行数:27,代码来源:autosave.c


示例5: retro_task_threaded_init

static void retro_task_threaded_init(void)
{
   running_lock  = slock_new();
   finished_lock = slock_new();
   worker_cond   = scond_new();

   slock_lock(running_lock);
   worker_continue = true;
   slock_unlock(running_lock);

   worker_thread = sthread_create(threaded_worker, NULL);
}
开发者ID:Ezio-PS,项目名称:RetroArch,代码行数:12,代码来源:task_queue.c


示例6: dispmanx_surface_setup

static void dispmanx_surface_setup(void *data, int width, int height, int pitch, float aspect,
   struct dispmanx_surface *surface)
{
   struct dispmanx_video *_dispvars = data;
   int i, dst_width, dst_height, dst_xpos, dst_ypos;

   /* Allocate memory for all the pages in each surface
    * and initialize variables inside each page's struct. */
   surface->pages = calloc(surface->numpages, sizeof(struct dispmanx_page));
   for (i = 0; i < surface->numpages; i++) {
      surface->pages[i].used = false;   
      surface->pages[i].dispvars = _dispvars;   
      surface->pages[i].page_used_mutex = slock_new(); 
   }

   /* Internal frame dimensions. Pitch is total pitch including info 
    * between scanlines */
   surface->width = width;
   surface->height = height;
   surface->pitch = pitch;
   surface->aspect = aspect;  
 
   /* The "visible" width obtained from the core pitch. We blit based on 
    * the "visible" width, for cores with things between scanlines. */
   int visible_width = pitch / surface->bpp;
 
   dst_width  = _dispvars->dispmanx_height * aspect;	
   dst_height = _dispvars->dispmanx_height;
   
   /* If we obtain a scaled image width that is bigger than the physical screen width,
   * then we keep the physical screen width as our maximun width. */
   if (dst_width > _dispvars->dispmanx_width) 
      dst_width = _dispvars->dispmanx_width;
   
   dst_xpos = (_dispvars->dispmanx_width - dst_width) / 2;
   dst_ypos = (_dispvars->dispmanx_height - dst_height) / 2;

   /* We configure the rects now. */
   vc_dispmanx_rect_set(&surface->dst_rect, dst_xpos, dst_ypos, dst_width, dst_height);
   vc_dispmanx_rect_set(&surface->bmp_rect, 0, 0, width, height);	
   vc_dispmanx_rect_set(&surface->src_rect, 0, 0, width << 16, height << 16);	

   for (i = 0; i < surface->numpages; i++) {
      surface->pages[i].resource = 
         vc_dispmanx_resource_create(surface->pixformat, 
	 visible_width, height, &(_dispvars->vc_image_ptr));
   }
   /* Add element. */
   _dispvars->update = vc_dispmanx_update_start(0);

   surface->element = vc_dispmanx_element_add(
      _dispvars->update,_dispvars->display, surface->layer, 
      &surface->dst_rect, surface->pages[0].resource, 
      &surface->src_rect, DISPMANX_PROTECTION_NONE,
      &surface->alpha, 0, (DISPMANX_TRANSFORM_T)0);

   vc_dispmanx_update_submit_sync(_dispvars->update);		

   surface->setup = true;
}
开发者ID:luiseduardohdbackup,项目名称:RetroArch,代码行数:60,代码来源:dispmanx_gfx.c


示例7: sizeof

async_job_t *async_job_new(void)
{
   async_job_t *ajob = (async_job_t*)calloc(1, sizeof(*ajob));
   
   if (!ajob)
      return NULL;

   ajob->lock   = slock_new();

   if (!ajob->lock)
      goto error;

   ajob->sem = ssem_new(0);

   if (!ajob->sem)
      goto error;

   ajob->thread = sthread_create(async_job_processor, (void*)ajob);

   if (!ajob->thread)
      goto error;

   return ajob;

error:
   if (ajob->lock)
      slock_free(ajob->lock);
   ajob->lock = NULL;
   if (ajob->sem)
      ssem_free(ajob->sem);
   if (ajob)
      free((void*)ajob);
   return NULL;
}
开发者ID:Kivutar,项目名称:RetroArch,代码行数:34,代码来源:async_job.c


示例8: sizeof

ssem_t *ssem_new(int value)
{
   ssem_t *semaphore = (ssem_t*)calloc(1, sizeof(*semaphore));

   if (!semaphore)
      goto error;
   
   semaphore->value   = value;
   semaphore->wakeups = 0;
   semaphore->mutex   = slock_new();

   if (!semaphore->mutex)
      goto error;

   semaphore->cond = scond_new();

   if (!semaphore->cond)
      goto error;

   return semaphore;

error:
   if (semaphore->mutex)
      slock_free(semaphore->mutex);
   semaphore->mutex = NULL;
   if (semaphore)
      free((void*)semaphore);
   return NULL;
}
开发者ID:Kivutar,项目名称:RetroArch,代码行数:29,代码来源:rsemaphore.c


示例9: calloc

static void *drm_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   struct drm_video *_drmvars = (struct drm_video*)
      calloc(1, sizeof(struct drm_video));
   if (!_drmvars)
      return NULL;

   /* Setup surface parameters */
   _drmvars->menu_active      = false;
   _drmvars->rgb32            = video->rgb32; 

   /* It's very important that we set aspect here because the 
    * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame()
    * and we don't want the main surface to be setup in set_aspect() 
    * before we get to gfx_frame(). */
   _drmvars->current_aspect = video_driver_get_aspect_ratio();

   /* Initialize the rest of the mutexes and conditions. */
   _drmvars->vsync_condition  = scond_new();
   _drmvars->vsync_cond_mutex = slock_new();
   _drmvars->pending_mutex    = slock_new();
   _drmvars->core_width       = 0;
   _drmvars->core_height      = 0;

   _drmvars->main_surface     = NULL;
   _drmvars->menu_surface     = NULL;

   if (input && input_data)
      *input = NULL;

   /* DRM Init */
   if (!init_drm())
   {
      RARCH_ERR ("DRM: Failed to initialize DRM\n");
      return NULL;
   }
   else
      RARCH_LOG ("DRM: Init succesful.\n");

   _drmvars->kms_width  = drm.current_mode->hdisplay;  
   _drmvars->kms_height = drm.current_mode->vdisplay;  
 
   return _drmvars;
}
开发者ID:IlDucci,项目名称:RetroArch,代码行数:45,代码来源:drm_gfx.c


示例10: drm_surface_setup

static void drm_surface_setup(void *data,  int src_width, int src_height, 
      int pitch, int bpp, uint32_t pixformat,
      int alpha, float aspect, int numpages, int layer, 
      struct drm_surface **sp)
{
   struct drm_video *_drmvars = data;
   int i;
   struct drm_surface *surface = NULL;

   *sp = calloc (1, sizeof(struct drm_surface));

   surface = *sp;   

   /* Setup surface parameters */
   surface->numpages = numpages;
   /* We receive the total pitch, including things that are 
    * between scanlines and we calculate the visible pitch 
    * from the visible width. 
    *
    * These will be used to increase the offsets for blitting. */
   surface->total_pitch = pitch;
   surface->pitch       = src_width * bpp; 
   surface->bpp         = bpp;
   surface->pixformat   = pixformat;
   surface->src_width   = src_width;
   surface->src_height  = src_height;
   surface->aspect      = aspect;
   
   /* Allocate memory for all the pages in each surface
    * and initialize variables inside each page's struct. */
   surface->pages = (struct drm_page*)
      calloc(surface->numpages, sizeof(struct drm_page));

   for (i = 0; i < surface->numpages; i++)
   {
      surface->pages[i].used            = false;   
      surface->pages[i].surface         = surface;   
      surface->pages[i].drmvars         = _drmvars;   
      surface->pages[i].page_used_mutex = slock_new(); 
   }

   /* Create the framebuffer for each one of the pages of the surface. */
   for (i = 0; i < surface->numpages; i++)
   {
      surface->pages[i].buf.width  = src_width;
      surface->pages[i].buf.height = src_height;
      int ret                      = modeset_create_dumbfb(
            drm.fd, &surface->pages[i].buf, bpp, pixformat);	

      if (ret)
      {
         RARCH_ERR ("DRM: can't create fb\n");
      }
   }

   surface->flip_page = 0;
}
开发者ID:IlDucci,项目名称:RetroArch,代码行数:57,代码来源:drm_gfx.c


示例11: calloc

static void *sunxi_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   struct sunxi_video *_dispvars = (struct sunxi_video*)
      calloc(1, sizeof(struct sunxi_video));

   if (!_dispvars)
      return NULL;

   _dispvars->src_bytes_per_pixel = video->rgb32 ? 4 : 2;
   _dispvars->sunxi_disp          = sunxi_disp_init("/dev/fb0");

   /* Blank text console and disable cursor blinking. */
   sunxi_blank_console(_dispvars);

   _dispvars->pages = (struct sunxi_page*)calloc(NUMPAGES, sizeof (struct sunxi_page));

   if (!_dispvars->pages)
      goto error;

   _dispvars->dst_pitch           = _dispvars->sunxi_disp->xres * _dispvars->sunxi_disp->bits_per_pixel / 8;
   /* Considering 4 bytes per pixel since we will be in 32bpp on the CB/CB2/CT for hw scalers to work. */
   _dispvars->dst_pixels_per_line = _dispvars->dst_pitch / 4;
   _dispvars->pageflip_pending    = false;
   _dispvars->nextPage            = &_dispvars->pages[0];
   _dispvars->keep_vsync          = true;
   _dispvars->menu_active         = false;
   _dispvars->bytes_per_pixel     = video->rgb32 ? 4 : 2;

   switch (_dispvars->bytes_per_pixel)
   {
      case 2:
         pixman_blit = pixman_composite_src_0565_8888_asm_neon;
         break;
      case 4:
         pixman_blit = pixman_composite_src_8888_8888_asm_neon;
         break;
      default:
         goto error;
   }

   _dispvars->pending_mutex    = slock_new();
   _dispvars->vsync_condition  = scond_new();

   if (input && input_data)
      *input = NULL;

   /* Launching vsync thread */
   _dispvars->vsync_thread     = sthread_create(sunxi_vsync_thread_func, _dispvars);

   return _dispvars;

error:
   if (_dispvars)
      free(_dispvars);
   return NULL;
}
开发者ID:luiseduardohdbackup,项目名称:RetroArch,代码行数:57,代码来源:sunxi_gfx.c


示例12: calloc

static void *dispmanx_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
	int i; 
	struct dispmanx_video *_dispvars = calloc(1, sizeof(struct dispmanx_video));

   if (!_dispvars)
      return NULL;

	_dispvars->bytes_per_pixel  = video->rgb32 ? 4 : 2;
	_dispvars->screen           = 0;
	_dispvars->vcImagePtr       = 0;
	_dispvars->pageflip_pending = 0;	
	_dispvars->currentPage      = NULL;
	_dispvars->pages            = calloc(NUMPAGES, sizeof(struct dispmanx_page));

   if (!_dispvars->pages)
   {
      free(_dispvars);
      return NULL;
   }

	for (i = 0; i < NUMPAGES; i++)
   {
		_dispvars->pages[i].numpage         = i;
		_dispvars->pages[i].used            = false;
		_dispvars->pages[i].dispvars        = _dispvars;
		_dispvars->pages[i].page_used_mutex = slock_new(); 
	}

	/* Initialize the rest of the mutexes and conditions. */
	_dispvars->vsync_condition  = scond_new();
	_dispvars->pending_mutex    = slock_new();
	_dispvars->vsync_cond_mutex = slock_new(); 

	bcm_host_init();

	_dispvars->display = vc_dispmanx_display_open(_dispvars->screen);

	if (input && input_data)
		*input = NULL;

	return _dispvars;
}
开发者ID:CautiousAlbino,项目名称:RetroArch,代码行数:44,代码来源:dispmanx_gfx.c


示例13: thread_init

static bool thread_init(thread_video_t *thr, const video_info_t *info,
      const input_driver_t **input, void **input_data)
{
   size_t max_size;
   thread_packet_t pkt = {CMD_INIT};

   thr->lock                 = slock_new();
   thr->alpha_lock           = slock_new();
   thr->frame.lock           = slock_new();
   thr->cond_cmd             = scond_new();
   thr->cond_thread          = scond_new();
   thr->input                = input;
   thr->input_data           = input_data;
   thr->info                 = *info;
   thr->alive                = true;
   thr->focus                = true;
   thr->has_windowed         = true;
   thr->suppress_screensaver = true;

   max_size                  = info->input_scale * RARCH_SCALE_BASE;
   max_size                 *= max_size;
   max_size                 *= info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
   thr->frame.buffer        = (uint8_t*)malloc(max_size);

   if (!thr->frame.buffer)
      return false;

   memset(thr->frame.buffer, 0x80, max_size);

   thr->last_time       = rarch_get_time_usec();
   thr->thread          = sthread_create(thread_loop, thr);
   if (!thr->thread)
      return false;

   thread_send_and_wait(thr, &pkt);

/*   thr->send_cmd_func   = thread_send_cmd;   */
/*   thr->wait_reply_func = thread_wait_reply; */

   thr->send_and_wait = thread_send_and_wait;
   return pkt.data.b;
}
开发者ID:netux79,项目名称:RAvideoFixes,代码行数:42,代码来源:video_thread_wrapper.c


示例14: slock_new

Task::Impl::Impl()
{
	_isThreadRunning = false;
	workFunc = NULL;
	workFuncParam = NULL;
	ret = NULL;
	exitThread = false;

	mutex = slock_new();
   condWork = scond_new();
}
开发者ID:lcsaintlee,项目名称:desmume-1,代码行数:11,代码来源:task.cpp


示例15: init_thread

static bool init_thread(ffemu_t *handle)
{
   handle->lock = slock_new();
   handle->cond_lock = slock_new();
   handle->cond = scond_new();
   handle->audio_fifo = fifo_new(32000 * sizeof(int16_t) * handle->params.channels * MAX_FRAMES / 60);
   handle->attr_fifo = fifo_new(sizeof(struct ffemu_video_data) * MAX_FRAMES);
   handle->video_fifo = fifo_new(handle->params.fb_width * handle->params.fb_height *
            handle->video.pix_size * MAX_FRAMES);

   handle->alive = true;
   handle->can_sleep = true;
   handle->thread = sthread_create(ffemu_thread, handle);

   assert(handle->lock && handle->cond_lock &&
      handle->cond && handle->audio_fifo &&
      handle->attr_fifo && handle->video_fifo && handle->thread);

   return true;
}
开发者ID:Wyrick,项目名称:RetroArch,代码行数:20,代码来源:ffemu.c


示例16: if

static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency)
{
   (void)device;
   if (SDL_WasInit(0) == 0)
   {
      if (SDL_Init(SDL_INIT_AUDIO) < 0)
         return NULL;
   }
   else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
      return NULL;

   sdl_audio_t *sdl = (sdl_audio_t*)calloc(1, sizeof(*sdl));
   if (!sdl)
      return NULL;

   // We have to buffer up some data ourselves, so we let SDL carry approx half of the latency. SDL double buffers audio and we do as well.
   int frames = find_num_frames(rate, latency / 4);

   SDL_AudioSpec spec = {0};
   spec.freq = rate;
   spec.format = AUDIO_S16SYS;
   spec.channels = 2;
   spec.samples = frames; // This is in audio frames, not samples ... :(
   spec.callback = sdl_audio_cb;
   spec.userdata = sdl;

   SDL_AudioSpec out;

   if (SDL_OpenAudio(&spec, &out) < 0)
   {
      RARCH_ERR("Failed to open SDL audio: %s\n", SDL_GetError());
      free(sdl);
      return 0;
   }
   g_settings.audio.out_rate = out.freq;

   sdl->lock = slock_new();
   sdl->cond = scond_new();

   RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / g_settings.audio.out_rate));

   // Create a buffer twice as big as needed and prefill the buffer.
   size_t bufsize = out.samples * 4 * sizeof(int16_t);
   void *tmp = calloc(1, bufsize);
   sdl->buffer = fifo_new(bufsize);
   if (tmp)
   {
      fifo_write(sdl->buffer, tmp, bufsize);
      free(tmp);
   }

   SDL_PauseAudio(0);
   return sdl;
}
开发者ID:mprobinson,项目名称:RetroArch,代码行数:54,代码来源:sdl_audio.c


示例17: rarch_main_msg_queue_init

void rarch_main_msg_queue_init(void)
{
   if (g_msg_queue)
      return;

   g_msg_queue = msg_queue_new(8);
   retro_assert(g_msg_queue);

#ifdef HAVE_THREADS
   mq_lock = slock_new();
   retro_assert(mq_lock);
#endif
}
开发者ID:ioev,项目名称:RetroArch,代码行数:13,代码来源:runloop_msg.c


示例18: calloc

static void *dispmanx_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   struct dispmanx_video *_dispvars = calloc(1, sizeof(struct dispmanx_video));

   bcm_host_init();
   _dispvars->display = vc_dispmanx_display_open(0 /* LCD */);
   /* If the console framebuffer has active overscan settings, 
    * the user must have overscan_scale=1 in config.txt to have 
    * the same size for both fb console and dispmanx. */
   graphics_get_display_size(_dispvars->display, &_dispvars->dispmanx_width, &_dispvars->dispmanx_height);

   /* Setup surface parameters */
   _dispvars->vc_image_ptr     = 0;
   _dispvars->pageflip_pending = 0;	
   _dispvars->current_page     = NULL;
   _dispvars->menu_active      = false;
  
   /* Initialize the rest of the mutexes and conditions. */
   _dispvars->vsync_condition  = scond_new();
   _dispvars->vsync_cond_mutex = slock_new();
   _dispvars->pending_mutex    = slock_new();

   dispmanx_surface_init(_dispvars,
      video->rgb32 ? 4 : 2, 
      video->rgb32 ? VC_IMAGE_XRGB8888 : VC_IMAGE_RGB565, 
      0   /* layer */, 
      255 /* alpha */, 
      3,  /* numpages */
      &_dispvars->surfaces[MAIN_SURFACE]);

   if (input && input_data)
      *input = NULL;
  
   dispmanx_blank_console(_dispvars);
 
   return _dispvars;
}
开发者ID:luiseduardohdbackup,项目名称:RetroArch,代码行数:38,代码来源:dispmanx_gfx.c


示例19: disc_cdaccess

CDIF_MT::CDIF_MT(CDAccess *cda) : disc_cdaccess(cda), CDReadThread(NULL), SBMutex(NULL), SBCond(NULL)
{
   try
   {
      CDIF_Message msg;
      RTS_Args s;

      SBMutex            = slock_new();
      SBCond             = scond_new();
      UnrecoverableError = false;

      s.cdif_ptr = this;

      CDReadThread = sthread_create((void (*)(void*))ReadThreadStart_C, &s);
      EmuThreadQueue.Read(&msg);
   }
   catch(...)
   {
      if(CDReadThread)
      {
         sthread_join((sthread_t*)CDReadThread);
         CDReadThread = NULL;
      }

      if(SBMutex)
      {
         slock_free((slock_t*)SBMutex);
         SBMutex = NULL;
      }

      if(SBCond)
      {
         scond_free((scond_t*)SBCond);
         SBCond = NULL;
      }

      if(disc_cdaccess)
      {
         delete disc_cdaccess;
         disc_cdaccess = NULL;
      }

      throw;
   }
}
开发者ID:Warriors-Blade,项目名称:beetle-psx-libretro-Simias,代码行数:45,代码来源:cdromif.cpp


示例20: sizeof

static void *rs_init(const char *device, unsigned rate, unsigned latency)
{
   int channels, format;
   rsd_t *rsd = (rsd_t*)calloc(1, sizeof(rsd_t));
   if (!rsd)
      return NULL;

   rsound_t *rd;

   if (rsd_init(&rd) < 0)
   {
      free(rsd);
      return NULL;
   }

   rsd->cond_lock = slock_new();
   rsd->cond = scond_new();

   rsd->buffer = fifo_new(1024 * 4);

   channels = 2;
   format   = RSD_S16_NE;

   rsd_set_param(rd, RSD_CHANNELS, &channels);
   rsd_set_param(rd, RSD_SAMPLERATE, &rate);
   rsd_set_param(rd, RSD_LATENCY, &latency);

   if (device)
      rsd_set_param(rd, RSD_HOST, (void*)device);

   rsd_set_param(rd, RSD_FORMAT, &format);

   rsd_set_callback(rd, rsound_audio_cb, err_cb, 256, rsd);

   if (rsd_start(rd) < 0)
   {
      free(rsd);
      rsd_free(rd);
      return NULL;
   }

   rsd->rd = rd;
   return rsd;
}
开发者ID:AirBrowse,项目名称:RetroArch,代码行数:44,代码来源:rsound.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ slock_unlock函数代码示例发布时间:2022-05-30
下一篇:
C++ slock_lock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap