From 1c9ee7257e9ea793b679b34fa4b1d6426042e974 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 6 Jul 2003 12:01:06 +0000 Subject: [PATCH 1/1] initial checkin --- Makefile | 16 ++++++ hdrec | Bin 0 -> 9485 bytes hdrec.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ hdrec.h | 12 +++++ oss_api.c | 117 ++++++++++++++++++++++++++++++++++++++++ oss_api.h | 27 ++++++++++ oss_api.o | Bin 0 -> 2716 bytes 7 files changed, 330 insertions(+) create mode 100644 Makefile create mode 100755 hdrec create mode 100644 hdrec.c create mode 100644 hdrec.h create mode 100644 oss_api.c create mode 100644 oss_api.h create mode 100644 oss_api.o diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6bd5fd0 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +# Makefile of hdrec + +CFLAGS = -O3 -Wall +CC = gcc + +TARGETS = hdrec + +all: $(TARGETS) + +hdrec: + $(CC) $(CFLAGS) -Wall oss_api.c hdrec.c -o hdrec + +clean: + rm $(OBJS) hdrec + +remake: clean all diff --git a/hdrec b/hdrec new file mode 100755 index 0000000000000000000000000000000000000000..41a6b8c8f03e6caacf7940391b7060c06c91de3d GIT binary patch literal 9485 zcmcgyeQ;FQb-%k>@FL4uVJB4e2Y#+42Qt=zK&FU5E1?fQB0wPV5rg!!+I`Y)vR~}J z#S(>9jwH-hR;_qK|7lHe?Y2(FGp3V{LdUf&jDy9DCoyC?P3mTf9oM6+NC(egjEh_K z_q+F9=}Fj0+dp!5&ffF8=iGD8z4zSv-n;MpQDbwH$Kw$?c}0;R8XxretC3&%EhVWI zhFB<;iTlO9$c3P+x*s~Aaqy%CARnj*bd3ZV=`Qdj%4mD0HOK_$0E8sg7o|!r%btS_ zv=SAnL2Q?DFS0oFOcOk^xN8vK8@I*NS+gG9F9jdV|?iaFvq5 zwDfJ$_TAuAJCea4`$YK{KzD!wAf3>Z^hsm3Ltoe*KWGuC7<4=6HV|!P#a4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szQeCNN&W=TSnM+Fi+w<_<^RRp8p+17a zm5RiDE=2j#nK+`rCqA5(jyhVz>=ExOSmeb{^q?bSMtKmq9uE)RM6L(c?vFPh7GPoN_*u+1yTI=E z()R<`qP-OA-HG-pxDYYkYa|w84Kd=CD~a!gHvpGHuHRel06u*T&j83-e?M{q@_vbh z_$G2*4^bWRVsQ|7CFDE>wbq!D$nD0-3JE5=No8OKtMX%R8@pZsr z;56inEBgBY<*>I};u7%{V7EV2z3ofz@79DdM$i~5j{ zIPLWUyWh({0j&Kmh5z3H*2w_#0`Mu9eRXl`uWv}LG1%ezIB*WE +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "oss_api.h" +#include "hdrec.h" + +int usage(void) { + printf("usage:\n\n"); + printf("-h \t\t print this help\n"); + printf("-r \t record to \n"); + printf("-p \t play from \n"); + printf("-s \t\t stereo\n"); + printf("-m \t\t mono\n"); + printf("-f \t 1=8bit - 2=16bit (le)\n"); + printf("-F \t frequency\n"); + + return 1; +} + +int main(int argc,char **argv) { + int sfile_fd; + int pfile_fd; + int audio_fd; + char device[MAX_C_DEVICE]; + int i,j,k; + int rw; + unsigned char mode=0; + int o_mode=0; + char record_file[MAX_C_FILE]; + char play_file[MAX_C_FILE]; + dsp_set set; + unsigned char *buf; + + /* defaults */ + strcpy(device,""); + set.format=AFMT_S16_LE; + set.freq=44100; + set.channel=STEREO; + + /* read argv */ + for(i=1;i +#include +#include +#include +#include +#include +#include +#include + +#include "oss_api.h" + +int get_dsp_cap(int fd,dsp_set *set,unsigned char print) { + if(ioctl(fd,SNDCTL_DSP_GETCAPS,&(set->cap))==-1) { + perror("SNDCTL_DSP_GETCAPS"); + return -1; + } + + if(print) { + printf("device capabilities:\n\n"); + printf("revision: %x\n",set->cap&DSP_CAP_REVISION); + printf("full duplex:\t%c\n",set->cap&DSP_CAP_DUPLEX?'y':'n'); + printf("real time:\t%c\n",set->cap&DSP_CAP_REALTIME?'y':'n'); + printf("int. buf:\t%c\n",set->cap&DSP_CAP_BATCH?'y':'n'); + printf("coprociessor:\t%c\n",set->cap&DSP_CAP_COPROC?'y':'n'); + printf("trigger:\t%c\n",set->cap&DSP_CAP_TRIGGER?'y':'n'); + printf("support mmap:\t%c\n",set->cap&DSP_CAP_MMAP?'y':'n'); + printf("multiple open:\t%c\n",set->cap&DSP_CAP_MULTI?'y':'n'); + printf("chan binding:\t%c\n",set->cap&DSP_CAP_BIND?'y':'n'); + } + + return 1; +} + +int set_dsp(int fd,dsp_set *set) { + int tmp; + + tmp=set->format; + if(ioctl(fd,SNDCTL_DSP_SETFMT,&(set->format))==-1) { + perror("SNDCTL_DSP_SETFMT"); + return -1; + } + if(set->format!=tmp) { + printf("format (%d) not supported!\n",tmp); + return -1; + } + tmp=set->channel; + if(ioctl(fd,SNDCTL_DSP_CHANNELS,&(set->channel))==-1) { + perror("SNDCTL_DSP_CHANNELS"); + return -1; + } + if(set->channel!=tmp) { + printf("%d-channel use not supported!\n",tmp); + return -1; + } + tmp=set->freq; + if(ioctl(fd,SNDCTL_DSP_SPEED,&(set->freq))==-1) { + perror("SNDCTL_DSP_SPEED"); + return -1; + } + if(set->freq!=tmp) { + printf("%d hz not suported!\n",tmp); + return -1; + } + if(ioctl(fd,SNDCTL_DSP_GETBLKSIZE,&(set->bufsize))==-1) { + perror("SOUNDCTL_DSP_GETBLKSIZE"); + return -1; + } + printf("\n\nSOUNDCTL_DSP_GETBLKSIZE = %d\n\n",set->bufsize); + + return 1; +} + +int open_sound_dev(char *dev,int mode) { + int fd; + + if((fd=open(dev,mode))==-1) { + perror("open"); + return -1; + } + + return fd; +} + +int open_file(char *file,int mode) { + int fd; + + if(mode) { + if((fd=open(file,mode,S_IRWXU))==-1) { + perror("open"); + return -1; + } + } else { + if((fd=open(file,mode))==-1) { + perror("open"); + return -1; + } + } + + return fd; +} + +int close_it(int fd) { + if(close(fd)==-1) { + perror("close"); + return -1; + } + + return 1; +} + diff --git a/oss_api.h b/oss_api.h new file mode 100644 index 0000000..67dbe65 --- /dev/null +++ b/oss_api.h @@ -0,0 +1,27 @@ +/* oss_api.h */ + +#ifndef OSS_API_H +#define OSS_API_H + +/* defines */ +#define MONO 1 +#define STEREO 2 +#define SAMPLES 100000 + +/* variables */ +typedef struct __dsp_set { + int cap; + int format; + int channel; + int freq; + int bufsize; +} dsp_set; + +/* function prototypes */ +int get_dsp_cap(int fd,dsp_set *set,unsigned char print); +int set_dsp(int fd,dsp_set *dsp_set); +int open_sound_dev(char *dev,int mode); +int open_file(char *file,int mode); +int close_it(int fd); + +#endif /* OSS_API_H */ diff --git a/oss_api.o b/oss_api.o new file mode 100644 index 0000000000000000000000000000000000000000..50654965ee4a474f4a3341474f11004cb27c90f7 GIT binary patch literal 2716 zcma)8QA}G^7(SE^I#$v;jlnqeF474xYX?XCBo5-=eW z%ZyF!i^~$9eDTG_7ZVBYVTo*L788w8XEfQ9b1ov7Xd;FOV*UPm&w)#~8Bfyu_xry8 z|Ia!9f6l#qJv`V~Q&Yp_sA08i7cutbK3h3%nHF|{d8Dgl$BMrcHkyk0ty11woZl|Z zd&=YP;>2I2sJr+?b8)oUbG5hGy>G<5^6Pe`Qt9?B{)V^{Q8y11Uut$=bvIKQOS=fY zQbH(_&2JYsCRWQctUT^1MLmvGb&gc;SgAa`(UEHX&yV%B!K(-#dyQ0^wdb)=D8qQR*tH&;n4*NgLz$(A zn`M540lZD%hw{=9ScZCyM+zH$l*_j~;it)cBkqM#*i+<~+$|>eEru}D;`O}mBF$L% z%>QE4st5AD2f~`xxBM{R5+Lp0qT0Uw8|?&p1+4GJbfKFYxVd<*_g`YPIt8;tvd!YaEANi?jE-c%3{?7Ro=sruobN+7V zhb{fK_4_`lgLoWbfGt!isk1AX#JBuS^*+}=|EE$B_3wkX-8?#AYafwJ5z!#(Eg3F~1W^Sihs-Cjv`*g5 z{;Wuz?B1_4Vdo5lWwq_7T82$HM(s}5rCyJ3x;kJUWY&Jn5HLq zn&k|<7*Z^!8isDLDO-!-O~Z0|Zd%tjX6pHDGKQCseVge@$5L8aweNLI