diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-02-02 04:03:15 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-02-02 04:03:15 +0000 |
commit | f39f779f299cd78a574999830699e30f92932f06 (patch) | |
tree | 3067da4b46b19289bac809fea3c3654e0e50bf2d /recordmydesktop/src | |
parent | a7d618cbe67d2c084c80e31a5df21f4fb7221a76 (diff) |
changed OSS buffer scheme, to work with frames(like ALSA) and reduce ifdefs
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@272 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/cache_audio.c | 9 | ||||
-rw-r--r-- | recordmydesktop/src/capture_sound.c | 9 | ||||
-rw-r--r-- | recordmydesktop/src/encode_sound_buffer.c | 11 | ||||
-rw-r--r-- | recordmydesktop/src/initialize_data.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/load_cache.c | 9 |
5 files changed, 15 insertions, 25 deletions
diff --git a/recordmydesktop/src/cache_audio.c b/recordmydesktop/src/cache_audio.c index edcabb3..bff4df2 100644 --- a/recordmydesktop/src/cache_audio.c +++ b/recordmydesktop/src/cache_audio.c @@ -33,6 +33,8 @@ void *CacheSoundBuffer(ProgData *pdata){ #ifdef HAVE_LIBASOUND int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)* pdata->args.channels; +#else + int framesize=pdata->args.channels<<1;//Always signed 16 bit data #endif while((pdata->running)){ SndBuffer *buff; @@ -58,15 +60,8 @@ void *CacheSoundBuffer(ProgData *pdata){ //advance the list pdata->sound_buffer=pdata->sound_buffer->next; pthread_mutex_unlock(&pdata->sound_buffer_mutex); -#ifdef HAVE_LIBASOUND fwrite(buff->data,1,pdata->periodsize*framesize, pdata->cache_data->afp); -#else - fwrite(buff->data,1,pdata->args.buffsize, - pdata->cache_data->afp); -#endif - - pdata->avd-=pdata->periodtime; free(buff->data); diff --git a/recordmydesktop/src/capture_sound.c b/recordmydesktop/src/capture_sound.c index 4314984..3b69764 100644 --- a/recordmydesktop/src/capture_sound.c +++ b/recordmydesktop/src/capture_sound.c @@ -94,7 +94,8 @@ void *CaptureSound(ProgData *pdata){ #ifdef HAVE_LIBASOUND newbuf->data=(signed char *)malloc(frames*framesize); #else - newbuf->data=(signed char *)malloc(pdata->args.buffsize); + newbuf->data=(signed char *)malloc(((pdata->args.buffsize<<1)* + pdata->args.channels)); #endif newbuf->next=NULL; @@ -124,7 +125,8 @@ void *CaptureSound(ProgData *pdata){ do{ int temp_sret=read(pdata->sound_handle, &newbuf->data[sret], - pdata->args.buffsize-sret); + ((pdata->args.buffsize<<1)* + pdata->args.channels)-sret); if(temp_sret<0){ fprintf(stderr,"An error occured while reading from soundcard" "%s\n" @@ -133,7 +135,8 @@ void *CaptureSound(ProgData *pdata){ } else sret+=temp_sret; - }while(sret<pdata->args.buffsize); + }while(sret<((pdata->args.buffsize<<1)* + pdata->args.channels)); #endif //queue the new buffer pthread_mutex_lock(&pdata->sound_buffer_mutex); diff --git a/recordmydesktop/src/encode_sound_buffer.c b/recordmydesktop/src/encode_sound_buffer.c index 0e8fa2c..c8a8781 100644 --- a/recordmydesktop/src/encode_sound_buffer.c +++ b/recordmydesktop/src/encode_sound_buffer.c @@ -28,11 +28,8 @@ #include <recordmydesktop.h> void *EncodeSoundBuffer(ProgData *pdata){ -#ifdef HAVE_LIBASOUND int sampread=pdata->periodsize; -#else - int sampread=(pdata->args.buffsize>>1)/pdata->args.channels; -#endif + pdata->v_encoding_clean=0; while((pdata->running)){ float **vorbis_buffer; @@ -103,12 +100,8 @@ void *EncodeSoundBuffer(ProgData *pdata){ void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff){ float **vorbis_buffer; int count=0,i,j; -#ifdef HAVE_LIBASOUND int sampread=(buff!=NULL)?pdata->periodsize:0; -#else - int sampread=(buff!=NULL)?((pdata->args.buffsize>>1)/ - pdata->args.channels):0; -#endif + vorbis_buffer=vorbis_analysis_buffer(&pdata->enc_data->m_vo_dsp,sampread); for(i=0;i<sampread;i++){ for(j=0;j<pdata->args.channels;j++){ diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c index 4df3a6f..d8f52c0 100644 --- a/recordmydesktop/src/initialize_data.c +++ b/recordmydesktop/src/initialize_data.c @@ -139,6 +139,8 @@ int InitializeData(ProgData *pdata, pdata->args.frequency); pdata->periodtime=(1000000*pdata->args.buffsize)/ ((pdata->args.channels<<1)*pdata->args.frequency); + //when using OSS periodsize serves as an alias of buffsize + pdata->periodsize=pdata->args.buffsize; if(pdata->sound_handle<0){ #endif fprintf(stderr,"Error while opening/configuring soundcard %s\n" diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c index 00ddf96..f75c375 100644 --- a/recordmydesktop/src/load_cache.c +++ b/recordmydesktop/src/load_cache.c @@ -135,10 +135,11 @@ void *LoadCache(ProgData *pdata){ #ifdef HAVE_LIBASOUND int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)* pdata->args.channels;//audio frame size - signed char *sound_data=(signed char *)malloc(pdata->periodsize*framesize); #else - signed char *sound_data=(signed char *)malloc(pdata->args.buffsize); + int framesize=pdata->args.channels<<1;//Always signed 16 bit data #endif + signed char *sound_data=(signed char *)malloc(pdata->periodsize*framesize); + u_int32_t YBlocks[(yuv->y_width*yuv->y_height)/Y_UNIT_BYTES], UBlocks[(yuv->uv_width*yuv->uv_height)/UV_UNIT_BYTES], VBlocks[(yuv->uv_width*yuv->uv_height)/UV_UNIT_BYTES]; @@ -254,11 +255,7 @@ void *LoadCache(ProgData *pdata){ //audio load and encoding else{ if(!audio_end){ -#ifdef HAVE_LIBASOUND int nbytes=fread(sound_data,1,pdata->periodsize*framesize,afp); -#else - int nbytes=fread(sound_data,1,pdata->args.buffsize,afp); -#endif if(nbytes<=0) audio_end=1; else |