Author: nyadav Date: Fri May 27 21:11:53 2011 New Revision: 51964
URL: http://svn.reactos.org/svn/reactos?rev=51964&view=rev Log: [AUDSRV] Add Playback of virtual buffer on virtual server to audio client
Modified: branches/nyadav-audio-branch/base/services/audsrv/audsrv.h branches/nyadav-audio-branch/dll/win32/audsrvapi/CMakeLists.txt branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.c branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.h branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.spec branches/nyadav-audio-branch/drivers/wdm/audio/backpln/audclient/audclient.c branches/nyadav-audio-branch/include/reactos/libs/audsrv/audsrvapi.h
Modified: branches/nyadav-audio-branch/base/services/audsrv/audsrv.h URL: http://svn.reactos.org/svn/reactos/branches/nyadav-audio-branch/base/service... ============================================================================== --- branches/nyadav-audio-branch/base/services/audsrv/audsrv.h [iso-8859-1] (original) +++ branches/nyadav-audio-branch/base/services/audsrv/audsrv.h [iso-8859-1] Fri May 27 21:11:53 2011 @@ -27,7 +27,7 @@ #include "audsrvrpc_s.h"
-typedef struct PortStream +typedef struct ServerStream { int volume; LONG freq; @@ -35,8 +35,9 @@ int channels; ULONG channelmask; HANDLE thread; - struct PortStream * next; -} PortStream; + float balance; + struct ServerStream * next; +} ServerStream;
typedef struct MixerEngine { @@ -60,6 +61,7 @@ HANDLE PinHandle; PKSPROPERTY Property; PKSSTREAM_HEADER Packet; + ServerStream * serverstreamlist; } MixerEngine;
extern MixerEngine engine;
Modified: branches/nyadav-audio-branch/dll/win32/audsrvapi/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/nyadav-audio-branch/dll/win32/au... ============================================================================== --- branches/nyadav-audio-branch/dll/win32/audsrvapi/CMakeLists.txt [iso-8859-1] (original) +++ branches/nyadav-audio-branch/dll/win32/audsrvapi/CMakeLists.txt [iso-8859-1] Fri May 27 21:11:53 2011 @@ -1,5 +1,5 @@ include_directories(${REACTOS_BINARY_DIR}/include/reactos/idl) -include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs/audsrv) +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs)
spec2def(audsrvapi.dll audsrvapi.spec)
Modified: branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.c URL: http://svn.reactos.org/svn/reactos/branches/nyadav-audio-branch/dll/win32/au... ============================================================================== --- branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.c [iso-8859-1] (original) +++ branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.c [iso-8859-1] Fri May 27 21:11:53 2011 @@ -1,1 +1,70 @@ -#include "audsrvapi.h" +#include "audsrvapi.h" + +/*All the wrappers for Remote Function should be here*/ +int status = 0; /*There can be any structure which can hold the connection status*/ +/*Every Function should ensure connection*/ + +/*Initialize an audio stream + *Return -1 if callbacks are NULL pointers + */ +WINAPI int initstream (ClientStream * clientstream,LONG frequency,int channels,int bitspersample, ULONG channelmask,int volume,int mute,float balance) +{ + if(clientstream == NULL ) return -1; + if (clientstream->callbacks.OpenComplete == NULL || clientstream->callbacks.BufferCopied == NULL || clientstream->callbacks.PlayComplete == NULL) return -2; + /*Validity of all other data will be checked at server*/ + /*Check Connection Status If not connected call Connect()*/ + /*If connected Properly call the remote audsrv_initstream() function*/ + /*Analyse the return by the function*/ + /*Currently Suppose the return is 0 and a valid streamid is returned*/ + clientstream->stream = &status; + + clientstream->ClientEventPool[0]=CreateEvent(NULL,FALSE,FALSE,NULL); + clientstream->dead = 0; + + return 0; +} + +WINAPI int playaudio ( ClientStream * clientstream) +{ + /*This is an ActiveScheduler*/ + clientstream->callbacks.OpenComplete(0); + while(1) + { + while(WaitForSingleObject(clientstream->ClientEventPool[0],100)!=0){if(clientstream->dead)goto DEAD;} + /*Check Connection Status If not connected call Connect()*/ + /*If connected Properly call the remote audsrv_play() function,This will be a blocking call, placing a dummy wait function here is a good idea.*/ + Sleep(1000); + printf("Played a virtual buffer on Virtual Audio Server :) %d\n",clientstream->dead); + clientstream->callbacks.BufferCopied(0); + } + clientstream->callbacks.PlayComplete(0); + +DEAD: +printf("\nAudio Thread Ended\n"); + + return 0; +} +WINAPI int stopaudio (ClientStream * clientstream ) +{ + /*Server Side termination is remaining*/ + /*Check Connection Status If not connected call Connect()*/ + /*If connected Properly call the remote audsrv_stop() function*/ + clientstream->dead = 1; /*Client Side termination*/ +} +WINAPI int Volume(ClientStream * clientstream, int * volume ) +{ +} +WINAPI int SetVolume(ClientStream * clientstream ,const int newvolume) +{ +} +WINAPI int Write(ClientStream * clientstream ,const char * aData) +{ + if(clientstream->dead) return -1; + SetEvent(clientstream->ClientEventPool[0]); +} +WINAPI int SetBalance(ClientStream * clientstream ,float balance) +{ +} +WINAPI int GetBalance(ClientStream * clientstream ,float * balance) +{ +}
Modified: branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.h URL: http://svn.reactos.org/svn/reactos/branches/nyadav-audio-branch/dll/win32/au... ============================================================================== --- branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.h [iso-8859-1] (original) +++ branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.h [iso-8859-1] Fri May 27 21:11:53 2011 @@ -1,2 +1,2 @@ #include "audsrvrpc_c.h" -#include <audsrvapi.h> +#include <audsrv/audsrvapi.h>
Modified: branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.spec URL: http://svn.reactos.org/svn/reactos/branches/nyadav-audio-branch/dll/win32/au... ============================================================================== --- branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.spec [iso-8859-1] (original) +++ branches/nyadav-audio-branch/dll/win32/audsrvapi/audsrvapi.spec [iso-8859-1] Fri May 27 21:11:53 2011 @@ -1,0 +1,8 @@ +@ stdcall initstream (ptr long long long long long long long) +@ stdcall playaudio ( ptr); +@ stdcall stopaudio (ptr ); +@ stdcall Volume(ptr ptr ); +@ stdcall SetVolume(ptr long); +@ stdcall Write(ptr ptr); +@ stdcall SetBalance(ptr long); +@ stdcall GetBalance(ptr ptr);
Modified: branches/nyadav-audio-branch/drivers/wdm/audio/backpln/audclient/audclient.c URL: http://svn.reactos.org/svn/reactos/branches/nyadav-audio-branch/drivers/wdm/... ============================================================================== --- branches/nyadav-audio-branch/drivers/wdm/audio/backpln/audclient/audclient.c [iso-8859-1] (original) +++ branches/nyadav-audio-branch/drivers/wdm/audio/backpln/audclient/audclient.c [iso-8859-1] Fri May 27 21:11:53 2011 @@ -3,10 +3,54 @@
#include <audsrvapi.h> #include <stdio.h> + +void opencomplete (int error ); +void buffercopied (int error ); +void playcomplete (int error ); + +ClientStream clientstream = {NULL,0,{NULL},{opencomplete,buffercopied,playcomplete}};/*This initialization should not be necessary for a typical client*/ + +DWORD WINAPI RunAudioThread(LPVOID param) +{ + ClientStream * localstream = (ClientStream *) param; + printf("Starting Audio Thread \n"); + playaudio(localstream); +} +void opencomplete (int error ) +{ + /*Copy First Buffer and write*/ + Write(&clientstream,"HELLO_RANDOM_STRING"); +} +void buffercopied (int error ) +{ + Write(&clientstream,"HELLO_RANDOM_STRING"); +} +void playcomplete (int error ) +{ + printf("Play Complete Code %d\n",error); +} int __cdecl wmain(int argc, char* argv[]) { - printf("ReactOS Audio Mixer Sample Client.\n"); + int error; + DWORD dwID; + HANDLE audiothread; + char input='\0'; + printf("ReactOS Audio Mixer Sample Client.Enter 'a' to Stop.\n"); + //if (clientstream->callbacks.OpenComplete == NULL || clientstream->callbacks.BufferCopied == NULL || clientstream->callbacks.PlayComplete == NULL) printf(""); + error = initstream ( &clientstream , 44100 , 2 , 16 , KSAUDIO_SPEAKER_STEREO , 1000 , 0, 0.0 ); /*[out]HANDLE * streamhandle,[in] long frequency,[in] int number of channels,[in] int bitspersample,[in]ULONG channelmask,[in] int volume,[in] int mute,[in] float balance*/ + if ( error ) + printf("Failed to Initialize Stream.Error %d\n", error); + else + { + printf("StreamID : %d\n",*((int *)clientstream.stream)); + audiothread = CreateThread(NULL,0,RunAudioThread,&clientstream,0,&dwID); + } + while ( input != 'a' ) + scanf("%c",&input); + printf("Stoping Audio Stream.\n"); + stopaudio(&clientstream); + WaitForSingleObject(audiothread,INFINITE); return 0; -} +}
Modified: branches/nyadav-audio-branch/include/reactos/libs/audsrv/audsrvapi.h URL: http://svn.reactos.org/svn/reactos/branches/nyadav-audio-branch/include/reac... ============================================================================== --- branches/nyadav-audio-branch/include/reactos/libs/audsrv/audsrvapi.h [iso-8859-1] (original) +++ branches/nyadav-audio-branch/include/reactos/libs/audsrv/audsrvapi.h [iso-8859-1] Fri May 27 21:11:53 2011 @@ -1,5 +1,34 @@ -#ifndef _PORTINTERFACE_H -#define _PORTINTERFACE_H +#ifndef _AUDSRVAPI_H +#define _AUDSRVAPI_H
+#include <windows.h> +#include <ks.h> +#include <ksmedia.h> +#include <stdio.h>
+/********************Structures*********************/ +typedef struct CallBacks +{ + void (*OpenComplete) (int error ); + void (*BufferCopied) (int error ); + void (*PlayComplete) (int error ); +} CallBacks; + +typedef struct ClientStream +{ +HANDLE stream; +int dead; +HANDLE ClientEventPool[1]; /*[0]th event is for Activescheduler*/ +struct CallBacks callbacks; +} ClientStream; + +/********************API Functions******************/ +WINAPI int initstream (ClientStream * clientstream,LONG frequency,int channels,int bitspersample, ULONG channelmask,int volume,int mute,float balance); +WINAPI int playaudio ( ClientStream * clientstream); +WINAPI int stopaudio (ClientStream * clientstream ); +WINAPI int Volume(ClientStream * clientstream, int * volume ); +WINAPI int SetVolume(ClientStream * clientstream ,const int newvolume); +WINAPI int Write(ClientStream * clientstream ,const char * aData); +WINAPI int SetBalance(ClientStream * clientstream ,float balance); +WINAPI int GetBalance(ClientStream * clientstream ,float * balance); #endif