-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 f088bef..b80b378 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -122,385 +122,385 @@ static char * vmemo_xpm[] = { | |||
122 | "d c #6B6B6F", | 122 | "d c #6B6B6F", |
123 | "e c #68686D", | 123 | "e c #68686D", |
124 | "f c #5B5B60", | 124 | "f c #5B5B60", |
125 | "g c #8A8A8F", | 125 | "g c #8A8A8F", |
126 | "h c #6B6B6E", | 126 | "h c #6B6B6E", |
127 | "i c #ADADB2", | 127 | "i c #ADADB2", |
128 | "j c #828289", | 128 | "j c #828289", |
129 | "k c #3E3E41", | 129 | "k c #3E3E41", |
130 | "l c #CFCFD7", | 130 | "l c #CFCFD7", |
131 | "m c #4C4C50", | 131 | "m c #4C4C50", |
132 | "n c #000000", | 132 | "n c #000000", |
133 | "o c #66666A", | 133 | "o c #66666A", |
134 | "p c #505054", | 134 | "p c #505054", |
135 | "q c #838388", | 135 | "q c #838388", |
136 | "r c #A1A1A7", | 136 | "r c #A1A1A7", |
137 | "s c #A9A9AE", | 137 | "s c #A9A9AE", |
138 | "t c #A8A8B0", | 138 | "t c #A8A8B0", |
139 | "u c #5E5E63", | 139 | "u c #5E5E63", |
140 | "v c #3A3A3E", | 140 | "v c #3A3A3E", |
141 | "w c #BDBDC6", | 141 | "w c #BDBDC6", |
142 | "x c #59595E", | 142 | "x c #59595E", |
143 | "y c #76767C", | 143 | "y c #76767C", |
144 | "z c #373738", | 144 | "z c #373738", |
145 | "A c #717174", | 145 | "A c #717174", |
146 | "B c #727278", | 146 | "B c #727278", |
147 | "C c #1C1C1E", | 147 | "C c #1C1C1E", |
148 | "D c #3C3C3F", | 148 | "D c #3C3C3F", |
149 | "E c #ADADB6", | 149 | "E c #ADADB6", |
150 | "F c #54555A", | 150 | "F c #54555A", |
151 | "G c #8B8C94", | 151 | "G c #8B8C94", |
152 | "H c #5A5A5F", | 152 | "H c #5A5A5F", |
153 | "I c #BBBBC3", | 153 | "I c #BBBBC3", |
154 | "J c #C4C4CB", | 154 | "J c #C4C4CB", |
155 | "K c #909098", | 155 | "K c #909098", |
156 | "L c #737379", | 156 | "L c #737379", |
157 | "M c #343437", | 157 | "M c #343437", |
158 | "N c #8F8F98", | 158 | "N c #8F8F98", |
159 | "O c #000407", | 159 | "O c #000407", |
160 | "P c #2D3137", | 160 | "P c #2D3137", |
161 | "Q c #B0B1BC", | 161 | "Q c #B0B1BC", |
162 | "R c #3B3C40", | 162 | "R c #3B3C40", |
163 | "S c #6E6E74", | 163 | "S c #6E6E74", |
164 | "T c #95959C", | 164 | "T c #95959C", |
165 | "U c #74747A", | 165 | "U c #74747A", |
166 | "V c #1D1D1E", | 166 | "V c #1D1D1E", |
167 | "W c #91929A", | 167 | "W c #91929A", |
168 | "X c #42444A", | 168 | "X c #42444A", |
169 | "Y c #22282E", | 169 | "Y c #22282E", |
170 | "Z c #B0B2BC", | 170 | "Z c #B0B2BC", |
171 | "` c #898A90", | 171 | "` c #898A90", |
172 | " . c #65656A", | 172 | " . c #65656A", |
173 | ".. c #999AA2", | 173 | ".. c #999AA2", |
174 | "+. c #52535A", | 174 | "+. c #52535A", |
175 | "@. c #151B21", | 175 | "@. c #151B21", |
176 | "#. c #515257", | 176 | "#. c #515257", |
177 | "$. c #B5B5BE", | 177 | "$. c #B5B5BE", |
178 | "%. c #616167", | 178 | "%. c #616167", |
179 | "&. c #1A1D22", | 179 | "&. c #1A1D22", |
180 | "*. c #000713", | 180 | "*. c #000713", |
181 | "=. c #1F1F21", | 181 | "=. c #1F1F21", |
182 | " ", | 182 | " ", |
183 | " . + @ # ", | 183 | " . + @ # ", |
184 | " $ % & * = - ", | 184 | " $ % & * = - ", |
185 | " ; > , ' ) ! ~ ", | 185 | " ; > , ' ) ! ~ ", |
186 | " { ] ^ / ( _ : ", | 186 | " { ] ^ / ( _ : ", |
187 | " < [ } | 1 2 3 ", | 187 | " < [ } | 1 2 3 ", |
188 | " 4 5 6 7 8 9 0 a b c ", | 188 | " 4 5 6 7 8 9 0 a b c ", |
189 | " d e f g h i j 3 k l m n ", | 189 | " d e f g h i j 3 k l m n ", |
190 | " o p q r s t u v w n ", | 190 | " o p q r s t u v w n ", |
191 | " o x y z A B C D E n ", | 191 | " o x y z A B C D E n ", |
192 | " F G H I J K L M N O ", | 192 | " F G H I J K L M N O ", |
193 | " P Q R S T U V W X ", | 193 | " P Q R S T U V W X ", |
194 | " Y Z ` b ...+. ", | 194 | " Y Z ` b ...+. ", |
195 | " @.#.$.%.&. ", | 195 | " @.#.$.%.&. ", |
196 | " *.B =. ", | 196 | " *.B =. ", |
197 | " n n n n n n n n n "}; | 197 | " n n n n n n n n n "}; |
198 | 198 | ||
199 | 199 | ||
200 | using namespace Opie::Ui; | 200 | using namespace Opie::Ui; |
201 | VMemo::VMemo( QWidget *parent, const char *_name ) | 201 | VMemo::VMemo( QWidget *parent, const char *_name ) |
202 | : QWidget( parent, _name ) { | 202 | : QWidget( parent, _name ) { |
203 | setFixedHeight( 18 ); | 203 | setFixedHeight( 18 ); |
204 | setFixedWidth( 14 ); | 204 | setFixedWidth( 14 ); |
205 | 205 | ||
206 | t_timer = new QTimer( this ); | 206 | t_timer = new QTimer( this ); |
207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
208 | 208 | ||
209 | Config vmCfg("Vmemo"); | 209 | Config vmCfg("Vmemo"); |
210 | vmCfg.setGroup("Defaults"); | 210 | vmCfg.setGroup("Defaults"); |
211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
213 | 213 | ||
214 | odebug << "toggleKey " << toggleKey << "" << oendl; | 214 | odebug << "toggleKey " << toggleKey << "" << oendl; |
215 | 215 | ||
216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
217 | // systemZaurus=TRUE; | 217 | // systemZaurus=TRUE; |
218 | // else | 218 | // else |
219 | systemZaurus = FALSE; | 219 | systemZaurus = FALSE; |
220 | 220 | ||
221 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 221 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
224 | 224 | ||
225 | if( toggleKey != -1 ) { | 225 | if( toggleKey != -1 ) { |
226 | odebug << "Register key " << toggleKey << "" << oendl; | 226 | odebug << "Register key " << toggleKey << "" << oendl; |
227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
228 | // e << 4096; // Key_Escape | 228 | // e << 4096; // Key_Escape |
229 | // e << Key_F5; //4148 | 229 | // e << Key_F5; //4148 |
230 | e << toggleKey; | 230 | e << toggleKey; |
231 | e << QString("QPE/VMemo"); | 231 | e << QString("QPE/VMemo"); |
232 | e << QString("toggleRecord()"); | 232 | e << QString("toggleRecord()"); |
233 | } | 233 | } |
234 | if(toggleKey == 1) | 234 | if(toggleKey == 1) |
235 | usingIcon = TRUE; | 235 | usingIcon = TRUE; |
236 | else | 236 | else |
237 | usingIcon = FALSE; | 237 | usingIcon = FALSE; |
238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) | 238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) |
239 | // hide(); | 239 | // hide(); |
240 | recording = FALSE; | 240 | recording = FALSE; |
241 | // } | 241 | // } |
242 | } | 242 | } |
243 | 243 | ||
244 | VMemo::~VMemo() { | 244 | VMemo::~VMemo() { |
245 | } | 245 | } |
246 | 246 | ||
247 | int VMemo::position() | 247 | int VMemo::position() |
248 | { | 248 | { |
249 | return 6; | 249 | return 6; |
250 | } | 250 | } |
251 | 251 | ||
252 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 252 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
253 | odebug << "Vmemo receive" << oendl; | 253 | odebug << "Vmemo receive" << oendl; |
254 | QDataStream stream( data, IO_ReadOnly ); | 254 | QDataStream stream( data, IO_ReadOnly ); |
255 | 255 | ||
256 | if (msg == "toggleRecord()") { | 256 | if (msg == "toggleRecord()") { |
257 | if (recording) { | 257 | if (recording) { |
258 | fromToggle = TRUE; | 258 | fromToggle = TRUE; |
259 | stopRecording(); | 259 | stopRecording(); |
260 | } else { | 260 | } else { |
261 | fromToggle = TRUE; | 261 | fromToggle = TRUE; |
262 | startRecording(); | 262 | startRecording(); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | void VMemo::paintEvent( QPaintEvent* ) { | 267 | void VMemo::paintEvent( QPaintEvent* ) { |
268 | QPainter p(this); | 268 | QPainter p(this); |
269 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 269 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
270 | } | 270 | } |
271 | 271 | ||
272 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { | 272 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { |
273 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 273 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
274 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 274 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
275 | 275 | ||
276 | // if (!systemZaurus && me != NULL) | 276 | // if (!systemZaurus && me != NULL) |
277 | // return; | 277 | // return; |
278 | // } | 278 | // } |
279 | 279 | ||
280 | if(!recording) | 280 | if(!recording) |
281 | startRecording(); | 281 | startRecording(); |
282 | else | 282 | else |
283 | stopRecording(); | 283 | stopRecording(); |
284 | } | 284 | } |
285 | 285 | ||
286 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 286 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
287 | } | 287 | } |
288 | 288 | ||
289 | bool VMemo::startRecording() { | 289 | bool VMemo::startRecording() { |
290 | Config config( "Vmemo" ); | 290 | Config config( "Vmemo" ); |
291 | config.setGroup( "System" ); | 291 | config.setGroup( "System" ); |
292 | 292 | ||
293 | useAlerts = config.readBoolEntry("Alert",1); | 293 | useAlerts = config.readBoolEntry("Alert",1); |
294 | if(useAlerts) { | 294 | if(useAlerts) { |
295 | 295 | ||
296 | msgLabel = new QLabel( 0, "alertLabel" ); | 296 | msgLabel = new QLabel( 0, "alertLabel" ); |
297 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 297 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
298 | msgLabel->show(); | 298 | msgLabel->show(); |
299 | } | 299 | } |
300 | 300 | ||
301 | odebug << "Start recording engines" << oendl; | 301 | odebug << "Start recording engines" << oendl; |
302 | recording = TRUE; | 302 | recording = TRUE; |
303 | 303 | ||
304 | if (openDSP() == -1) { | 304 | if (openDSP() == -1) { |
305 | recording = FALSE; | 305 | recording = FALSE; |
306 | return FALSE; | 306 | return FALSE; |
307 | } | 307 | } |
308 | 308 | ||
309 | config.setGroup("Defaults"); | 309 | config.setGroup("Defaults"); |
310 | 310 | ||
311 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 311 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
312 | date.replace(QRegExp("'"),""); | 312 | date.replace(QRegExp("'"),""); |
313 | date.replace(QRegExp(" "),"_"); | 313 | date.replace(QRegExp(" "),"_"); |
314 | date.replace(QRegExp(":"),"."); | 314 | date.replace(QRegExp(":"),"-"); |
315 | date.replace(QRegExp(","),""); | 315 | date.replace(QRegExp(","),""); |
316 | 316 | ||
317 | QString fName; | 317 | QString fName; |
318 | config.setGroup( "System" ); | 318 | config.setGroup( "System" ); |
319 | fName = QPEApplication::documentDir() ; | 319 | fName = QPEApplication::documentDir() ; |
320 | fileName = config.readEntry("RecLocation", fName); | 320 | fileName = config.readEntry("RecLocation", fName); |
321 | 321 | ||
322 | int s; | 322 | int s; |
323 | s=fileName.find(':'); | 323 | s=fileName.find(':'); |
324 | if(s) | 324 | if(s) |
325 | fileName=fileName.right(fileName.length()-s-2); | 325 | fileName=fileName.right(fileName.length()-s-2); |
326 | odebug << "pathname will be "+fileName << oendl; | 326 | odebug << "pathname will be "+fileName << oendl; |
327 | 327 | ||
328 | if( fileName.left(1).find('/') == -1) | 328 | if( fileName.left(1).find('/') == -1) |
329 | fileName="/"+fileName; | 329 | fileName="/"+fileName; |
330 | if( fileName.right(1).find('/') == -1) | 330 | if( fileName.right(1).find('/') == -1) |
331 | fileName+="/"; | 331 | fileName+="/"; |
332 | fName = "vm_"+ date + ".wav"; | 332 | fName = "vm_"+ date + ".wav"; |
333 | 333 | ||
334 | fileName+=fName; | 334 | fileName+=fName; |
335 | odebug << "filename is " + fileName << oendl; | 335 | odebug << "filename is " + fileName << oendl; |
336 | // open tmp file here | 336 | // open tmp file here |
337 | char *pointer; | 337 | char *pointer; |
338 | pointer=tmpnam(NULL); | 338 | pointer=tmpnam(NULL); |
339 | odebug << "Opening tmp file " << pointer << "" << oendl; | 339 | odebug << "Opening tmp file " << pointer << "" << oendl; |
340 | 340 | ||
341 | if(openWAV(pointer ) == -1) { | 341 | if(openWAV(pointer ) == -1) { |
342 | 342 | ||
343 | QString err("Could not open the temp file\n"); | 343 | QString err("Could not open the temp file\n"); |
344 | err += fileName; | 344 | err += fileName; |
345 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 345 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
346 | ::close(dsp); | 346 | ::close(dsp); |
347 | return FALSE; | 347 | return FALSE; |
348 | } | 348 | } |
349 | if( record() ) { | 349 | if( record() ) { |
350 | 350 | ||
351 | QString cmd; | 351 | QString cmd; |
352 | if( fileName.find(".wav",0,TRUE) == -1) | 352 | if( fileName.find(".wav",0,TRUE) == -1) |
353 | fileName += ".wav"; | 353 | fileName += ".wav"; |
354 | 354 | ||
355 | cmd.sprintf("mv %s "+fileName, pointer); | 355 | cmd.sprintf("mv %s "+fileName, pointer); |
356 | // move tmp file to regular file here | 356 | // move tmp file to regular file here |
357 | 357 | ||
358 | system(cmd.latin1()); | 358 | system(cmd.latin1()); |
359 | 359 | ||
360 | QArray<int> cats(1); | 360 | QArray<int> cats(1); |
361 | cats[0] = config.readNumEntry("Category", 0); | 361 | cats[0] = config.readNumEntry("Category", 0); |
362 | 362 | ||
363 | QString dlName("vm_"); | 363 | QString dlName("vm_"); |
364 | dlName += date; | 364 | dlName += date; |
365 | DocLnk l; | 365 | DocLnk l; |
366 | l.setFile(fileName); | 366 | l.setFile(fileName); |
367 | l.setName(dlName); | 367 | l.setName(dlName); |
368 | l.setType("audio/x-wav"); | 368 | l.setType("audio/x-wav"); |
369 | l.setCategories(cats); | 369 | l.setCategories(cats); |
370 | l.writeLink(); | 370 | l.writeLink(); |
371 | return TRUE; | 371 | return TRUE; |
372 | } else | 372 | } else |
373 | return FALSE; | 373 | return FALSE; |
374 | 374 | ||
375 | } | 375 | } |
376 | 376 | ||
377 | void VMemo::stopRecording() { | 377 | void VMemo::stopRecording() { |
378 | show(); | 378 | show(); |
379 | odebug << "Stopped recording" << oendl; | 379 | odebug << "Stopped recording" << oendl; |
380 | recording = FALSE; | 380 | recording = FALSE; |
381 | if(useAlerts) { | 381 | if(useAlerts) { |
382 | msgLabel->close(); | 382 | msgLabel->close(); |
383 | msgLabel=0; | 383 | msgLabel=0; |
384 | delete msgLabel; | 384 | delete msgLabel; |
385 | } | 385 | } |
386 | t_timer->stop(); | 386 | t_timer->stop(); |
387 | Config cfg("Vmemo"); | 387 | Config cfg("Vmemo"); |
388 | cfg.setGroup("Defaults"); | 388 | cfg.setGroup("Defaults"); |
389 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) | 389 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) |
390 | // hide(); | 390 | // hide(); |
391 | } | 391 | } |
392 | 392 | ||
393 | int VMemo::openDSP() { | 393 | int VMemo::openDSP() { |
394 | Config cfg("Vmemo"); | 394 | Config cfg("Vmemo"); |
395 | cfg.setGroup("Record"); | 395 | cfg.setGroup("Record"); |
396 | 396 | ||
397 | speed = cfg.readNumEntry("SampleRate", 22050); | 397 | speed = cfg.readNumEntry("SampleRate", 22050); |
398 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 398 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
399 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 399 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
400 | format = AFMT_S16_LE; | 400 | format = AFMT_S16_LE; |
401 | resolution = 16; | 401 | resolution = 16; |
402 | } else { | 402 | } else { |
403 | format = AFMT_U8; | 403 | format = AFMT_U8; |
404 | resolution = 8; | 404 | resolution = 8; |
405 | } | 405 | } |
406 | 406 | ||
407 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; | 407 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; |
408 | 408 | ||
409 | if(systemZaurus) { | 409 | if(systemZaurus) { |
410 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 410 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
411 | channels=1; //zaurus has one input channel | 411 | channels=1; //zaurus has one input channel |
412 | } else { | 412 | } else { |
413 | dsp = open("/dev/dsp", O_RDONLY); | 413 | dsp = open("/dev/dsp", O_RDONLY); |
414 | } | 414 | } |
415 | 415 | ||
416 | if(dsp == -1) { | 416 | if(dsp == -1) { |
417 | msgLabel->close(); | 417 | msgLabel->close(); |
418 | msgLabel=0; | 418 | msgLabel=0; |
419 | delete msgLabel; | 419 | delete msgLabel; |
420 | 420 | ||
421 | perror("open(\"/dev/dsp\")"); | 421 | perror("open(\"/dev/dsp\")"); |
422 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 422 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
423 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 423 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
424 | return -1; | 424 | return -1; |
425 | } | 425 | } |
426 | 426 | ||
427 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 427 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
428 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 428 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
429 | return -1; | 429 | return -1; |
430 | } | 430 | } |
431 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 431 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
432 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 432 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
433 | return -1; | 433 | return -1; |
434 | } | 434 | } |
435 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 435 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
436 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 436 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
437 | return -1; | 437 | return -1; |
438 | } | 438 | } |
439 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 439 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
440 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 440 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
441 | return -1; | 441 | return -1; |
442 | } | 442 | } |
443 | 443 | ||
444 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 444 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
445 | 445 | ||
446 | return 1; | 446 | return 1; |
447 | } | 447 | } |
448 | 448 | ||
449 | int VMemo::openWAV(const char *filename) { | 449 | int VMemo::openWAV(const char *filename) { |
450 | track.setName(filename); | 450 | track.setName(filename); |
451 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 451 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
452 | errorMsg=filename; | 452 | errorMsg=filename; |
453 | return -1; | 453 | return -1; |
454 | } | 454 | } |
455 | 455 | ||
456 | wav=track.handle(); | 456 | wav=track.handle(); |
457 | Config vmCfg("Vmemo"); | 457 | Config vmCfg("Vmemo"); |
458 | vmCfg.setGroup("Defaults"); | 458 | vmCfg.setGroup("Defaults"); |
459 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 459 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
460 | 460 | ||
461 | WaveHeader wh; | 461 | WaveHeader wh; |
462 | 462 | ||
463 | wh.main_chunk = RIFF; | 463 | wh.main_chunk = RIFF; |
464 | wh.length=0; | 464 | wh.length=0; |
465 | wh.chunk_type = WAVE; | 465 | wh.chunk_type = WAVE; |
466 | wh.sub_chunk = FMT; | 466 | wh.sub_chunk = FMT; |
467 | wh.sc_len = 16; | 467 | wh.sc_len = 16; |
468 | if(useADPCM) | 468 | if(useADPCM) |
469 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; | 469 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; |
470 | else | 470 | else |
471 | wh.format = PCM_CODE; | 471 | wh.format = PCM_CODE; |
472 | wh.modus = channels; | 472 | wh.modus = channels; |
473 | wh.sample_fq = speed; | 473 | wh.sample_fq = speed; |
474 | wh.byte_p_sec = speed * channels * resolution/8; | 474 | wh.byte_p_sec = speed * channels * resolution/8; |
475 | wh.byte_p_spl = channels * (resolution / 8); | 475 | wh.byte_p_spl = channels * (resolution / 8); |
476 | wh.bit_p_spl = resolution; | 476 | wh.bit_p_spl = resolution; |
477 | wh.data_chunk = DATA; | 477 | wh.data_chunk = DATA; |
478 | wh.data_length= 0; | 478 | wh.data_length= 0; |
479 | // odebug << "Write header channels " << wh.modus << ", speed " << wh.sample_fq << ", b/s " | 479 | // odebug << "Write header channels " << wh.modus << ", speed " << wh.sample_fq << ", b/s " |
480 | // << wh.byte_p_sec << ", blockalign " << wh.byte_p_spl << ", bitrate " << wh.bit_p_spl << oendl; | 480 | // << wh.byte_p_sec << ", blockalign " << wh.byte_p_spl << ", bitrate " << wh.bit_p_spl << oendl; |
481 | write (wav, &wh, sizeof(WaveHeader)); | 481 | write (wav, &wh, sizeof(WaveHeader)); |
482 | 482 | ||
483 | return 1; | 483 | return 1; |
484 | } | 484 | } |
485 | 485 | ||
486 | bool VMemo::record() { | 486 | bool VMemo::record() { |
487 | length = 0; | 487 | length = 0; |
488 | int bytesWritten = 0; | 488 | int bytesWritten = 0; |
489 | int result = 0; | 489 | int result = 0; |
490 | int value = 0; | 490 | int value = 0; |
491 | QString msg; | 491 | QString msg; |
492 | msg.sprintf("Recording format %d", format); | 492 | msg.sprintf("Recording format %d", format); |
493 | odebug << msg << oendl; | 493 | odebug << msg << oendl; |
494 | Config config("Vmemo"); | 494 | Config config("Vmemo"); |
495 | config.setGroup("Record"); | 495 | config.setGroup("Record"); |
496 | int sRate = config.readNumEntry("SizeLimit", 30); | 496 | int sRate = config.readNumEntry("SizeLimit", 30); |
497 | if(sRate > 0) | 497 | if(sRate > 0) |
498 | t_timer->start( sRate * 1000+1000, TRUE); | 498 | t_timer->start( sRate * 1000+1000, TRUE); |
499 | 499 | ||
500 | msg.sprintf("Recording format other"); | 500 | msg.sprintf("Recording format other"); |
501 | odebug << msg << oendl; | 501 | odebug << msg << oendl; |
502 | 502 | ||
503 | config.setGroup("Defaults"); | 503 | config.setGroup("Defaults"); |
504 | useADPCM = config.readBoolEntry("use_ADPCM", 0); | 504 | useADPCM = config.readBoolEntry("use_ADPCM", 0); |
505 | 505 | ||
506 | int bufsize = config.readNumEntry("BufferSize",1024); | 506 | int bufsize = config.readNumEntry("BufferSize",1024); |