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

C++ AudioQueueStart函数代码示例

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

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



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

示例1: auPlay

/*auStart-------------------------------------------------*/
BOOL auPlay(Audio* self)
{ 
  if(!self->isPlaying)
    {

#ifdef __APPLE__
      int i;
      for(i=0; i<AU_NUM_AUDIO_BUFFERS; i++)
        {
          if(self->isOutput)
            auAudioOutputCallback(self, self->queue, self->buffers[i]);
          else
            AudioQueueEnqueueBuffer(self->queue, self->buffers[i],0, NULL);
        }
      OSStatus error = AudioQueueStart(self->queue, NULL);
      if(error) fprintf(stderr, "Audio.c: unable to start queue\n");

#elif defined __linux__
      int error = pthread_create(&(self->thread), NULL, auAudioCallback, self);
      if(error != 0) perror("Audio.c: error creating Audio thread");

#endif
      else self->isPlaying = YES;
    }
    
  return self->isPlaying;
}
开发者ID:masinde70,项目名称:Everything,代码行数:28,代码来源:AudioSuperclass.c


示例2: seekToPacket

 void seekToPacket(uint64_t packet) {
     AudioQueueStop(aqData.mQueue, true);
     aqData.mCurrentPacket = rand()%1000;
     primeBuffer();
     AudioQueueStart(aqData.mQueue, NULL);
     
 }
开发者ID:sammyshj,项目名称:assignment,代码行数:7,代码来源:AudioPlayer.cpp


示例3: sizeof

