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


C++ pa_simple_new函数代码示例

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


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

示例1: pulse_initialize

int pulse_initialize(struct iaxc_audio_driver *d, int sample_rate)
{
  pa_simple *sp = NULL;
  pa_simple *sr = NULL;
  
  if (!sample_rate || sample_rate < 8000)
    sample_rate = 8000;

  ss.channels = 1; 
  ss.rate = sample_rate; 
  ss.format = PA_SAMPLE_S16LE; 

  // record stream pointer
  sr = pa_simple_new(NULL,
    "QRadioLink",
    PA_STREAM_RECORD, 
    NULL, 
    "Iax2-Client", 
    &ss, 
    NULL, 
    NULL, 
    NULL 
  );
  // playback stream pointer
  sp = pa_simple_new(NULL, 
    "QRadioLink", 
    PA_STREAM_PLAYBACK, 
    NULL, 
    "Iax2-Client", 
    &ss, 
    NULL, 
    NULL, 
    NULL 
  );
  d->priv = sr;
  d->priv2 = sp;
  d->initialize = pulse_initialize; /* This function */
  d->destroy = pulse_destroy; /* Implemented to flush buffers and then free resources */
  d->select_devices = pulse_select_devices; /* Bogey function, pulse audio connects via resource thread */
  d->selected_devices = pulse_selected_devices; /* Same as above */
  d->start = pulse_start; 
  d->stop = pulse_stop; 
  d->output = pulse_output; /* playback stream */
  d->input = pulse_input; /* record stream */
  d->input_level_get = pulse_input_level_get;
  d->input_level_set = pulse_input_level_set;
  d->output_level_get = pulse_output_level_get;
  d->output_level_set = pulse_output_level_set;
  d->play_sound = pulse_play_sound;
  d->stop_sound = pulse_stop_sound;

  return 0;
}
开发者ID:QDeltaSoft,项目名称:iaxclient,代码行数:53,代码来源:audio_pulseaudio.c

示例2: pulse_thread

static void* pulse_thread(void* context)
{
	sem_t* init = (sem_t*)context;

	pa_sample_spec ss;
	ss.format = PA_SAMPLE_S16LE;
	ss.channels = 2;
	ss.rate = g_sample_rate;

	int err;
	g_pulse = pa_simple_new(NULL, g_appname, PA_STREAM_PLAYBACK, NULL, g_appname, &ss, NULL, NULL, &err);
	if (!g_pulse) {
		snprintf(g_lasterror, c_nlasterror, "failed to connect to pulse server: %d", err);
	}

	sem_post(init);
	if (!g_pulse)
		return 0;

	pa_simple* s = g_pulse;
	short samples[c_nsamples*2];

	g_running = true;
	while (g_running) {
		g_callback(samples, c_nsamples);
		if (0 > pa_simple_write(s, samples, sizeof(samples), NULL))
			break;
	}

	pa_simple_flush(s, NULL);
	pa_simple_free(s);
	g_pulse = 0;
	return 0;
}
开发者ID:DevonJWells,项目名称:tinyaudio,代码行数:34,代码来源:tinyaudio_pulse.cpp

示例3: pa_simple_new

Dialup::Dialup(int len) {
    buffsize = len;
    buffind = 0;
    buffer = new unsigned char[len];

    int err;
    pa_sample_spec spec;
    pa_buffer_attr bfat;

    bfat.maxlength = -1;
    bfat.fragsize = -1;

    spec.format = PA_SAMPLE_U8;
    spec.channels = 2;
    spec.rate = 44100;

    

    audiosrv = pa_simple_new(
        0, // default pulseaudio server
        "phone_dialup", // app name
        PA_STREAM_RECORD,
        0, // default device
        "phone dialup rosnode", //description
        &spec,
        0, // default channel map
        &bfat,
        &err  // get error codes
    );

    if (!audiosrv) throw pa_exception(err);
}
开发者ID:thecheatscalc,项目名称:IGVC2013,代码行数:32,代码来源:dialup.cpp

示例4: pulse_setup

