本文整理汇总了C++中AudioQueueStart函数的典型用法代码示例。如果您正苦于以下问题:C++ AudioQueueStart函数的具体用法?C++ AudioQueueStart怎么用?C++ AudioQueueStart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AudioQueueStart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: seekToPacket
void seekToPacket(uint64_t packet) {
AudioQueueStop(aqData.mQueue, true);
aqData.mCurrentPacket = rand()%1000;
primeBuffer();
AudioQueueStart(aqData.mQueue, NULL);
}
示例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");
}
示例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;
}
}
}
示例5: printf
bool QueueAudioData::start()
{
printf("QueueAudioData::start()\n");
AudioQueueStart(audioQueue, 0);
running = true;
return true;
}
示例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();
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例12: Start
OSStatus Start()
{
OSStatus result = AudioQueuePrime(mQueue, 1, NULL);
if (result)
{
printf("Error priming queue");
return result;
}
return AudioQueueStart(mQueue, NULL);
}
示例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;
}
示例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);
}
}
}
示例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;
}