void CL_SoundOutput_MacOSX::mixer_thread_starting()
{
    audio_format.mSampleRate = frequency;
    audio_format.mFormatID = kAudioFormatLinearPCM;
    audio_format.mFormatFlags = kAudioFormatFlagsCanonical;
    audio_format.mBytesPerPacket = 2 * sizeof(short);
    audio_format.mFramesPerPacket = 1;
    audio_format.mBytesPerFrame = 2 * sizeof(short);
    audio_format.mChannelsPerFrame = 2;
    audio_format.mBitsPerChannel = sizeof(short) * 8;
    audio_format.mReserved = 0;

    OSStatus result = AudioQueueNewOutput(&audio_format, &CL_SoundOutput_MacOSX::static_audio_queue_callback, this, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 0, &audio_queue);
    if (result != 0)
        throw CL_Exception("AudioQueueNewOutput failed");

    for (int i = 0; i < fragment_buffer_count; i++)
    {
        result = AudioQueueAllocateBuffer(audio_queue, fragment_size * sizeof(short) * 2, &audio_buffers[i]);
        if (result != 0)
            throw CL_Exception("AudioQueueAllocateBuffer failed");
        audio_queue_callback(audio_queue, audio_buffers[i]);
    }
    
    result = AudioQueueStart(audio_queue, 0);
    if (result != 0)
        throw CL_Exception("AudioQueueStart failed");
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:28,代码来源:soundoutput_macosx.cpp


示例4: pthread_mutex_lock

void
Moose::Sound::CMusicClip::Play()
{
    
 if ( IsPaused())
 {
     m_bPaused = false;
     pthread_mutex_lock(&m_pData->mutex); 
     AudioQueueStart(m_pData->audioQueue, NULL);
     pthread_mutex_unlock(&m_pData->mutex);
 }
 else 
 {
     if ( IsRunning()) Stop();
     if ( m_bHasThread ) 
     {
         void *status;
         pthread_join(m_thread, &status);
         m_bHasThread = false;
     }
     OSStatus err = pthread_create( &m_thread, NULL, audio_decode_play_proc, this);
     if ( err ) {
         g_Error << "Could not create thread for music clip, error: " << err << endl;
         
     }
    }
      
	
	    
    
}
开发者ID:moose3d,项目名称:moose,代码行数:31,代码来源:MooseMusicClip.cpp


示例5: printf

bool QueueAudioData::start()
      {
      printf("QueueAudioData::start()\n");
      AudioQueueStart(audioQueue, 0);
      running = true;
      return true;
      }
开发者ID:SSMN,项目名称:MuseScore,代码行数:7,代码来源:audioqueue.cpp


示例6: play

void play() {
    int i;

    AudioStreamBasicDescription format;
    AudioQueueRef queue;
    AudioQueueBufferRef buffers[NUM_BUFFERS];

    format.mSampleRate       = SAMPLE_RATE;
    format.mFormatID         = kAudioFormatLinearPCM;
    format.mFormatFlags      = kLinearPCMFormatFlagIsSignedInteger |
                               kAudioFormatFlagIsPacked;
    format.mBitsPerChannel   = 8*sizeof(SAMPLE_TYPE);
    format.mChannelsPerFrame = NUM_CHANNELS;
    format.mBytesPerFrame    = sizeof(SAMPLE_TYPE)*NUM_CHANNELS;
    format.mFramesPerPacket  = 1;
    format.mBytesPerPacket   = format.mBytesPerFrame*format.mFramesPerPacket;
    format.mReserved         = 0;
    
    AudioQueueNewOutput(&format, callback, NULL, CFRunLoopGetCurrent(),
                        kCFRunLoopCommonModes, 0, &queue);
    
    for (i = 0; i < NUM_BUFFERS; i++) {
        AudioQueueAllocateBuffer(queue, BUFFER_SIZE, &buffers[i]);
        buffers[i]->mAudioDataByteSize = BUFFER_SIZE;
        callback(NULL, queue, buffers[i]);
    }
    AudioQueueStart(queue, NULL);
    CFRunLoopRun();    
}
开发者ID:chreekat,项目名称:Moodler,代码行数:29,代码来源:audio.c


示例7: play

    void play() {
        
        OSStatus status;
        
        aqData.mIsRunning = true;                          // 1
        aqData.mCurrentPacket = 0;                                // 1

        primeBuffer();
        
        Float32 gain = 1.0;                                       // 1
            // Optionally, allow user to override gain setting here
        status = AudioQueueSetParameter (                                  // 2
            aqData.mQueue,                                        // 3
            kAudioQueueParam_Volume,                              // 4
            gain                                                  // 5
        );
        checkStatus(status);

        status = AudioQueueStart (                                  // 2
            aqData.mQueue,                                 // 3
            NULL                                           // 4
        );
        checkStatus(status);

    }
开发者ID:sammyshj,项目名称:assignment,代码行数:25,代码来源:AudioPlayer.cpp


示例8: cs

void IPhoneSoundDevice::Enable(bool fEnable)
{
    base::CritScope cs(&m_crit);

    if (fEnable) {
        if (!m_fEnable) {
            memset(m_achnl, 0, sizeof(m_achnl));
            m_tSilence = 0;
            m_fEnable = true;
            for (int i = 0; i < kcBuffers; i++) {
                InitAudioBuffer(m_apaqb[i]);
            }
            AudioQueuePrime(m_haq, 0, NULL);
            AudioQueueStart(m_haq, NULL);
            SetSoundServiceDevice(this);
        }
    } else {
        if (m_fEnable) {
            m_fEnable = false;
            memset(m_achnl, 0, sizeof(m_achnl));
            m_tSilence = 0;
            AudioQueueStop(m_haq, false);
            SetSoundServiceDevice(NULL);
        }
    }
}
开发者ID:Ahmar,项目名称:hostile-takeover,代码行数:26,代码来源:iphonesounddev.cpp


示例9: setup_queue

int32_t setup_queue(
	ALACMagicCookie cookie,
	PlayerInfo *playerInfo,
	uint32_t buffer_size,
	uint32_t num_buffers,
	uint32_t num_packets
) {
  // Create Audio Queue for ALAC
  AudioStreamBasicDescription inFormat = {0};
  inFormat.mSampleRate = ntohl(cookie.sampleRate);
  inFormat.mFormatID = kAudioFormatAppleLossless;
  inFormat.mFormatFlags = 0; // ALAC uses no flags
  inFormat.mBytesPerPacket = 0; // Variable size (must use AudioStreamPacketDescription)
  inFormat.mFramesPerPacket = ntohl(cookie.frameLength);
  inFormat.mBytesPerFrame = 0; // Compressed
  inFormat.mChannelsPerFrame = 2; // Stero TODO: get from fmtp?
  inFormat.mBitsPerChannel = 0; // Compressed
  inFormat.mReserved = 0;

  OSStatus err = AudioQueueNewOutput(
      &inFormat,
      c_callback,
      playerInfo, // User data
      NULL, // Run on audio queue's thread
      NULL, // Callback run loop's mode
      0, // Reserved
      &playerInfo->queue);

  if (err) return err;

  // Need to set the magic cookie too (tail fmtp)
  err = AudioQueueSetProperty(playerInfo->queue, kAudioQueueProperty_MagicCookie,
			&cookie, sizeof(ALACMagicCookie));
  if (err) return err;

	// Create input buffers, and enqueue using callback
	for (int i = 0; i < num_buffers; i++) {
		AudioQueueBufferRef buffer;
		err = AudioQueueAllocateBufferWithPacketDescriptions(
				playerInfo->queue, buffer_size, num_packets, &buffer);
		if (err) return err;

		c_callback(playerInfo, playerInfo->queue, buffer);
	}

	// Volume full
	err = AudioQueueSetParameter(playerInfo->queue, kAudioQueueParam_Volume, 1.0);
	if (err) return err;

  // Prime
  err = AudioQueuePrime(playerInfo->queue, 0, NULL);
  if (err) return err;

	// Start
	err = AudioQueueStart(playerInfo->queue, NULL);
	if (err) return err;

	return 0;
}
开发者ID:gopherstein,项目名称:air-mixer,代码行数:59,代码来源:core_audio_play.c


示例10: Open

static int Open ( vlc_object_t *p_this )
{
    audio_output_t *p_aout = (audio_output_t *)p_this;
    struct aout_sys_t *p_sys = malloc(sizeof(aout_sys_t));
    p_aout->sys = p_sys;

    OSStatus status = 0;

    // Setup the audio device.
    AudioStreamBasicDescription deviceFormat;
    deviceFormat.mSampleRate = 44100;
    deviceFormat.mFormatID = kAudioFormatLinearPCM;
    deviceFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger; // Signed integer, little endian
    deviceFormat.mBytesPerPacket = 4;
    deviceFormat.mFramesPerPacket = 1;
    deviceFormat.mBytesPerFrame = 4;
    deviceFormat.mChannelsPerFrame = 2;
    deviceFormat.mBitsPerChannel = 16;
    deviceFormat.mReserved = 0;

    // Create a new output AudioQueue for the device.
    status = AudioQueueNewOutput(&deviceFormat,         // Format
                                 AudioQueueCallback,    // Callback
                                 p_aout,                // User data, passed to the callback
                                 CFRunLoopGetMain(),    // RunLoop
                                 kCFRunLoopDefaultMode, // RunLoop mode
                                 0,                     // Flags ; must be zero (per documentation)...
                                 &(p_sys->audioQueue)); // Output

    // This will be used for boosting the audio without the need of a mixer (floating-point conversion is expensive on ARM)
    // AudioQueueSetParameter(p_sys->audioQueue, kAudioQueueParam_Volume, 12.0); // Defaults to 1.0

    msg_Dbg(p_aout, "New AudioQueue output created (status = %i)", status);

    // Allocate buffers for the AudioQueue, and pre-fill them.
    for (int i = 0; i < NUMBER_OF_BUFFERS; ++i) {
        AudioQueueBufferRef buffer = NULL;
        status = AudioQueueAllocateBuffer(p_sys->audioQueue, FRAME_SIZE * 4, &buffer);
        AudioQueueCallback(NULL, p_sys->audioQueue, buffer);
    }

    /* Volume is entirely done in software. */
    aout_SoftVolumeInit( p_aout );

    p_aout->format.i_format = VLC_CODEC_S16L;
    p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
    p_aout->format.i_rate = 44100;
    aout_PacketInit(p_aout, &p_sys->packet, FRAME_SIZE);
    p_aout->pf_play = aout_PacketPlay;
    p_aout->pf_pause = aout_PacketPause;
    p_aout->pf_flush = aout_PacketFlush;

    msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status);
    status = AudioQueueStart(p_sys->audioQueue, NULL);

    return VLC_SUCCESS;
}
开发者ID:RodrigoNieves,项目名称:vlc,代码行数:57,代码来源:audioqueue.c


