From 8eaba5b0025b5cc3a6384944161578a78d53d123 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 24 Nov 2017 12:46:01 +0100 Subject: [PATCH] Fixed mac server compilation. --- server/CMakeLists.txt | 2 +- server/Mac/mf_info.c | 5 +- server/Mac/mf_input.c | 117 ++++++++++++++++----------------- server/Mac/mf_input.h | 18 ++--- server/Mac/mf_peer.c | 143 +++++++++++++++++++++------------------- server/Mac/mf_peer.h | 17 ----- server/Mac/mf_rdpsnd.c | 146 ++++++++++++++++++----------------------- 7 files changed, 210 insertions(+), 238 deletions(-) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 24f7bb182..65e5c5140 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -27,7 +27,7 @@ if(FREERDP_VENDOR) if(NOT WIN32) if(APPLE AND (NOT IOS)) - #add_subdirectory(Mac) + add_subdirectory(Mac) endif() else() #add_subdirectory(Windows) diff --git a/server/Mac/mf_info.c b/server/Mac/mf_info.c index 13254445d..da7b44d06 100644 --- a/server/Mac/mf_info.c +++ b/server/Mac/mf_info.c @@ -28,6 +28,9 @@ #include "mf_info.h" #include "mf_mountain_lion.h" +#define MF_INFO_DEFAULT_FPS 30 +#define MF_INFO_MAXPEERS 32 + static mfInfo* mfInfoInstance = NULL; int mf_info_lock(mfInfo* mfi) @@ -142,7 +145,7 @@ void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context) mf_mlion_start_getting_screen_updates(); } - peerId = NULL; + peerId = 0; for(i=0; iservscreen_width; height = (float) mfi->servscreen_height; - x += mfi->servscreen_xoffset; y += mfi->servscreen_yoffset; - + if (flags & PTR_FLAGS_MOVE) { if (mfi->mouse_down_left == TRUE) @@ -433,21 +427,20 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { mouseType = kCGEventMouseMoved; } - + CGEventRef move = CGEventCreateMouseEvent(source, - mouseType, - CGPointMake(x, y), - mouseButton // ignored for just movement - ); - + mouseType, + CGPointMake(x, y), + mouseButton // ignored for just movement + ); CGEventPost(kCGHIDEventTap, move); - CFRelease(move); } - + if (flags & PTR_FLAGS_BUTTON1) { mouseButton = kCGMouseButtonLeft; + if (flags & PTR_FLAGS_DOWN) { mouseType = kCGEventLeftMouseDown; @@ -462,6 +455,7 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) else if (flags & PTR_FLAGS_BUTTON2) { mouseButton = kCGMouseButtonRight; + if (flags & PTR_FLAGS_DOWN) { mouseType = kCGEventRightMouseDown; @@ -472,11 +466,11 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) mouseType = kCGEventRightMouseUp; mfi->mouse_down_right = FALSE; } - } else if (flags & PTR_FLAGS_BUTTON3) { mouseButton = kCGMouseButtonCenter; + if (flags & PTR_FLAGS_DOWN) { mouseType = kCGEventOtherMouseDown; @@ -487,40 +481,43 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) mouseType = kCGEventOtherMouseUp; mfi->mouse_down_other = FALSE; } - } - - + CGEventRef mouseEvent = CGEventCreateMouseEvent(source, - mouseType, - CGPointMake(x, y), - mouseButton - ); + mouseType, + CGPointMake(x, y), + mouseButton + ); CGEventPost(kCGHIDEventTap, mouseEvent); - CFRelease(mouseEvent); CFRelease(source); } + + return TRUE; } -void mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) +BOOL mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { - + return FALSE; } -void mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code) +BOOL mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code) { + return FALSE; } -void mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code) +BOOL mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code) { + return FALSE; } -void mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) +BOOL mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { + return FALSE; } -void mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) +BOOL mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { + return FALSE; } diff --git a/server/Mac/mf_input.h b/server/Mac/mf_input.h index 8e8903cfb..336ac24f1 100644 --- a/server/Mac/mf_input.h +++ b/server/Mac/mf_input.h @@ -22,15 +22,15 @@ #include "mf_interface.h" -void mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code); -void mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code); -void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); -void mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); +BOOL mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code); +BOOL mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code); +BOOL mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); +BOOL mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); //dummy versions -void mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code); -void mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code); -void mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); -void mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); +BOOL mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code); +BOOL mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code); +BOOL mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); +BOOL mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); -#endif /* FREERDP_SERVER_MAC_INPUT_H */ \ No newline at end of file +#endif /* FREERDP_SERVER_MAC_INPUT_H */ diff --git a/server/Mac/mf_peer.c b/server/Mac/mf_peer.c index bcc09140f..feafe1273 100644 --- a/server/Mac/mf_peer.c +++ b/server/Mac/mf_peer.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -33,6 +34,7 @@ #include "mf_input.h" #include "mf_event.h" #include "mf_rdpsnd.h" +#include "mf_audin.h" #include #include @@ -44,22 +46,19 @@ #include "CoreVideo/CoreVideo.h" //refactor these -int info_last_sec = 0; -int info_last_nsec = 0; +static int info_last_sec = 0; +static int info_last_nsec = 0; -dispatch_source_t info_timer; -dispatch_queue_t info_queue; +static dispatch_source_t info_timer; +static dispatch_queue_t info_queue; -mfEventQueue* info_event_queue; +static mfEventQueue* info_event_queue; +static CGLContextObj glContext; +static CGContextRef bmp; +static CGImageRef img; -CGLContextObj glContext; -CGContextRef bmp; -CGImageRef img; - - - -BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) +static BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) { if (info_event_queue->pipe_fd[0] == -1) return TRUE; @@ -69,33 +68,8 @@ BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) return TRUE; } -BOOL mf_peer_check_fds(freerdp_peer* client) -{ - mfPeerContext* context = (mfPeerContext*) client->context; - mfEvent* event; - if (context->activated == FALSE) - return TRUE; - - event = mf_event_peek(info_event_queue); - - if (event != NULL) - { - if (event->type == MF_EVENT_TYPE_REGION) - { - } - else if (event->type == MF_EVENT_TYPE_FRAME_TICK) - { - event = mf_event_pop(info_event_queue); - mf_peer_rfx_update(client); - mf_event_free(event); - } - } - - return TRUE; -} - -void mf_peer_rfx_update(freerdp_peer* client) +static void mf_peer_rfx_update(freerdp_peer* client) { //check mfInfo* mfi = mf_info_get_instance(); @@ -154,8 +128,34 @@ void mf_peer_rfx_update(freerdp_peer* client) //clean up... maybe? } +static BOOL mf_peer_check_fds(freerdp_peer* client) +{ + mfPeerContext* context = (mfPeerContext*) client->context; + mfEvent* event; + + if (context->activated == FALSE) + return TRUE; + + event = mf_event_peek(info_event_queue); + + if (event != NULL) + { + if (event->type == FREERDP_SERVER_MAC_EVENT_TYPE_REGION) + { + } + else if (event->type == FREERDP_SERVER_MAC_EVENT_TYPE_FRAME_TICK) + { + event = mf_event_pop(info_event_queue); + mf_peer_rfx_update(client); + mf_event_free(event); + } + } + + return TRUE; +} + /* Called when we have a new peer connecting */ -BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context) +static BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context) { if (!(context->info = mf_info_get_instance())) return FALSE; @@ -166,7 +166,7 @@ BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context) context->rfx_context->mode = RLGR3; context->rfx_context->width = client->settings->DesktopWidth; context->rfx_context->height = client->settings->DesktopHeight; - rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_BGRA32); + rfx_context_set_pixel_format(context->rfx_context, PIXEL_FORMAT_BGRA32); if (!(context->s = Stream_New(NULL, 0xFFFF))) goto fail_stream_new; @@ -189,7 +189,7 @@ fail_rfx_context: } /* Called after a peer disconnects */ -void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context) +static void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context) { if (context) { @@ -204,19 +204,19 @@ void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context) audin_server_context_free(context->audin); #endif - //#ifdef CHANNEL_RDPSND_SERVER +#ifdef CHANNEL_RDPSND_SERVER mf_peer_rdpsnd_stop(); if (context->rdpsnd) rdpsnd_server_context_free(context->rdpsnd); - //#endif +#endif WTSCloseServer(context->vcm); } } /* Called when a new client connects */ -BOOL mf_peer_init(freerdp_peer* client) +static BOOL mf_peer_init(freerdp_peer* client) { client->ContextSize = sizeof(mfPeerContext); client->ContextNew = (psPeerContextNew) mf_peer_context_new; @@ -239,7 +239,7 @@ BOOL mf_peer_init(freerdp_peer* client) dispatch_source_set_event_handler(info_timer, ^ { //DEBUG_WARN( "dispatch\n"); - mfEvent* event = mf_event_new(MF_EVENT_TYPE_FRAME_TICK); + mfEvent* event = mf_event_new(FREERDP_SERVER_MAC_EVENT_TYPE_FRAME_TICK); mf_event_push(info_event_queue, (mfEvent*) event); } ); @@ -249,7 +249,7 @@ BOOL mf_peer_init(freerdp_peer* client) return TRUE; } -BOOL mf_peer_post_connect(freerdp_peer* client) +static BOOL mf_peer_post_connect(freerdp_peer* client) { mfPeerContext* context = (mfPeerContext*) client->context; rdpSettings* settings = client->settings; @@ -271,12 +271,14 @@ BOOL mf_peer_post_connect(freerdp_peer* client) mfi->mouse_down_left = FALSE; mfi->mouse_down_right = FALSE; mfi->mouse_down_other = FALSE; +#ifdef CHANNEL_RDPSND_SERVER if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpsnd")) { mf_peer_rdpsnd_init(context); /* Audio Output */ } +#endif /* Dynamic Virtual Channels */ #ifdef CHANNEL_AUDIN_SERVER mf_peer_audin_init(context); /* Audio Input */ @@ -284,16 +286,18 @@ BOOL mf_peer_post_connect(freerdp_peer* client) return TRUE; } -BOOL mf_peer_activate(freerdp_peer* client) +static BOOL mf_peer_activate(freerdp_peer* client) { mfPeerContext* context = (mfPeerContext*) client->context; - rfx_context_reset(context->rfx_context); + rfx_context_reset(context->rfx_context, client->settings->DesktopWidth, + client->settings->DesktopHeight); context->activated = TRUE; return TRUE; } -void mf_peer_synchronize_event(rdpInput* input, UINT32 flags) +static BOOL mf_peer_synchronize_event(rdpInput* input, UINT32 flags) { + return TRUE; } void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) @@ -308,29 +312,19 @@ void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) } } -void mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) +static BOOL mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) { -} - -static void mf_peer_suppress_output(rdpContext* context, BYTE allow, - RECTANGLE_16* area) -{ -} - -BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) -{ - pthread_t th; - - if (pthread_create(&th, 0, mf_peer_main_loop, client) == 0) - { - pthread_detach(th); - return TRUE; - } - return FALSE; } -void* mf_peer_main_loop(void* arg) +static BOOL mf_peer_suppress_output(rdpContext* context, BYTE allow, + const RECTANGLE_16* area) +{ + return FALSE; +} + + +static void* mf_peer_main_loop(void* arg) { int i; int fds; @@ -439,3 +433,16 @@ void* mf_peer_main_loop(void* arg) freerdp_peer_free(client); return NULL; } + +BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) +{ + pthread_t th; + + if (pthread_create(&th, 0, mf_peer_main_loop, client) == 0) + { + pthread_detach(th); + return TRUE; + } + + return FALSE; +} diff --git a/server/Mac/mf_peer.h b/server/Mac/mf_peer.h index 9b137dbad..3e14ccdf6 100644 --- a/server/Mac/mf_peer.h +++ b/server/Mac/mf_peer.h @@ -22,23 +22,6 @@ #include "mf_interface.h" -BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount); -BOOL mf_peer_check_fds(freerdp_peer* client); - -void mf_peer_rfx_update(freerdp_peer* client); - -BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context); -void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context); - -BOOL mf_peer_init(freerdp_peer* client); - -BOOL mf_peer_post_connect(freerdp_peer* client); -BOOL mf_peer_activate(freerdp_peer* client); - -void mf_peer_synchronize_event(rdpInput* input, UINT32 flags); - BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client); -void* mf_peer_main_loop(void* arg); - #endif /* FREERDP_SERVER_MAC_PEER_H */ diff --git a/server/Mac/mf_rdpsnd.c b/server/Mac/mf_rdpsnd.c index 6ae987ac1..55900db2c 100644 --- a/server/Mac/mf_rdpsnd.c +++ b/server/Mac/mf_rdpsnd.c @@ -28,6 +28,7 @@ #include "mf_info.h" #include "mf_rdpsnd.h" +#include #include #define TAG SERVER_TAG("mac") @@ -45,7 +46,6 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) int i, j; BOOL formatAgreed = FALSE; AUDIO_FORMAT* agreedFormat = NULL; - //we should actually loop through the list of client formats here //and see if we can send the client something that it supports... WLog_DBG(TAG, "Client supports the following %d formats: ", context->num_client_formats); @@ -65,11 +65,11 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) break; } } + if (formatAgreed == TRUE) break; - } - + if (formatAgreed == FALSE) { WLog_DBG(TAG, "Could not agree on a audio format with the server"); @@ -78,75 +78,66 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) context->SelectFormat(context, i); context->SetVolume(context, 0x7FFF, 0x7FFF); - + switch (agreedFormat->wFormatTag) { case WAVE_FORMAT_ALAW: recorderState.dataFormat.mFormatID = kAudioFormatDVIIntelIMA; break; - + case WAVE_FORMAT_PCM: recorderState.dataFormat.mFormatID = kAudioFormatLinearPCM; break; - + default: recorderState.dataFormat.mFormatID = kAudioFormatLinearPCM; break; } - + recorderState.dataFormat.mSampleRate = agreedFormat->nSamplesPerSec; - recorderState.dataFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;; + recorderState.dataFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | + kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;; recorderState.dataFormat.mBytesPerPacket = 4; recorderState.dataFormat.mFramesPerPacket = 1; recorderState.dataFormat.mBytesPerFrame = 4; recorderState.dataFormat.mChannelsPerFrame = agreedFormat->nChannels; recorderState.dataFormat.mBitsPerChannel = agreedFormat->wBitsPerSample; - - recorderState.snd_context = context; - status = AudioQueueNewInput(&recorderState.dataFormat, - mf_peer_rdpsnd_input_callback, - &recorderState, - NULL, - kCFRunLoopCommonModes, - 0, - &recorderState.queue); - + mf_peer_rdpsnd_input_callback, + &recorderState, + NULL, + kCFRunLoopCommonModes, + 0, + &recorderState.queue); + if (status != noErr) { WLog_DBG(TAG, "Failed to create a new Audio Queue. Status code: %"PRId32"", status); } - - UInt32 dataFormatSize = sizeof (recorderState.dataFormat); - + + UInt32 dataFormatSize = sizeof(recorderState.dataFormat); AudioQueueGetProperty(recorderState.queue, - kAudioConverterCurrentInputStreamDescription, - &recorderState.dataFormat, - &dataFormatSize); - - - mf_rdpsnd_derive_buffer_size(recorderState.queue, &recorderState.dataFormat, 0.05, &recorderState.bufferByteSize); - - + kAudioConverterCurrentInputStreamDescription, + &recorderState.dataFormat, + &dataFormatSize); + mf_rdpsnd_derive_buffer_size(recorderState.queue, &recorderState.dataFormat, 0.05, + &recorderState.bufferByteSize); + for (i = 0; i < SND_NUMBUFFERS; ++i) { AudioQueueAllocateBuffer(recorderState.queue, - recorderState.bufferByteSize, - &recorderState.buffers[i]); - + recorderState.bufferByteSize, + &recorderState.buffers[i]); AudioQueueEnqueueBuffer(recorderState.queue, - recorderState.buffers[i], - 0, - NULL); + recorderState.buffers[i], + 0, + NULL); } - - + recorderState.currentPacket = 0; recorderState.isRunning = true; - - AudioQueueStart (recorderState.queue, NULL); - + AudioQueueStart(recorderState.queue, NULL); } BOOL mf_peer_rdpsnd_init(mfPeerContext* context) @@ -154,19 +145,15 @@ BOOL mf_peer_rdpsnd_init(mfPeerContext* context) context->rdpsnd = rdpsnd_server_context_new(context->vcm); context->rdpsnd->rdpcontext = &context->_p; context->rdpsnd->data = context; - context->rdpsnd->server_formats = supported_audio_formats; - context->rdpsnd->num_server_formats = sizeof(supported_audio_formats) / sizeof(supported_audio_formats[0]); - + context->rdpsnd->num_server_formats = sizeof(supported_audio_formats) / sizeof( + supported_audio_formats[0]); context->rdpsnd->src_format.wFormatTag = 1; context->rdpsnd->src_format.nChannels = 2; context->rdpsnd->src_format.nSamplesPerSec = 44100; context->rdpsnd->src_format.wBitsPerSample = 16; - context->rdpsnd->Activated = mf_peer_rdpsnd_activated; - context->rdpsnd->Initialize(context->rdpsnd, TRUE); - return TRUE; } @@ -174,71 +161,66 @@ BOOL mf_peer_rdpsnd_stop() { recorderState.isRunning = false; AudioQueueStop(recorderState.queue, true); - return TRUE; } -void mf_peer_rdpsnd_input_callback (void *inUserData, - AudioQueueRef inAQ, - AudioQueueBufferRef inBuffer, - const AudioTimeStamp *inStartTime, - UInt32 inNumberPacketDescriptions, - const AudioStreamPacketDescription *inPacketDescs) +void mf_peer_rdpsnd_input_callback(void* inUserData, + AudioQueueRef inAQ, + AudioQueueBufferRef inBuffer, + const AudioTimeStamp* inStartTime, + UInt32 inNumberPacketDescriptions, + const AudioStreamPacketDescription* inPacketDescs) { OSStatus status; - AQRecorderState * rState; + AQRecorderState* rState; rState = inUserData; - - + if (inNumberPacketDescriptions == 0 && rState->dataFormat.mBytesPerPacket != 0) { inNumberPacketDescriptions = inBuffer->mAudioDataByteSize / rState->dataFormat.mBytesPerPacket; } - - + if (rState->isRunning == 0) { return ; } - + rState->snd_context->SendSamples(rState->snd_context, inBuffer->mAudioData, - inBuffer->mAudioDataByteSize/4, (UINT16)(GetTickCount() & 0xffff)); - + inBuffer->mAudioDataByteSize / 4, (UINT16)(GetTickCount() & 0xffff)); status = AudioQueueEnqueueBuffer( - rState->queue, - inBuffer, - 0, - NULL); - + rState->queue, + inBuffer, + 0, + NULL); + if (status != noErr) { WLog_DBG(TAG, "AudioQueueEnqueueBuffer() returned status = %"PRId32"", status); } - } -void mf_rdpsnd_derive_buffer_size (AudioQueueRef audioQueue, - AudioStreamBasicDescription *ASBDescription, - Float64 seconds, - UInt32 *outBufferSize) +void mf_rdpsnd_derive_buffer_size(AudioQueueRef audioQueue, + AudioStreamBasicDescription* ASBDescription, + Float64 seconds, + UInt32* outBufferSize) { static const int maxBufferSize = 0x50000; - int maxPacketSize = ASBDescription->mBytesPerPacket; + if (maxPacketSize == 0) { UInt32 maxVBRPacketSize = sizeof(maxPacketSize); - AudioQueueGetProperty (audioQueue, - kAudioQueueProperty_MaximumOutputPacketSize, - // in Mac OS X v10.5, instead use - // kAudioConverterPropertyMaximumOutputPacketSize - &maxPacketSize, - &maxVBRPacketSize - ); + AudioQueueGetProperty(audioQueue, + kAudioQueueProperty_MaximumOutputPacketSize, + // in Mac OS X v10.5, instead use + // kAudioConverterPropertyMaximumOutputPacketSize + &maxPacketSize, + &maxVBRPacketSize + ); } - + Float64 numBytesForTime = - ASBDescription->mSampleRate * maxPacketSize * seconds; - *outBufferSize = (UInt32) (numBytesForTime < maxBufferSize ? numBytesForTime : maxBufferSize); + ASBDescription->mSampleRate * maxPacketSize * seconds; + *outBufferSize = (UInt32)(numBytesForTime < maxBufferSize ? numBytesForTime : maxBufferSize); }