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


C++ AudioOutputUnitStart函数代码示例

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


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

示例1: AudioOutputUnitStart

void AudioDestinationMac::start()
{
    OSStatus result = AudioOutputUnitStart(m_outputUnit);

    if (!result)
        m_isPlaying = true;
    
    // LabSound
    result = AudioOutputUnitStart(m_input->m_inputUnit);
}
开发者ID:cor3ntin,项目名称:LabSound,代码行数:10,代码来源:AudioDestinationMac.cpp

示例2: ca_start_capture

static void ca_start_capture(ALCdevice *device)
{
    ca_data *data = (ca_data*)device->ExtraData;
    OSStatus err = AudioOutputUnitStart(data->audioUnit);
    if(err != noErr)
        ERR("AudioOutputUnitStart failed\n");
}
开发者ID:carriercomm,项目名称:openal-soft-chowdren,代码行数:7,代码来源:coreaudio.c

示例3: zeromem

Error AudioDriverIphone::init() {

	active = false;
	channels = 2;

	AudioStreamBasicDescription strdesc;
	strdesc.mFormatID = kAudioFormatLinearPCM;
	strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
	strdesc.mChannelsPerFrame = channels;
	strdesc.mSampleRate = 44100;
	strdesc.mFramesPerPacket = 1;
	strdesc.mBitsPerChannel = 16;
	strdesc.mBytesPerFrame =
		strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
	strdesc.mBytesPerPacket =
		strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;

	OSStatus result = noErr;
	AURenderCallbackStruct callback;
	AudioComponentDescription desc;
	AudioComponent comp = NULL;
	const AudioUnitElement output_bus = 0;
	const AudioUnitElement bus = output_bus;
	const AudioUnitScope scope = kAudioUnitScope_Input;

	zeromem(&desc, sizeof(desc));
	desc.componentType = kAudioUnitType_Output;
	desc.componentSubType = kAudioUnitSubType_RemoteIO;  /* !!! FIXME: ? */
	comp = AudioComponentFindNext(NULL, &desc);
	desc.componentManufacturer = kAudioUnitManufacturer_Apple;

	result = AudioComponentInstanceNew(comp, &audio_unit);
	ERR_FAIL_COND_V(result != noErr, FAILED);
	ERR_FAIL_COND_V(comp == NULL, FAILED);

	result = AudioUnitSetProperty(audio_unit,
								  kAudioUnitProperty_StreamFormat,
								  scope, bus, &strdesc, sizeof(strdesc));
	ERR_FAIL_COND_V(result != noErr, FAILED);

	zeromem(&callback, sizeof(AURenderCallbackStruct));
	callback.inputProc = &AudioDriverIphone::output_callback;
	callback.inputProcRefCon = this;
	result = AudioUnitSetProperty(audio_unit,
								  kAudioUnitProperty_SetRenderCallback,
								  scope, bus, &callback, sizeof(callback));
	ERR_FAIL_COND_V(result != noErr, FAILED);

	result = AudioUnitInitialize(audio_unit);
	ERR_FAIL_COND_V(result != noErr, FAILED);

	result = AudioOutputUnitStart(audio_unit);
	ERR_FAIL_COND_V(result != noErr, FAILED);

	const int samples = 1024;
	samples_in = memnew_arr(int32_t, samples); // whatever
	buffer_frames = samples / channels;

	return FAILED;
};
开发者ID:AMG194,项目名称:godot,代码行数:60,代码来源:audio_driver_iphone.cpp

示例4: audio_unit_interruption_listener

