summaryrefslogtreecommitdiff
path: root/recordmydesktop/src/opendev.c
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-29 05:49:07 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-01-29 05:49:07 +0000
commit46028c7ea0c7cd37d6c5e6c6196978afc950dce4 (patch)
tree94943bfa739d6611e17584383f84f72ec832b021 /recordmydesktop/src/opendev.c
parentc1a890715d4791b75b9512c1d9b02cb691c5de39 (diff)
Added support for compilation with OSS, instead of ALSA.
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@267 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src/opendev.c')
-rw-r--r--recordmydesktop/src/opendev.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/recordmydesktop/src/opendev.c b/recordmydesktop/src/opendev.c
index 5fc24f7..7810ec6 100644
--- a/recordmydesktop/src/opendev.c
+++ b/recordmydesktop/src/opendev.c
@@ -29,6 +29,7 @@
#include <recordmydesktop.h>
+#ifdef HAVE_LIBASOUND
snd_pcm_t *OpenDev( const char *pcm_dev,
unsigned int *channels,
@@ -114,4 +115,50 @@ snd_pcm_t *OpenDev( const char *pcm_dev,
return mhandle;
}
+#else
+int OpenDev( const char *pcm_dev,
+ unsigned int channels,
+ unsigned int frequency){
+ int fd ;
+ fd=open(pcm_dev,O_RDONLY);
+
+ if(fd!=-1){
+ unsigned int value;
+
+ if(ioctl(fd,SNDCTL_DSP_GETFMTS,&value)<0){
+ fprintf(stderr,"Couldn't get audio format list\n");
+ return -1;
+ }
+ if(value & AFMT_S16_LE){
+ value=AFMT_S16_LE;
+ }
+ else if(value & AFMT_S16_BE){
+ value=AFMT_S16_BE;
+ }
+ else{
+ fprintf(stderr,"Soundcard doesn't support signed 16-bit-data\n");
+ return -1;
+ }
+ if(ioctl(fd,SNDCTL_DSP_SETFMT,&value)<0){
+ fprintf(stderr,"Couldn't set audio format\n" );
+ return -1;
+ }
+ value = channels;
+ if(ioctl(fd,SNDCTL_DSP_CHANNELS,&value)<0){
+ fprintf(stderr,"Cannot set the number of channels\n" );
+ return -1;
+ }
+ value = frequency;
+ if(ioctl(fd,SNDCTL_DSP_SPEED,&value)<0){
+ fprintf(stderr,"Couldn't set audio frequency\n" );
+ return -1;
+ }
+ if(fcntl(fd,F_SETFL,fcntl(fd,F_GETFL) & ~O_NONBLOCK)<0){
+ fprintf(stderr,"Couldn't set audio blocking mode\n" );
+ return -1;
+ }
+ }
+ return fd;
+}
+#endif
© All Rights Reserved