static void
pulse_setup (sw_handle * handle, sw_format * format)
{
  struct pa_sample_spec ss;
  pa_stream_direction_t dir;
  int error;

  if (format->channels > PA_CHANNELS_MAX) {
    fprintf(stderr, __FILE__": pulse_setup(): The maximum number of channels supported is %d, while %d have been requested.\n", PA_CHANNELS_MAX, format->channels);
    return;
  }

  ss.format = PA_SAMPLE_FLOAT32;
  ss.rate = format->rate;
  ss.channels = format->channels;

  if (handle->driver_flags == O_RDONLY) {
    dir = PA_STREAM_RECORD;
  } else if (handle->driver_flags == O_WRONLY) {
    dir = PA_STREAM_PLAYBACK;
  } else {
    return;
  }

  if (!(handle->custom_data = pa_simple_new(NULL, "Sweep", dir, NULL, "Sweep Stream", &ss, NULL, NULL, &error))) {
    fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
    return;
  }

  handle->driver_rate = ss.rate;
  handle->driver_channels = ss.channels;
}
开发者ID:JamesLinus,项目名称:sweep,代码行数:32,代码来源:driver_pulseaudio.c

示例5: mexFunction

void mexFunction(int nlhs, mxArray *plhs[],
    int nrhs, const mxArray *prhs[])
{
    const mxArray *Data = prhs[0];
    int16_t *data = (int16_t*)mxGetData(prhs[0]);
    size_t r = mxGetN(Data);
    
    // PA code
    pa_simple *s;
    pa_sample_spec ss;

    ss.format = PA_SAMPLE_S16LE;
    ss.channels = 1;
    ss.rate = 22050;
    
    s = pa_simple_new(NULL,               // Use the default server.
                      "knife-alien",      // Our application's name.
                      PA_STREAM_PLAYBACK,
                      NULL,               // Use the default device.
                      "Music",            // Description of our stream.
                      &ss,                // Our sample format.
                      NULL,               // Use default channel map
                      NULL,               // Use default buffering attributes.
                      NULL                // Ignore error code.
                      );
    
    pa_simple_write(s,data,(size_t)r,NULL);
}
开发者ID:Risca,项目名称:knife-alien,代码行数:28,代码来源:foo.c

示例6: pa_simple_new

/**
    \fn init
    \brief Take & initialize the device

*/
uint8_t pulseSimpleAudioDevice::init(uint8_t channels, uint32_t fq) 
{

pa_simple *s;
pa_sample_spec ss;
int er;
 
#ifdef ADM_PULSE_INT16
  ss.format = PA_SAMPLE_S16NE;
#else
    ss.format = PA_SAMPLE_FLOAT32NE;//PA_SAMPLE_S16NE; //FIXME big endian
#endif
  ss.channels = channels;
  ss.rate =fq;
 
  instance= pa_simple_new(NULL,               // Use the default server.
                    "Avidemux2",           // Our application's name.
                    PA_STREAM_PLAYBACK,
                    NULL,               // Use the default device.
                    "Sound",            // Description of our stream.
                    &ss,                // Our sample format.
                    NULL,               // Use default channel map
                    NULL ,             // Use default buffering attributes.
                    &er               // Ignore error code.
                    );
  if(!instance)
    {
        printf("[PulseSimple] open failed\n");
        return 0;
    }
    printf("[PulseSimple] open ok\n");
    return 1;

}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:39,代码来源:ADM_devicePulseSimple.cpp

示例7: sound_pulse_init

void sound_pulse_init()
{
    pa_sample_spec ss;
    pa_buffer_attr ba;

    ss.format = PA_SAMPLE_S16NE;
    ss.channels = 2;
    ss.rate = 48000;

    g_setenv("PULSE_PROP_media.role", "game", TRUE);

    ba.minreq = -1;
    ba.maxlength = -1;
    ba.prebuf = -1;
    ba.tlength = (1024*8)/2;

    s = pa_simple_new(NULL,               // Use the default server.
                   "PerfectZX",           // Our application's name.
                   PA_STREAM_PLAYBACK,
                   NULL,               // Use the default device.
                   "Sound",            // Description of our stream.
                   &ss,                // Our sample format.
                   NULL,               // Use default channel map
                   &ba,               // Use custom buffering attributes.
                   NULL               // Ignore error code.
                   );

	bufferFrames = SNDFRAME_LEN * ss.rate / 1000;
	sound_buffer = calloc( bufferFrames, sizeof(SNDFRAME) );
}
开发者ID:Tallefer,项目名称:perfectzx,代码行数:30,代码来源:sound_pulse.c

示例8: init

