This commit is contained in:
C-o-r-E 2013-02-19 15:06:56 -05:00
commit 43f2ab1c5c
7 changed files with 56 additions and 37 deletions

View File

@ -40,6 +40,7 @@
#cmakedefine WITH_NATIVE_SSPI
#cmakedefine WITH_JPEG
#cmakedefine WITH_WIN8
#cmakedefine WITH_RDPSND_DSOUND
/* Plugins */
#cmakedefine STATIC_CHANNELS

View File

@ -33,16 +33,30 @@ set(${MODULE_PREFIX}_SRCS
wf_mirage.h
wf_peer.c
wf_peer.h
wf_rdpsnd.c
wf_rdpsnd.h
wf_directsound.c
wf_directsound.h
wf_wasapi.c
wf_wasapi.h
wf_settings.c
wf_settings.h
wf_info.c
wf_info.h)
if(CHANNEL_RDPSND AND NOT WITH_RDPSND_DSOUND)
set(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_SRCS}
wf_rdpsnd.c
wf_rdpsnd.h
wf_wasapi.c
wf_wasapi.h
)
endif()
if(CHANNEL_RDPSND AND WITH_RDPSND_DSOUND)
set(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_SRCS}
wf_rdpsnd.c
wf_rdpsnd.h
wf_directsound.c
wf_directsound.h
)
endif()
if(WITH_SERVER_INTERFACE)
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})

View File

@ -20,7 +20,7 @@ DSCBUFFERDESC dscbd;
DWORD lastPos;
wfPeerContext* latestPeer;
int wf_directsound_set_latest_peer(wfPeerContext* peer)
int wf_rdpsnd_set_latest_peer(wfPeerContext* peer)
{
latestPeer = peer;
return 0;

View File

@ -4,7 +4,7 @@
#include <freerdp/server/rdpsnd.h>
#include "wf_interface.h"
int wf_directsound_set_latest_peer(wfPeerContext* peer);
int wf_rdpsnd_set_latest_peer(wfPeerContext* peer);
int wf_directsound_activate(rdpsnd_server_context* context);

View File

@ -27,28 +27,19 @@
#include <winpr/windows.h>
#define INITGUID
#include <initguid.h>
#include <objbase.h>
#define CINTERFACE
#include <mmsystem.h>
#include <dsound.h>
#include <freerdp/server/rdpsnd.h>
#include "wf_rdpsnd.h"
#include "wf_directsound.h"
#include "wf_wasapi.h"
#include "wf_info.h"
#ifdef WITH_RDPSND_DSOUND
#include "wf_directsound.h"
#else
//#define BYTESPERSEC 176400
#include "wf_wasapi.h"
#endif
//FIXME support multiple clients
//wfPeerContext* latestPeer;
static const rdpsndFormat test_audio_formats[] =
{
@ -66,9 +57,16 @@ static const rdpsndFormat test_audio_formats[] =
static void wf_peer_rdpsnd_activated(rdpsnd_server_context* context)
{
#ifdef WITH_RDPSND_DSOUND
wf_directsound_activate(context);
#else
//wf_directsound_activate(context);
wf_wasapi_activate(context);
#endif
}
int wf_rdpsnd_lock()
@ -138,7 +136,7 @@ BOOL wf_peer_rdpsnd_init(wfPeerContext* context)
context->rdpsnd->Initialize(context->rdpsnd);
wf_directsound_set_latest_peer(context);
wf_rdpsnd_set_latest_peer(context);
wfi->snd_stop = FALSE;
return TRUE;

View File

@ -7,8 +7,15 @@
#include <Functiondiscoverykeys_devpkey.h>
#include <Audioclient.h>
#define REFTIMES_PER_SEC 10000000
#define REFTIMES_PER_MILLISEC 10000
//#define REFTIMES_PER_SEC 10000000
//#define REFTIMES_PER_MILLISEC 10000
#define REFTIMES_PER_SEC 100000
#define REFTIMES_PER_MILLISEC 100
//#define REFTIMES_PER_SEC 50000
//#define REFTIMES_PER_MILLISEC 50
DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C,
0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E);
@ -20,12 +27,13 @@ DEFINE_GUID(IID_IAudioCaptureClient, 0xc8adbd64, 0xe71e, 0x48a0, 0xa4,0xde, 0x18
LPWSTR devStr = NULL;
wfPeerContext* latestPeer = NULL;
int wf_wasapi_set_latest_peer(wfPeerContext* peer)
int wf_rdpsnd_set_latest_peer(wfPeerContext* peer)
{
latestPeer = peer;
return 0;
}
int wf_wasapi_activate(rdpsnd_server_context* context)
{
wchar_t * pattern = L"Stereo Mix";
@ -119,8 +127,6 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR * deviceStr)
exit(1);
}
//do this a more reliable way
if (wcscmp(pattern, nameVar.pwszVal) < 0)
{
@ -246,7 +252,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
}
hnsActualDuration = (double)REFTIMES_PER_SEC * bufferFrameCount / pwfx->nSamplesPerSec;
hnsActualDuration = (UINT32)REFTIMES_PER_SEC * bufferFrameCount / pwfx->nSamplesPerSec;
hr = pAudioClient->lpVtbl->Start(pAudioClient);
if (FAILED(hr))
@ -262,7 +268,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
Sleep(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
hr = pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength);
if (FAILED(hr))
{
@ -279,9 +285,10 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
exit(1);
}
//write data here
//fwrite(pData, 1, packetLength * 4, pFile);
context->rdpsnd->SendSamples(context->rdpsnd, pData, packetLength);
//Here we are writing the audio data
//not sure if this flag is ever set by the system; msdn is not clear about it
if (!(flags & AUDCLNT_BUFFERFLAGS_SILENT))
context->rdpsnd->SendSamples(context->rdpsnd, pData, packetLength);
hr = pCaptureClient->lpVtbl->ReleaseBuffer(pCaptureClient, numFramesAvailable);
if (FAILED(hr))

View File

@ -4,8 +4,7 @@
#include <freerdp/server/rdpsnd.h>
#include "wf_interface.h"
//TODO: fix how this is handled
int wf_wasapi_set_latest_peer(wfPeerContext* peer);
int wf_rdpsnd_set_latest_peer(wfPeerContext* peer);
int wf_wasapi_activate(rdpsnd_server_context* context);