author | llornkcor <llornkcor> | 2002-03-18 01:56:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-18 01:56:12 (UTC) |
commit | 2ed59c2eb1694b3dda2ab709f54a4ad25a24c6cc (patch) (unidiff) | |
tree | f14f5f50b091add26e880e6268bde46e836864af /core/applets/vmemo | |
parent | c09cb25eb6bbf31bed0d4a415802469cfd1efedf (diff) | |
download | opie-2ed59c2eb1694b3dda2ab709f54a4ad25a24c6cc.zip opie-2ed59c2eb1694b3dda2ab709f54a4ad25a24c6cc.tar.gz opie-2ed59c2eb1694b3dda2ab709f54a4ad25a24c6cc.tar.bz2 |
added Portuguese translations from 'covarde_anonimo' on #opie
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 150 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.pro | 1 |
2 files changed, 102 insertions, 49 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 48dd193..9d69130 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -8,17 +8,17 @@ | |||
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | ************************************************************************************/ | 11 | ************************************************************************************/ |
12 | 12 | ||
13 | /* | 13 | /* |
14 | * $Id$ | 14 | * $Id$ |
15 | */ | 15 | */ |
16 | 16 | // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> | |
17 | #include <sys/utsname.h> | 17 | #include <sys/utsname.h> |
18 | #include <sys/time.h> | 18 | #include <sys/time.h> |
19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
20 | #include <unistd.h> | 20 | #include <unistd.h> |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <sys/stat.h> | 22 | #include <sys/stat.h> |
23 | #include <fcntl.h> | 23 | #include <fcntl.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
@@ -136,37 +136,32 @@ static char * vmemo_xpm[] = { | |||
136 | VMemo::VMemo( QWidget *parent, const char *name ) | 136 | VMemo::VMemo( QWidget *parent, const char *name ) |
137 | : QWidget( parent, name ) | 137 | : QWidget( parent, name ) |
138 | { | 138 | { |
139 | setFixedHeight( 18 ); | 139 | setFixedHeight( 18 ); |
140 | setFixedWidth( 14 ); | 140 | setFixedWidth( 14 ); |
141 | 141 | ||
142 | recording = FALSE; | 142 | recording = FALSE; |
143 | 143 | ||
144 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 144 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
145 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 145 | if (uname(&name) != -1) { |
146 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | ||
147 | |||
148 | struct utsname name; /* check for embedix kernel running on the zaurus, if | ||
149 | lineo change string, this break | ||
150 | */ | ||
151 | if (uname(&name) != -1) | ||
152 | { | ||
153 | QString release=name.release; | 146 | QString release=name.release; |
154 | if(release.find("embedix",0,TRUE) !=-1) | 147 | if(release.find("embedix",0,TRUE) !=-1) |
155 | systemZaurus=TRUE; | 148 | systemZaurus=TRUE; |
156 | else | 149 | else { |
157 | { | ||
158 | systemZaurus=FALSE; | 150 | systemZaurus=FALSE; |
159 | 151 | // myChannel = new QCopChannel( "QPE/VMemo", this ); | |
160 | // Register the REC key press. | 152 | // connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
161 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 153 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); |
162 | e << 4096; | 154 | |
163 | e << QString("QPE/VMemo"); | 155 | // // Register the REC key press, for ipaq only |
164 | e << QString("toggleRecord()"); | 156 | // QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
157 | // e << 4096; | ||
158 | // e << QString("QPE/VMemo"); | ||
159 | // e << QString("toggleRecord()"); | ||
165 | } | 160 | } |
166 | } | 161 | } |
167 | } | 162 | } |
168 | 163 | ||
169 | VMemo::~VMemo() | 164 | VMemo::~VMemo() |
170 | { | 165 | { |
171 | } | 166 | } |
172 | 167 | ||
@@ -196,21 +191,21 @@ void VMemo::mousePressEvent( QMouseEvent *me ) | |||
196 | recording = FALSE; | 191 | recording = FALSE; |
197 | return; | 192 | return; |
198 | } | 193 | } |
199 | 194 | ||
200 | /* | 195 | /* |
201 | No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 196 | No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
202 | mousePressEvent and mouseReleaseEvent with a NULL parameter. | 197 | mousePressEvent and mouseReleaseEvent with a NULL parameter. |
203 | */ | 198 | */ |
204 | if (!systemZaurus && me != NULL) | 199 | // if (!systemZaurus && me != NULL) |
205 | return; | 200 | // return; |
206 | 201 | ||
207 | QSound::play(Resource::findSound("vmemob")); | 202 | QSound::play(Resource::findSound("vmemob")); |
208 | 203 | qDebug("Start recording"); | |
209 | recording = TRUE; | 204 | recording = TRUE; |
210 | if (openDSP() == -1) | 205 | if (openDSP() == -1) |
211 | { | 206 | { |
212 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); | 207 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); |
213 | recording = FALSE; | 208 | recording = FALSE; |
214 | return; | 209 | return; |
215 | } | 210 | } |
216 | 211 | ||
@@ -267,58 +262,50 @@ void VMemo::mouseReleaseEvent( QMouseEvent * ) | |||
267 | 262 | ||
268 | int VMemo::openDSP() | 263 | int VMemo::openDSP() |
269 | { | 264 | { |
270 | Config cfg("Sound"); | 265 | Config cfg("Sound"); |
271 | cfg.setGroup("Record"); | 266 | cfg.setGroup("Record"); |
272 | 267 | ||
273 | speed = cfg.readNumEntry("SampleRate", 22050); | 268 | speed = cfg.readNumEntry("SampleRate", 22050); |
274 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 269 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
275 | if (cfg.readNumEntry("SixteenBit", 1)==1) | 270 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
276 | { | ||
277 | format = AFMT_S16_LE; | 271 | format = AFMT_S16_LE; |
278 | resolution = 16; | 272 | resolution = 16; |
279 | } | 273 | } |
280 | else | 274 | // else { |
281 | { | 275 | // format = AFMT_U8; |
282 | format = AFMT_U8; | 276 | // resolution = 8; |
283 | resolution = 8; | 277 | // } |
284 | } | ||
285 | 278 | ||
286 | if(systemZaurus) | 279 | if(systemZaurus) { |
287 | { | ||
288 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 280 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
289 | channels=1; //zaurus has one input channel | 281 | channels=1; //zaurus has one input channel |
290 | } | 282 | } else { |
291 | else | ||
292 | dsp = open("/dev/dsp", O_RDWR); | 283 | dsp = open("/dev/dsp", O_RDWR); |
284 | } | ||
293 | 285 | ||
294 | if(dsp == -1) | 286 | if(dsp == -1) { |
295 | { | ||
296 | perror("open(\"/dev/dsp\")"); | 287 | perror("open(\"/dev/dsp\")"); |
297 | return -1; | 288 | return -1; |
298 | } | 289 | } |
299 | 290 | ||
300 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) | 291 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
301 | { | ||
302 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 292 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
303 | return -1; | 293 | return -1; |
304 | } | 294 | } |
305 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) | 295 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
306 | { | ||
307 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 296 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
308 | return -1; | 297 | return -1; |
309 | } | 298 | } |
310 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) | 299 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
311 | { | ||
312 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 300 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
313 | return -1; | 301 | return -1; |
314 | } | 302 | } |
315 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) | 303 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
316 | { | ||
317 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 304 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
318 | return -1; | 305 | return -1; |
319 | } | 306 | } |
320 | 307 | ||
321 | return 1; | 308 | return 1; |
322 | } | 309 | } |
323 | 310 | ||
324 | int VMemo::openWAV(const char *filename) | 311 | int VMemo::openWAV(const char *filename) |
@@ -349,34 +336,99 @@ int VMemo::openWAV(const char *filename) | |||
349 | write (wav, &wh, sizeof(WaveHeader)); | 336 | write (wav, &wh, sizeof(WaveHeader)); |
350 | 337 | ||
351 | return 1; | 338 | return 1; |
352 | } | 339 | } |
353 | 340 | ||
354 | void VMemo::record(void) | 341 | void VMemo::record(void) |
355 | { | 342 | { |
356 | int length=0, result, value; | 343 | int length=0, result, value; |
357 | char sound[512]; | 344 | qDebug("Recording"); |
358 | 345 | ||
359 | while(recording) | 346 | if(format==AFMT_S16_LE) { |
360 | { | 347 | signed short sound[512], monoBuffer[512]; |
348 | while(recording) { | ||
361 | result = read(dsp, sound, 512); // 8192 | 349 | result = read(dsp, sound, 512); // 8192 |
362 | qApp->processEvents(); | 350 | qApp->processEvents(); |
363 | 351 | int j=0; | |
364 | write(wav, sound, result); | 352 | if(systemZaurus) { |
365 | length += result; | 353 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
366 | 354 | monoBuffer[i] = sound[i]; | |
355 | } | ||
356 | qApp->processEvents(); | ||
357 | length+=write(wav, monoBuffer, result); | ||
358 | } else { //ipaq /stereo inputs | ||
359 | for (int i = 0; i < result; i+=2) { | ||
360 | monoBuffer[j] = (sound[i]+sound[i+1])/2; | ||
361 | j++; | ||
362 | } | ||
367 | qApp->processEvents(); | 363 | qApp->processEvents(); |
364 | length+=write(wav, monoBuffer, result/2); | ||
365 | } | ||
366 | printf("%d\r",length); | ||
367 | fflush(stdout); | ||
368 | } | 368 | } |
369 | } | ||
370 | // else { //AFMT_U8 // don't try this yet.. as player doesn't understand | ||
371 | // 8bit unsigned | ||
372 | // unsigned short sound[512], monoBuffer[512]; | ||
373 | // while(recording) | ||
374 | // { | ||
375 | // result = read(dsp, sound, 512); // 8192 | ||
376 | // qApp->processEvents(); | ||
377 | // int j=0; | ||
378 | // if(systemZaurus) | ||
379 | // { | ||
380 | // for (int i = 0; i < result; i++) { //since Z is mono do normally | ||
381 | // monoBuffer[i] = sound[i]; | ||
382 | // } | ||
383 | // qApp->processEvents(); | ||
384 | // length+=write(wav, monoBuffer, result); | ||
385 | // } else { //ipaq /stereo inputs | ||
386 | // for (int i = 0; i < result; i+=2) { | ||
387 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; | ||
388 | // j++; | ||
389 | // } | ||
390 | // qApp->processEvents(); | ||
391 | // length+=write(wav, monoBuffer, result/2); | ||
392 | // } | ||
393 | // // length += result; | ||
394 | // printf("%d\r",length); | ||
395 | // fflush(stdout); | ||
396 | |||
397 | // qApp->processEvents(); | ||
398 | // } | ||
399 | // } | ||
400 | |||
401 | |||
402 | |||
403 | // char sound[512]; //char is 8 bit | ||
404 | |||
405 | // while(recording) | ||
406 | // { | ||
407 | // result = read(dsp, sound, 512); // 8192 | ||
408 | // qApp->processEvents(); | ||
409 | |||
410 | // write(wav, sound, result); | ||
411 | // length += result; | ||
412 | |||
413 | // qApp->processEvents(); | ||
414 | // } | ||
415 | // qDebug("file has length of %d lasting %d seconds", | ||
416 | // length, (( length / speed) / channels) / 2 ); | ||
417 | // medialplayer states wrong length in secs | ||
418 | |||
369 | 419 | ||
370 | value = length+36; | 420 | value = length+36; |
371 | lseek(wav, 4, SEEK_SET); | 421 | lseek(wav, 4, SEEK_SET); |
372 | write(wav, &value, 4); | 422 | write(wav, &value, 4); |
373 | lseek(wav, 40, SEEK_SET); | 423 | lseek(wav, 40, SEEK_SET); |
374 | write(wav, &length, 4); | 424 | write(wav, &length, 4); |
375 | track.close(); | 425 | track.close(); |
376 | 426 | ||
377 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 427 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
378 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 428 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
379 | ::close(dsp); | 429 | ::close(dsp); |
430 | // if(systemZaurus) | ||
431 | QMessageBox::message("Vmemo"," Done recording"); | ||
380 | 432 | ||
381 | QSound::play(Resource::findSound("vmemoe")); | 433 | QSound::play(Resource::findSound("vmemoe")); |
382 | } | 434 | } |
diff --git a/core/applets/vmemo/vmemo.pro b/core/applets/vmemo/vmemo.pro index bf9af4b..29f99fb 100644 --- a/core/applets/vmemo/vmemo.pro +++ b/core/applets/vmemo/vmemo.pro | |||
@@ -4,8 +4,9 @@ HEADERS = vmemo.h vmemoimpl.h | |||
4 | SOURCES= vmemo.cpp vmemoimpl.cpp | 4 | SOURCES= vmemo.cpp vmemoimpl.cpp |
5 | TARGET = vmemoapplet | 5 | TARGET = vmemoapplet |
6 | DESTDIR = ../../plugins/applets | 6 | DESTDIR = ../../plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 8 | DEPENDPATH += ../$(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe |
10 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
11 | 11 | ||
12 | TRANSLATIONS = ../../i18n/pt_BR/libvmemoapplet.ts | ||