merged upstream

This commit is contained in:
C-o-r-E 2013-02-28 16:45:47 -05:00
commit 88207eaf68
339 changed files with 7378 additions and 5481 deletions

1
.gitignore vendored
View File

@ -41,6 +41,7 @@ client/X11/xfreerdp.1
# Mac OS X
.DS_Store
*.xcodeproj/
DerivedData/
# Windows
*.vcxproj

View File

@ -209,7 +209,7 @@ if(ANDROID)
message(STATUS "FREERDP_ANDROID_EXTERNAL_SSL_PATH not set! - Needs to be set if openssl is not found in the android NDK (which usually isn't)")
endif()
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${FREERDP_ANDROID_EXTERNAL_SSL_PATH})
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/client/Android/libs/${ANDROID_ABI})
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/client/Android/FreeRDPCore/libs/${ANDROID_ABI})
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)

View File

@ -31,8 +31,9 @@
#include <alsa/asoundlib.h>
#include <freerdp/addin.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/utils/thread.h>
#include <freerdp/channels/rdpsnd.h>
#include "audin_main.h"
@ -73,15 +74,12 @@ static BOOL audin_alsa_set_params(AudinALSADevice* alsa, snd_pcm_t* capture_hand
snd_strerror(error));
return FALSE;
}
snd_pcm_hw_params_any(capture_handle, hw_params);
snd_pcm_hw_params_set_access(capture_handle, hw_params,
SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format(capture_handle, hw_params,
alsa->format);
snd_pcm_hw_params_set_rate_near(capture_handle, hw_params,
&alsa->actual_rate, NULL);
snd_pcm_hw_params_set_channels_near(capture_handle, hw_params,
&alsa->actual_channels);
snd_pcm_hw_params_set_access(capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format(capture_handle, hw_params, alsa->format);
snd_pcm_hw_params_set_rate_near(capture_handle, hw_params, &alsa->actual_rate, NULL);
snd_pcm_hw_params_set_channels_near(capture_handle, hw_params, &alsa->actual_channels);
snd_pcm_hw_params(capture_handle, hw_params);
snd_pcm_hw_params_free(hw_params);
snd_pcm_prepare(capture_handle);
@ -94,6 +92,7 @@ static BOOL audin_alsa_set_params(AudinALSADevice* alsa, snd_pcm_t* capture_hand
alsa->actual_rate, alsa->actual_channels,
alsa->target_rate, alsa->target_channels);
}
return TRUE;
}
@ -133,20 +132,25 @@ static BOOL audin_alsa_thread_receive(AudinALSADevice* alsa, BYTE* src, int size
break;
cframes = alsa->frames_per_packet - alsa->buffer_frames;
if (cframes > frames)
cframes = frames;
memcpy(alsa->buffer + alsa->buffer_frames * tbytes_per_frame,
src, cframes * tbytes_per_frame);
CopyMemory(alsa->buffer + alsa->buffer_frames * tbytes_per_frame, src, cframes * tbytes_per_frame);
alsa->buffer_frames += cframes;
if (alsa->buffer_frames >= alsa->frames_per_packet)
{
if (alsa->wformat == 0x11)
if (alsa->wformat == WAVE_FORMAT_DVI_ADPCM)
{
alsa->dsp_context->encode_ima_adpcm(alsa->dsp_context,
alsa->buffer, alsa->buffer_frames * tbytes_per_frame,
alsa->target_channels, alsa->block_size);
encoded_data = alsa->dsp_context->adpcm_buffer;
encoded_size = alsa->dsp_context->adpcm_size;
DEBUG_DVC("encoded %d to %d",
alsa->buffer_frames * tbytes_per_frame, encoded_size);
}
@ -162,11 +166,16 @@ static BOOL audin_alsa_thread_receive(AudinALSADevice* alsa, BYTE* src, int size
frames = 0;
}
else
{
ret = alsa->receive(encoded_data, encoded_size, alsa->user_data);
}
alsa->buffer_frames = 0;
if (!ret)
break;
}
src += cframes * tbytes_per_frame;
frames -= cframes;
}
@ -225,8 +234,10 @@ static void* audin_alsa_thread_func(void* arg)
} while (0);
free(buffer);
free(alsa->buffer);
alsa->buffer = NULL;
if (capture_handle)
snd_pcm_close(capture_handle);
@ -253,7 +264,7 @@ static BOOL audin_alsa_format_supported(IAudinDevice* device, audinFormat* forma
{
switch (format->wFormatTag)
{
case 1: /* PCM */
case WAVE_FORMAT_PCM:
if (format->cbSize == 0 &&
(format->nSamplesPerSec <= 48000) &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
@ -263,7 +274,7 @@ static BOOL audin_alsa_format_supported(IAudinDevice* device, audinFormat* forma
}
break;
case 0x11: /* IMA ADPCM */
case WAVE_FORMAT_DVI_ADPCM:
if ((format->nSamplesPerSec <= 48000) &&
(format->wBitsPerSample == 4) &&
(format->nChannels == 1 || format->nChannels == 2))
@ -272,6 +283,7 @@ static BOOL audin_alsa_format_supported(IAudinDevice* device, audinFormat* forma
}
break;
}
return FALSE;
}
@ -284,9 +296,10 @@ static void audin_alsa_set_format(IAudinDevice* device, audinFormat* format, UIN
alsa->actual_rate = format->nSamplesPerSec;
alsa->target_channels = format->nChannels;
alsa->actual_channels = format->nChannels;
switch (format->wFormatTag)
{
case 1: /* PCM */
case WAVE_FORMAT_PCM:
switch (format->wBitsPerSample)
{
case 8:
@ -300,7 +313,7 @@ static void audin_alsa_set_format(IAudinDevice* device, audinFormat* format, UIN
}
break;
case 0x11: /* IMA ADPCM */
case WAVE_FORMAT_DVI_ADPCM:
alsa->format = SND_PCM_FORMAT_S16_LE;
alsa->bytes_per_channel = 2;
bs = (format->nBlockAlign - 4 * format->nChannels) * 4;
@ -310,6 +323,7 @@ static void audin_alsa_set_format(IAudinDevice* device, audinFormat* format, UIN
alsa->frames_per_packet);
break;
}
alsa->wformat = format->wFormatTag;
alsa->block_size = format->nBlockAlign;
}

View File

@ -32,7 +32,7 @@
#include <freerdp/types.h>
#include <freerdp/addin.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include "audin_main.h"

View File

@ -27,6 +27,6 @@ set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp
MODULES freerdp-utils)
MODULES freerdp-codec freerdp-utils)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")

View File

@ -27,7 +27,7 @@
#include <winpr/crt.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/utils/thread.h>
#include <freerdp/utils/stream.h>
#include <freerdp/channels/wtsvc.h>
@ -134,8 +134,8 @@ static BOOL audin_server_recv_formats(audin_server* audin, STREAM* s, UINT32 len
if (audin->context.num_client_formats <= 0)
return FALSE;
audin->context.client_formats = malloc(audin->context.num_client_formats * sizeof(rdpsndFormat));
ZeroMemory(audin->context.client_formats, audin->context.num_client_formats * sizeof(rdpsndFormat));
audin->context.client_formats = malloc(audin->context.num_client_formats * sizeof(AUDIO_FORMAT));
ZeroMemory(audin->context.client_formats, audin->context.num_client_formats * sizeof(AUDIO_FORMAT));
for (i = 0; i < audin->context.num_client_formats; i++)
{
@ -206,7 +206,7 @@ static BOOL audin_server_recv_open_reply(audin_server* audin, STREAM* s, UINT32
static BOOL audin_server_recv_data(audin_server* audin, STREAM* s, UINT32 length)
{
rdpsndFormat* format;
AUDIO_FORMAT* format;
int sbytes_per_sample;
int sbytes_per_frame;
BYTE* src;
@ -284,7 +284,8 @@ static void* audin_server_thread_func(void* arg)
/* Wait for the client to confirm that the Audio Input dynamic channel is ready */
while (1)
{
freerdp_thread_wait(thread);
if (freerdp_thread_wait(thread) < 0)
break;
if (freerdp_thread_is_stopped(thread))
break;
@ -309,7 +310,8 @@ static void* audin_server_thread_func(void* arg)
while (ready)
{
freerdp_thread_wait(thread);
if (freerdp_thread_wait(thread) < 0)
break;
if (freerdp_thread_is_stopped(thread))
break;

View File

@ -44,7 +44,7 @@
#include <winpr/file.h>
#include <winpr/synch.h>
#include <winpr/library.h>
#include <winpr/interlocked.h>
#include <winpr/collections.h>
#ifdef WITH_DEBUG_CHANNELS
#define DEBUG_CHANNELS(fmt, ...) DEBUG_CLASS(CHANNELS, fmt, ## __VA_ARGS__)
@ -383,15 +383,14 @@ struct channel_data
PCHANNEL_OPEN_EVENT_FN open_event_proc;
};
struct _SYNC_DATA
struct _CHANNEL_OPEN_EVENT
{
SLIST_ENTRY ItemEntry;
void* Data;
UINT32 DataLength;
void* UserData;
int Index;
};
typedef struct _SYNC_DATA SYNC_DATA;
typedef struct _CHANNEL_OPEN_EVENT CHANNEL_OPEN_EVENT;
typedef struct rdp_init_handle rdpInitHandle;
@ -430,15 +429,7 @@ struct rdp_channels
/* used for locating the channels for a given instance */
freerdp* instance;
/* signal for incoming data or event */
HANDLE signal;
/* used for sync write */
PSLIST_HEADER pSyncDataList;
/* used for sync event */
HANDLE event_sem;
RDP_EVENT* event;
wMessagePipe* MsgPipe;
};
/**
@ -505,6 +496,7 @@ static rdpChannels* freerdp_channels_find_by_instance(freerdp* instance)
for (channels_list = g_channels_list; channels_list; channels_list = channels_list->next)
{
channels = channels_list->channels;
if (channels->instance == instance)
{
ReleaseMutex(g_mutex_list);
@ -605,7 +597,7 @@ static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF
PCHANNEL_DEF lchannel_def;
struct channel_data* lchannel_data;
if (ppInitHandle == NULL)
if (!ppInitHandle)
{
DEBUG_CHANNELS("error bad init handle");
return CHANNEL_RC_BAD_INIT_HANDLE;
@ -630,7 +622,7 @@ static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF
return CHANNEL_RC_TOO_MANY_CHANNELS;
}
if (pChannel == 0)
if (!pChannel)
{
DEBUG_CHANNELS("error bad channel");
return CHANNEL_RC_BAD_CHANNEL;
@ -709,13 +701,13 @@ static UINT32 FREERDP_CC MyVirtualChannelOpen(void* pInitHandle, UINT32* pOpenHa
channels = ((rdpInitHandle*) pInitHandle)->channels;
if (pOpenHandle == 0)
if (!pOpenHandle)
{
DEBUG_CHANNELS("error bad channel handle");
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
}
if (pChannelOpenEventProc == 0)
if (!pChannelOpenEventProc)
{
DEBUG_CHANNELS("error bad proc");
return CHANNEL_RC_BAD_PROC;
@ -729,7 +721,7 @@ static UINT32 FREERDP_CC MyVirtualChannelOpen(void* pInitHandle, UINT32* pOpenHa
lchannel_data = freerdp_channels_find_channel_data_by_name(channels, pChannelName, &index);
if (lchannel_data == 0)
if (!lchannel_data)
{
DEBUG_CHANNELS("error channel name");
return CHANNEL_RC_UNKNOWN_CHANNEL_NAME;
@ -785,13 +777,13 @@ static UINT32 FREERDP_CC MyVirtualChannelClose(UINT32 openHandle)
static UINT32 FREERDP_CC MyVirtualChannelWrite(UINT32 openHandle, void* pData, UINT32 dataLength, void* pUserData)
{
int index;
SYNC_DATA* item;
CHANNEL_OPEN_EVENT* item;
rdpChannels* channels;
struct channel_data* lchannel_data;
channels = freerdp_channels_find_by_open_handle(openHandle, &index);
if ((channels == NULL) || (index < 0) || (index >= CHANNEL_MAX_COUNT))
if ((!channels) || (index < 0) || (index >= CHANNEL_MAX_COUNT))
{
DEBUG_CHANNELS("error bad channel handle");
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
@ -803,13 +795,13 @@ static UINT32 FREERDP_CC MyVirtualChannelWrite(UINT32 openHandle, void* pData, U
return CHANNEL_RC_NOT_CONNECTED;
}
if (pData == 0)
if (!pData)
{
DEBUG_CHANNELS("error bad pData");
return CHANNEL_RC_NULL_DATA;
}
if (dataLength == 0)
if (!dataLength)
{
DEBUG_CHANNELS("error bad dataLength");
return CHANNEL_RC_ZERO_LENGTH;
@ -829,16 +821,13 @@ static UINT32 FREERDP_CC MyVirtualChannelWrite(UINT32 openHandle, void* pData, U
return CHANNEL_RC_NOT_CONNECTED;
}
item = (SYNC_DATA*) _aligned_malloc(sizeof(SYNC_DATA), MEMORY_ALLOCATION_ALIGNMENT);
item = (CHANNEL_OPEN_EVENT*) malloc(sizeof(CHANNEL_OPEN_EVENT));
item->Data = pData;
item->DataLength = dataLength;
item->UserData = pUserData;
item->Index = index;
InterlockedPushEntrySList(channels->pSyncDataList, &(item->ItemEntry));
/* set the event */
SetEvent(channels->signal);
MessageQueue_Post(channels->MsgPipe->Out, (void*) channels, 0, (void*) item, NULL);
return CHANNEL_RC_OK;
}
@ -851,7 +840,7 @@ static UINT32 FREERDP_CC MyVirtualChannelEventPush(UINT32 openHandle, RDP_EVENT*
channels = freerdp_channels_find_by_open_handle(openHandle, &index);
if ((channels == NULL) || (index < 0) || (index >= CHANNEL_MAX_COUNT))
if ((!channels) || (index < 0) || (index >= CHANNEL_MAX_COUNT))
{
DEBUG_CHANNELS("error bad channels handle");
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
@ -863,7 +852,7 @@ static UINT32 FREERDP_CC MyVirtualChannelEventPush(UINT32 openHandle, RDP_EVENT*
return CHANNEL_RC_NOT_CONNECTED;
}
if (event == NULL)
if (!event)
{
DEBUG_CHANNELS("error bad event");
return CHANNEL_RC_NULL_DATA;
@ -877,19 +866,20 @@ static UINT32 FREERDP_CC MyVirtualChannelEventPush(UINT32 openHandle, RDP_EVENT*
return CHANNEL_RC_NOT_OPEN;
}
/* lock channels->event */
WaitForSingleObject(channels->event_sem, INFINITE);
if (!channels->is_connected)
{
ReleaseSemaphore(channels->event_sem, 1, NULL);
DEBUG_CHANNELS("error not connected");
return CHANNEL_RC_NOT_CONNECTED;
}
channels->event = event;
/* set the event */
SetEvent(channels->signal);
/**
* We really intend to use the In queue for events, but we're pushing on both
* to wake up threads waiting on the out queue. Doing this cleanly would require
* breaking freerdp_pop_event() a bit too early in this refactoring.
*/
MessageQueue_Post(channels->MsgPipe->In, (void*) channels, 1, (void*) event, NULL);
MessageQueue_Post(channels->MsgPipe->Out, (void*) channels, 1, (void*) event, NULL);
return CHANNEL_RC_OK;
}
@ -929,11 +919,7 @@ rdpChannels* freerdp_channels_new(void)
channels = (rdpChannels*) malloc(sizeof(rdpChannels));
ZeroMemory(channels, sizeof(rdpChannels));
channels->pSyncDataList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
InitializeSListHead(channels->pSyncDataList);
channels->event_sem = CreateSemaphore(NULL, 1, 16, NULL);
channels->signal = CreateEvent(NULL, TRUE, FALSE, NULL);
channels->MsgPipe = MessagePipe_New();
/* Add it to the global list */
channels_list = (rdpChannelsList*) malloc(sizeof(rdpChannelsList));
@ -953,11 +939,7 @@ void freerdp_channels_free(rdpChannels* channels)
rdpChannelsList* list;
rdpChannelsList* prev;
InterlockedFlushSList(channels->pSyncDataList);
_aligned_free(channels->pSyncDataList);
CloseHandle(channels->event_sem);
CloseHandle(channels->signal);
MessagePipe_Free(channels->MsgPipe);
/* Remove from global list */
@ -1144,15 +1126,15 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat
channels = freerdp_channels_find_by_instance(instance);
if (channels == 0)
if (!channels)
{
DEBUG_CHANNELS("could not find channel manager");
return 1;
}
lrdp_channel = freerdp_channels_find_channel_by_id(channels, instance->settings,
channel_id, &index);
if (lrdp_channel == 0)
lrdp_channel = freerdp_channels_find_channel_by_id(channels, instance->settings, channel_id, &index);
if (!lrdp_channel)
{
DEBUG_CHANNELS("could not find channel id");
return 1;
@ -1160,7 +1142,7 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat
lchannel_data = freerdp_channels_find_channel_data_by_name(channels, lrdp_channel->Name, &index);
if (lchannel_data == 0)
if (!lchannel_data)
{
DEBUG_CHANNELS("could not find channel name");
return 1;
@ -1198,7 +1180,7 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, RDP_EVENT* ev
name = event_class_to_name_table[event->event_class];
if (name == NULL)
if (!name)
{
DEBUG_CHANNELS("unknown event_class %d", event->event_class);
freerdp_event_free(event);
@ -1207,17 +1189,16 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, RDP_EVENT* ev
lchannel_data = freerdp_channels_find_channel_data_by_name(channels, name, &index);
if (lchannel_data == NULL)
if (!lchannel_data)
{
DEBUG_CHANNELS("could not find channel name %s", name);
freerdp_event_free(event);
return 1;
}
if (lchannel_data->open_event_proc != NULL)
if (lchannel_data->open_event_proc)
{
lchannel_data->open_event_proc(lchannel_data->open_handle,
CHANNEL_EVENT_USER,
lchannel_data->open_event_proc(lchannel_data->open_handle, CHANNEL_EVENT_USER,
event, sizeof(RDP_EVENT), sizeof(RDP_EVENT), 0);
}
@ -1229,32 +1210,49 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, RDP_EVENT* ev
*/
static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instance)
{
SYNC_DATA* item;
wMessage message;
RDP_EVENT* event;
CHANNEL_OPEN_EVENT* item;
rdpChannel* lrdp_channel;
struct channel_data* lchannel_data;
while (QueryDepthSList(channels->pSyncDataList) > 0)
while (MessageQueue_Peek(channels->MsgPipe->Out, &message, TRUE))
{
item = (SYNC_DATA*) InterlockedPopEntrySList(channels->pSyncDataList);
if (!item)
if (message.id == WMQ_QUIT)
break;
lchannel_data = channels->channels_data + item->Index;
lrdp_channel = freerdp_channels_find_channel_by_name(channels, instance->settings,
lchannel_data->name, &item->Index);
if (lrdp_channel != NULL)
instance->SendChannelData(instance, lrdp_channel->ChannelId, item->Data, item->DataLength);
if (lchannel_data->open_event_proc != 0)
if (message.id == 0)
{
lchannel_data->open_event_proc(lchannel_data->open_handle,
CHANNEL_EVENT_WRITE_COMPLETE, item->UserData, sizeof(void*), sizeof(void*), 0);
}
item = (CHANNEL_OPEN_EVENT*) message.wParam;
_aligned_free(item);
if (!item)
break;
lchannel_data = channels->channels_data + item->Index;
lrdp_channel = freerdp_channels_find_channel_by_name(channels, instance->settings,
lchannel_data->name, &item->Index);
if (lrdp_channel)
instance->SendChannelData(instance, lrdp_channel->ChannelId, item->Data, item->DataLength);
if (lchannel_data->open_event_proc)
{
lchannel_data->open_event_proc(lchannel_data->open_handle,
CHANNEL_EVENT_WRITE_COMPLETE, item->UserData, item->DataLength, item->DataLength, 0);
}
free(item);
}
else if (message.id == 1)
{
event = (RDP_EVENT*) message.wParam;
/**
* Ignore for now, the same event is being pushed on the In queue,
* and we're pushing it on the Out queue just to wake other threads
*/
}
}
}
@ -1266,7 +1264,7 @@ BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** r
{
void* pfd;
pfd = GetEventWaitObject(channels->signal);
pfd = GetEventWaitObject(MessageQueue_Event(channels->MsgPipe->Out));
if (pfd)
{
@ -1283,7 +1281,7 @@ HANDLE freerdp_channels_get_event_handle(freerdp* instance)
rdpChannels* channels;
channels = instance->context->channels;
event = channels->signal;
event = MessageQueue_Event(channels->MsgPipe->Out);
return event;
}
@ -1294,9 +1292,8 @@ int freerdp_channels_process_pending_messages(freerdp* instance)
channels = instance->context->channels;
if (WaitForSingleObject(channels->signal, 0) == WAIT_OBJECT_0)
if (WaitForSingleObject(MessageQueue_Event(channels->MsgPipe->Out), 0) == WAIT_OBJECT_0)
{
ResetEvent(channels->signal);
freerdp_channels_process_sync(channels, instance);
}
@ -1308,9 +1305,8 @@ int freerdp_channels_process_pending_messages(freerdp* instance)
*/
BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance)
{
if (WaitForSingleObject(channels->signal, 0) == WAIT_OBJECT_0)
if (WaitForSingleObject(MessageQueue_Event(channels->MsgPipe->Out), 0) == WAIT_OBJECT_0)
{
ResetEvent(channels->signal);
freerdp_channels_process_sync(channels, instance);
}
@ -1319,16 +1315,16 @@ BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance)
RDP_EVENT* freerdp_channels_pop_event(rdpChannels* channels)
{
RDP_EVENT* event;
wMessage message;
RDP_EVENT* event = NULL;
if (channels->event == NULL)
return NULL;
event = channels->event;
channels->event = NULL;
/* release channels->event */
ReleaseSemaphore(channels->event_sem, 1, NULL);
if (MessageQueue_Peek(channels->MsgPipe->In, &message, TRUE))
{
if (message.id == 1)
{
event = (RDP_EVENT*) message.wParam;
}
}
return event;
}

View File

@ -470,14 +470,11 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP*
}
/* http://msdn.microsoft.com/en-us/library/cc241518.aspx */
static void drive_process_irp_silent_ignore(DRIVE_DEVICE* disk, IRP* irp)
{
UINT32 FsInformationClass;
UINT32 pad;
STREAM* output = irp->output;
char* volumeLabel;
int length;
int status;
stream_read_UINT32(irp->input, FsInformationClass);

View File

@ -268,7 +268,8 @@ static void* parallel_thread_func(void* arg)
while (1)
{
freerdp_thread_wait(parallel->thread);
if (freerdp_thread_wait(parallel->thread) < 0)
break;
if (freerdp_thread_is_stopped(parallel->thread))
break;

View File

@ -33,7 +33,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE winpr
MODULES winpr-utils)
MODULES winpr-sysinfo winpr-utils)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})

View File

@ -28,12 +28,14 @@
#include <winpr/crt.h>
#include <winpr/cmdline.h>
#include <winpr/sysinfo.h>
#include <winpr/collections.h>
#include <alsa/asoundlib.h>
#include <freerdp/types.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/utils/svc_plugin.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/utils/debug.h>
#include "rdpsnd_main.h"
@ -43,94 +45,175 @@ struct rdpsnd_alsa_plugin
{
rdpsndDevicePlugin device;
int latency;
int wformat;
int block_size;
char* device_name;
snd_pcm_t* out_handle;
snd_pcm_t* pcm_handle;
snd_mixer_t* mixer_handle;
UINT32 source_rate;
UINT32 actual_rate;
UINT32 wLocalTimeClose;
snd_pcm_format_t format;
UINT32 source_channels;
UINT32 actual_channels;
int bytes_per_channel;
int wformat;
int block_size;
int latency;
snd_pcm_uframes_t buffer_size;
snd_pcm_uframes_t period_size;
snd_pcm_uframes_t start_threshold;
snd_async_handler_t* pcm_callback;
FREERDP_DSP_CONTEXT* dsp_context;
};
static void rdpsnd_alsa_set_params(rdpsndAlsaPlugin* alsa)
#define SND_PCM_CHECK(_func, _status) \
if (_status < 0) \
{ \
printf("%s: %d\n", _func, _status); \
return -1; \
}
int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)
{
int status;
snd_pcm_hw_params_t* hw_params;
snd_pcm_sw_params_t* sw_params;
snd_pcm_uframes_t frames;
snd_pcm_uframes_t start_threshold;
snd_pcm_drop(alsa->out_handle);
snd_pcm_uframes_t buffer_size_max;
status = snd_pcm_hw_params_malloc(&hw_params);
SND_PCM_CHECK("snd_pcm_hw_params_malloc", status);
if (status < 0)
status = snd_pcm_hw_params_any(alsa->pcm_handle, hw_params);
SND_PCM_CHECK("snd_pcm_hw_params_any", status);
/* Set interleaved read/write access */
status = snd_pcm_hw_params_set_access(alsa->pcm_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
SND_PCM_CHECK("snd_pcm_hw_params_set_access", status);
/* Set sample format */
status = snd_pcm_hw_params_set_format(alsa->pcm_handle, hw_params, alsa->format);
SND_PCM_CHECK("snd_pcm_hw_params_set_format", status);
/* Set sample rate */
status = snd_pcm_hw_params_set_rate_near(alsa->pcm_handle, hw_params, &alsa->actual_rate, NULL);
SND_PCM_CHECK("snd_pcm_hw_params_set_rate_near", status);
/* Set number of channels */
status = snd_pcm_hw_params_set_channels(alsa->pcm_handle, hw_params, alsa->actual_channels);
SND_PCM_CHECK("snd_pcm_hw_params_set_channels", status);
/* Get maximum buffer size */
status = snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size_max);
SND_PCM_CHECK("snd_pcm_hw_params_get_buffer_size_max", status);
if (alsa->buffer_size > buffer_size_max)
{
DEBUG_WARN("snd_pcm_hw_params_malloc failed");
return;
printf("Warning: requested sound buffer size %d, got %d instead\n",
(int) alsa->buffer_size, (int) buffer_size_max);
alsa->buffer_size = buffer_size_max;
}
snd_pcm_hw_params_any(alsa->out_handle, hw_params);
snd_pcm_hw_params_set_access(alsa->out_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format(alsa->out_handle, hw_params, alsa->format);
snd_pcm_hw_params_set_rate_near(alsa->out_handle, hw_params, &alsa->actual_rate, NULL);
snd_pcm_hw_params_set_channels_near(alsa->out_handle, hw_params, &alsa->actual_channels);
/* Set buffer size */
status = snd_pcm_hw_params_set_buffer_size_near(alsa->pcm_handle, hw_params, &alsa->buffer_size);
SND_PCM_CHECK("snd_pcm_hw_params_set_buffer_size_near", status);
if (alsa->latency < 0)
frames = alsa->actual_rate * 4 / 10; /* Default to 400ms buffer */
else
frames = alsa->latency * alsa->actual_rate * 2 / 1000; /* Double of the latency */
/* Get period size */
status = snd_pcm_hw_params_get_period_size_min(hw_params, &alsa->period_size, NULL);
SND_PCM_CHECK("snd_pcm_hw_params_get_period_size_min", status);
if (frames < alsa->actual_rate / 2)
frames = alsa->actual_rate / 2; /* Minimum 0.5-second buffer */
/* Set period size */
status = snd_pcm_hw_params_set_period_size_near(alsa->pcm_handle, hw_params, &alsa->period_size, NULL);
SND_PCM_CHECK("snd_pcm_hw_params_set_period_size_near", status);
status = snd_pcm_hw_params(alsa->pcm_handle, hw_params);
SND_PCM_CHECK("snd_pcm_hw_params", status);
snd_pcm_hw_params_set_buffer_size_near(alsa->out_handle, hw_params, &frames);
snd_pcm_hw_params(alsa->out_handle, hw_params);
snd_pcm_hw_params_free(hw_params);
status = snd_pcm_sw_params_malloc(&sw_params);
if (status < 0)
{
DEBUG_WARN("snd_pcm_sw_params_malloc failed");
return;
}
snd_pcm_sw_params_current(alsa->out_handle, sw_params);
if (alsa->latency == 0)
start_threshold = 0;
else
start_threshold = frames / 2;
snd_pcm_sw_params_set_start_threshold(alsa->out_handle, sw_params, start_threshold);
snd_pcm_sw_params(alsa->out_handle, sw_params);
snd_pcm_sw_params_free(sw_params);
snd_pcm_prepare(alsa->out_handle);
DEBUG_SVC("hardware buffer %d frames, playback buffer %.2g seconds",
(int) frames, (double) frames / 2.0 / (double) alsa->actual_rate);
if ((alsa->actual_rate != alsa->source_rate) || (alsa->actual_channels != alsa->source_channels))
{
DEBUG_SVC("actual rate %d / channel %d is different from source rate %d / channel %d, resampling required.",
alsa->actual_rate, alsa->actual_channels, alsa->source_rate, alsa->source_channels);
}
return 0;
}
static void rdpsnd_alsa_set_format(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
int rdpsnd_alsa_set_sw_params(rdpsndAlsaPlugin* alsa)
{
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
int status;
snd_pcm_sw_params_t* sw_params;
if (format != NULL)
alsa->start_threshold = alsa->buffer_size;
status = snd_pcm_sw_params_malloc(&sw_params);
SND_PCM_CHECK("snd_pcm_sw_params_malloc", status);
status = snd_pcm_sw_params_current(alsa->pcm_handle, sw_params);
SND_PCM_CHECK("snd_pcm_sw_params_current", status);
status = snd_pcm_sw_params_set_start_threshold(alsa->pcm_handle, sw_params, alsa->start_threshold);
SND_PCM_CHECK("snd_pcm_sw_params_set_start_threshold", status);
status = snd_pcm_sw_params(alsa->pcm_handle, sw_params);
SND_PCM_CHECK("snd_pcm_sw_params", status);
snd_pcm_sw_params_free(sw_params);
status = snd_pcm_prepare(alsa->pcm_handle);
SND_PCM_CHECK("snd_pcm_prepare", status);
return 0;
}
int rdpsnd_alsa_validate_params(rdpsndAlsaPlugin* alsa)
{
int status;
snd_pcm_uframes_t buffer_size;
snd_pcm_uframes_t period_size;
status = snd_pcm_get_params(alsa->pcm_handle, &buffer_size, &period_size);
SND_PCM_CHECK("snd_pcm_get_params", status);
return 0;
}
static int rdpsnd_alsa_set_params(rdpsndAlsaPlugin* alsa)
{
/**
* ALSA Parameters
*
* http://www.alsa-project.org/main/index.php/FramesPeriods
*
* buffer_size = period_size * periods
* period_bytes = period_size * bytes_per_frame
* bytes_per_frame = channels * bytes_per_sample
*
* A frame is equivalent of one sample being played,
* irrespective of the number of channels or the number of bits
*
* A period is the number of frames in between each hardware interrupt.
*
* The buffer size always has to be greater than one period size.
* Commonly this is (2 * period_size), but some hardware can do 8 periods per buffer.
* It is also possible for the buffer size to not be an integer multiple of the period size.
*/
snd_pcm_drop(alsa->pcm_handle);
if (alsa->latency < 0)
alsa->latency = 400;
alsa->buffer_size = alsa->latency * (alsa->actual_rate / 1000);
if (rdpsnd_alsa_set_hw_params(alsa) < 0)
return -1;
if (rdpsnd_alsa_set_sw_params(alsa) < 0)
return -1;
rdpsnd_alsa_validate_params(alsa);
return 0;
}
static void rdpsnd_alsa_set_format(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
if (format)
{
alsa->source_rate = format->nSamplesPerSec;
alsa->actual_rate = format->nSamplesPerSec;
@ -139,13 +222,19 @@ static void rdpsnd_alsa_set_format(rdpsndDevicePlugin* device, rdpsndFormat* for
switch (format->wFormatTag)
{
case 1: /* PCM */
case WAVE_FORMAT_PCM:
switch (format->wBitsPerSample)
{
case 4:
alsa->format = SND_PCM_FORMAT_S16_LE;
alsa->bytes_per_channel = 2;
break;
case 8:
alsa->format = SND_PCM_FORMAT_S8;
alsa->bytes_per_channel = 1;
break;
case 16:
alsa->format = SND_PCM_FORMAT_S16_LE;
alsa->bytes_per_channel = 2;
@ -153,8 +242,8 @@ static void rdpsnd_alsa_set_format(rdpsndDevicePlugin* device, rdpsndFormat* for
}
break;
case 2: /* MS ADPCM */
case 0x11: /* IMA ADPCM */
case WAVE_FORMAT_ADPCM:
case WAVE_FORMAT_DVI_ADPCM:
alsa->format = SND_PCM_FORMAT_S16_LE;
alsa->bytes_per_channel = 2;
break;
@ -172,9 +261,11 @@ static void rdpsnd_alsa_set_format(rdpsndDevicePlugin* device, rdpsndFormat* for
static void rdpsnd_alsa_open_mixer(rdpsndAlsaPlugin* alsa)
{
int status;
snd_mixer_t* handle;
status = snd_mixer_open(&handle, 0);
if (alsa->mixer_handle)
return;
status = snd_mixer_open(&alsa->mixer_handle, 0);
if (status < 0)
{
@ -182,47 +273,47 @@ static void rdpsnd_alsa_open_mixer(rdpsndAlsaPlugin* alsa)
return;
}
status = snd_mixer_attach(handle, alsa->device_name);
status = snd_mixer_attach(alsa->mixer_handle, alsa->device_name);
if (status < 0)
{
DEBUG_WARN("snd_mixer_attach failed");
snd_mixer_close(handle);
snd_mixer_close(alsa->mixer_handle);
return;
}
status = snd_mixer_selem_register(handle, NULL, NULL);
status = snd_mixer_selem_register(alsa->mixer_handle, NULL, NULL);
if (status < 0)
{
DEBUG_WARN("snd_mixer_selem_register failed");
snd_mixer_close(handle);
snd_mixer_close(alsa->mixer_handle);
return;
}
status = snd_mixer_load(handle);
status = snd_mixer_load(alsa->mixer_handle);
if (status < 0)
{
DEBUG_WARN("snd_mixer_load failed");
snd_mixer_close(handle);
snd_mixer_close(alsa->mixer_handle);
return;
}
alsa->mixer_handle = handle;
}
static void rdpsnd_alsa_open(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
static void rdpsnd_alsa_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
int mode;
int status;
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
if (alsa->out_handle != 0)
if (alsa->pcm_handle)
return;
DEBUG_SVC("opening");
mode = 0;
//mode |= SND_PCM_NONBLOCK;
status = snd_pcm_open(&alsa->out_handle, alsa->device_name, SND_PCM_STREAM_PLAYBACK, 0);
status = snd_pcm_open(&alsa->pcm_handle, alsa->device_name, SND_PCM_STREAM_PLAYBACK, mode);
if (status < 0)
{
@ -238,14 +329,32 @@ static void rdpsnd_alsa_open(rdpsndDevicePlugin* device, rdpsndFormat* format, i
static void rdpsnd_alsa_close(rdpsndDevicePlugin* device)
{
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
int status;
snd_htimestamp_t tstamp;
snd_pcm_uframes_t frames;
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
if (alsa->out_handle != 0)
if (!alsa->pcm_handle)
return;
status = snd_pcm_htimestamp(alsa->pcm_handle, &frames, &tstamp);
if (status != 0)
frames = 0;
alsa->wLocalTimeClose = GetTickCount();
alsa->wLocalTimeClose += (((frames * 1000) / alsa->actual_rate) / alsa->actual_channels);
}
static void rdpsnd_alsa_free(rdpsndDevicePlugin* device)
{
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
if (alsa->pcm_handle)
{
DEBUG_SVC("close");
snd_pcm_drain(alsa->out_handle);
snd_pcm_close(alsa->out_handle);
alsa->out_handle = 0;
snd_pcm_drain(alsa->pcm_handle);
snd_pcm_close(alsa->pcm_handle);
alsa->pcm_handle = 0;
}
if (alsa->mixer_handle)
@ -253,23 +362,19 @@ static void rdpsnd_alsa_close(rdpsndDevicePlugin* device)
snd_mixer_close(alsa->mixer_handle);
alsa->mixer_handle = NULL;
}
}
static void rdpsnd_alsa_free(rdpsndDevicePlugin* device)
{
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
rdpsnd_alsa_close(device);
free(alsa->device_name);
freerdp_dsp_context_free(alsa->dsp_context);
free(alsa);
}
static BOOL rdpsnd_alsa_format_supported(rdpsndDevicePlugin* device, rdpsndFormat* format)
static BOOL rdpsnd_alsa_format_supported(rdpsndDevicePlugin* device, AUDIO_FORMAT* format)
{
switch (format->wFormatTag)
{
case 1: /* PCM */
case WAVE_FORMAT_PCM:
if (format->cbSize == 0 &&
format->nSamplesPerSec <= 48000 &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
@ -279,8 +384,8 @@ static BOOL rdpsnd_alsa_format_supported(rdpsndDevicePlugin* device, rdpsndForma
}
break;
case 2: /* MS ADPCM */
case 0x11: /* IMA ADPCM */
case WAVE_FORMAT_ADPCM:
case WAVE_FORMAT_DVI_ADPCM:
if (format->nSamplesPerSec <= 48000 &&
format->wBitsPerSample == 4 &&
(format->nChannels == 1 || format->nChannels == 2))
@ -288,10 +393,63 @@ static BOOL rdpsnd_alsa_format_supported(rdpsndDevicePlugin* device, rdpsndForma
return TRUE;
}
break;
case WAVE_FORMAT_ALAW:
break;
case WAVE_FORMAT_MULAW:
break;
case WAVE_FORMAT_GSM610:
break;
}
return FALSE;
}
static UINT32 rdpsnd_alsa_get_volume(rdpsndDevicePlugin* device)
{
long volume_min;
long volume_max;
long volume_left;
long volume_right;
int percent_left;
int percent_right;
UINT32 dwVolume;
UINT16 dwVolumeLeft;
UINT16 dwVolumeRight;
snd_mixer_elem_t* elem;
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
if (!alsa->mixer_handle)
rdpsnd_alsa_open_mixer(alsa);
for (elem = snd_mixer_first_elem(alsa->mixer_handle); elem; elem = snd_mixer_elem_next(elem))
{
if (snd_mixer_selem_has_playback_volume(elem))
{
snd_mixer_selem_get_playback_volume_range(elem, &volume_min, &volume_max);
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &volume_left);
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, &volume_right);
dwVolumeLeft = (UINT16) (((volume_left * 0xFFFF) - volume_min) / (volume_max - volume_min));
dwVolumeRight = (UINT16) (((volume_right * 0xFFFF) - volume_min) / (volume_max - volume_min));
percent_left = (dwVolumeLeft * 100) / 0xFFFF;
percent_right = (dwVolumeRight * 100) / 0xFFFF;
break;
}
}
dwVolume = (dwVolumeLeft << 16) | dwVolumeRight;
return dwVolume;
}
static void rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value)
{
long left;
@ -300,15 +458,20 @@ static void rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value)
long volume_max;
long volume_left;
long volume_right;
int percent_left;
int percent_right;
snd_mixer_elem_t* elem;
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
if (!alsa->mixer_handle)
return;
rdpsnd_alsa_open_mixer(alsa);
left = (value & 0xFFFF);
right = ((value >> 16) & 0xFFFF);
percent_left = (left * 100) / 0xFFFF;
percent_right = (right * 100) / 0xFFFF;
for (elem = snd_mixer_first_elem(alsa->mixer_handle); elem; elem = snd_mixer_elem_next(elem))
{
if (snd_mixer_selem_has_playback_volume(elem))
@ -322,99 +485,141 @@ static void rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value)
}
}
static void rdpsnd_alsa_play(rdpsndDevicePlugin* device, BYTE* data, int size)
BYTE* rdpsnd_alsa_process_audio_sample(rdpsndDevicePlugin* device, BYTE* data, int* size)
{
BYTE* src;
int len;
int status;
int frames;
int rbytes_per_frame;
int sbytes_per_frame;
BYTE* pindex;
BYTE* end;
BYTE* srcData;
int srcFrameSize;
int dstFrameSize;
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
if (alsa->out_handle == 0)
return;
if (alsa->wformat == 2)
if (alsa->wformat == WAVE_FORMAT_ADPCM)
{
alsa->dsp_context->decode_ms_adpcm(alsa->dsp_context,
data, size, alsa->source_channels, alsa->block_size);
size = alsa->dsp_context->adpcm_size;
src = alsa->dsp_context->adpcm_buffer;
data, *size, alsa->source_channels, alsa->block_size);
*size = alsa->dsp_context->adpcm_size;
srcData = alsa->dsp_context->adpcm_buffer;
}
else if (alsa->wformat == 0x11)
else if (alsa->wformat == WAVE_FORMAT_DVI_ADPCM)
{
alsa->dsp_context->decode_ima_adpcm(alsa->dsp_context,
data, size, alsa->source_channels, alsa->block_size);
size = alsa->dsp_context->adpcm_size;
src = alsa->dsp_context->adpcm_buffer;
data, *size, alsa->source_channels, alsa->block_size);
*size = alsa->dsp_context->adpcm_size;
srcData = alsa->dsp_context->adpcm_buffer;
}
else
{
src = data;
srcData = data;
}
sbytes_per_frame = alsa->source_channels * alsa->bytes_per_channel;
rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel;
srcFrameSize = alsa->source_channels * alsa->bytes_per_channel;
dstFrameSize = alsa->actual_channels * alsa->bytes_per_channel;
if ((size % sbytes_per_frame) != 0)
{
DEBUG_WARN("error len mod");
return;
}
if ((*size % srcFrameSize) != 0)
return NULL;
if ((alsa->source_rate == alsa->actual_rate) && (alsa->source_channels == alsa->actual_channels))
if (!((alsa->source_rate == alsa->actual_rate) && (alsa->source_channels == alsa->actual_channels)))
{
}
else
{
alsa->dsp_context->resample(alsa->dsp_context, src, alsa->bytes_per_channel,
alsa->source_channels, alsa->source_rate, size / sbytes_per_frame,
alsa->dsp_context->resample(alsa->dsp_context, srcData, alsa->bytes_per_channel,
alsa->source_channels, alsa->source_rate, *size / srcFrameSize,
alsa->actual_channels, alsa->actual_rate);
frames = alsa->dsp_context->resampled_frames;
DEBUG_SVC("resampled %d frames at %d to %d frames at %d",
size / sbytes_per_frame, alsa->source_rate, frames, alsa->actual_rate);
size = frames * rbytes_per_frame;
src = alsa->dsp_context->resampled_buffer;
*size = frames * dstFrameSize;
srcData = alsa->dsp_context->resampled_buffer;
}
pindex = src;
end = pindex + size;
data = srcData;
while (pindex < end)
return data;
}
static void rdpsnd_alsa_wave_decode(rdpsndDevicePlugin* device, RDPSND_WAVE* wave)
{
int size;
BYTE* data;
size = wave->length;
data = rdpsnd_alsa_process_audio_sample(device, wave->data, &size);
wave->data = (BYTE*) malloc(size);
CopyMemory(wave->data, data, size);
wave->length = size;
}
static void rdpsnd_alsa_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave)
{
BYTE* data;
int offset;
int length;
int status;
int frame_size;
UINT32 wCurrentTime;
snd_htimestamp_t tstamp;
snd_pcm_uframes_t frames;
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
offset = 0;
data = wave->data;
length = wave->length;
frame_size = alsa->actual_channels * alsa->bytes_per_channel;
if (alsa->wLocalTimeClose)
{
len = end - pindex;
frames = len / rbytes_per_frame;
status = snd_pcm_writei(alsa->out_handle, pindex, frames);
wCurrentTime = GetTickCount();
if (snd_pcm_htimestamp(alsa->pcm_handle, &frames, &tstamp) == -EPIPE)
{
if (wCurrentTime > alsa->wLocalTimeClose)
snd_pcm_recover(alsa->pcm_handle, -EPIPE, 1);
}
alsa->wLocalTimeClose = 0;
}
while (offset < length)
{
status = snd_pcm_writei(alsa->pcm_handle, &data[offset], (length - offset) / frame_size);
if (status == -EPIPE)
{
snd_pcm_recover(alsa->out_handle, status, 0);
snd_pcm_recover(alsa->pcm_handle, status, 0);
status = 0;
}
else if (status == -EAGAIN)
{
status = 0;
}
else if (status < 0)
{
DEBUG_WARN("status %d", status);
snd_pcm_close(alsa->out_handle);
alsa->out_handle = 0;
rdpsnd_alsa_open(device, NULL, alsa->latency);
printf("status: %d\n", status);
snd_pcm_close(alsa->pcm_handle);
alsa->pcm_handle = NULL;
rdpsnd_alsa_open((rdpsndDevicePlugin*) alsa, NULL, alsa->latency);
break;
}
pindex += status * rbytes_per_frame;
offset += status * frame_size;
}
}
static void rdpsnd_alsa_start(rdpsndDevicePlugin* device)
{
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
free(data);
if (alsa->out_handle == 0)
return;
snd_pcm_htimestamp(alsa->pcm_handle, &frames, &tstamp);
snd_pcm_start(alsa->out_handle);
wave->wPlaybackDelay = ((frames * 1000) / alsa->actual_rate);
wave->wLocalTimeB = GetTickCount();
wave->wLocalTimeB += wave->wPlaybackDelay;
wave->wLatency = (UINT16) (wave->wLocalTimeB - wave->wLocalTimeA);
wave->wTimeStampB = wave->wTimeStampA + wave->wLatency;
//printf("wTimeStampA: %d wTimeStampB: %d wLatency: %d\n", wave->wTimeStampA, wave->wTimeStampB, wave->wLatency);
device->WaveConfirm(device, wave);
}
COMMAND_LINE_ARGUMENT_A rdpsnd_alsa_args[] =
@ -468,9 +673,10 @@ int freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pE
alsa->device.Open = rdpsnd_alsa_open;
alsa->device.FormatSupported = rdpsnd_alsa_format_supported;
alsa->device.SetFormat = rdpsnd_alsa_set_format;
alsa->device.GetVolume = rdpsnd_alsa_get_volume;
alsa->device.SetVolume = rdpsnd_alsa_set_volume;
alsa->device.Play = rdpsnd_alsa_play;
alsa->device.Start = rdpsnd_alsa_start;
alsa->device.WaveDecode = rdpsnd_alsa_wave_decode;
alsa->device.WavePlay = rdpsnd_alsa_wave_play;
alsa->device.Close = rdpsnd_alsa_close;
alsa->device.Free = rdpsnd_alsa_free;
@ -480,7 +686,7 @@ int freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pE
if (!alsa->device_name)
alsa->device_name = _strdup("default");
alsa->out_handle = 0;
alsa->pcm_handle = 0;
alsa->source_rate = 22050;
alsa->actual_rate = 22050;
alsa->format = SND_PCM_FORMAT_S16_LE;

View File

@ -32,7 +32,7 @@
#include <winpr/crt.h>
#include <freerdp/types.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/utils/svc_plugin.h>
#include <AudioToolbox/AudioToolbox.h>
@ -72,7 +72,7 @@ static void rdpsnd_audio_close(rdpsndDevicePlugin* device)
aq_plugin_p->is_open = 0;
}
static void rdpsnd_audio_open(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
static void rdpsnd_audio_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
int rv;
int i;
@ -127,7 +127,7 @@ static void rdpsnd_audio_free(rdpsndDevicePlugin* device)
{
}
static BOOL rdpsnd_audio_format_supported(rdpsndDevicePlugin* device, rdpsndFormat* format)
static BOOL rdpsnd_audio_format_supported(rdpsndDevicePlugin* device, AUDIO_FORMAT* format)
{
switch (format->wFormatTag)
{
@ -144,7 +144,7 @@ static BOOL rdpsnd_audio_format_supported(rdpsndDevicePlugin* device, rdpsndForm
return 0;
}
static void rdpsnd_audio_set_format(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
static void rdpsnd_audio_set_format(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
}

View File

@ -31,7 +31,7 @@
#include <pulse/pulseaudio.h>
#include <freerdp/types.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/utils/svc_plugin.h>
#include "rdpsnd_main.h"
@ -43,10 +43,10 @@ struct rdpsnd_pulse_plugin
rdpsndDevicePlugin device;
char* device_name;
pa_threaded_mainloop *mainloop;
pa_context *context;
pa_threaded_mainloop* mainloop;
pa_context* context;
pa_sample_spec sample_spec;
pa_stream *stream;
pa_stream* stream;
int format;
int block_size;
int latency;
@ -106,13 +106,16 @@ static BOOL rdpsnd_pulse_connect(rdpsndDevicePlugin* device)
for (;;)
{
state = pa_context_get_state(pulse->context);
if (state == PA_CONTEXT_READY)
break;
if (!PA_CONTEXT_IS_GOOD(state))
{
DEBUG_WARN("bad context state (%d)", pa_context_errno(pulse->context));
break;
}
pa_threaded_mainloop_wait(pulse->mainloop);
}
@ -139,7 +142,7 @@ static void rdpsnd_pulse_stream_success_callback(pa_stream* stream, int success,
static void rdpsnd_pulse_wait_for_operation(rdpsndPulsePlugin* pulse, pa_operation* operation)
{
if (operation == NULL)
if (!operation)
return;
while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
@ -200,7 +203,7 @@ static void rdpsnd_pulse_close(rdpsndDevicePlugin* device)
pa_threaded_mainloop_unlock(pulse->mainloop);
}
static void rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, rdpsndFormat* format)
static void rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, AUDIO_FORMAT* format)
{
pa_sample_spec sample_spec = { 0 };
@ -212,7 +215,7 @@ static void rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, rdpsndFormat*
switch (format->wFormatTag)
{
case 1: /* PCM */
case WAVE_FORMAT_PCM:
switch (format->wBitsPerSample)
{
case 8:
@ -224,17 +227,20 @@ static void rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, rdpsndFormat*
}
break;
case 6: /* A-LAW */
case WAVE_FORMAT_ADPCM:
case WAVE_FORMAT_DVI_ADPCM:
sample_spec.format = PA_SAMPLE_S16LE;
break;
case WAVE_FORMAT_ALAW:
sample_spec.format = PA_SAMPLE_ALAW;
break;
case 7: /* U-LAW */
case WAVE_FORMAT_MULAW:
sample_spec.format = PA_SAMPLE_ULAW;
break;
case 2: /* MS ADPCM */
case 0x11: /* IMA ADPCM */
sample_spec.format = PA_SAMPLE_S16LE;
case WAVE_FORMAT_GSM610:
break;
}
@ -243,7 +249,7 @@ static void rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, rdpsndFormat*
pulse->block_size = format->nBlockAlign;
}
static void rdpsnd_pulse_open(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
static void rdpsnd_pulse_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
pa_stream_state_t state;
pa_stream_flags_t flags;
@ -278,7 +284,7 @@ static void rdpsnd_pulse_open(rdpsndDevicePlugin* device, rdpsndFormat* format,
return;
}
/* install essential callbacks */
/* register essential callbacks */
pa_stream_set_state_callback(pulse->stream, rdpsnd_pulse_stream_state_callback, pulse);
pa_stream_set_write_callback(pulse->stream, rdpsnd_pulse_stream_request_callback, pulse);
@ -365,7 +371,7 @@ static void rdpsnd_pulse_free(rdpsndDevicePlugin* device)
free(pulse);
}
static BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, rdpsndFormat* format)
static BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, AUDIO_FORMAT* format)
{
rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
@ -374,7 +380,7 @@ static BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, rdpsndForm
switch (format->wFormatTag)
{
case 1: /* PCM */
case WAVE_FORMAT_PCM:
if (format->cbSize == 0 &&
(format->nSamplesPerSec <= PA_RATE_MAX) &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
@ -384,8 +390,8 @@ static BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, rdpsndForm
}
break;
case 6: /* A-LAW */
case 7: /* U-LAW */
case WAVE_FORMAT_ALAW:
case WAVE_FORMAT_MULAW:
if (format->cbSize == 0 &&
(format->nSamplesPerSec <= PA_RATE_MAX) &&
(format->wBitsPerSample == 8) &&
@ -395,8 +401,8 @@ static BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, rdpsndForm
}
break;
case 2: /* MS ADPCM */
case 0x11: /* IMA ADPCM */
case WAVE_FORMAT_ADPCM:
case WAVE_FORMAT_DVI_ADPCM:
if ((format->nSamplesPerSec <= PA_RATE_MAX) &&
(format->wBitsPerSample == 4) &&
(format->nChannels == 1 || format->nChannels == 2))
@ -408,7 +414,7 @@ static BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, rdpsndForm
return FALSE;
}
static void rdpsnd_pulse_set_format(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
static void rdpsnd_pulse_set_format(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
@ -463,17 +469,19 @@ static void rdpsnd_pulse_play(rdpsndDevicePlugin* device, BYTE* data, int size)
if (!pulse->stream)
return;
if (pulse->format == 2)
if (pulse->format == WAVE_FORMAT_ADPCM)
{
pulse->dsp_context->decode_ms_adpcm(pulse->dsp_context,
data, size, pulse->sample_spec.channels, pulse->block_size);
size = pulse->dsp_context->adpcm_size;
src = pulse->dsp_context->adpcm_buffer;
}
else if (pulse->format == 0x11)
else if (pulse->format == WAVE_FORMAT_DVI_ADPCM)
{
pulse->dsp_context->decode_ima_adpcm(pulse->dsp_context,
data, size, pulse->sample_spec.channels, pulse->block_size);
size = pulse->dsp_context->adpcm_size;
src = pulse->dsp_context->adpcm_buffer;
}

File diff suppressed because it is too large Load Diff

View File

@ -22,29 +22,60 @@
#include <freerdp/channels/rdpsnd.h>
struct _RDPSND_WAVE
{
BYTE* data;
int length;
BYTE cBlockNo;
UINT16 wFormatNo;
UINT16 wTimeStampA;
UINT16 wTimeStampB;
UINT16 wLatency;
UINT16 wAudioLength;
UINT16 wPlaybackDelay;
UINT32 wLocalTimeA;
UINT32 wLocalTimeB;
};
typedef struct _RDPSND_WAVE RDPSND_WAVE;
typedef struct rdpsnd_plugin rdpsndPlugin;
typedef struct rdpsnd_device_plugin rdpsndDevicePlugin;
typedef BOOL (*pcFormatSupported) (rdpsndDevicePlugin* device, rdpsndFormat* format);
typedef void (*pcOpen) (rdpsndDevicePlugin* device, rdpsndFormat* format, int latency);
typedef void (*pcSetFormat) (rdpsndDevicePlugin* device, rdpsndFormat* format, int latency);
typedef BOOL (*pcFormatSupported) (rdpsndDevicePlugin* device, AUDIO_FORMAT* format);
typedef void (*pcOpen) (rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency);
typedef void (*pcSetFormat) (rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency);
typedef UINT32 (*pcGetVolume) (rdpsndDevicePlugin* device);
typedef void (*pcSetVolume) (rdpsndDevicePlugin* device, UINT32 value);
typedef void (*pcPlay) (rdpsndDevicePlugin* device, BYTE* data, int size);
typedef void (*pcStart) (rdpsndDevicePlugin* device);
typedef void (*pcClose) (rdpsndDevicePlugin* device);
typedef void (*pcFree) (rdpsndDevicePlugin* device);
typedef void (*pcWaveDecode) (rdpsndDevicePlugin* device, RDPSND_WAVE* wave);
typedef void (*pcWavePlay) (rdpsndDevicePlugin* device, RDPSND_WAVE* wave);
typedef void (*pcWaveConfirm) (rdpsndDevicePlugin* device, RDPSND_WAVE* wave);
struct rdpsnd_device_plugin
{
rdpsndPlugin* rdpsnd;
pcFormatSupported FormatSupported;
pcOpen Open;
pcSetFormat SetFormat;
pcGetVolume GetVolume;
pcSetVolume SetVolume;
pcPlay Play;
pcStart Start;
pcClose Close;
pcFree Free;
pcWaveDecode WaveDecode;
pcWavePlay WavePlay;
pcWaveConfirm WaveConfirm;
};
#define RDPSND_DEVICE_EXPORT_FUNC_NAME "freerdp_rdpsnd_client_subsystem_entry"

View File

@ -33,7 +33,7 @@
#include <winpr/cmdline.h>
#include <freerdp/types.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/utils/svc_plugin.h>
#include "rdpsnd_main.h"
@ -63,7 +63,7 @@ struct rdpsnd_winmm_plugin
FREERDP_DSP_CONTEXT* dsp_context;
};
static BOOL rdpsnd_winmm_convert_format(const rdpsndFormat* in, WAVEFORMATEX* out)
static BOOL rdpsnd_winmm_convert_format(const AUDIO_FORMAT* in, WAVEFORMATEX* out)
{
BOOL result = FALSE;
@ -71,6 +71,7 @@ static BOOL rdpsnd_winmm_convert_format(const rdpsndFormat* in, WAVEFORMATEX* ou
out->wFormatTag = WAVE_FORMAT_PCM;
out->nChannels = in->nChannels;
out->nSamplesPerSec = in->nSamplesPerSec;
switch (in->wFormatTag)
{
case WAVE_FORMAT_PCM:
@ -78,12 +79,13 @@ static BOOL rdpsnd_winmm_convert_format(const rdpsndFormat* in, WAVEFORMATEX* ou
result = TRUE;
break;
case 2: /* MS ADPCM */
case 0x11: /* IMA ADPCM */
case WAVE_FORMAT_ADPCM:
case WAVE_FORMAT_DVI_ADPCM:
out->wBitsPerSample = 16;
result = TRUE;
break;
}
out->nBlockAlign = out->nChannels * out->wBitsPerSample / 8;
out->nAvgBytesPerSec = out->nSamplesPerSec * out->nBlockAlign;
@ -98,19 +100,22 @@ static void rdpsnd_winmm_clear_datablocks(rdpsndWinmmPlugin* winmm, BOOL drain)
{
if (!drain && (datablock->header.dwFlags & WHDR_DONE) == 0)
break;
while ((datablock->header.dwFlags & WHDR_DONE) == 0)
WaitForSingleObject(winmm->event, INFINITE);
winmm->datablock_head = datablock->next;
free(datablock->header.lpData);
free(datablock);
}
}
static void rdpsnd_winmm_set_format(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
static void rdpsnd_winmm_set_format(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
if (format != NULL)
if (format)
{
rdpsnd_winmm_convert_format(format, &winmm->format);
@ -121,7 +126,7 @@ static void rdpsnd_winmm_set_format(rdpsndDevicePlugin* device, rdpsndFormat* fo
winmm->latency = latency;
}
static void rdpsnd_winmm_open(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency)
static void rdpsnd_winmm_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
MMRESULT result;
rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
@ -135,6 +140,7 @@ static void rdpsnd_winmm_open(rdpsndDevicePlugin* device, rdpsndFormat* format,
freerdp_dsp_context_reset_adpcm(winmm->dsp_context);
result = waveOutOpen(&winmm->out_handle, WAVE_MAPPER, &winmm->format, (DWORD_PTR) winmm->event, 0, CALLBACK_EVENT);
if (result != MMSYSERR_NOERROR)
{
DEBUG_WARN("waveOutOpen failed: %d", result);
@ -145,14 +151,16 @@ static void rdpsnd_winmm_close(rdpsndDevicePlugin* device)
{
rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
if (winmm->out_handle != NULL)
if (winmm->out_handle)
{
DEBUG_SVC("close");
rdpsnd_winmm_clear_datablocks(winmm, TRUE);
if (waveOutClose(winmm->out_handle) != MMSYSERR_NOERROR)
{
DEBUG_WARN("waveOutClose error");
}
winmm->out_handle = NULL;
}
}
@ -167,7 +175,7 @@ static void rdpsnd_winmm_free(rdpsndDevicePlugin* device)
free(winmm);
}
static BOOL rdpsnd_winmm_format_supported(rdpsndDevicePlugin* device, rdpsndFormat* format)
static BOOL rdpsnd_winmm_format_supported(rdpsndDevicePlugin* device, AUDIO_FORMAT* format)
{
MMRESULT result;
WAVEFORMATEX out;
@ -175,6 +183,7 @@ static BOOL rdpsnd_winmm_format_supported(rdpsndDevicePlugin* device, rdpsndForm
if (rdpsnd_winmm_convert_format(format, &out))
{
result = waveOutOpen(NULL, WAVE_MAPPER, &out, 0, 0, WAVE_FORMAT_QUERY);
if (result == MMSYSERR_NOERROR)
return TRUE;
}
@ -182,11 +191,31 @@ static BOOL rdpsnd_winmm_format_supported(rdpsndDevicePlugin* device, rdpsndForm
return FALSE;
}
static UINT32 rdpsnd_winmm_get_volume(rdpsndDevicePlugin* device)
{
DWORD dwVolume;
UINT16 dwVolumeLeft;
UINT16 dwVolumeRight;
rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
dwVolume = (dwVolumeLeft << 16) | dwVolumeRight;
if (!winmm->out_handle)
return dwVolume;
waveOutGetVolume(winmm->out_handle, &dwVolume);
return dwVolume;
}
static void rdpsnd_winmm_set_volume(rdpsndDevicePlugin* device, UINT32 value)
{
rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
if (winmm->out_handle == NULL)
if (!winmm->out_handle)
return;
waveOutSetVolume(winmm->out_handle, value);
@ -200,17 +229,17 @@ static void rdpsnd_winmm_play(rdpsndDevicePlugin* device, BYTE* data, int size)
rdpsndWinmmDatablock* datablock;
rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
if (winmm->out_handle == NULL)
if (!winmm->out_handle)
return;
if (winmm->wformat == 2)
if (winmm->wformat == WAVE_FORMAT_ADPCM)
{
winmm->dsp_context->decode_ms_adpcm(winmm->dsp_context,
data, size, winmm->format.nChannels, winmm->block_size);
size = winmm->dsp_context->adpcm_size;
src = winmm->dsp_context->adpcm_buffer;
}
else if (winmm->wformat == 0x11)
else if (winmm->wformat == WAVE_FORMAT_DVI_ADPCM)
{
winmm->dsp_context->decode_ima_adpcm(winmm->dsp_context,
data, size, winmm->format.nChannels, winmm->block_size);
@ -223,25 +252,32 @@ static void rdpsnd_winmm_play(rdpsndDevicePlugin* device, BYTE* data, int size)
}
rdpsnd_winmm_clear_datablocks(winmm, FALSE);
for (last = winmm->datablock_head; last && last->next; last = last->next)
{
}
datablock = (rdpsndWinmmDatablock*) malloc(sizeof(rdpsndWinmmDatablock));
ZeroMemory(datablock, sizeof(rdpsndWinmmDatablock));
if (last)
last->next = datablock;
else
winmm->datablock_head = datablock;
datablock->header.dwBufferLength = size;
datablock->header.lpData = (LPSTR) malloc(size);
CopyMemory(datablock->header.lpData, src, size);
result = waveOutPrepareHeader(winmm->out_handle, &datablock->header, sizeof(datablock->header));
if (result != MMSYSERR_NOERROR)
{
DEBUG_WARN("waveOutPrepareHeader: %d", result);
return;
}
ResetEvent(winmm->event);
waveOutWrite(winmm->out_handle, &datablock->header, sizeof(datablock->header));
}
@ -272,6 +308,7 @@ int freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pE
winmm->device.Open = rdpsnd_winmm_open;
winmm->device.FormatSupported = rdpsnd_winmm_format_supported;
winmm->device.SetFormat = rdpsnd_winmm_set_format;
winmm->device.GetVolume = rdpsnd_winmm_get_volume;
winmm->device.SetVolume = rdpsnd_winmm_set_volume;
winmm->device.Play = rdpsnd_winmm_play;
winmm->device.Start = rdpsnd_winmm_start;

View File

@ -27,7 +27,7 @@
#include <winpr/crt.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/thread.h>
#include <freerdp/channels/wtsvc.h>
@ -129,8 +129,8 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, STREAM* s)
if (rdpsnd->context.num_client_formats > 0)
{
rdpsnd->context.client_formats = (rdpsndFormat*) malloc(rdpsnd->context.num_client_formats * sizeof(rdpsndFormat));
ZeroMemory(rdpsnd->context.client_formats, sizeof(rdpsndFormat));
rdpsnd->context.client_formats = (AUDIO_FORMAT*) malloc(rdpsnd->context.num_client_formats * sizeof(AUDIO_FORMAT));
ZeroMemory(rdpsnd->context.client_formats, sizeof(AUDIO_FORMAT));
for (i = 0; i < rdpsnd->context.num_client_formats; i++)
{
@ -184,7 +184,8 @@ static void* rdpsnd_server_thread_func(void* arg)
while (1)
{
freerdp_thread_wait(thread);
if (freerdp_thread_wait(thread) < 0)
break;
if (freerdp_thread_is_stopped(thread))
break;
@ -254,7 +255,7 @@ static void rdpsnd_server_select_format(rdpsnd_server_context* context, int clie
{
int bs;
int out_buffer_size;
rdpsndFormat *format;
AUDIO_FORMAT *format;
rdpsnd_server* rdpsnd = (rdpsnd_server*) context;
if (client_format_index < 0 || client_format_index >= context->num_client_formats)
@ -308,7 +309,7 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd)
BYTE* src;
int frames;
int fill_size;
rdpsndFormat* format;
AUDIO_FORMAT* format;
int tbytes_per_frame;
STREAM* s = rdpsnd->rdpsnd_pdu;

View File

@ -45,14 +45,8 @@ struct sample_plugin
rdpSvcPlugin plugin;
/* put your private data here */
};
static void sample_process_interval(rdpSvcPlugin* plugin)
{
printf("sample_process_interval:\n");
}
static void sample_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
{
int bytes;
@ -61,17 +55,18 @@ static void sample_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
printf("sample_process_receive:\n");
if (sample == NULL)
if (!sample)
{
printf("sample_process_receive: sample is nil\n");
return;
}
/* process data in(from server) here */
/* process data in (from server) here */
/* here we just send the same data back */
bytes = stream_get_size(data_in);
printf("sample_process_receive: got bytes %d\n", bytes);
if (bytes > 0)
{
data_out = stream_new(bytes);
@ -95,22 +90,15 @@ static void sample_process_connect(rdpSvcPlugin* plugin)
printf("sample_process_connect:\n");
if (sample == NULL)
{
if (!sample)
return;
}
/* if you want a call from channel thread once is a while do this */
plugin->interval_ms = 1000;
plugin->interval_callback = sample_process_interval;
}
static void sample_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event)
{
printf("sample_process_event:\n");
/* events comming from main freerdp window to plugin */
/* events coming from main freerdp window to plugin */
/* send them back with svc_plugin_send_event */
freerdp_event_free(event);
@ -118,14 +106,12 @@ static void sample_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event)
static void sample_process_terminate(rdpSvcPlugin* plugin)
{
samplePlugin* sample = (samplePlugin*)plugin;
samplePlugin* sample = (samplePlugin*) plugin;
printf("sample_process_terminate:\n");
if (sample == NULL)
{
if (!sample)
return;
}
/* put your cleanup here */

View File

@ -341,7 +341,8 @@ static void* serial_thread_func(void* arg)
while (1)
{
freerdp_thread_wait_timeout(serial->thread, 500);
if (freerdp_thread_wait_timeout(serial->thread, 500) < 0)
break;
serial->nfds = 1;
FD_ZERO(&serial->read_fds);

View File

@ -35,7 +35,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVER
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp
MODULES freerdp-utils)
MODULES freerdp-codec freerdp-utils)
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}

View File

@ -32,7 +32,7 @@
#include <alsa/asoundlib.h>
#include <freerdp/types.h>
#include <freerdp/utils/dsp.h>
#include <freerdp/codec/dsp.h>
#include "tsmf_audio.h"

View File

@ -1,109 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
package="com.freerdp.afreerdp"
android:versionCode="1"
android:versionName="@FREERDP_VERSION_FULL@" >
<uses-sdk android:targetSdkVersion="8" android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING" />
<supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" />
<application android:name="com.freerdp.afreerdp.application.GlobalApp"
android:label="aFreeRDP"
android:icon="@drawable/icon_launcher_freerdp" >
<!-- Main activity -->
<activity android:name="com.freerdp.afreerdp.presentation.HomeActivity"
android:label="@string/app_title"
android:theme="@style/Theme.Main"
android:alwaysRetainTaskState="true"
>
<intent-filter android:label="@string/app_title">
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Acra crash report dialog activity -->
<activity android:name="org.acra.CrashReportDialog"
android:theme="@android:style/Theme.Dialog" android:launchMode="singleInstance"
android:excludeFromRecents="true" android:finishOnTaskLaunch="true" />
<!-- Session request handler activity - used for search and internally to start sessions -->
<activity android:name="com.freerdp.afreerdp.services.SessionRequestHandlerActivity"
android:theme="@android:style/Theme.NoDisplay"
android:noHistory="true"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<!-- Activity to create shortcuts -->
<activity android:name="com.freerdp.afreerdp.presentation.ShortcutsActivity"
android:theme="@style/Theme.Main"
android:label="@string/title_create_shortcut">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- It is recommended that you use an activity-alias to provide the "CREATE_SHORTCUT" -->
<!-- intent-filter. This gives you a way to set the text (and optionally the -->
<!-- icon) that will be seen in the launcher's create-shortcut user interface. -->
<activity-alias android:name="com.freerdp.afreerdp.presentation.CreateShortcuts"
android:targetActivity="com.freerdp.afreerdp.presentation.ShortcutsActivity"
android:label="@string/title_create_shortcut">
<!-- This intent-filter allows your shortcuts to be created in the launcher. -->
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>
<activity android:name="com.freerdp.afreerdp.presentation.BookmarkActivity"
android:label="@string/title_bookmark_settings"
android:theme="@style/Theme.Settings">
</activity>
<activity android:name="com.freerdp.afreerdp.presentation.ApplicationSettingsActivity"
android:label="@string/title_application_settings"
android:theme="@style/Theme.Settings"
android:windowSoftInputMode="stateHidden">
</activity>
<activity android:name="com.freerdp.afreerdp.presentation.SessionActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard"
android:windowSoftInputMode="adjustResize">
</activity>
<activity android:name="com.freerdp.afreerdp.presentation.AboutActivity"
android:label="@string/title_about"
android:theme="@style/Theme.Main">
</activity>
<activity android:name="com.freerdp.afreerdp.presentation.HelpActivity"
android:label="@string/title_help"
android:theme="@style/Theme.Main">
</activity>
<provider android:name="com.freerdp.afreerdp.services.FreeRDPSuggestionProvider"
android:authorities="com.freerdp.afreerdp.services.freerdpsuggestionprovider"
>
</provider>
<receiver android:name="com.freerdp.afreerdp.application.NetworkStateReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -1,7 +1,6 @@
# FreeRDP: A Remote Desktop Protocol Implementation
# Android Client
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2013 Bernhard Miklautz <bmiklautz@thinstuff.at>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -16,23 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(ANDROID_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(ANDROID_PACKAGE_NAME "aFreeRDP")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml.cmake ${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml @ONLY)
if (ANDROID_SDK)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/local.properties.cmake ${CMAKE_CURRENT_SOURCE_DIR}/local.properties @ONLY)
endif()
add_subdirectory(jni)
if(ANDROID_BUILD_JAVA)
if (NOT ANDROID_SDK)
message(FATAL_ERROR "ANDROID_SDK not set but required for building the java gui (ANDROID_BUILD_JAVA)")
endif()
# And isn't shiped with the android ndk/sdk so
# we need to find it on the local machine
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER, BOTH)
@ -43,22 +29,12 @@ if(ANDROID_BUILD_JAVA)
message(FATAL_ERROR "ant not found but required to build android java")
endif()
if(ANDROID_BUILD_JAVA_DEBUG)
if(ANDROID_BUILD_JAVA_DEBUG)
set(ANDROID_BUILD_TYPE "debug")
set(APK "${ANDROID_SOURCE_DIR}/bin/${ANDROID_PACKAGE_NAME}-release-unsigned.apk")
else()
set(ANDROID_BUILD_TYPE "release")
set(APK "${ANDROID_SOURCE_DIR}/bin/${ANDROID_PACKAGE_NAME}-debug.apk")
endif()
endif(ANDROID_BUILD_JAVA)
# command to create the android package
add_custom_command(
OUTPUT "${APK}"
COMMAND ${ANT_COMMAND} ${ANDROID_BUILD_TYPE}
WORKING_DIRECTORY "${ANDROID_SOURCE_DIR}"
MAIN_DEPENDENCY AndroidManifest.xml
DEPENDS freerdp-android local.properties
)
add_custom_target(android-package ALL SOURCES "${APK}")
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "gen;bin")
endif()
add_subdirectory(FreeRDPCore)
add_subdirectory(aFreeRDP)

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FreeRDPCore</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
package="com.freerdp.freerdpcore"
android:versionCode="1"
android:versionName="@FREERDP_VERSION_FULL@" >
<uses-sdk android:targetSdkVersion="8" android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" />
<application>
<!-- Activity to create shortcuts -->
<activity android:name=".presentation.ShortcutsActivity"
android:theme="@style/Theme.Main"
android:label="@string/title_create_shortcut">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- It is recommended that you use an activity-alias to provide the "CREATE_SHORTCUT" -->
<!-- intent-filter. This gives you a way to set the text (and optionally the -->
<!-- icon) that will be seen in the launcher's create-shortcut user interface. -->
<activity-alias android:name=".presentation.CreateShortcuts"
android:targetActivity="com.freerdp.freerdpcore.presentation.ShortcutsActivity"
android:label="@string/title_create_shortcut">
<!-- This intent-filter allows your shortcuts to be created in the launcher. -->
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>
<activity android:name=".presentation.BookmarkActivity"
android:label="@string/title_bookmark_settings"
android:theme="@style/Theme.Settings">
<intent-filter>
<action android:name="freerdp.intent.action.BOOKMARK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="preferences"/>
</intent-filter>
</activity>
<activity android:name=".presentation.ApplicationSettingsActivity"
android:label="@string/title_application_settings"
android:theme="@style/Theme.Settings"
android:windowSoftInputMode="stateHidden">
</activity>
<activity android:name=".presentation.SessionActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard"
android:windowSoftInputMode="adjustResize">
</activity>
<activity android:name=".presentation.AboutActivity"
android:label="@string/title_about"
android:theme="@style/Theme.Main">
</activity>
<activity android:name=".presentation.HelpActivity"
android:label="@string/title_help"
android:theme="@style/Theme.Main">
</activity>
<receiver android:name=".application.NetworkStateReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -0,0 +1,44 @@
# FreeRDP: A Remote Desktop Protocol Implementation
# Android Client
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2013 Bernhard Miklautz <bmiklautz@thinstuff.at>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(ANDROID_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(ANDROID_PACKAGE_NAME "aFreeRDPCore")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml.cmake ${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml @ONLY)
if (ANDROID_SDK)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/local.properties.cmake ${CMAKE_CURRENT_SOURCE_DIR}/local.properties @ONLY)
endif()
add_subdirectory(jni)
if(ANDROID_BUILD_JAVA)
set(ANDROIDLIB "${ANDROID_SOURCE_DIR}/bin/classes.jar")
# command to create the android package
add_custom_command(
OUTPUT "${ANDROIDLIB}"
COMMAND ${ANT_COMMAND} ${ANDROID_BUILD_TYPE}
WORKING_DIRECTORY "${ANDROID_SOURCE_DIR}"
MAIN_DEPENDENCY AndroidManifest.xml
DEPENDS freerdp-android local.properties
)
add_custom_target(android-lib ALL SOURCES "${ANDROIDLIB}")
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "gen;bin")
endif()

View File

@ -0,0 +1,16 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="." default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -24,6 +24,7 @@
#include <freerdp/utils/event.h>
#include <freerdp/constants.h>
#include <freerdp/locale/keyboard.h>
#include <freerdp/utils/file.h>
#include <android/bitmap.h>
#include <machine/cpu-features.h>
@ -536,7 +537,10 @@ JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, j
const jbyte *directory = (*env)->GetStringUTFChars(env, jdirectory, NULL);
free(settings->HomePath);
free(settings->ConfigPath);
settings->HomePath = strdup(directory);
settings->ConfigPath = NULL;
freerdp_detect_paths(settings);
(*env)->ReleaseStringUTFChars(env, jdirectory, directory);
}
@ -655,7 +659,6 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(
settings->FastPathOutput = TRUE;
settings->ColorDepth = 32;
settings->LargePointerFlag = TRUE;
settings->PerformanceFlags = PERF_FLAG_NONE;
settings->FrameMarkerCommandEnabled = TRUE;
}
@ -680,6 +683,7 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(
/* Create performance flags from settings */
settings->PerformanceFlags = PERF_FLAG_NONE;
if (settings->AllowFontSmoothing)
settings->PerformanceFlags |= PERF_ENABLE_FONT_SMOOTHING;

View File

@ -20,32 +20,32 @@
#include "android_freerdp.h"
#include "android_freerdp_jni.h"
JNIEXPORT jint JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1new(JNIEnv *env, jclass cls)
JNIEXPORT jint JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1new(JNIEnv *env, jclass cls)
{
return jni_freerdp_new(env, cls);
}
JNIEXPORT void JNICALL JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1free(JNIEnv *env, jclass cls, jint instance)
JNIEXPORT void JNICALL JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1free(JNIEnv *env, jclass cls, jint instance)
{
jni_freerdp_free(env, cls, instance);
}
JNIEXPORT jboolean JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1connect(JNIEnv *env, jclass cls, jint instance)
JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1connect(JNIEnv *env, jclass cls, jint instance)
{
return jni_freerdp_connect(env, cls, instance);
}
JNIEXPORT jboolean JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1disconnect(JNIEnv *env, jclass cls, jint instance)
JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1disconnect(JNIEnv *env, jclass cls, jint instance)
{
return jni_freerdp_disconnect(env, cls, instance);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1cancel_1connection(JNIEnv *env, jclass cls, jint instance)
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1cancel_1connection(JNIEnv *env, jclass cls, jint instance)
{
jni_freerdp_cancel_connection(env, cls, instance);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1set_1connection_1info(JNIEnv *env, jclass cls, jint instance,
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1connection_1info(JNIEnv *env, jclass cls, jint instance,
jstring jhostname, jstring jusername, jstring jpassword, jstring jdomain, jint width, jint height, jint color_depth, jint port,
jboolean console, jint security, jstring certname)
{
@ -53,48 +53,48 @@ JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1se
width, height, color_depth, port, console, security, certname);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1set_1advanced_1settings(JNIEnv *env, jclass cls, jint instance, jstring remote_program, jstring work_dir)
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1advanced_1settings(JNIEnv *env, jclass cls, jint instance, jstring remote_program, jstring work_dir)
{
jni_freerdp_set_advanced_settings(env, cls, instance, remote_program, work_dir);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1set_1data_1directory(JNIEnv *env, jclass cls, jint instance, jstring directory)
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory(JNIEnv *env, jclass cls, jint instance, jstring directory)
{
jni_freerdp_set_data_directory(env, cls, instance, directory);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1set_1performance_1flags(
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1performance_1flags(
JNIEnv *env, jclass cls, jint instance, jboolean remotefx, jboolean disableWallpaper, jboolean disableFullWindowDrag,
jboolean disableMenuAnimations, jboolean disableTheming, jboolean enableFontSmoothing, jboolean enableDesktopComposition)
{
jni_freerdp_set_performance_flags(env, cls, instance, remotefx, disableWallpaper, disableFullWindowDrag, disableMenuAnimations, disableTheming, enableFontSmoothing, enableDesktopComposition);
}
JNIEXPORT jboolean JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1update_1graphics(
JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1update_1graphics(
JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height)
{
return jni_freerdp_update_graphics(env, cls, instance, bitmap, x, y, width, height);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1send_1cursor_1event(
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1cursor_1event(
JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags)
{
jni_freerdp_send_cursor_event(env, cls, instance, x, y, flags);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1send_1key_1event(
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1key_1event(
JNIEnv *env, jclass cls, jint instance, jint keycode, jboolean down)
{
jni_freerdp_send_key_event(env, cls, instance, keycode, down);
}
JNIEXPORT void JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1send_1unicodekey_1event
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1unicodekey_1event
(JNIEnv *env, jclass cls, jint instance, jint keycode)
{
jni_freerdp_send_unicodekey_event(env, cls, instance, keycode);
}
JNIEXPORT jstring JNICALL Java_com_freerdp_afreerdp_services_LibFreeRDP_freerdp_1get_1version(JNIEnv *env, jclass cls)
JNIEXPORT jstring JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1get_1version(JNIEnv *env, jclass cls)
{
return jni_freerdp_get_version(env, cls);
}

View File

@ -20,9 +20,9 @@
#ifndef __ANDROID_FREERDP_JNI_H
#define __ANDROID_FREERDP_JNI_H
#include "com_freerdp_afreerdp_services_LibFreeRDP.h"
#include "com_freerdp_freerdpcore_services_LibFreeRDP.h"
#define JAVA_LIBFREERDP_CLASS "com/freerdp/afreerdp/services/LibFreeRDP"
#define JAVA_LIBFREERDP_CLASS "com/freerdp/freerdpcore/services/LibFreeRDP"
#endif /* __ANDROID_FREERDP_JNI_H */

View File

@ -0,0 +1,125 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_freerdp_freerdpcore_services_LibFreeRDP */
#ifndef _Included_com_freerdp_freerdpcore_services_LibFreeRDP
#define _Included_com_freerdp_freerdpcore_services_LibFreeRDP
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_new
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1new
(JNIEnv *, jclass);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_free
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1free
(JNIEnv *, jclass, jint);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_connect
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1connect
(JNIEnv *, jclass, jint);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_disconnect
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1disconnect
(JNIEnv *, jclass, jint);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_cancel_connection
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1cancel_1connection
(JNIEnv *, jclass, jint);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_set_connection_info
* Signature: (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIZILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1connection_1info
(JNIEnv *, jclass, jint, jstring, jstring, jstring, jstring, jint, jint, jint, jint, jboolean, jint, jstring);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_set_performance_flags
* Signature: (IZZZZZZZ)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1performance_1flags
(JNIEnv *, jclass, jint, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_set_advanced_settings
* Signature: (ILjava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1advanced_1settings
(JNIEnv *, jclass, jint, jstring, jstring);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_set_data_directory
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory
(JNIEnv *, jclass, jint, jstring);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_update_graphics
* Signature: (ILandroid/graphics/Bitmap;IIII)Z
*/
JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1update_1graphics
(JNIEnv *, jclass, jint, jobject, jint, jint, jint, jint);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_send_cursor_event
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1cursor_1event
(JNIEnv *, jclass, jint, jint, jint, jint);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_send_key_event
* Signature: (IIZ)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1key_1event
(JNIEnv *, jclass, jint, jint, jboolean);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_send_unicodekey_event
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1unicodekey_1event
(JNIEnv *, jclass, jint, jint);
/*
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
* Method: freerdp_get_version
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1get_1version
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,15 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-8
android.library=true

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 301 B

After

Width:  |  Height:  |  Size: 301 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 707 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 237 B

View File

Before

Width:  |  Height:  |  Size: 892 B

After

Width:  |  Height:  |  Size: 892 B

View File

Before

Width:  |  Height:  |  Size: 572 B

After

Width:  |  Height:  |  Size: 572 B

View File

Before

Width:  |  Height:  |  Size: 930 B

After

Width:  |  Height:  |  Size: 930 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 293 B

Some files were not shown because too many files have changed in this diff Show More