summaryrefslogtreecommitdiff
path: root/recordmydesktop/src/opendev.c
diff options
context:
space:
mode:
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