From: <st...@us...> - 2003-07-10 15:03:50
|
Update of /cvsroot/iaxclient/iaxclient/lib In directory sc8-pr-cvs1:/tmp/cvs-serv30429/lib Modified Files: audio_portaudio.c iaxclient.h iaxclient_lib.c iaxclient_lib.h Log Message: Add APIs for getting audio device info, and selecting devices. Index: audio_portaudio.c =================================================================== RCS file: /cvsroot/iaxclient/iaxclient/lib/audio_portaudio.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- audio_portaudio.c 10 Jul 2003 14:19:53 -0000 1.13 +++ audio_portaudio.c 10 Jul 2003 15:03:46 -0000 1.14 @@ -23,7 +23,7 @@ static PortAudioStream *iStream, *oStream; -static selectedInput, selectedOutput; +static selectedInput, selectedOutput, selectedRing; #define FRAMES_PER_BUFFER 80 /* 80 frames == 10ms */ @@ -316,20 +316,22 @@ return 0; } -int pa_select_input (struct iaxc_audio_driver *d, int input) { +int pa_select_devices (struct iaxc_audio_driver *d, int input, int output, int ring) { selectedInput = input; + selectedOutput = output; + selectedRing = ring; if(running) { pa_stop(d); pa_start(d); } + return 0; } -int pa_select_output (struct iaxc_audio_driver *d, int output) { - selectedOutput = output; - if(running) { - pa_stop(d); - pa_start(d); - } +int pa_selected_devices (struct iaxc_audio_driver *d, int *input, int *output, int *ring) { + *input = selectedInput; + *output = selectedOutput; + *ring = selectedRing; + return 0; } int pa_destroy (struct iaxc_audio_driver *d ) { @@ -351,8 +353,8 @@ /* setup methods */ d->initialize = pa_initialize; d->destroy = pa_destroy; - d->select_input = pa_select_input; - d->select_output = pa_select_output; + d->select_devices = pa_select_devices; + d->selected_devices = pa_selected_devices; d->start = pa_start; d->stop = pa_stop; d->output = pa_output; @@ -361,6 +363,7 @@ /* setup private data stuff */ selectedInput = Pa_GetDefaultInputDeviceID(); selectedOutput = Pa_GetDefaultOutputDeviceID(); + selectedRing = Pa_GetDefaultOutputDeviceID(); RingBuffer_Init(&inRing, RBSZ, inRingBuf); RingBuffer_Init(&outRing, RBSZ, outRingBuf); Index: iaxclient.h =================================================================== RCS file: /cvsroot/iaxclient/iaxclient/lib/iaxclient.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- iaxclient.h 19 Jun 2003 19:09:52 -0000 1.14 +++ iaxclient.h 10 Jul 2003 15:03:46 -0000 1.15 @@ -110,6 +110,21 @@ void iaxc_set_audio_output(int mode); int iaxc_select_call(int callNo); +#define IAXC_AD_INPUT (1<<0) +#define IAXC_AD_OUTPUT (1<<1) +#define IAXC_AD_INPUT_DEFAULT (1<<2) +#define IAXC_AD_OUTPUT_DEFAULT (1<<3) + +struct iaxc_audio_device { + char *name; /* name of the device */ + long capabilities; /* flags, defined above */ + int devID; /* driver-specific ID */ +}; + +int iaxc_audio_devices_get(struct iaxc_audio_device **devs, int *nDevs, int *input, int *output, int *ring); +int iaxc_audio_devices_set(int input, int output, int ring); + + #ifdef __cplusplus } #endif Index: iaxclient_lib.c =================================================================== RCS file: /cvsroot/iaxclient/iaxclient/lib/iaxclient_lib.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- iaxclient_lib.c 10 Jul 2003 14:19:53 -0000 1.30 +++ iaxclient_lib.c 10 Jul 2003 15:03:46 -0000 1.31 @@ -770,3 +770,15 @@ // To be coded in the future return; } + +int iaxc_audio_devices_get(struct iaxc_audio_device **devs, int *nDevs, int *input, int *output, int *ring) { + *devs = audio.devices; + *nDevs = audio.nDevices; + audio.selected_devices(&audio,input,output,ring); + return 0; +} + +int iaxc_audio_devices_set(int input, int output, int ring) { + return audio.select_devices(&audio, input, output, ring); +} + Index: iaxclient_lib.h =================================================================== RCS file: /cvsroot/iaxclient/iaxclient/lib/iaxclient_lib.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- iaxclient_lib.h 10 Jul 2003 14:19:53 -0000 1.19 +++ iaxclient_lib.h 10 Jul 2003 15:03:46 -0000 1.20 @@ -74,17 +74,7 @@ void iaxc_service_network(int netfd); void iaxc_do_levels_callback(float input, float output); - -#define IAXC_AD_INPUT (1<<0) -#define IAXC_AD_OUTPUT (1<<1) -#define IAXC_AD_INPUT_DEFAULT (1<<2) -#define IAXC_AD_OUTPUT_DEFAULT (1<<3) - -struct iaxc_audio_device { - char *name; /* name of the device */ - long capabilities; /* flags, defined above */ - int devID; /* driver-specific ID */ -}; +#include "iaxclient.h" struct iaxc_audio_driver { /* data */ @@ -96,8 +86,8 @@ /* methods */ int (*initialize)(struct iaxc_audio_driver *d); int (*destroy)(struct iaxc_audio_driver *d); /* free resources */ - int (*select_input)(struct iaxc_audio_driver *d, int devID); - int (*select_output)(struct iaxc_audio_driver *d, int devID); + int (*select_devices)(struct iaxc_audio_driver *d, int input, int output, int ring); + int (*selected_devices)(struct iaxc_audio_driver *d, int *input, int *output, int *ring); /* * select_ring ? @@ -114,7 +104,6 @@ -#include "iaxclient.h" struct iaxc_call { |