if(NOT WIN32)
if(APPLE AND (NOT IOS))
- #add_subdirectory(Mac)
+ add_subdirectory(Mac)
endif()
else()
#add_subdirectory(Windows)
#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)
mf_mlion_start_getting_screen_updates();
}
- peerId = NULL;
+ peerId = 0;
for(i=0; i<MF_INFO_MAXPEERS; ++i)
{
0xFF, //0xfe
};
-void mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
+BOOL mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
- CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
-
+ CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
BOOL keyDown = TRUE;
CGEventRef kbEvent;
CGKeyCode kCode = 0xFF;
-
+
if (flags & KBD_FLAGS_RELEASE)
{
keyDown = FALSE;
}
-
+
if (flags & KBD_FLAGS_EXTENDED)
{
- switch (code) {
+ switch (code)
+ {
//case 0x52: //insert
case 0x53:
kCode = kVK_ForwardDelete;
break;
-
+
case 0x4B:
kCode = kVK_LeftArrow;
break;
-
+
case 0x47:
kCode = kVK_Home;
break;
-
+
case 0x4F:
kCode = kVK_End;
break;
-
+
case 0x48:
kCode = kVK_UpArrow;
break;
-
+
case 0x50:
kCode = kVK_DownArrow;
break;
-
+
case 0x49:
kCode = kVK_PageUp;
break;
-
+
case 0x51:
kCode = kVK_PageDown;
break;
-
+
case 0x4D:
kCode = kVK_RightArrow;
break;
-
+
default:
break;
}
{
kCode = keymap[code];
}
-
+
kbEvent = CGEventCreateKeyboardEvent(source, kCode, keyDown);
CGEventPost(kCGHIDEventTap, kbEvent);
CFRelease(kbEvent);
CFRelease(source);
+ return TRUE;
}
-void mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
+BOOL mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
-
+ return FALSE;
}
-void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
+BOOL mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
float width, height;
-
CGWheelCount wheelCount = 2;
INT32 scroll_x = 0;
INT32 scroll_y = 0;
else
scroll_x = scroll;
- CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
- CGEventRef scroll = CGEventCreateScrollWheelEvent(source,
- kCGScrollEventUnitLine,
- wheelCount,
- scroll_y,
- scroll_x);
- CGEventPost(kCGHIDEventTap, scroll);
-
- CFRelease(scroll);
+ CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
+ CGEventRef scrollEvent = CGEventCreateScrollWheelEvent(source,
+ kCGScrollEventUnitLine,
+ wheelCount,
+ scroll_y,
+ scroll_x);
+ CGEventPost(kCGHIDEventTap, scrollEvent);
+ CFRelease(scrollEvent);
CFRelease(source);
}
else
{
-
- mfInfo * mfi;
- CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
+ mfInfo* mfi;
+ CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventType mouseType = kCGEventNull;
CGMouseButton mouseButton = kCGMouseButtonLeft;
-
-
mfi = mf_info_get_instance();
-
//width and height of primary screen (even in multimon setups
width = (float) mfi->servscreen_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)
{
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;
else if (flags & PTR_FLAGS_BUTTON2)
{
mouseButton = kCGMouseButtonRight;
+
if (flags & PTR_FLAGS_DOWN)
{
mouseType = kCGEventRightMouseDown;
mouseType = kCGEventRightMouseUp;
mfi->mouse_down_right = FALSE;
}
-
}
else if (flags & PTR_FLAGS_BUTTON3)
{
mouseButton = kCGMouseButtonCenter;
+
if (flags & PTR_FLAGS_DOWN)
{
mouseType = kCGEventOtherMouseDown;
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;
}
#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 */
#include <freerdp/codec/rfx.h>
#include <winpr/stream.h>
#include <freerdp/peer.h>
+#include <freerdp/codec/color.h>
#include <winpr/crt.h>
#include "mf_input.h"
#include "mf_event.h"
#include "mf_rdpsnd.h"
+#include "mf_audin.h"
#include <mach/clock.h>
#include <mach/mach.h>
#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;
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();
//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;
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;
}
/* 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)
{
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;
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);
}
);
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;
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 */
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)
}
}
-void mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
-{
-}
-
-static void mf_peer_suppress_output(rdpContext* context, BYTE allow,
- RECTANGLE_16* area)
+static BOOL mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
+ return FALSE;
}
-BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
+static BOOL mf_peer_suppress_output(rdpContext* context, BYTE allow,
+ const RECTANGLE_16* area)
{
- 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 void* mf_peer_main_loop(void* arg)
{
int i;
int fds;
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;
+}
#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 */
#include "mf_info.h"
#include "mf_rdpsnd.h"
+#include <winpr/sysinfo.h>
#include <freerdp/log.h>
#define TAG SERVER_TAG("mac")
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);
break;
}
}
+
if (formatAgreed == TRUE)
break;
-
}
-
+
if (formatAgreed == FALSE)
{
WLog_DBG(TAG, "Could not agree on a audio format with the server");
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)
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;
}
{
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);
}