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


C++ pa_threaded_mainloop_lock函数代码示例

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


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

示例1: get_delay_pulse

static double get_delay_pulse(struct ao *ao)
{
    struct priv *priv = ao->priv;
    pa_usec_t latency = (pa_usec_t) -1;
    pa_threaded_mainloop_lock(priv->mainloop);
    while (pa_stream_get_latency(priv->stream, &latency, NULL) < 0) {
        if (pa_context_errno(priv->context) != PA_ERR_NODATA) {
            GENERIC_ERR_MSG("pa_stream_get_latency() failed");
            break;
        }
        /* Wait until latency data is available again */
        pa_threaded_mainloop_wait(priv->mainloop);
    }
    pa_threaded_mainloop_unlock(priv->mainloop);
    return latency == (pa_usec_t) -1 ? 0 : latency / 1000000.0;
}
开发者ID:jmglogow,项目名称:mpv,代码行数:16,代码来源:ao_pulse.c

示例2: pulse_write_process

static void pulse_write_process(MSFilter *f){
	PulseWriteState *s=(PulseWriteState*)f->data;
	mblk_t *im;
	while((im=ms_queue_get(f->inputs[0]))!=NULL){
		int bsize=msgdsize(im);
		if (s->stream){
			pa_threaded_mainloop_lock(pa_loop);
			if (pa_stream_writable_size(s->stream)>=bsize){
				//ms_message("Pushing data to pulseaudio");
				pa_stream_write(s->stream,im->b_rptr,bsize,NULL,0,PA_SEEK_RELATIVE);
			}
			pa_threaded_mainloop_unlock(pa_loop);
		}
		freemsg(im);
	}
}
开发者ID:LaughingAngus,项目名称:linphone-vs2008,代码行数:16,代码来源:pulseaudio.c

示例3: audin_pulse_connect

static tbool audin_pulse_connect(IAudinDevice* device)
{
    pa_context_state_t state;
    AudinPulseDevice* pulse = (AudinPulseDevice*) device;

    if (!pulse->context)
        return false;

    if (pa_context_connect(pulse->context, NULL, 0, NULL))
    {
        DEBUG_WARN("pa_context_connect failed (%d)",
                   pa_context_errno(pulse->context));
        return false;
    }
    pa_threaded_mainloop_lock(pulse->mainloop);
    if (pa_threaded_mainloop_start(pulse->mainloop) < 0)
    {
        pa_threaded_mainloop_unlock(pulse->mainloop);
        DEBUG_WARN("pa_threaded_mainloop_start failed (%d)",
                   pa_context_errno(pulse->context));
        return false;
    }
    for (;;)
    {
        state = pa_context_get_state(pulse->context);
        if (state == PA_CONTEXT_READY)
            break;
        if (!PA_CONTEXT_IS_GOOD(state))
        {
            DEBUG_WARN("bad context state (%d)",
                       pa_context_errno(pulse->context));
            break;
        }
        pa_threaded_mainloop_wait(pulse->mainloop);
    }
    pa_threaded_mainloop_unlock(pulse->mainloop);
    if (state == PA_CONTEXT_READY)
    {
        DEBUG_DVC("connected");
        return true;
    }
    else
    {
        pa_context_disconnect(pulse->context);
        return false;
    }
}
开发者ID:joshiggins,项目名称:NeutrinoRDP,代码行数:47,代码来源:audin_pulse.c

示例4: Open

