diff options
author | jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8> | 2006-10-18 15:54:57 (GMT) |
---|---|---|
committer | jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8> | 2006-10-18 15:54:57 (GMT) |
commit | 7bd31f117f311eb966beab75ff469df4cb58fdca (patch) | |
tree | 623207a54b8a0d6e65781e29d4138a8016e06490 | |
parent | 32d692890c5a3dd1ac61ce52ba59b03e7c6c3b1c (diff) |
some minor tweaks
git-svn-id: svn://dyne.org/montevideo/ivysync@74 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r-- | branches/lydia/cmdline.cpp | 17 | ||||
-rw-r--r-- | branches/lydia/sound_device.cpp | 48 |
2 files changed, 38 insertions, 27 deletions
diff --git a/branches/lydia/cmdline.cpp b/branches/lydia/cmdline.cpp index b76166a..a0197ec 100644 --- a/branches/lydia/cmdline.cpp +++ b/branches/lydia/cmdline.cpp @@ -34,6 +34,7 @@ #include <decoder.h> +#include <sound_device.h> #include <xmlrpc.h> #include <gui.h> @@ -51,13 +52,16 @@ int videobuf = 64; Linklist decoders; // graphical interface -Gui *gui; +Gui *gui = NULL; // xmlrpc interface -XmlRpcServer *xmlrpc; +XmlRpcServer *xmlrpc = NULL; + +// sound device +SoundDevice *snd = NULL; // Threaded daemon -IvySyncDaemon *ivydaemon; +IvySyncDaemon *ivydaemon = NULL; char *help = "Usage: ivysync [-hsDgt] [ -d /dev/video16 [ -p playmode files ] ]\n" @@ -340,6 +344,12 @@ int main(int argc, char **argv) { //////////////////////////////// + //////////////////////////////// + /// Sound device + snd = new SoundDevice(); + // open only for playback + snd->open(false, true); + //////////////////////////////// //////////////////////////////// @@ -406,5 +416,6 @@ int main(int argc, char **argv) { N("quit!"); + exit(1); } diff --git a/branches/lydia/sound_device.cpp b/branches/lydia/sound_device.cpp index b3373ca..76ee5a4 100644 --- a/branches/lydia/sound_device.cpp +++ b/branches/lydia/sound_device.cpp @@ -64,16 +64,16 @@ static int pa_process( void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTimestamp outTime, void *userData ) { -int i,n; -void *rBuf; -int readBytes; -PaDevices *dev = (PaDevices *)userData; -long len = framesPerBuffer * (PA_SAMPLES_PER_FRAME*sizeof(PA_SAMPLE_TYPE)); + unsigned int i,n; + void *rBuf; + int readBytes; + PaDevices *dev = (PaDevices *)userData; + long len = framesPerBuffer * (PA_SAMPLES_PER_FRAME*sizeof(PA_SAMPLE_TYPE)); if(inputBuffer != NULL) { /* handle input from soundcard */ - if(dev->input->info) { + if(dev->input->info) { if(dev->input->info->maxInputChannels>1) { readBytes = dev->input->pipe->write(len,inputBuffer); - } + } else { rBuf = malloc(len); n=0; @@ -85,26 +85,26 @@ long len = framesPerBuffer * (PA_SAMPLES_PER_FRAME*sizeof(PA_SAMPLE_TYPE)); readBytes = dev->input->pipe->write(len,rBuf); free(rBuf); } - if(readBytes <= 0) memset(inputBuffer,0,len); - } + if(readBytes <= 0) memset(inputBuffer,0,len); + } } if(outputBuffer != NULL) { /* handle output to soundcard */ - if(dev->output->info) { - if(dev->output->info->maxOutputChannels>1) { - readBytes = dev->output->pipe->read(len,outputBuffer); - } + if(dev->output->info) { + if(dev->output->info->maxOutputChannels>1) { + readBytes = dev->output->pipe->read(len,outputBuffer); + } else { - rBuf = malloc(len); - readBytes = dev->output->pipe->read(len,rBuf); - n=0; - for(i=0;i<(len/sizeof(PA_SAMPLE_TYPE))/2;i++) { - ((float *)outputBuffer)[n]=((float *)rBuf)[i]; - ((float *)outputBuffer)[n+1]=((float *)rBuf)[i]; - n+=2; - } - free(rBuf); - } - if(readBytes <= 0) memset(outputBuffer,0,len); + rBuf = malloc(len); + readBytes = dev->output->pipe->read(len,rBuf); + n=0; + for(i=0; i < (len / sizeof(PA_SAMPLE_TYPE)) /2 ;i++) { + ((float *)outputBuffer)[n]=((float *)rBuf)[i]; + ((float *)outputBuffer)[n+1]=((float *)rBuf)[i]; + n+=2; + } + free(rBuf); + } + if(readBytes <= 0) memset(outputBuffer,0,len); } } return 0; |