static int init(struct xmp_context *ctx)
{
	struct xmp_options *o = &ctx->o;
	pa_sample_spec ss;
	int error;

	ss.format = PA_SAMPLE_S16NE;
	ss.channels = o->outfmt & XMP_FMT_MONO ? 1 : 2;
	ss.rate = o->freq;

	s = pa_simple_new(NULL,		/* Use the default server */
		"xmp",			/* Our application's name */
		PA_STREAM_PLAYBACK,
		NULL,			/* Use the default device */
		"Music",		/* Description of our stream */
		&ss,			/* Our sample format */
		NULL,			/* Use default channel map */
		NULL,			/* Use default buffering attributes */
		&error);		/* Ignore error code */

	if (s == 0) {
		fprintf(stderr, "pulseaudio error: %s\n", pa_strerror(error));
		return XMP_ERR_DINIT;
	}

	return xmp_smix_on(ctx);
}
开发者ID:ProjectZeroSlackr,项目名称:XMP,代码行数:27,代码来源:pulseaudio.c

示例9: main

int main(int argc, char*argv[]) {
    /* The sample type to use */
    static const pa_sample_spec ss = {
        .format = PA_SAMPLE_S16LE,
        .rate = 44100,
        .channels = 2
    };
    pa_simple *s = NULL;
    int ret = 1;
    int error;
    /* Create the recording stream */
    if (!(s = pa_simple_new(NULL, argv[0], PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error))) {
        fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
        goto finish;
    }
    for (;;) {
        uint8_t buf[BUFSIZE];
        /* Record some data ... */
        if (pa_simple_read(s, buf, sizeof(buf), &error) < 0) {
            fprintf(stderr, __FILE__": pa_simple_read() failed: %s\n", pa_strerror(error));
            goto finish;
        }
        /* And write it to STDOUT */
        if (loop_write(STDOUT_FILENO, buf, sizeof(buf)) != sizeof(buf)) {
            fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno));
            goto finish;
        }
    }
    ret = 0;
finish:
    if (s)
        pa_simple_free(s);
    return ret;
}
开发者ID:cshengqun,项目名称:raop,代码行数:34,代码来源:capture.c

示例10: sound_init_pulse

int sound_init_pulse() {

	pa_sample_spec ss;
	pa_buffer_attr buf;

	ss.format = PA_SAMPLE_U8;
	ss.channels = 1;
	ss.rate = 48000;

	buf.maxlength=8192;
	buf.tlength=4096;
	buf.prebuf=4096;
	buf.minreq=4096;
	buf.fragsize=4096;

	pulse_s = pa_simple_new(NULL,"fbzx",PA_STREAM_PLAYBACK,NULL,"Spectrum",&ss,NULL,&buf,NULL);
	if (pulse_s==NULL) {
		return -1;
	}
	ordenador.sign=0;
	ordenador.format=0;
	ordenador.channels=1;
	ordenador.freq=48000;
	ordenador.buffer_len=4096;

	return 0;

}
开发者ID:Oibaf66,项目名称:fbzx-wii,代码行数:28,代码来源:sound.c

示例11: RTC_DEBUG

RTC::ReturnCode_t PulseAudioInput::onActivated(RTC::UniqueId ec_id)
{
  RTC_DEBUG(("onActivated start"));
  try {
    pa_cvolume cv;
//    mp_vol = pa_cvolume_reset(&cv, 1);
//    pa_cvolume_init(mp_vol);
    m_spec.format = getFormat(m_formatstr);
    m_spec.channels = (uint8_t)m_channels;

    m_simple = pa_simple_new(
                  NULL,               //!< Server name, or NULL for default
                  "PulseAudioInput",  //!< A descriptive name for this client (application name, ...)
                  PA_STREAM_RECORD,   //!< Open this stream for recording or playback?
                  NULL,               //!< Sink (resp. source) name, or NULL for default
                  "record",           //!< A descriptive name for this client (application name, song title, ...)
                  &m_spec,            //!< The sample type to use
                  NULL,               //!< The channel map to use, or NULL for default
                  NULL,               //!< Buffering attributes, or NULL for default
                  &m_err );           //!< A pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here.
    if ( m_simple == NULL ) {
      throw m_err;
    }
  } catch (...) {
    std::string error_str = pa_strerror(m_err);
    RTC_WARN(("pa_simple_new() failed onActivated:%s", error_str.c_str()));
  }
  is_active = true;

  RTC_DEBUG(("onActivated finish"));
  return RTC::RTC_OK;
}
开发者ID:SeishoIrie,项目名称:OpenHRIAudio,代码行数:32,代码来源:PulseAudioInput.cpp