/* interruption listeners */
void audio_unit_interruption_listener(void *closure, UInt32 inInterruptionState)
{
  OSStatus err = 0;
  aubio_audio_unit_t *o = (aubio_audio_unit_t *) closure;
  AudioUnit this_unit = o->audio_unit;

  if (inInterruptionState == kAudioSessionEndInterruption) {
    AUBIO_WRN("audio_unit: session interruption ended\n");
    err = AudioSessionSetActive(true);
    if (err) {
      AUBIO_ERR("audio_unit: could not make session active after interruption (%d)\n", (int)err);
      goto fail;
    }
    err = AudioOutputUnitStart(this_unit);
    if (err) {
      AUBIO_ERR("audio_unit: failed starting unit (%d)\n", (int)err);
      goto fail;
    }
  }
  if (inInterruptionState == kAudioSessionBeginInterruption) {
    AUBIO_WRN("audio_unit: session interruption started\n");
    err = AudioOutputUnitStop(this_unit);
    if (err) {
      AUBIO_ERR("audio_unit: could not stop unit at interruption (%d)\n", (int)err);
      goto fail;
    }
    err = AudioSessionSetActive(false);
    if (err) {
      AUBIO_ERR("audio_unit: could not make session inactive after interruption (%d)\n", (int)err);
      goto fail;
    }
  }
fail:
  return;
}
开发者ID:Craig-J,项目名称:RhythMIR,代码行数:36,代码来源:audio_unit.c

示例5: AudioOutputUnitStart

void AudioDestinationMac::start()
{
    OSStatus result = AudioOutputUnitStart(m_outputUnit);

    if (!result)
        setIsPlaying(true);
}
开发者ID:caiolima,项目名称:webkit,代码行数:7,代码来源:AudioDestinationMac.cpp

示例6: main

int main (int argc, const char * argv[]) {
	
 	MyAUGraphPlayer player = {0};
	
	// create the input unit
	CreateInputUnit(&player);
	
	// build a graph with output unit
	CreateMyAUGraph(&player);
	
#ifdef PART_II
	// configure the speech synthesizer
	PrepareSpeechAU(&player);
	
#endif
	
	// start playing
	CheckError (AudioOutputUnitStart(player.inputUnit), "AudioOutputUnitStart failed");
	CheckError(AUGraphStart(player.graph), "AUGraphStart failed");
	
	// and wait
	printf("Capturing, press <return> to stop:\n");
	getchar();
	
cleanup:
	AUGraphStop (player.graph);
	AUGraphUninitialize (player.graph);
	AUGraphClose(player.graph);
	
	
}
开发者ID:Contexter,项目名称:learning-core-audio-xcode4-projects,代码行数:31,代码来源:main.cpp

示例7: CoreAudioDrv_PCM_BeginPlayback

int CoreAudioDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize,
                                   int NumDivisions, void ( *CallBackFunc )( void ) )
{
	if (!Initialised) {
		ErrorCode = CAErr_Uninitialised;
		return CAErr_Error;
	}
	
	if (Playing) {
		CoreAudioDrv_PCM_StopPlayback();
	}
	
	MixBuffer = BufferStart;
	MixBufferSize = BufferSize;
	MixBufferCount = NumDivisions;
	MixBufferCurrent = 0;
	MixBufferUsed = 0;
	MixCallBack = CallBackFunc;
	
	// prime the buffer
	MixCallBack();
	
	AudioOutputUnitStart(output_audio_unit);
	
	Playing = 1;
	
	return CAErr_Ok;
}
开发者ID:TermiT,项目名称:sw-redux,代码行数:28,代码来源:driver_coreaudio.c

示例8: sa_stream_resume

