From 9567fc9b2dab3b8fb0f9c2115cd5ef9d2ea304cd Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Fri, 11 Jul 2014 19:52:32 +0400 Subject: [PATCH 1/1] Added stdin source (to use with 'arecord -t raw' command for 16-bit audio) --- oss-streamer | Bin 12099 -> 12327 bytes oss-streamer.c | 13 ++++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/oss-streamer b/oss-streamer index deb0d96216beaa546dda6bb1d7f217688adbdca0..ceabc2e898569ffcf81c4b715e07515fc5578253 100755 GIT binary patch literal 12327 zcmd5?eQ;dWbw6)+W!AE6uVi6KM!=IT+p@7%k}cP^qM1BdGT0zvAq(mj!_#Wt^J?w= z>h8)|ty4C^v`oHiDCro(w1hxQTc$R$3~46}P9Rg7kJgB0;sQfe#srr#ttd)kh^OlB z+>iaj&~*Aw@6OqCfA^gGeeQkl-goZZ)_4tosl6z48Fv^!iMgSN@SAl#^_MO|nuM~v*N`j&^Ut26X(iU@C z$9fS72Q$fFJ57-BpG7({+H)d@2oKCPk{gYR|C-{z4PHgof_2~v$+{X0{kJ?kL=|LR z^)UE6vb?k4l|-J;gD(IDps*DEpGI6{0{2qSvSZ-YWX=Bv@EVW_S_1MzpWDG>&vV2T zpj;wwluH%h)!<#=oUaL-^KAj~ys@kf<#IcCY&S!`9`#=U{@;d`$k3%Sal9F{4738Y z0n`T4VGSZd4HP%Q*Mc^It^?fwS`Fg%c7oP}xXtY#9_K|M9;2n84p1FvGiW)8ZI0)L z$Di%~N&)>9fyeK&0?&&MixF7};&J2g)**lhkFO4F(>k#2T?^tdXFK7*>r96#6KURBk*{im9&*V}BBBrV;Hy-;Kvh5xshoC~V&j=IJW+;+H8w@W<3aykK~(qe1ud8Lc@~qkh;4z#7j|R3R4Ru} z%eBo01iLnVP$u7Bij7yxaDKc@AuxVgCePctYEKK=EBdJBGjHosj)%WDJx!(Uqa(n_Sf^UppQnp@Zm<~3 z_R|TDb5QL+B~c!ikN3|@<%PXm<^M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mJ1;%K&GhxdnBhM;H*=`A2HF3>* zo!OI9uL5f`zSmGy5-Ezi5_u_&M%+huBT)ul!AKbQ9Zr8K8!E><>V`IJ!bGYtSI7LU wF!VDF*Mv=)u+nnWg%O>ThOk?ct*V9sEW%*wg=WdCm3&@MMqAS0P1wHu4=O%$Qvd(} diff --git a/oss-streamer.c b/oss-streamer.c index c5702d4..a64a166 100644 --- a/oss-streamer.c +++ b/oss-streamer.c @@ -15,7 +15,6 @@ #include #define SOURCE_VERSION "0.0" -#define BOUNDARY "arflebarfle" typedef enum { SNAPSHOT, STREAM } answer_t; @@ -23,7 +22,7 @@ typedef enum { SNAPSHOT, STREAM } answer_t; int stop=0, sd; int force_delay=0; #define BUF_SIZE 4096 -int source_dev; +FILE *source_dev; /* signal fresh frames */ pthread_mutex_t db = PTHREAD_MUTEX_INITIALIZER; @@ -97,7 +96,7 @@ void *get_thread( void *arg ) { while( !stop ) { /* grab a frame */ - if( read(source_dev,rbuffer,BUF_SIZE) < 0 ) { + if( fread(rbuffer,1,BUF_SIZE,source_dev) < 0 ) { fprintf(stderr, "Error grabbing\n"); exit(1); } @@ -281,8 +280,12 @@ int main(int argc, char *argv[]) /* allocate audio datastructure */ /* open video device and prepare data structure */ - source_dev = open(dev,O_RDONLY); - if (source_dev < 0) { + if (strcmp(dev,"stdin")==0) { + source_dev = stdin; + } else { + source_dev = fopen(dev,"r"); + } + if (source_dev == NULL) { fprintf(stderr, "error opening source device\n"); exit(1); } -- 2.34.1