diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-12-09 13:25:18 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-12-09 13:25:18 +0000 |
commit | 5cc91a08f6313e0b758063b7dfd31244d43eb9a0 (patch) | |
tree | 32984f973b7698406f34530dc389d85a223442cc /recordmydesktop/src | |
parent | 2d2449959edc3b6dfef3b43980fcd10c202455e4 (diff) |
minor corrections in sound handling
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@225 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/capture_sound.c | 12 | ||||
-rw-r--r-- | recordmydesktop/src/opendev.c | 4 |
2 files changed, 9 insertions, 7 deletions
diff --git a/recordmydesktop/src/capture_sound.c b/recordmydesktop/src/capture_sound.c index 702d325..159ccd3 100644 --- a/recordmydesktop/src/capture_sound.c +++ b/recordmydesktop/src/capture_sound.c @@ -29,8 +29,8 @@ void *CaptureSound(ProgData *pdata){ - int frames=pdata->periodsize>>pdata->args.channels; -// fprintf(stderr,"fr %d ps %d\n",frames,pdata->periodsize);fflush(stderr); + int frames=pdata->periodsize; + int framesize=snd_pcm_format_width(SND_PCM_FORMAT_S16_LE)*pdata->args.channels; pthread_mutex_t pmut; pthread_mutex_init(&pmut,NULL); @@ -66,16 +66,18 @@ void *CaptureSound(ProgData *pdata){ //create new buffer newbuf=(SndBuffer *)malloc(sizeof(SndBuffer *)); - newbuf->data=(signed char *)malloc(pdata->periodsize); + newbuf->data=(signed char *)malloc(frames*framesize); newbuf->next=NULL; //read data into new buffer while(sret<frames){ int temp_sret=snd_pcm_readi(pdata->sound_handle, - newbuf->data+2*pdata->args.channels*sret, + newbuf->data+framesize*sret, frames-sret); - if(temp_sret==-EPIPE) + if(temp_sret==-EPIPE){ + fprintf(stderr,"An error occured while reading sound data:\n %s\n",snd_strerror(temp_sret)); snd_pcm_prepare(pdata->sound_handle); + } else if (temp_sret<0){ fprintf(stderr,"An error occured while reading sound data:\n %s\n",snd_strerror(temp_sret)); snd_pcm_prepare(pdata->sound_handle); diff --git a/recordmydesktop/src/opendev.c b/recordmydesktop/src/opendev.c index 7eb5d2b..9250bab 100644 --- a/recordmydesktop/src/opendev.c +++ b/recordmydesktop/src/opendev.c @@ -31,7 +31,7 @@ snd_pcm_t *OpenDev(const char *pcm_dev,unsigned int *channels,unsigned int *frequency,snd_pcm_uframes_t *periodsize,unsigned int *periodtime,int *hard_pause){ - + snd_pcm_t *mhandle; snd_pcm_hw_params_t *hwparams; unsigned int periods=2; @@ -76,7 +76,7 @@ snd_pcm_t *OpenDev(const char *pcm_dev,unsigned int *channels,unsigned int *freq fprintf(stderr, "Couldn't set periods.\n"); return NULL; } - buffsize=(exactrate*(*channels))/2; + buffsize=(exactrate)>>2; if (snd_pcm_hw_params_set_buffer_size_near(mhandle, hwparams,&buffsize)<0){ fprintf(stderr, "Couldn't set buffer size.\n"); return NULL; |