示例12: ad_open_dev

ad_rec_t *
ad_open_dev(const char *dev, int32 samples_per_sec)
{
    ad_rec_t *handle;
    pa_simple *pa;
    pa_sample_spec ss;
    int error;

    ss.format = PA_SAMPLE_S16LE;
    ss.channels = 1;
    ss.rate = 16000; //samples_per_sec;
    
    pa = pa_simple_new(NULL, "ASR", PA_STREAM_RECORD, dev, "Speech", &ss, NULL, NULL, &error);
    if (pa == NULL) {
        fprintf(stderr, "Error opening audio device %s for capture: %s\n", dev, pa_strerror(error));
        return NULL;
    }

    if ((handle = (ad_rec_t *) calloc(1, sizeof(ad_rec_t))) == NULL) {
        fprintf(stderr, "Failed to allocate memory for ad device\n");
	return NULL;
    }

    handle->pa = pa;
    handle->recording = 0;
    handle->sps = samples_per_sec;
    handle->bps = sizeof(int16);

    return handle;
}
开发者ID:DanBuehrer,项目名称:pocketsphinx.js,代码行数:30,代码来源:ad_pulse.c

示例13: _openPlay

int _openPlay(char *identificacion)
{
    int error;

    if (!(sp = pa_simple_new(NULL, identificacion, PA_STREAM_PLAYBACK, NULL, "record", &ss, NULL, NULL, &error)))
        return error;
    return 0;
}
开发者ID:padsof-uam,项目名称:redes2,代码行数:8,代码来源:sound.c

示例14: _openRecord

int _openRecord(char *identificacion)
{
    int error;

    if (!(sr = pa_simple_new(NULL, identificacion, PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error)))
        return error;
    return 0;
}
开发者ID:padsof-uam,项目名称:redes2,代码行数:8,代码来源:sound.c

示例15: pulseaudio_allocate_voice

static int pulseaudio_allocate_voice(ALLEGRO_VOICE *voice)
{
   PULSEAUDIO_VOICE *pv = al_malloc(sizeof(PULSEAUDIO_VOICE));
   pa_sample_spec ss;
   pa_buffer_attr ba;

   ss.channels = al_get_channel_count(voice->chan_conf);
   ss.rate = voice->frequency;

   if (voice->depth == ALLEGRO_AUDIO_DEPTH_UINT8)
      ss.format = PA_SAMPLE_U8;
   else if (voice->depth == ALLEGRO_AUDIO_DEPTH_INT16)
      ss.format = PA_SAMPLE_S16NE;
#if PA_API_VERSION > 11
   else if (voice->depth == ALLEGRO_AUDIO_DEPTH_INT24)
      ss.format = PA_SAMPLE_S24NE;
#endif
   else if (voice->depth == ALLEGRO_AUDIO_DEPTH_FLOAT32)
      ss.format = PA_SAMPLE_FLOAT32NE;
   else {
      ALLEGRO_ERROR("Unsupported PulseAudio sound format.\n");
      al_free(pv);
      return 1;
   }

   ba.maxlength = 0x10000; // maximum length of buffer
   ba.tlength   = 0x2000;  // target length of buffer
   ba.prebuf    = 0;       // minimum data size required before playback starts
   ba.minreq    = 0;       // minimum size of request 
   ba.fragsize  = -1;      // fragment size (recording)

   pv->s = pa_simple_new(NULL,         // Use the default server.
                   al_get_app_name(),     
                   PA_STREAM_PLAYBACK,
                   NULL,               // Use the default device.
                   "Allegro Voice",    
                   &ss,                
                   NULL,               // Use default channel map
                   &ba,                
                   NULL                // Ignore error code.
   );

   if (!pv->s) {
      al_free(pv);
      return 1;
   }

   voice->extra = pv;

   pv->frame_size = ss.channels * al_get_audio_depth_size(voice->depth);
   pv->status = PV_STOPPED;
   pv->buffer_mutex = al_create_mutex();

   pv->poll_thread = al_create_thread(pulseaudio_update, (void*)voice);
   al_start_thread(pv->poll_thread);

   return 0;
}
开发者ID:Frozenhorns,项目名称:project,代码行数:58,代码来源:pulseaudio.c


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