-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index aa23ba7..48dd193 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -151,7 +151,6 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
151 | if (uname(&name) != -1) | 151 | if (uname(&name) != -1) |
152 | { | 152 | { |
153 | QString release=name.release; | 153 | QString release=name.release; |
154 | qWarning("System release: %s\n", name.release); | ||
155 | if(release.find("embedix",0,TRUE) !=-1) | 154 | if(release.find("embedix",0,TRUE) !=-1) |
156 | systemZaurus=TRUE; | 155 | systemZaurus=TRUE; |
157 | else | 156 | else |
@@ -165,7 +164,6 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
165 | e << QString("toggleRecord()"); | 164 | e << QString("toggleRecord()"); |
166 | } | 165 | } |
167 | } | 166 | } |
168 | qWarning("VMemo done init"); | ||
169 | } | 167 | } |
170 | 168 | ||
171 | VMemo::~VMemo() | 169 | VMemo::~VMemo() |
@@ -175,7 +173,6 @@ VMemo::~VMemo() | |||
175 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 173 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
176 | { | 174 | { |
177 | QDataStream stream( data, IO_ReadOnly ); | 175 | QDataStream stream( data, IO_ReadOnly ); |
178 | qWarning("VMemo::receive: %s", (const char *)msg); | ||
179 | if (msg == "toggleRecord()") | 176 | if (msg == "toggleRecord()") |
180 | { | 177 | { |
181 | if (recording) | 178 | if (recording) |
@@ -191,7 +188,7 @@ void VMemo::paintEvent( QPaintEvent* ) | |||
191 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 188 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
192 | } | 189 | } |
193 | 190 | ||
194 | void VMemo::mousePressEvent( QMouseEvent * ) | 191 | void VMemo::mousePressEvent( QMouseEvent *me ) |
195 | { | 192 | { |
196 | // just to be safe | 193 | // just to be safe |
197 | if (recording) | 194 | if (recording) |
@@ -200,14 +197,18 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
200 | return; | 197 | return; |
201 | } | 198 | } |
202 | 199 | ||
203 | qWarning("VMemo::mousePress()"); | 200 | /* |
201 | No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | ||
202 | mousePressEvent and mouseReleaseEvent with a NULL parameter. | ||
203 | */ | ||
204 | if (!systemZaurus && me != NULL) | ||
205 | return; | ||
206 | |||
204 | QSound::play(Resource::findSound("vmemob")); | 207 | QSound::play(Resource::findSound("vmemob")); |
205 | 208 | ||
206 | recording = TRUE; | 209 | recording = TRUE; |
207 | qWarning("VMemo::mousePress() -> Starting to record"); | ||
208 | if (openDSP() == -1) | 210 | if (openDSP() == -1) |
209 | { | 211 | { |
210 | // ### Display an error box | ||
211 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); | 212 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); |
212 | recording = FALSE; | 213 | recording = FALSE; |
213 | return; | 214 | return; |
@@ -218,6 +219,7 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
218 | 219 | ||
219 | QDateTime dt = QDateTime::currentDateTime(); | 220 | QDateTime dt = QDateTime::currentDateTime(); |
220 | QString fileName; | 221 | QString fileName; |
222 | |||
221 | if(systemZaurus) | 223 | if(systemZaurus) |
222 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs | 224 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs |
223 | else | 225 | else |
@@ -235,8 +237,10 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
235 | 237 | ||
236 | if(openWAV(fileName.latin1()) == -1) | 238 | if(openWAV(fileName.latin1()) == -1) |
237 | { | 239 | { |
238 | // ### Display an error box | 240 | QString err("Could not open the output file: "); |
239 | qWarning("VMemo::mousePress() -> WAV error"); | 241 | err += fileName; |
242 | |||
243 | QMessageBox::critical(0, "VMemo", err, "Abort"); | ||
240 | close(dsp); | 244 | close(dsp); |
241 | return; | 245 | return; |
242 | } | 246 | } |
@@ -258,7 +262,6 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
258 | 262 | ||
259 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 263 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
260 | { | 264 | { |
261 | qWarning("VMemo::mouseRelese() -> Done recording"); | ||
262 | recording = FALSE; | 265 | recording = FALSE; |
263 | } | 266 | } |
264 | 267 | ||
@@ -320,13 +323,10 @@ int VMemo::openDSP() | |||
320 | 323 | ||
321 | int VMemo::openWAV(const char *filename) | 324 | int VMemo::openWAV(const char *filename) |
322 | { | 325 | { |
323 | qDebug("Creating %s ",filename); | ||
324 | track.setName(filename); | 326 | track.setName(filename); |
325 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) | 327 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) |
326 | { | ||
327 | qDebug("Could not open file"); | ||
328 | return -1; | 328 | return -1; |
329 | } | 329 | |
330 | wav=track.handle(); | 330 | wav=track.handle(); |
331 | 331 | ||
332 | WaveHeader wh; | 332 | WaveHeader wh; |
@@ -353,38 +353,20 @@ int VMemo::openWAV(const char *filename) | |||
353 | 353 | ||
354 | void VMemo::record(void) | 354 | void VMemo::record(void) |
355 | { | 355 | { |
356 | int length=0, result, value; //, i; | 356 | int length=0, result, value; |
357 | char sound[512]; //, leftBuffer[256], rightBuffer[256]; | 357 | char sound[512]; |
358 | |||
359 | qWarning("VMemo::record()"); | ||
360 | 358 | ||
361 | while(recording) | 359 | while(recording) |
362 | { | 360 | { |
363 | result = read(dsp, sound, 512); // 8192 | 361 | result = read(dsp, sound, 512); // 8192 |
364 | qApp->processEvents(); | 362 | qApp->processEvents(); |
365 | 363 | ||
366 | /* attempt to write only one channel...didnt work. | ||
367 | for (i = 0; i < result; i++) { | ||
368 | leftBuffer[i] = sound[2*i]; | ||
369 | rightBuffer[i] = sound[2*i+1]; | ||
370 | } | ||
371 | */ | ||
372 | qApp->processEvents(); | ||
373 | |||
374 | /* needed to only write one channel. comment out above "write/length" code. | ||
375 | write(wav, leftBuffer, result / 2); | ||
376 | length += result/2; | ||
377 | */ | ||
378 | |||
379 | write(wav, sound, result); | 364 | write(wav, sound, result); |
380 | length += result; | 365 | length += result; |
381 | 366 | ||
382 | qApp->processEvents(); | 367 | qApp->processEvents(); |
383 | } | 368 | } |
384 | 369 | ||
385 | qWarning("VMemo::record() -> Done recording"); | ||
386 | qWarning("VMemo::record() -> Closing dsp"); | ||
387 | |||
388 | value = length+36; | 370 | value = length+36; |
389 | lseek(wav, 4, SEEK_SET); | 371 | lseek(wav, 4, SEEK_SET); |
390 | write(wav, &value, 4); | 372 | write(wav, &value, 4); |
@@ -396,8 +378,5 @@ void VMemo::record(void) | |||
396 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 378 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
397 | ::close(dsp); | 379 | ::close(dsp); |
398 | 380 | ||
399 | qWarning("VMemo::record() -> playing done recording sound"); | ||
400 | QSound::play(Resource::findSound("vmemoe")); | 381 | QSound::play(Resource::findSound("vmemoe")); |
401 | qWarning("VMemo::record() -> terminating"); | ||
402 | //QMessageBox::information(0, "VMemo", "Recording Done", 1); | ||
403 | } | 382 | } |