int
sa_stream_resume(sa_stream_t *s) {

  if (s == NULL || s->output_unit == NULL) {
    return SA_ERROR_NO_INIT;
  }

  pthread_mutex_lock(&s->mutex);
  /*
   * The audio device resets its mSampleTime counter after pausing,
   * so we need to clear our tracking value to keep that in sync.
   */
  s->total_bytes_played += s->bytes_played;
  s->bytes_played = 0;
  pthread_mutex_unlock(&s->mutex);

  /*
   * Don't hold the mutex when starting the audio device, because it is
   * possible to deadlock with this thread holding mutex then waiting on an
   * internal Core Audio lock, and with the callback thread holding the Core
   * Audio lock and waiting on the mutex.
  */
  if (AudioOutputUnitStart(s->output_unit) != 0) {
    return SA_ERROR_SYSTEM;
  }
  s->playing = TRUE;

  return SA_SUCCESS;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:29,代码来源:sydney_audio_mac.c

示例9: audiounits_start

static int audiounits_start(void *usr) {
	au_instance_t *ap = (au_instance_t*) usr;
	OSStatus err;
	if (ap->kind == AI_RECORDER) {
#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED>=MAC_OS_X_VERSION_10_5)
		err = AudioDeviceStart(ap->inDev, ap->inIOProcID);
#else
		err = AudioDeviceStart(ap->inDev, inputRenderProc);
#endif
		if (err) Rf_error("unable to start recording (%08x)", err);
	} else {
		AURenderCallbackStruct renderCallback = { outputRenderProc, usr };
		ap->done = NO;
		/* set format */
		ap->fmtOut.mSampleRate = ap->sample_rate;
		err = AudioUnitSetProperty(ap->outUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &ap->fmtOut, sizeof(ap->fmtOut));
		if (err) Rf_error("unable to set output audio format (%08x)", err);
		/* set callback */
		err = AudioUnitSetProperty(ap->outUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &renderCallback, sizeof(renderCallback));
		if (err) Rf_error("unable to register audio callback (%08x)", err);
		/* start audio */
		err = AudioOutputUnitStart(ap->outUnit);
		if (err) Rf_error("unable to start playback (%08x)", err);
	}
	return 1;
}
开发者ID:brezniczky,项目名称:audio,代码行数:26,代码来源:au.c

示例10: write_coreaudio

static int write_coreaudio(audio_output_t *ao, unsigned char *buf, int len)
{
	mpg123_coreaudio_t* ca = (mpg123_coreaudio_t*)ao->userptr;
	int written;

	/* If there is no room, then sleep for half the length of the FIFO */
	while (sfifo_space( &ca->fifo ) < len ) {
		usleep( (FIFO_DURATION/2) * 1000000 );
	}
	
	/* Store converted audio in ring buffer */
	written = sfifo_write( &ca->fifo, (char*)buf, len);
	if (written != len) {
		warning( "Failed to write audio to ring buffer" );
		return -1;
	}
	
	/* Start playback now that we have something to play */
	if(!ca->play)
	{
		if(AudioOutputUnitStart(ca->outputUnit)) {
			error("AudioOutputUnitStart failed");
			return(-1);
		}
		ca->play = 1;
	}
	
	return len;
}
开发者ID:abraxasrex,项目名称:mpk-mini-js,代码行数:29,代码来源:coreaudio.c

示例11: ca_start_w

static void ca_start_w(CAData *d){
	OSStatus err= noErr;

	if (d->write_started==FALSE){
		AudioStreamBasicDescription inASBD;
		int i;
		
		i = ca_open_w(d);
		if (i<0)
			return;

		inASBD = d->caOutASBD;
		inASBD.mSampleRate = d->rate;
		inASBD.mFormatID = kAudioFormatLinearPCM;
		inASBD.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
		if (htonl(0x1234) == 0x1234)
		  inASBD.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
		inASBD.mChannelsPerFrame = d->stereo ? 2 : 1;
		inASBD.mBytesPerPacket = (d->bits / 8) * inASBD.mChannelsPerFrame;
		inASBD.mBytesPerFrame = (d->bits / 8) * inASBD.mChannelsPerFrame;
		inASBD.mFramesPerPacket = 1;
		inASBD.mBitsPerChannel = d->bits;


		err = AudioConverterNew( &inASBD, &d->caOutASBD, &d->caOutConverter);
		if(err != noErr)
			ms_error("AudioConverterNew %x %d", err, inASBD.mBytesPerFrame);
		else
			CAShow(d->caOutConverter);

		if (inASBD.mChannelsPerFrame == 1 && d->caOutASBD.mChannelsPerFrame == 2)
		{
			if (d->caOutConverter)
			{
				// This should be as large as the number of output channels,
				// each element specifies which input channel's data is routed to that output channel
				SInt32 channelMap[] = { 0, 0 };
				err = AudioConverterSetProperty(d->caOutConverter, kAudioConverterChannelMap, 2*sizeof(SInt32), channelMap);
			}
		}

		memset((char*)&d->caOutRenderCallback, 0, sizeof(AURenderCallbackStruct));
		d->caOutRenderCallback.inputProc = writeRenderProc;
		d->caOutRenderCallback.inputProcRefCon = d;
		err = AudioUnitSetProperty (d->caOutAudioUnit, 
                            kAudioUnitProperty_SetRenderCallback, 
                            kAudioUnitScope_Input, 
                            0,
                            &d->caOutRenderCallback, 
                            sizeof(AURenderCallbackStruct));
		if(err != noErr)
			ms_error("AudioUnitSetProperty %x", err);

		if(err == noErr) {
			if(AudioOutputUnitStart(d->caOutAudioUnit) == noErr)
				d->write_started=TRUE;
		}
	}
}
开发者ID:biddyweb,项目名称:mediastream-plus,代码行数:59,代码来源:macsnd.c

示例12: coreaudio_start

static bool coreaudio_start(void *data)
{
   coreaudio_t *dev = (coreaudio_t*)data;
   if (!dev)
      return false;
   dev->is_paused = (AudioOutputUnitStart(dev->dev) == noErr) ? false : true;
   return dev->is_paused ? false : true;
}
开发者ID:ColinKinloch,项目名称:RetroArch,代码行数:8,代码来源:coreaudio.c

示例13: AudioOutputUnitStart

void AudioLoopImplCocoa::start()
{
    if (initialized)
    {
        OSStatus err = AudioOutputUnitStart(audioUnit);
        if (err) printf("AudioOutputUnitStart ERROR: %d\n", (int)err);
    }
}
开发者ID:arielm,项目名称:new-chronotext-toolkit,代码行数:8,代码来源:AudioLoopImplCocoa.cpp

示例14: OFXAU_RET_BOOL

// ----------------------------------------------------------
bool ofxAudioUnitInput::start()
// ----------------------------------------------------------
{
	if(!_impl->isReady) _impl->isReady = configureInputDevice();
	if(!_impl->isReady) return false;
	
	OFXAU_RET_BOOL(AudioOutputUnitStart(*_unit), "starting hardware input unit");
}
开发者ID:microcosm,项目名称:ofxAudioUnit,代码行数:9,代码来源:ofxAudioUnitInput.cpp

示例15: ao_plugin_play

int ao_plugin_play(ao_device *device, const char *output_samples,
		uint_32 num_bytes)
{
  ao_macosx_internal *internal = (ao_macosx_internal *) device->internal;
  int err;
  unsigned int bytesToCopy;
  unsigned int firstEmptyByteOffset, emptyByteCount;

  while (num_bytes) {

    // Get a consistent set of data about the available space in the queue,
    // figure out the maximum number of bytes we can copy in this chunk,
    // and claim that amount of space
    pthread_mutex_lock(&mutex);

    // Wait until there is some empty space in the queue
    emptyByteCount = internal->bufferByteCount - internal->validByteCount;
    while (emptyByteCount == 0) {
      if(!internal->started){
	err = AudioOutputUnitStart(internal->outputAudioUnit);
	adebug("Starting audio output unit\n");
	if(err){
	  pthread_mutex_unlock(&mutex);
	  aerror("Failed to start audio output => %d\n",(int)err);
	  return 0;
	}
	internal->started = true;
      }

      err = pthread_cond_wait(&cond, &mutex);
      if (err)
        adebug("pthread_cond_wait() => %d\n",err);
      emptyByteCount = internal->bufferByteCount - internal->validByteCount;
    }

    // Compute the offset to the first empty byte and the maximum number of
    // bytes we can copy given the fact that the empty space might wrap
    // around the end of the queue.
    firstEmptyByteOffset = (internal->firstValidByteOffset + internal->validByteCount) % internal->bufferByteCount;
    if (firstEmptyByteOffset + emptyByteCount > internal->bufferByteCount)
      bytesToCopy = MIN(num_bytes, internal->bufferByteCount - firstEmptyByteOffset);
    else
      bytesToCopy = MIN(num_bytes, emptyByteCount);

    // Copy the bytes and get ready for the next chunk, if any
    memcpy(internal->buffer + firstEmptyByteOffset, output_samples, bytesToCopy);

    num_bytes -= bytesToCopy;
    output_samples += bytesToCopy;
    internal->validByteCount += bytesToCopy;

    pthread_mutex_unlock(&mutex);

  }

  return 1;
}
开发者ID:MisterZeus,项目名称:libao,代码行数:57,代码来源:ao_macosx.c


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