author | llornkcor <llornkcor> | 2002-02-15 02:36:29 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-15 02:36:29 (UTC) |
commit | e5ac946b3ced52f4aba73dfc64398bb3d8245734 (patch) (unidiff) | |
tree | 32f88c29a365816eb0b888244e299bd24a164d5d | |
parent | 77ea163d796ac330ad688210e049ab3763d9dd11 (diff) | |
download | opie-e5ac946b3ced52f4aba73dfc64398bb3d8245734.zip opie-e5ac946b3ced52f4aba73dfc64398bb3d8245734.tar.gz opie-e5ac946b3ced52f4aba73dfc64398bb3d8245734.tar.bz2 |
changed default format
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 83f19f5..25ee476 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -181,129 +181,129 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
181 | recording = TRUE; | 181 | recording = TRUE; |
182 | qWarning("VMemo::mousePress() -> Starting to record"); | 182 | qWarning("VMemo::mousePress() -> Starting to record"); |
183 | if (openDSP() == -1) | 183 | if (openDSP() == -1) |
184 | { | 184 | { |
185 | // ### Display an error box | 185 | // ### Display an error box |
186 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); | 186 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); |
187 | recording = FALSE; | 187 | recording = FALSE; |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | 190 | ||
191 | Config vmCfg("VMemo"); | 191 | Config vmCfg("VMemo"); |
192 | vmCfg.setGroup("Defaults"); | 192 | vmCfg.setGroup("Defaults"); |
193 | 193 | ||
194 | QDateTime dt = QDateTime::currentDateTime(); | 194 | QDateTime dt = QDateTime::currentDateTime(); |
195 | QString fileName; | 195 | QString fileName; |
196 | if(systemZaurus) | 196 | if(systemZaurus) |
197 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs | 197 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs |
198 | else | 198 | else |
199 | fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); | 199 | fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); |
200 | 200 | ||
201 | fileName += "vm_"; | 201 | fileName += "vm_"; |
202 | fileName += dt.toString(); | 202 | fileName += dt.toString(); |
203 | fileName += ".wav"; | 203 | fileName += ".wav"; |
204 | 204 | ||
205 | // No spaces in the filename | 205 | // No spaces in the filename |
206 | fileName.replace(QRegExp("'"),""); | 206 | fileName.replace(QRegExp("'"),""); |
207 | fileName.replace(QRegExp(" "),"_"); | 207 | fileName.replace(QRegExp(" "),"_"); |
208 | fileName.replace(QRegExp(":"),"."); | 208 | fileName.replace(QRegExp(":"),"."); |
209 | fileName.replace(QRegExp(","),""); | 209 | fileName.replace(QRegExp(","),""); |
210 | 210 | ||
211 | if(openWAV(fileName.latin1()) == -1) | 211 | if(openWAV(fileName.latin1()) == -1) |
212 | { | 212 | { |
213 | // ### Display an error box | 213 | // ### Display an error box |
214 | qWarning("VMemo::mousePress() -> WAV error"); | 214 | qWarning("VMemo::mousePress() -> WAV error"); |
215 | close(dsp); | 215 | close(dsp); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | 218 | ||
219 | QArray<int> cats(1); | 219 | QArray<int> cats(1); |
220 | cats[0] = vmCfg.readNumEntry("Category", 0); | 220 | cats[0] = vmCfg.readNumEntry("Category", 0); |
221 | 221 | ||
222 | QString dlName("vm_"); | 222 | QString dlName("vm_"); |
223 | dlName += dt.toString(); | 223 | dlName += dt.toString(); |
224 | DocLnk l; | 224 | DocLnk l; |
225 | l.setFile(fileName); | 225 | l.setFile(fileName); |
226 | l.setName(dlName); | 226 | l.setName(dlName); |
227 | l.setType("audio/x-wav"); | 227 | l.setType("audio/x-wav"); |
228 | l.setCategories(cats); | 228 | l.setCategories(cats); |
229 | l.writeLink(); | 229 | l.writeLink(); |
230 | 230 | ||
231 | record(); | 231 | record(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 234 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
235 | { | 235 | { |
236 | qWarning("VMemo::mouseRelese() -> Done recording"); | 236 | qWarning("VMemo::mouseRelese() -> Done recording"); |
237 | recording = FALSE; | 237 | recording = FALSE; |
238 | } | 238 | } |
239 | 239 | ||
240 | int VMemo::openDSP() | 240 | int VMemo::openDSP() |
241 | { | 241 | { |
242 | Config cfg("Sound"); | 242 | Config cfg("Sound"); |
243 | cfg.setGroup("Record"); | 243 | cfg.setGroup("Record"); |
244 | 244 | ||
245 | speed = cfg.readNumEntry("SampleRate", 11025); | 245 | speed = cfg.readNumEntry("SampleRate", 22050); |
246 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 246 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
247 | if (cfg.readNumEntry("SixteenBit", 1)==1) | 247 | if (cfg.readNumEntry("SixteenBit", 1)==1) |
248 | { | 248 | { |
249 | format = AFMT_S16_LE; | 249 | format = AFMT_S16_LE; |
250 | resolution = 16; | 250 | resolution = 16; |
251 | } | 251 | } |
252 | else | 252 | else |
253 | { | 253 | { |
254 | format = AFMT_U8; | 254 | format = AFMT_U8; |
255 | resolution = 8; | 255 | resolution = 8; |
256 | } | 256 | } |
257 | 257 | ||
258 | if(systemZaurus) | 258 | if(systemZaurus) |
259 | { | 259 | { |
260 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 260 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
261 | channels=1; //zaurus has one input channel | 261 | channels=1; //zaurus has one input channel |
262 | } | 262 | } |
263 | else | 263 | else |
264 | dsp = open("/dev/dsp", O_RDWR); | 264 | dsp = open("/dev/dsp", O_RDWR); |
265 | 265 | ||
266 | if(dsp == -1) | 266 | if(dsp == -1) |
267 | { | 267 | { |
268 | perror("open(\"/dev/dsp\")"); | 268 | perror("open(\"/dev/dsp\")"); |
269 | return -1; | 269 | return -1; |
270 | } | 270 | } |
271 | 271 | ||
272 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) | 272 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) |
273 | { | 273 | { |
274 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 274 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
275 | return -1; | 275 | return -1; |
276 | } | 276 | } |
277 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) | 277 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) |
278 | { | 278 | { |
279 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 279 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
280 | return -1; | 280 | return -1; |
281 | } | 281 | } |
282 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) | 282 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) |
283 | { | 283 | { |
284 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 284 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
285 | return -1; | 285 | return -1; |
286 | } | 286 | } |
287 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) | 287 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) |
288 | { | 288 | { |
289 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 289 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
290 | return -1; | 290 | return -1; |
291 | } | 291 | } |
292 | 292 | ||
293 | return 1; | 293 | return 1; |
294 | } | 294 | } |
295 | 295 | ||
296 | int VMemo::openWAV(const char *filename) | 296 | int VMemo::openWAV(const char *filename) |
297 | { | 297 | { |
298 | qDebug("Creating %s ",filename); | 298 | qDebug("Creating %s ",filename); |
299 | track.setName(filename); | 299 | track.setName(filename); |
300 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) | 300 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) |
301 | { | 301 | { |
302 | qDebug("Could not open file"); | 302 | qDebug("Could not open file"); |
303 | return -1; | 303 | return -1; |
304 | } | 304 | } |
305 | wav=track.handle(); | 305 | wav=track.handle(); |
306 | 306 | ||
307 | WaveHeader wh; | 307 | WaveHeader wh; |
308 | 308 | ||
309 | wh.main_chunk = RIFF;// RIFF | 309 | wh.main_chunk = RIFF;// RIFF |