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

C++ pa_stream_get_state函数代码示例

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

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



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

示例1: check_pulse_health

static gboolean check_pulse_health (xmms_pulse *p, int *rerror)
{
	if (!p->context || pa_context_get_state (p->context) != PA_CONTEXT_READY ||
	    !p->stream || pa_stream_get_state (p->stream) != PA_STREAM_READY) {
		if ((p->context &&
		     pa_context_get_state (p->context) == PA_CONTEXT_FAILED) ||
		    (p->stream &&
		     pa_stream_get_state (p->stream) == PA_STREAM_FAILED)) {
			if (rerror)
				*(rerror) = pa_context_errno (p->context);
		} else if (rerror)
			*(rerror) = PA_ERR_BADSTATE;
		return FALSE;
	}
	return TRUE;
}
开发者ID:kfihihc,项目名称:xmms2-devel,代码行数:16,代码来源:backend.c


示例2: inputStreamStateCallback

static void inputStreamStateCallback(pa_stream *stream, void *userdata)
{
    Q_UNUSED(userdata);
    pa_stream_state_t state = pa_stream_get_state(stream);
#ifdef DEBUG_PULSE
    qDebug() << "Stream state: " << QPulseAudioInternal::stateToQString(state);
#endif
    switch (state) {
        case PA_STREAM_CREATING:
        break;
        case PA_STREAM_READY: {
#ifdef DEBUG_PULSE
            QPulseAudioInput *audioInput = static_cast<QPulseAudioInput*>(userdata);
            const pa_buffer_attr *buffer_attr = pa_stream_get_buffer_attr(stream);
            qDebug() << "*** maxlength: " << buffer_attr->maxlength;
            qDebug() << "*** prebuf: " << buffer_attr->prebuf;
            qDebug() << "*** fragsize: " << buffer_attr->fragsize;
            qDebug() << "*** minreq: " << buffer_attr->minreq;
            qDebug() << "*** tlength: " << buffer_attr->tlength;

            pa_sample_spec spec = QPulseAudioInternal::audioFormatToSampleSpec(audioInput->format());
            qDebug() << "*** bytes_to_usec: " << pa_bytes_to_usec(buffer_attr->fragsize, &spec);
#endif
            }
            break;
        case PA_STREAM_TERMINATED:
            break;
        case PA_STREAM_FAILED:
        default:
            qWarning() << QString("Stream error: %1").arg(pa_strerror(pa_context_errno(pa_stream_get_context(stream))));
            QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance();
            pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
            break;
    }
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:35,代码来源:qaudioinput_pulse.cpp


示例3: rdpsnd_pulse_stream_state_callback

static void
rdpsnd_pulse_stream_state_callback(pa_stream * stream, void * userdata)
{
	rdpsndDevicePlugin * devplugin;
	struct pulse_device_data * pulse_data;
	pa_stream_state_t state;

	devplugin = (rdpsndDevicePlugin *) userdata;
	pulse_data = (struct pulse_device_data *) devplugin->device_data;
	state = pa_stream_get_state(stream);
	switch (state)
	{
		case PA_STREAM_READY:
			LLOGLN(10, ("rdpsnd_pulse_stream_state_callback: PA_STREAM_READY"));
			pa_threaded_mainloop_signal (pulse_data->mainloop, 0);
			break;

		case PA_STREAM_FAILED:
		case PA_STREAM_TERMINATED:
			LLOGLN(10, ("rdpsnd_pulse_stream_state_callback: state %d", (int)state));
			pa_threaded_mainloop_signal (pulse_data->mainloop, 0);
			break;

		default:
			LLOGLN(10, ("rdpsnd_pulse_stream_state_callback: state %d", (int)state));
			break;
	}
}
开发者ID:nidelius,项目名称:FreeRDP,代码行数:28,代码来源:rdpsnd_pulse.c


示例4: stream_state_callback

/*
 * Stream state callbacks
 *
 * A 'stream' represents a data path between the client and server.
 * Sample streams include a playback stream, a recording stream, or
 * a file upload stream.
 *
 * A single client-server connection ('context') can have multiple
 * streams. Each stream can have its own latency and time fragment
 * requirements through PulseAudio buffer attributes. A stream can
 * be moved to a different sink during its lifetime.
 */
static void stream_state_callback(pa_stream *stream, void *userdata) {
    struct context *ctx = userdata;

    assert(ctx);
    assert(ctx->context);

    switch (pa_stream_get_state(stream)) {
    case PA_STREAM_CREATING:
    case PA_STREAM_TERMINATED:
        break;

    case PA_STREAM_READY:
        out("Playback stream succesfully created");
        break;

    case PA_STREAM_FAILED:
    default:
        error("Playback stream error: %s",
              pa_strerror(pa_context_errno(ctx->context)));
        goto fail;
    }

    return;

fail:
    quit(ctx, EXIT_FAILURE);
}
开发者ID:a-darwish,项目名称:malicious-pulseaudio-clients,代码行数:39,代码来源:kill_server_quickly_open_write_streams.c


示例5: lock

float AudioDriverPulseAudio::get_latency() {

	if (latency == 0) { //only do this once since it's approximate anyway
		lock();

		pa_usec_t palat = 0;
		if (pa_stream_get_state(pa_str) == PA_STREAM_READY) {
			int negative = 0;

			if (pa_stream_get_latency(pa_str, &palat, &negative) >= 0) {
				if (negative) {
					palat = 0;
				}
			}
		}

		if (palat > 0) {
			latency = double(palat) / 1000000.0;
		}

		unlock();
	}

	return latency;
}
开发者ID:bigscorpions,项目名称:godot,代码行数:25,代码来源:audio_driver_pulseaudio.cpp


示例6: pa_stream_get_state

bool AudioStream::isReady()
{
    if (!audiostream_)
        return false;

    return pa_stream_get_state(audiostream_) == PA_STREAM_READY;
}
开发者ID:dyfet,项目名称:sflphone,代码行数:7,代码来源:audiostream.cpp


示例7: pa_stream_get_state

void AudioSinksManager::InternalAudioSink::stream_state_change_callback(pa_stream* /*stream*/,
                                                                        void* userdata) {
    AudioSinksManager::InternalAudioSink* sink =
            static_cast<AudioSinksManager::InternalAudioSink*>(userdata);
    pa_stream_state_t state = pa_stream_get_state(sink->stream);
    const char* state_str = "Wrong impossible state";
    switch (state) {
        case PA_STREAM_UNCONNECTED: state_str = "UNCONNECTED"; break;
        case PA_STREAM_CREATING: state_str = "CREATING"; break;
        case PA_STREAM_READY: state_str = "READY"; break;
        case PA_STREAM_FAILED: state_str = "FAILED"; break;
        case PA_STREAM_TERMINATED: state_str = "TERMINATED"; break;
    }
    sink->manager->logger->trace("(AudioSink '{}') Stream new state: {}", sink->name, state_str);

    switch (state) {
        case PA_STREAM_FAILED:
            sink->manager->logger->error("(AudioSink '{}') Stream failed: {}", sink->name,
                                         sink->manager->get_pa_error());
            sink->state = State::DEAD;
        // FALLTHROUGH
        case PA_STREAM_TERMINATED:
            pa_stream_unref(sink->stream);
            sink->stream = nullptr;
            sink->stop_sink();
            break;
        default: break;
    }
}
开发者ID:p2004a,项目名称:pulseaudio-chromecast-sink,代码行数:29,代码来源:audio_sinks_manager.cpp


示例8: GetBufferedOnSoundcard

int AudioOutputPulseAudio::GetBufferedOnSoundcard(void) const
{
    pa_usec_t latency = 0;
    size_t buffered = 0;

    if (!pcontext || pa_context_get_state(pcontext) != PA_CONTEXT_READY)
        return 0;

    if (!pstream || pa_stream_get_state(pstream) != PA_STREAM_READY)
        return 0;

    const pa_buffer_attr *buf_attr =  pa_stream_get_buffer_attr(pstream);
    size_t bfree = pa_stream_writable_size(pstream);
    buffered = buf_attr->tlength - bfree;

    pa_threaded_mainloop_lock(mainloop);

    while (pa_stream_get_latency(pstream, &latency, NULL) < 0)
    {
        if (pa_context_errno(pcontext) != PA_ERR_NODATA)
        {
            latency = 0;
            break;
        }
        pa_threaded_mainloop_wait(mainloop);
    }

    pa_threaded_mainloop_unlock(mainloop);

    return ((uint64_t)latency * samplerate *
            output_bytes_per_frame / 1000000) + buffered;
}
开发者ID:aravilife,项目名称:mythtv-stabilize2,代码行数:32,代码来源:audiooutputpulse.cpp


示例9: tsmf_pulse_stream_state_callback

static void
tsmf_pulse_stream_state_callback(pa_stream * stream, void * userdata)
{
	TSMFPulseAudioDevice * pulse = (TSMFPulseAudioDevice *) userdata;
	pa_stream_state_t state;

	state = pa_stream_get_state(stream);
	switch (state)
	{
		case PA_STREAM_READY:
			LLOGLN(10, ("tsmf_pulse_stream_state_callback: PA_STREAM_READY"));
			pa_threaded_mainloop_signal (pulse->mainloop, 0);
			break;

		case PA_STREAM_FAILED:
		case PA_STREAM_TERMINATED:
			LLOGLN(10, ("tsmf_pulse_stream_state_callback: state %d", (int)state));
			pa_threaded_mainloop_signal (pulse->mainloop, 0);
			break;

		default:
			LLOGLN(10, ("tsmf_pulse_stream_state_callback: state %d", (int)state));
			break;
	}
}
开发者ID:LawrenceK,项目名称:FreeRDP,代码行数:25,代码来源:tsmf_pulse.c


示例10: switch

void
AudioStream::stream_state_callback(pa_stream* s, void* /*user_data*/)
{
    char str[PA_SAMPLE_SPEC_SNPRINT_MAX];

    switch (pa_stream_get_state(s)) {
        case PA_STREAM_CREATING:
            DEBUG("Stream is creating...");
            break;

        case PA_STREAM_TERMINATED:
            DEBUG("Stream is terminating...");
            break;

        case PA_STREAM_READY:
            DEBUG("Stream successfully created, connected to %s", pa_stream_get_device_name(s));
            DEBUG("maxlength %u", pa_stream_get_buffer_attr(s)->maxlength);
            DEBUG("tlength %u", pa_stream_get_buffer_attr(s)->tlength);
            DEBUG("prebuf %u", pa_stream_get_buffer_attr(s)->prebuf);
            DEBUG("minreq %u", pa_stream_get_buffer_attr(s)->minreq);
            DEBUG("fragsize %u", pa_stream_get_buffer_attr(s)->fragsize);
            DEBUG("samplespec %s", pa_sample_spec_snprint(str, sizeof(str), pa_stream_get_sample_spec(s)));
            break;

        case PA_STREAM_UNCONNECTED:
            DEBUG("Stream unconnected");
            break;

        case PA_STREAM_FAILED:
        default:
            ERROR("Sink/Source doesn't exists: %s" , pa_strerror(pa_context_errno(pa_stream_get_context(s))));
            break;
    }
}
开发者ID:dyfet,项目名称:sflphone,代码行数:34,代码来源:audiostream.cpp


示例11: play

/** Play the specified data to the polypaudio server */
static int play(void* data, int len, int flags) {
    assert(stream && context);

    if (pa_stream_get_state(stream) != PA_STREAM_READY)
        return -1;

    if (!len)
        wait_for_operation(pa_stream_trigger(stream, NULL, NULL));
    else
        pa_stream_write(stream, data, len, NULL, 0);

    wait_for_completion();

    if (pa_stream_get_state(stream) != PA_STREAM_READY)
        return -1;

    return len;
}
开发者ID:OpenSageTV,项目名称:mplayer-sage9orig,代码行数:19,代码来源:ao_polyp.c


示例12: stream_state_cb

static void stream_state_cb(pa_stream *s, void *userdata) {
    switch (pa_stream_get_state(s)) {
        case PA_STREAM_READY:
        case PA_STREAM_FAILED:
        case PA_STREAM_TERMINATED:
            pa_threaded_mainloop_signal(mainloop, 0);
            break;
    }
}
开发者ID:interactive-matter,项目名称:ap_led_tile_mplayer,代码行数:9,代码来源:ao_pulse.c


示例13: pa_stream_get_state

void AudioOutputPulseAudio::WriteAudio(uchar *aubuf, int size)
{
    QString fn_log_tag = "WriteAudio, ";
    pa_stream_state_t sstate = pa_stream_get_state(pstream);

    VBAUDIOTS(fn_log_tag + QString("writing %1 bytes").arg(size));

    /* NB This "if" check can be replaced with PA_STREAM_IS_GOOD() in
       PulseAudio API from 0.9.11. As 0.9.10 is still widely used
       we use the more verbose version for now */

    if (sstate == PA_STREAM_CREATING || sstate == PA_STREAM_READY)
    {
        int write_status = PA_ERR_INVALID;
        size_t to_write = size;
        unsigned char *buf_ptr = aubuf;

        pa_threaded_mainloop_lock(mainloop);
        while (to_write > 0)
        {
            write_status = 0;
            size_t writable = pa_stream_writable_size(pstream);
            if (writable > 0)
            {
                size_t write = min(to_write, writable);
                write_status = pa_stream_write(pstream, buf_ptr, write,
                                               NULL, 0, PA_SEEK_RELATIVE);

                if (0 != write_status)
                    break;

                buf_ptr += write;
                to_write -= write;
            }
            else
            {
                pa_threaded_mainloop_wait(mainloop);
            }
        }
        pa_threaded_mainloop_unlock(mainloop);

        if (to_write > 0)
        {
            if (write_status != 0)
                VBERROR(fn_log_tag + QString("stream write failed: %1")
                                     .arg(write_status == PA_ERR_BADSTATE
                                                ? "PA_ERR_BADSTATE"
                                                : "PA_ERR_INVALID"));

            VBERROR(fn_log_tag + QString("short write, %1 of %2")
                                 .arg(size - to_write).arg(size));
        }
    }
    else
        VBERROR(fn_log_tag + QString("stream state not good: %1")
                             .arg(sstate,0,16));
}
开发者ID:aravilife,项目名称:mythtv-stabilize2,代码行数:57,代码来源:audiooutputpulse.cpp


示例14: stream_state_callback

// PulseAudio Event Callbacks //{{{
static void stream_state_callback(pa_stream *stream, void *pdata) //{{{
{
    pa_threaded_mainloop *loop = pdata;
    pa_stream_state_t state;

    state = pa_stream_get_state(stream);
    if(state == PA_STREAM_READY || !PA_STREAM_IS_GOOD(state))
        pa_threaded_mainloop_signal(loop, 0);
}//}}}
开发者ID:siana,项目名称:2p-openal,代码行数:10,代码来源:pulseaudio.c


示例15: get_space

/** Return number of bytes that may be written to the server without blocking */
static int get_space(void) {
    uint32_t l;
    assert(stream && context && pa_stream_get_state(stream) == PA_STREAM_READY);
    
    keep_alive();

    l = pa_stream_writable_size(stream);
    
    return l;
}
开发者ID:OpenSageTV,项目名称:mplayer-sage9orig,代码行数:11,代码来源:ao_polyp.c


示例16: stream_state_callback

/**
 * Pulseaudio stream state callback
 */
static void
stream_state_callback (pa_stream * s, void *userdata)
{
  GNUNET_assert (NULL != s);

  switch (pa_stream_get_state (s))
  {
  case PA_STREAM_CREATING:
  case PA_STREAM_TERMINATED:
    break;
  case PA_STREAM_READY:
    {
      const pa_buffer_attr *a;
      char cmt[PA_CHANNEL_MAP_SNPRINT_MAX];
      char sst[PA_SAMPLE_SPEC_SNPRINT_MAX];

      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
		  _("Stream successfully created.\n"));

      if (!(a = pa_stream_get_buffer_attr (s)))
      {
	GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
		    _("pa_stream_get_buffer_attr() failed: %s\n"),
		    pa_strerror (pa_context_errno
				 (pa_stream_get_context (s))));

      }
      else
      {
	GNUNET_log (GNUNET_ERROR_TYPE_INFO,
		    _("Buffer metrics: maxlength=%u, fragsize=%u\n"),
		    a->maxlength, a->fragsize);
      }
      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
		  _("Using sample spec '%s', channel map '%s'.\n"),
		  pa_sample_spec_snprint (sst, sizeof (sst),
					  pa_stream_get_sample_spec (s)),
		  pa_channel_map_snprint (cmt, sizeof (cmt),
					  pa_stream_get_channel_map (s)));

      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
		  _("Connected to device %s (%u, %ssuspended).\n"),
		  pa_stream_get_device_name (s),
		  pa_stream_get_device_index (s),
		  pa_stream_is_suspended (s) ? "" : "not ");
    }
    break;
  case PA_STREAM_FAILED:
  default:
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
		_("Stream error: %s\n"),
		pa_strerror (pa_context_errno (pa_stream_get_context (s))));
    quit (1);
  }
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:58,代码来源:gnunet-helper-audio-record.c


