/[marvin]/marvin/src/gui/record.cc
ViewVC logotype

Diff of /marvin/src/gui/record.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by castor_fou, Tue Sep 16 20:25:36 2003 UTC revision 1.4 by castor_fou, Wed Sep 17 02:09:04 2003 UTC
# Line 47  char audio_name[20] = "/dev/dsp"; Line 47  char audio_name[20] = "/dev/dsp";
47    
48  int record  (const char *file)  int record  (const char *file)
49  {  {
50  //   int prof = APF_NORMAL;    //   int prof = APF_NORMAL;
51  //   int timelimit = 2;    //   int timelimit = 2;
52  //   int dsp_speed = 11025;    //   int dsp_speed = 11025;
53  //   int dsp_stereo = 0;    //   int dsp_stereo = 0;
54  //   int samplesize = 16;    //   int samplesize = 16;
55  //   int audio, abuf_size;    //   int audio, abuf_size;
56  //   int blksize=0;    //   int blksize=0;
57  //   int fragsize=0;    //   int fragsize=0;
58  //   int tmp;    //   int tmp;
59  //   int fd, l;    //   int fd, l;
60  //   int count, ch;    //   int count, ch;
61  //   char *audiobuf;    //   char *audiobuf;
62    
63  //   audio = open (audio_name, O_RDONLY, 0);    //   audio = open (audio_name, O_RDONLY, 0);
64  //   if (audio == -1)    //   if (audio == -1)
65  //     {    //     {
66  //       perror (audio_name);    //       perror (audio_name);
67  //       return 1;    //       return 1;
68  //     }    //     }
69    
70  //   if (fragsize != 0)    //   if (fragsize != 0)
71  //     if (ioctl(audio, SNDCTL_DSP_SETFRAGMENT, &fragsize)==-1)    //     if (ioctl(audio, SNDCTL_DSP_SETFRAGMENT, &fragsize)==-1)
72  //       {    //       {
73  //      perror("SETFRAGMENT");    //    perror("SETFRAGMENT");
74  //      return 1;    //    return 1;
75  //       }    //       }
76    
77  //   tmp = samplesize;    //   tmp = samplesize;
78  //   ioctl(audio, SNDCTL_DSP_SAMPLESIZE, &samplesize);    //   ioctl(audio, SNDCTL_DSP_SAMPLESIZE, &samplesize);
79  //   if (tmp != samplesize)    //   if (tmp != samplesize)
80  //     {    //     {
81  //       fprintf(stderr, "Unable to set the sample size\n");    //       fprintf(stderr, "Unable to set the sample size\n");
82  //       return 1;    //       return 1;
83  //     }    //     }
84    
85  //   ioctl(audio, SNDCTL_DSP_PROFILE, &prof);    //   ioctl(audio, SNDCTL_DSP_PROFILE, &prof);
86    
87  //   if (ioctl (audio, SNDCTL_DSP_STEREO, &dsp_stereo)==-1)    //   if (ioctl (audio, SNDCTL_DSP_STEREO, &dsp_stereo)==-1)
88  //     {    //     {
89  //       perror (audio_name);    //       perror (audio_name);
90  //       return 1;    //       return 1;
91  //     }    //     }
92        
93  //   if (ioctl (audio, SNDCTL_DSP_SPEED, &dsp_speed) == -1)    //   if (ioctl (audio, SNDCTL_DSP_SPEED, &dsp_speed) == -1)
94  //     {    //     {
95  //       perror (audio_name);    //       perror (audio_name);
96  //       return 1;    //       return 1;
97  //     }    //     }
98    
99  //   if (blksize > 0)    //   if (blksize > 0)
100  //     abuf_size = blksize;    //     abuf_size = blksize;
101  //   else    //   else
102  //     {    //     {
103  //       ioctl (audio, SNDCTL_DSP_GETBLKSIZE, &abuf_size);    //       ioctl (audio, SNDCTL_DSP_GETBLKSIZE, &abuf_size);
104  //       if (abuf_size < 1)    //       if (abuf_size < 1)
105  //      {    //    {
106  //        perror ("GETBLKSIZE");    //      perror ("GETBLKSIZE");
107  //        return 1;    //      return 1;
108  //      }    //    }
109  //     }    //     }
110    
111  //   if ((audiobuf = (char *)malloc (abuf_size)) == NULL)    //   if ((audiobuf = (char *)malloc (abuf_size)) == NULL)
112  //     {    //     {
113  //       fprintf (stderr, "Unable to allocate input/output buffer\n");    //       fprintf (stderr, "Unable to allocate input/output buffer\n");
114  //       return 1;    //       return 1;
115  //     }    //     }
116    
117  //   if (!timelimit)    //   if (!timelimit)
118  //     count = 0x7fffffff;    //     count = 0x7fffffff;
119  //   else    //   else
120  //     {    //     {
121  //       count = timelimit * dsp_speed;    //       count = timelimit * dsp_speed;
122  //       if (dsp_stereo)    //       if (dsp_stereo)
123  //      count *= 2;    //    count *= 2;
124  //       if (samplesize != 8)    //       if (samplesize != 8)
125  //         count *= 2;    //         count *= 2;
126  //     }    //     }
127    
128  //   if (!file)    //   if (!file)
129  //     {    //     {
130  //       fd = 1;    //       fd = 1;
131  //       file = "stdout";    //       file = "stdout";
132  //     }    //     }
133  //   else    //   else
134  //     {    //     {
135  //       if ((fd = open (file, O_WRONLY | O_CREAT, 0666)) == -1)    //       if ((fd = open (file, O_WRONLY | O_CREAT, 0666)) == -1)
136  //      {    //    {
137  //        perror (file);    //      perror (file);
138  //        return 1;    //      return 1;
139  //      }    //    }
140  //     }    //     }
141    
142  //   while (count)    //   while (count)
143  //     {    //     {
144  //       ch = count;    //       ch = count;
145  //       if (ch > abuf_size)    //       if (ch > abuf_size)
146  //      ch = abuf_size;    //    ch = abuf_size;
147    
148  //       if ((l = read (audio, audiobuf, ch)) > 0)    //       if ((l = read (audio, audiobuf, ch)) > 0)
149  //      {    //    {
150  //        if (write (fd, audiobuf, l) != l)    //      if (write (fd, audiobuf, l) != l)
151  //          {    //        {
152  //            perror (file);    //          perror (file);
153  //            return 1;    //          return 1;
154  //          }    //        }
155  //        count -= l;    //      count -= l;
156  //      }    //    }
157    
158  //       if (l == -1)    //       if (l == -1)
159  //      {    //    {
160  //        perror (audio_name);    //      perror (audio_name);
161  //        return 1;    //      return 1;
162  //      }    //    }
163  //     }                            //     }                      
164    
165  //   if (fd != 1)    //   if (fd != 1)
166  //     close (fd);    //     close (fd);
167    
168  //   close (audio);    //   close (audio);
169    
170     std::string cmd = "brec -s11025 -b16 -w -t 2 ";    std::string cmd = "brec -s11025 -b16 -w -t 2 ";
171     cmd += file;    cmd += file;
172     cmd += " 1> /dev/null 2> /dev/null";    cmd += " 1> /dev/null 2> /dev/null";
173    
174     system(cmd.c_str());    system(cmd.c_str());
175        
176    return 0;    return 0;
177  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26