static int Open (vlc_object_t *obj)
{
    services_discovery_t *sd = (services_discovery_t *)obj;
    pa_operation *op;
    pa_context *ctx;

    services_discovery_sys_t *sys = malloc (sizeof (*sys));
    if (unlikely(sys == NULL))
        return VLC_ENOMEM;

    ctx = vlc_pa_connect (obj, &sys->mainloop);
    if (ctx == NULL)
    {
        free (sys);
        return VLC_EGENERIC;
    }

    sd->p_sys = sys;
    sd->description = _("Audio capture");
    sys->context = ctx;
    sys->root = NULL;

    /* Subscribe for source events */
    const pa_subscription_mask_t mask = PA_SUBSCRIPTION_MASK_SOURCE;
    pa_threaded_mainloop_lock (sys->mainloop);
    pa_context_set_subscribe_callback (ctx, ContextCallback, sd);
    op = pa_context_subscribe (ctx, mask, NULL, NULL);
    if (likely(op != NULL))
        pa_operation_unref (op);

    /* Enumerate existing sources */
    op = pa_context_get_source_info_list (ctx, SourceCallback, sd);
    if (likely(op != NULL))
    {
        //while (pa_operation_get_state (op) == PA_OPERATION_RUNNING)
        //    pa_threaded_mainloop_wait (sys->mainloop);
        pa_operation_unref (op);
    }
    pa_threaded_mainloop_unlock (sys->mainloop);
    return VLC_SUCCESS;
/*
error:
    pa_threaded_mainloop_unlock (sys->mainloop);
    vlc_pa_disconnect (obj, ctx, sys->mainloop);
    free (sys);
    return VLC_EGENERIC;*/
}
开发者ID:IAPark,项目名称:vlc,代码行数:47,代码来源:pulse.c

示例5: tsmf_pulse_connect

static int
tsmf_pulse_connect(TSMFPulseAudioDevice * pulse)
{
	pa_context_state_t state;

	if (!pulse->context)
		return 1;

	if (pa_context_connect(pulse->context, NULL, 0, NULL))
	{
		LLOGLN(0, ("tsmf_pulse_connect: pa_context_connect failed (%d)",
			pa_context_errno(pulse->context)));
		return 1;
	}
	pa_threaded_mainloop_lock(pulse->mainloop);
	if (pa_threaded_mainloop_start(pulse->mainloop) < 0)
	{
		pa_threaded_mainloop_unlock(pulse->mainloop);
		LLOGLN(0, ("tsmf_pulse_connect: pa_threaded_mainloop_start failed (%d)",
			pa_context_errno(pulse->context)));
		return 1;
	}
	for (;;)
	{
		state = pa_context_get_state(pulse->context);
		if (state == PA_CONTEXT_READY)
			break;
        if (!PA_CONTEXT_IS_GOOD(state))
		{
			LLOGLN(0, ("tsmf_pulse_connect: bad context state (%d)",
				pa_context_errno(pulse->context)));
			break;
		}
		pa_threaded_mainloop_wait(pulse->mainloop);
	}
	pa_threaded_mainloop_unlock(pulse->mainloop);
	if (state == PA_CONTEXT_READY)
	{
		LLOGLN(0, ("tsmf_pulse_connect: connected"));
		return 0;
	}
	else
	{
		pa_context_disconnect(pulse->context);
		return 1;
	}
}
开发者ID:FreeRDP,项目名称:FreeRDP-old,代码行数:47,代码来源:tsmf_pulse.c

示例6: quisk_flush_pulseaudio

//Flush function. Holds mainloop lock until operation is completed.
void quisk_flush_pulseaudio(struct sound_dev *dev) {
    pa_stream *s = dev->handle;
    pa_operation *o;
    
    pa_threaded_mainloop_lock(pa_ml);
    
    if (!(o = pa_stream_flush(s, stream_flushed_callback, dev))) {
        printf("pa_stream_flush(): %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
        exit(1);
    }
    else {
        while(pa_operation_get_state(o) == PA_OPERATION_RUNNING)
            pa_threaded_mainloop_wait(pa_ml);
        pa_operation_unref(o);
    }
    pa_threaded_mainloop_unlock(pa_ml);
}
开发者ID:gonesurfing,项目名称:quisk-main,代码行数:18,代码来源:sound_pulseaudio.c

示例7: instream_pause_pa

static int instream_pause_pa(SoundIoPrivate *si, SoundIoInStreamPrivate *is, bool pause) {
    SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio;
    SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;

    pa_threaded_mainloop_lock(sipa->main_loop);

    if (pause != pa_stream_is_corked(ispa->stream)) {
        pa_operation *op = pa_stream_cork(ispa->stream, pause, NULL, NULL);
        if (!op)
            return SoundIoErrorStreaming;
        pa_operation_unref(op);
    }

    pa_threaded_mainloop_unlock(sipa->main_loop);

    return 0;
}
开发者ID:siavashserver,项目名称:libsoundio,代码行数:17,代码来源:pulseaudio.cpp

示例8: instream_destroy_pa

static void instream_destroy_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
    struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio;
    struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
    pa_stream *stream = ispa->stream;
    if (stream) {
        pa_threaded_mainloop_lock(sipa->main_loop);

        pa_stream_set_state_callback(stream, NULL, NULL);
        pa_stream_set_read_callback(stream, NULL, NULL);
        pa_stream_disconnect(stream);
        pa_stream_unref(stream);

        pa_threaded_mainloop_unlock(sipa->main_loop);

        ispa->stream = NULL;
    }
}
开发者ID:IceDragon200,项目名称:libsoundio,代码行数:17,代码来源:pulseaudio.c