示例17: pulse_capture_samples

static ALCenum pulse_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples)
{
    pulse_data *data = device->ExtraData;
    ALCuint todo = samples * pa_frame_size(&data->spec);

    pa_threaded_mainloop_lock(data->loop);
    /* Capture is done in fragment-sized chunks, so we loop until we get all
     * that's available */
    data->last_readable -= todo;
    while(todo > 0)
    {
        size_t rem = todo;

        if(data->cap_len == 0)
        {
            pa_stream_state_t state;

            state = pa_stream_get_state(data->stream);
            if(!PA_STREAM_IS_GOOD(state))
            {
                aluHandleDisconnect(device);
                break;
            }
            if(pa_stream_peek(data->stream, &data->cap_store, &data->cap_len) < 0)
            {
                ERR("pa_stream_peek() failed: %s\n",
                    pa_strerror(pa_context_errno(data->context)));
                aluHandleDisconnect(device);
                break;
            }
            data->cap_remain = data->cap_len;
        }
        if(rem > data->cap_remain)
            rem = data->cap_remain;

        memcpy(buffer, data->cap_store, rem);

        buffer = (ALbyte*)buffer + rem;
        todo -= rem;

        data->cap_store = (ALbyte*)data->cap_store + rem;
        data->cap_remain -= rem;
        if(data->cap_remain == 0)
        {
            pa_stream_drop(data->stream);
            data->cap_len = 0;
        }
    }
    if(todo > 0)
        memset(buffer, ((device->FmtType==DevFmtUByte) ? 0x80 : 0), todo);
    pa_threaded_mainloop_unlock(data->loop);

    return ALC_NO_ERROR;
}
开发者ID:24BitGames,项目名称:LoomSDK,代码行数:54,代码来源:pulseaudio.c