示例11: app_OpenSound

int app_OpenSound(int samples_per_sync, int sample_rate) {
    Float64 sampleRate = 44100.0;
    int i;

    LOGDEBUG("app_SoundOpen()");
    
    app_MuteSound();
    
    if(preferences.muted)
    {
    	return 0;
    }

    soundInit = 0;

    in.mDataFormat.mSampleRate = sampleRate;
    in.mDataFormat.mFormatID = kAudioFormatLinearPCM;
    in.mDataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger
                                | kAudioFormatFlagIsPacked;
    in.mDataFormat.mBytesPerPacket = 4;
    in.mDataFormat.mFramesPerPacket = 1;
    in.mDataFormat.mBytesPerFrame = 2;
    in.mDataFormat.mChannelsPerFrame = 2;
    in.mDataFormat.mBitsPerChannel = 16;

    /* Pre-buffer before we turn on audio */
    UInt32 err;
    err = AudioQueueNewOutput(&in.mDataFormat,
                      AQBufferCallback,
                      &in,
                      NULL,
                      kCFRunLoopCommonModes,
                      0,
                      &in.queue);
   if (err) {
     LOGDEBUG("AudioQueueNewOutput err %d\n", err);
   }

   in.frameCount = 512 * 1; //512; //(1024 * (16)) / 4;
   UInt32 bufferBytes = in.frameCount * in.mDataFormat.mBytesPerFrame;

   for (i=0; i<AUDIO_BUFFERS; i++) {
      err = AudioQueueAllocateBuffer(in.queue, bufferBytes, &in.mBuffers[i]);
      if (err) {
	LOGDEBUG("AudioQueueAllocateBuffer[%d] err %d\n",i, err);
      }
      /* "Prime" by calling the callback once per buffer */
      AQBufferCallback (&in, in.queue, in.mBuffers[i]);
   }

   soundInit = 1;
   LOGDEBUG("app_QueueSample.AudioQueueStart");
   err = AudioQueueStart(in.queue, NULL);
   
    return 0;
}
开发者ID:Garrant3,项目名称:gameboy4iphone,代码行数:56,代码来源:app_iPhone.c


