diff options
Diffstat (limited to 'recordmydesktop')
-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; |