author | jeremy <jeremy> | 2002-02-14 04:01:40 (UTC) |
---|---|---|
committer | jeremy <jeremy> | 2002-02-14 04:01:40 (UTC) |
commit | c47e1afcc185c05f4e1d9178566032df74981489 (patch) (unidiff) | |
tree | 7e3a6d3660920de9d3f6b888fac87a4f8c8e92f1 /core/applets/vmemo | |
parent | 3d4486b3a89e45785f92d8d963b334ddd4ac095a (diff) | |
download | opie-c47e1afcc185c05f4e1d9178566032df74981489.zip opie-c47e1afcc185c05f4e1d9178566032df74981489.tar.gz opie-c47e1afcc185c05f4e1d9178566032df74981489.tar.bz2 |
Just eradicating bugs. Still not ready for public/general use.
----------------------------------------------------------------------
-rw-r--r-- | core/applets/vmemo/moc_vmemo.cpp | 2 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 74 |
2 files changed, 34 insertions, 42 deletions
diff --git a/core/applets/vmemo/moc_vmemo.cpp b/core/applets/vmemo/moc_vmemo.cpp index 7e68ac1..fbe1f6b 100644 --- a/core/applets/vmemo/moc_vmemo.cpp +++ b/core/applets/vmemo/moc_vmemo.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** VMemo meta object code from reading C++ file 'vmemo.h' | 2 | ** VMemo meta object code from reading C++ file 'vmemo.h' |
3 | ** | 3 | ** |
4 | ** Created: Wed Feb 13 17:52:12 2002 | 4 | ** Created: Wed Feb 13 21:49:42 2002 |
5 | ** by: The Qt MOC ($Id$) | 5 | ** by: The Qt MOC ($Id$) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 6bd1622..73bd996 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -1,4 +1,4 @@ | |||
1 | /**************************************************************************************94x78** | 1 | /************************************************************************************ |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
@@ -8,7 +8,7 @@ | |||
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$ |
@@ -62,6 +62,7 @@ typedef struct _waveheader { | |||
62 | #include <qdatetime.h> | 62 | #include <qdatetime.h> |
63 | #include <qsound.h> | 63 | #include <qsound.h> |
64 | #include <qfile.h> | 64 | #include <qfile.h> |
65 | #include <qmessagebox.h> | ||
65 | 66 | ||
66 | int seq = 0; | 67 | int seq = 0; |
67 | 68 | ||
@@ -138,13 +139,16 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
138 | 139 | ||
139 | recording = FALSE; | 140 | recording = FALSE; |
140 | 141 | ||
141 | struct utsname name; //check for embedix kernel running on the zaurus, if lineo change string, this break | 142 | struct utsname name; /* check for embedix kernel running on the zaurus, if |
142 | if (uname(&name) != -1) { | 143 | lineo change string, this break |
144 | */ | ||
145 | if (uname(&name) != -1) | ||
146 | { | ||
143 | QString release=name.release; | 147 | QString release=name.release; |
144 | if(release.find("embedix",0,TRUE) !=-1) { | 148 | qWarning("System release: %s\n", name.release); |
149 | if(release.find("embedix",0,TRUE) !=-1) | ||
145 | systemZaurus=TRUE; | 150 | systemZaurus=TRUE; |
146 | printf("System release: %s\n", name.release); | 151 | else |
147 | } else | ||
148 | systemZaurus=FALSE; | 152 | systemZaurus=FALSE; |
149 | } | 153 | } |
150 | 154 | ||
@@ -162,6 +166,13 @@ void VMemo::paintEvent( QPaintEvent* ) | |||
162 | 166 | ||
163 | void VMemo::mousePressEvent( QMouseEvent * ) | 167 | void VMemo::mousePressEvent( QMouseEvent * ) |
164 | { | 168 | { |
169 | // just to be safe | ||
170 | if (recording) | ||
171 | { | ||
172 | recording = FALSE; | ||
173 | return; | ||
174 | } | ||
175 | |||
165 | qWarning("VMemo::mousePress()"); | 176 | qWarning("VMemo::mousePress()"); |
166 | QSound::play(Resource::findSound("vmemob")); | 177 | QSound::play(Resource::findSound("vmemob")); |
167 | 178 | ||
@@ -170,7 +181,7 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
170 | if (openDSP() == -1) | 181 | if (openDSP() == -1) |
171 | { | 182 | { |
172 | // ### Display an error box | 183 | // ### Display an error box |
173 | qWarning("VMemo::mousePress() -> DSP error"); | 184 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); |
174 | recording = FALSE; | 185 | recording = FALSE; |
175 | return; | 186 | return; |
176 | } | 187 | } |
@@ -222,7 +233,6 @@ void VMemo::mouseReleaseEvent( QMouseEvent * ) | |||
222 | { | 233 | { |
223 | qWarning("VMemo::mouseRelese() -> Done recording"); | 234 | qWarning("VMemo::mouseRelese() -> Done recording"); |
224 | recording = FALSE; | 235 | recording = FALSE; |
225 | QSound::play(Resource::findSound("vmemoe")); | ||
226 | } | 236 | } |
227 | 237 | ||
228 | int VMemo::openDSP() | 238 | int VMemo::openDSP() |
@@ -248,39 +258,38 @@ int VMemo::openDSP() | |||
248 | else | 258 | else |
249 | dsp = open("/dev/dsp", O_RDWR); | 259 | dsp = open("/dev/dsp", O_RDWR); |
250 | 260 | ||
251 | qWarning("speed = %i", speed); | ||
252 | |||
253 | if(dsp == -1) | 261 | if(dsp == -1) |
254 | { | 262 | { |
255 | perror("open(\"/dev/dsp\")"); | 263 | perror("open(\"/dev/dsp\")"); |
256 | return -1; | 264 | return -1; |
257 | } | 265 | } |
258 | 266 | ||
259 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 267 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) |
268 | { | ||
260 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 269 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
261 | return -1; | 270 | return -1; |
262 | } | 271 | } |
263 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 272 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) |
273 | { | ||
264 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 274 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
265 | return -1; | 275 | return -1; |
266 | } | 276 | } |
267 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 277 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) |
278 | { | ||
268 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 279 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
269 | return -1; | 280 | return -1; |
270 | } | 281 | } |
271 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 282 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) |
283 | { | ||
272 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 284 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
273 | return -1; | 285 | return -1; |
274 | } | 286 | } |
275 | qWarning("speed = %i", speed); | ||
276 | 287 | ||
277 | return 1; | 288 | return 1; |
278 | } | 289 | } |
279 | 290 | ||
280 | int VMemo::openWAV(const char *filename) | 291 | int VMemo::openWAV(const char *filename) |
281 | { | 292 | { |
282 | char buffer[256]; | ||
283 | |||
284 | qDebug("Creating %s ",filename); | 293 | qDebug("Creating %s ",filename); |
285 | track.setName(filename); | 294 | track.setName(filename); |
286 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) | 295 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) |
@@ -292,22 +301,6 @@ int VMemo::openWAV(const char *filename) | |||
292 | 301 | ||
293 | WaveHeader wh; | 302 | WaveHeader wh; |
294 | 303 | ||
295 | /* | ||
296 | wh.main_chunk = RIFF; | ||
297 | wh.length = 0; | ||
298 | wh.chunk_type = WAVE; | ||
299 | wh.sub_chunk = FMT; | ||
300 | wh.sc_len = 16; | ||
301 | wh.format = PCM_CODE; | ||
302 | wh.modus = channels; | ||
303 | wh.sample_fq = speed; | ||
304 | wh.byte_p_spl = ((resolution == 8) ? 1 : 2) * (channels ? 2 : 1); | ||
305 | wh.byte_p_sec = resolution; //speed * wh.modus * wh.byte_p_spl; | ||
306 | wh.bit_p_spl = resolution; | ||
307 | wh.data_chunk = DATA; | ||
308 | wh.data_length= 0; | ||
309 | */ | ||
310 | |||
311 | wh.main_chunk = RIFF; | 304 | wh.main_chunk = RIFF; |
312 | wh.length = 0; | 305 | wh.length = 0; |
313 | wh.chunk_type = WAVE; | 306 | wh.chunk_type = WAVE; |
@@ -321,12 +314,6 @@ int VMemo::openWAV(const char *filename) | |||
321 | wh.byte_p_sec = wh.sample_fq * wh.bit_p_spl; | 314 | wh.byte_p_sec = wh.sample_fq * wh.bit_p_spl; |
322 | wh.byte_p_spl = channels * (wh.bit_p_spl % 8); | 315 | wh.byte_p_spl = channels * (wh.bit_p_spl % 8); |
323 | 316 | ||
324 | qWarning("channels = %i\n" | ||
325 | "samplesPerSecond = %i\n" | ||
326 | "avgBytesPerSecond = %i\n" | ||
327 | "blockAlign = %i\n" | ||
328 | "bitsPerSecond = %i\n", wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl); | ||
329 | |||
330 | wh.data_chunk = DATA; | 317 | wh.data_chunk = DATA; |
331 | wh.data_length= 0; | 318 | wh.data_length= 0; |
332 | 319 | ||
@@ -344,8 +331,10 @@ void VMemo::record(void) | |||
344 | 331 | ||
345 | while(recording) | 332 | while(recording) |
346 | { | 333 | { |
347 | result = read(dsp, sound, 8192); | 334 | result = read(dsp, sound, 512); // 8192 |
335 | qApp->processEvents(); | ||
348 | write(wav, sound, result); | 336 | write(wav, sound, result); |
337 | qApp->processEvents(); | ||
349 | length += result; | 338 | length += result; |
350 | qApp->processEvents(); | 339 | qApp->processEvents(); |
351 | } | 340 | } |
@@ -364,5 +353,8 @@ void VMemo::record(void) | |||
364 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 353 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
365 | ::close(dsp); | 354 | ::close(dsp); |
366 | 355 | ||
356 | qWarning("VMemo::record() -> playing done recording sound"); | ||
357 | QSound::play(Resource::findSound("vmemoe")); | ||
367 | qWarning("VMemo::record() -> terminating"); | 358 | qWarning("VMemo::record() -> terminating"); |
359 | QMessageBox::information(0, "VMemo", "Recording Done", 1); | ||
368 | } | 360 | } |