示例12: Start

		OSStatus Start()
		{
			OSStatus result = AudioQueuePrime(mQueue, 1, NULL);	
			if (result)
			{
				printf("Error priming queue");
				return result;
			}
			return AudioQueueStart(mQueue, NULL);
		}
开发者ID:melling,项目名称:Sierpinski,代码行数:10,代码来源:SoundEngine.cpp


示例13: StartQueueIfNeeded

OSStatus StartQueueIfNeeded(struct audioPlayer* player)
{
	OSStatus err = noErr;
	if (!player->started) {		// start the queue if it has not been started already
		err = AudioQueueStart(player->audioQueue, NULL);
		if (err) { PRINTERROR("AudioQueueStart"); player->failed = true; return err; }		
		player->started = true;
	}
	return err;
}
开发者ID:mattball,项目名称:pianobar,代码行数:10,代码来源:mac_audio.c


示例14: audio_start

void audio_start(audio_player_t *player) {
	state_t *state = (state_t *) player->internal_state;
	if (noErr != AudioQueueStart(state->queue, NULL)) puts("AudioQueueStart failed");
	state->playing = true;
	if (state->running) {
		if (player->on_start) {
			player->on_start(player);
		}
	}
}
开发者ID:also,项目名称:spotfm,代码行数:10,代码来源:osx-audio.c


示例15: StartQueueIfNeeded

OSStatus StartQueueIfNeeded(MyData* myData)
{
	OSStatus err = noErr;
	if (!myData->started) {		// start the queue if it has not been started already
		err = AudioQueueStart(myData->audioQueue, NULL);
		if (err) { PRINTERROR("AudioQueueStart"); myData->failed = true; return err; }		
		myData->started = true;
		printf("started\n");
	}
	return err;
}
开发者ID:fruitsamples,项目名称:AudioFileStreamExample,代码行数:11,代码来源:afsclient.cpp


示例16: AQ_TRACE

void Audio_Queue::pause()
{
    if (m_state == RUNNING) {
        if (AudioQueuePause(m_outAQ) != 0) {
            AQ_TRACE("Audio_Queue::pause(): AudioQueuePause failed!\n");
        }
        setState(PAUSED);
    } else if (m_state == PAUSED) {
        AudioQueueStart(m_outAQ, NULL);
        setState(RUNNING);
    }
}
开发者ID:chinshou,项目名称:FreeStreamer,代码行数:12,代码来源:audio_queue.cpp


示例17: AudioQueueStart

void CAudioQueueManager::resume() {
	if (_isRunning)
		return;
	
	if (!_isInitialized) {
		_autoStart = true;
		return;
	}
	
	AudioQueueStart(_queue, NULL);
	_isRunning = true;
}
开发者ID:mdbergmann,项目名称:iAmiga,代码行数:12,代码来源:AudioQueueManager.cpp