示例9: pa_simple_get_stream_index

int pa_simple_get_stream_index(pa_simple *p, unsigned int *idx, int *rerror) {
    pa_assert(p);
    CHECK_VALIDITY_RETURN_ANY(rerror, idx != NULL, PA_ERR_INVALID, -1);

    pa_threaded_mainloop_lock(p->mainloop);

    CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);

	*idx = pa_stream_get_index(p->stream);

    pa_threaded_mainloop_unlock(p->mainloop);
    return 0;

unlock_and_fail:
    pa_threaded_mainloop_unlock(p->mainloop);
    return -1;
}
开发者ID:tizenorg,项目名称:framework.multimedia.pulseaudio,代码行数:17,代码来源:simple.c

示例10: gst_pulsesrc_device_description

static gchar *
gst_pulsesrc_device_description (GstPulseSrc * pulsesrc)
{
  pa_operation *o = NULL;
  gchar *t;

  if (!pulsesrc->mainloop)
    goto no_mainloop;

  pa_threaded_mainloop_lock (pulsesrc->mainloop);

  if (!(o = pa_context_get_source_info_by_name (pulsesrc->context,
              pulsesrc->device, gst_pulsesrc_source_info_cb, pulsesrc))) {

    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
        ("pa_stream_get_source_info() failed: %s",
            pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
    goto unlock;
  }

  while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {

    if (gst_pulsesrc_is_dead (pulsesrc, FALSE))
      goto unlock;

    pa_threaded_mainloop_wait (pulsesrc->mainloop);
  }

unlock:

  if (o)
    pa_operation_unref (o);

  t = g_strdup (pulsesrc->device_description);

  pa_threaded_mainloop_unlock (pulsesrc->mainloop);

  return t;

no_mainloop:
  {
    GST_DEBUG_OBJECT (pulsesrc, "have no mainloop");
    return NULL;
  }
}
开发者ID:spunktsch,项目名称:svtplayer,代码行数:45,代码来源:pulsesrc.c

示例11: pulse_output_enable

static bool
pulse_output_enable(struct audio_output *ao, GError **error_r)
{
	struct pulse_output *po = (struct pulse_output *)ao;

	assert(po->mainloop == NULL);
	assert(po->context == NULL);

	/* create the libpulse mainloop and start the thread */

	po->mainloop = pa_threaded_mainloop_new();
	if (po->mainloop == NULL) {
		g_free(po);

		g_set_error(error_r, pulse_output_quark(), 0,
			    "pa_threaded_mainloop_new() has failed");
		return false;
	}

	pa_threaded_mainloop_lock(po->mainloop);

	if (pa_threaded_mainloop_start(po->mainloop) < 0) {
		pa_threaded_mainloop_unlock(po->mainloop);
		pa_threaded_mainloop_free(po->mainloop);
		po->mainloop = NULL;

		g_set_error(error_r, pulse_output_quark(), 0,
			    "pa_threaded_mainloop_start() has failed");
		return false;
	}

	/* create the libpulse context and connect it */

	if (!pulse_output_setup_context(po, error_r)) {
		pa_threaded_mainloop_unlock(po->mainloop);
		pa_threaded_mainloop_stop(po->mainloop);
		pa_threaded_mainloop_free(po->mainloop);
		po->mainloop = NULL;
		return false;
	}

	pa_threaded_mainloop_unlock(po->mainloop);

	return true;
}
开发者ID:Acidburn0zzz,项目名称:mpd,代码行数:45,代码来源:pulse_output_plugin.c

示例12: rdpsnd_pulse_play

static void rdpsnd_pulse_play(rdpsndDevicePlugin* device, uint8* data, int size)
{
	rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
	int len;
	int ret;
	uint8* src;

	if (!pulse->stream)
		return;

	if (pulse->format == 0x11)
	{
		pulse->dsp_context->decode_ima_adpcm(pulse->dsp_context,
			data, size, pulse->sample_spec.channels, pulse->block_size);
		size = pulse->dsp_context->adpcm_size;
		src = pulse->dsp_context->adpcm_buffer;
	}
	else
	{
		src = data;
	}

	pa_threaded_mainloop_lock(pulse->mainloop);
	while (size > 0)
	{
		while ((len = pa_stream_writable_size(pulse->stream)) == 0)
		{
			pa_threaded_mainloop_wait(pulse->mainloop);
		}
		if (len < 0)
			break;
		if (len > size)
			len = size;
		ret = pa_stream_write(pulse->stream, src, len, NULL, 0LL, PA_SEEK_RELATIVE);
		if (ret < 0)
		{
			DEBUG_WARN("pa_stream_write failed (%d)",
				pa_context_errno(pulse->context));
			break;
		}
		src += len;
		size -= len;
	}
	pa_threaded_mainloop_unlock(pulse->mainloop);
}
开发者ID:littlejawa,项目名称:FreeRDP,代码行数:45,代码来源:rdpsnd_pulse.c

示例13: tsmf_pulse_close_stream

static boolean tsmf_pulse_close_stream(TSMFPulseAudioDevice* pulse)
{
    if (!pulse->context || !pulse->stream)
        return false;

    DEBUG_DVC("");

    pa_threaded_mainloop_lock(pulse->mainloop);
    pa_stream_set_write_callback(pulse->stream, NULL, NULL);
    tsmf_pulse_wait_for_operation(pulse,
                                  pa_stream_drain(pulse->stream, tsmf_pulse_stream_success_callback, pulse));
    pa_stream_disconnect(pulse->stream);
    pa_stream_unref(pulse->stream);
    pulse->stream = NULL;
    pa_threaded_mainloop_unlock(pulse->mainloop);

    return true;
}
开发者ID:felfert,项目名称:FreeRDP,代码行数:18,代码来源:tsmf_pulse.c

示例14: pa_threaded_mainloop_lock

void CAESinkPULSE::GetDelay(AEDelayStatus& status)
{
  if (!m_IsAllocated)
  {
    status.SetDelay(0);
    return;
  }

  pa_threaded_mainloop_lock(m_MainLoop);
  pa_usec_t r_usec;
  int negative;

  if (pa_stream_get_latency(m_Stream, &r_usec, &negative) < 0)
    r_usec = 0;

  pa_threaded_mainloop_unlock(m_MainLoop);
  status.SetDelay(r_usec / 1000000.0);
}
开发者ID:anaconda,项目名称:xbmc,代码行数:18,代码来源:AESinkPULSE.cpp

示例15: rdpsnd_pulse_close

static int
rdpsnd_pulse_close(rdpsndDevicePlugin * devplugin)
{
	struct pulse_device_data * pulse_data;

	pulse_data = (struct pulse_device_data *) devplugin->device_data;
	if (!pulse_data->context || !pulse_data->stream)
		return 1;
	LLOGLN(0, ("rdpsnd_pulse_close:"));
	pa_threaded_mainloop_lock(pulse_data->mainloop);
	rdpsnd_pulse_wait_for_operation(devplugin,
		pa_stream_drain(pulse_data->stream, rdpsnd_pulse_stream_success_callback, devplugin));
	pa_stream_disconnect(pulse_data->stream);
	pa_stream_unref(pulse_data->stream);
	pulse_data->stream = NULL;
	pa_threaded_mainloop_unlock(pulse_data->mainloop);
	return 0;
}
开发者ID:nidelius,项目名称:FreeRDP,代码行数:18,代码来源:rdpsnd_pulse.c


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