示例18: time_event_callback

static void time_event_callback(pa_mainloop_api *m, pa_time_event *e, const struct timeval *t, void *userdata) {
    if (stream && pa_stream_get_state(stream) == PA_STREAM_READY) {
        pa_operation *o;
        if (!(o = pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL)))
            pa_log(_("pa_stream_update_timing_info() failed: %s"), pa_strerror(pa_context_errno(context)));
        else
            pa_operation_unref(o);
    }

    pa_context_rttime_restart(context, e, pa_rtclock_now() + TIME_EVENT_USEC);
}
开发者ID:almosthappy4u,项目名称:PulseAudio-UCM,代码行数:11,代码来源:pacat.c


示例19: switch

void PulseAudioSystem::stream_callback(pa_stream *s, void *userdata) {
	PulseAudioSystem *pas = reinterpret_cast<PulseAudioSystem *>(userdata);
	switch (pa_stream_get_state(s)) {
		case PA_STREAM_FAILED:
			qWarning("PulseAudio: Stream error: %s", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
			break;
		default:
			break;
	}
	pas->wakeup();
}
开发者ID:AceXare,项目名称:mumble,代码行数:11,代码来源:PulseAudio.cpp


示例20: stream_state_callback

static void stream_state_callback(pa_stream *s,void*){
  fxmessage("[pulse] stream_state_callback:");
  switch(pa_stream_get_state(s)) {
    case PA_STREAM_UNCONNECTED : fxmessage(" unconnected\n"); break;
    case PA_STREAM_CREATING    : fxmessage(" creating\n"); break;
    case PA_STREAM_READY       : fxmessage(" ready\n"); break;
    case PA_STREAM_FAILED      : fxmessage(" failed\n"); break;
    case PA_STREAM_TERMINATED  : fxmessage(" terminated\n"); break;
    default                     : fxmessage(" unknown\n"); break;
    }
  }
开发者ID:gogglesmm,项目名称:gogglesmm,代码行数:11,代码来源:ap_pulse.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pa_stream_new函数代码示例发布时间:2022-05-30
下一篇:
C++ pa_stream_disconnect函数代码示例发布时间: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