示例18: AudioQueueEnqueueBuffer

long AudioStreamDecoder::EnqueueBuffer()
{
	bool locked = false;

	if (mFinished)
		return 0;

	long err = AudioQueueEnqueueBuffer(mQueue, *mCurrentBuffer, 0, NULL);
	BAIL_IF(err, "AudioQueueEnqueueBuffer returned %ld\n", err);

	if (++mCurrentBuffer == mBuffers + kBufferCount)
		mCurrentBuffer = mBuffers;

	if (!mStarted && !mFinished)
	{
		mStarted = true;

		err = AudioQueueStart(mQueue, NULL);
		BAIL_IF(err, "AudioQueueStart returned %ld\n", err);
	}

	err = pthread_mutex_lock(&mMutex);
	BAIL_IF(err, "pthread_mutex_lock returned %ld\n", err);

	locked = true;

	while ((*mCurrentBuffer)->mUserData && !mFinished)
	{
		err = pthread_cond_wait(&mCond, &mMutex);
		BAIL_IF(err, "pthread_cond_wait returned %ld\n", err);
	}

	(*mCurrentBuffer)->mUserData = this;
	(*mCurrentBuffer)->mAudioDataByteSize = 0;
	(*mCurrentBuffer)->mPacketDescriptionCount = 0;

bail:
	long err2;

	if (locked)
	{
		err2 = pthread_mutex_unlock(&mMutex);
		CARP_IF(err2, "pthread_mutex_unlock returned %ld\n", err2);
	}

	if (err && mStarted)
	{
		err2 = SetFinished();
		CARP_IF(err2, "SetFinished returned %ld\n", err2);
	}

	return err;
}
开发者ID:hhool,项目名称:Blackmagic_DeckLink_SDK,代码行数:53,代码来源:AudioStreamDecoder.cpp


示例19: AudioQueueStart

void Audio_Queue::startQueueIfNeeded()
{
    if (!m_audioQueueStarted) {
        // start the queue if it has not been started already
        OSStatus err = AudioQueueStart(m_outAQ, NULL);
        if (!err) {
            m_audioQueueStarted = true;
            m_lastError = noErr;
        } else {	
            m_lastError = err;
        }
    }
}
开发者ID:chinshou,项目名称:FreeStreamer,代码行数:13,代码来源:audio_queue.cpp


示例20: dmsg

    /**
     * Entry point for the thread.
     */
    int AudioOutputDeviceCoreAudio::Main() {
        dmsg(1,("CoreAudio thread started\n"));
        OSStatus res;
        if(aqPlayerState.mQueue == NULL) {
            /*
             * Need to be run from this thread because of CFRunLoopGetCurrent()
             * which returns the CFRunLoop object for the current thread.
             */
            try { CreateAndStartAudioQueue(); }
            catch(Exception e) {
                std::cerr << "Failed to star audio queue: " + e.Message() << std::endl;
                return 0;
            }
        }

        destroyMutex.Lock();
        do {
            if(atomic_read(&pausedNew) != pausedOld) {
                pausedOld = atomic_read(&pausedNew);

                if(pausedOld) {
                    res = AudioQueuePause(aqPlayerState.mQueue);
                    if(res) std::cerr << "AudioQueuePause: Error " << res << std::endl;
                } else {
                    res = AudioQueuePrime(aqPlayerState.mQueue, 0, NULL);
                    if(res) std::cerr << "AudioQueuePrime: Error " << res << std::endl;
                    res = AudioQueueStart(aqPlayerState.mQueue, NULL);
                    if(res) std::cerr << "AudioQueueStart: Error " << res << std::endl;
                }
            }

            if(atomic_read(&restartQueue)) {
                DestroyAudioQueue();
                try { CreateAndStartAudioQueue(); }
                catch(Exception e) {
                    destroyMutex.Unlock();
                    throw e;
                }
                atomic_set(&restartQueue, 0);
                dmsg(1,("Audio queue restarted"));
            }
            
            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.2, false);
        } while (atomic_read(&(aqPlayerState.mIsRunning)));
        destroyMutex.Unlock();

        dmsg(2,("CoreAudio thread stopped\n"));

        pthread_exit(NULL);
        return 0;
    }
开发者ID:svn2github,项目名称:linuxsampler,代码行数:54,代码来源:AudioOutputDeviceCoreAudio.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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