summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-18 01:36:32 (UTC)
committer llornkcor <llornkcor>2002-05-18 01:36:32 (UTC)
commit441e976481ced45c4884f336b18c06111e1f2ebc (patch) (side-by-side diff)
tree6c5c31d578b29dd09ba9177c7e0cdf80fbcb7bb7
parent893358440deca10dfca9e19f38598dec2eb73c98 (diff)
downloadopie-441e976481ced45c4884f336b18c06111e1f2ebc.zip
opie-441e976481ced45c4884f336b18c06111e1f2ebc.tar.gz
opie-441e976481ced45c4884f336b18c06111e1f2ebc.tar.bz2
added jeremy's copyright, and maybe fixed or broke things for ipaq
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 118fcde..e14d532 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -1,35 +1,36 @@
/************************************************************************************
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
************************************************************************************/
+// copyright 2002 Jeremy Cowgar <jc@cowgar.com>
/*
* $Id$
*/
// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com>
#include <sys/utsname.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
typedef struct _waveheader {
u_long main_chunk; /* 'RIFF' */
u_long length; /* filelen */
u_long chunk_type; /* 'WAVE' */
u_long sub_chunk; /* 'fmt ' */
u_long sc_len; /* length of sub_chunk, =16
@@ -233,52 +234,52 @@ void VMemo::receive( const QCString &msg, const QByteArray &data )
mouseReleaseEvent(NULL);
else
mousePressEvent(NULL);
}
}
void VMemo::paintEvent( QPaintEvent* )
{
QPainter p(this);
p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
}
void VMemo::mousePressEvent( QMouseEvent *me )
{
// just to be safe
if (recording) {
recording = FALSE;
return;
}
/*
No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
mousePressEvent and mouseReleaseEvent with a NULL parameter.
*/
-#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
- if (!systemZaurus )
- return;
-#endif
+// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
+// if (!systemZaurus )
+// return;
+// #endif
Config config( "Sound" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert");
// if(useAlerts)
// QMessageBox::message("VMemo","Really Record?");//) ==1)
// return;
// } else {
if (!systemZaurus )
QSound::play(Resource::findSound("vmemob"));
// }
qDebug("Start recording");
recording = TRUE;
if (openDSP() == -1) {
QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
recording = FALSE;
return;
}
Config vmCfg("VMemo");
vmCfg.setGroup("Defaults");
QDateTime dt = QDateTime::currentDateTime();
@@ -415,110 +416,100 @@ int VMemo::openWAV(const char *filename)
wh.modus = channels;
wh.sample_fq = speed;
wh.byte_p_sec = speed * channels * resolution/8;
wh.byte_p_spl = channels * (resolution / 8);
wh.bit_p_spl = resolution;
wh.data_chunk = DATA;
wh.data_length= 0;
// qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d"
// , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl );
write (wav, &wh, sizeof(WaveHeader));
return 1;
}
void VMemo::record(void)
{
int length=0, result, value;
qDebug("Recording");
if(systemZaurus) {
signed short sound[512], monoBuffer[512];
if(format==AFMT_S16_LE) {
while(recording) {
result = read(dsp, sound, 512); // 8192
- qApp->processEvents();
int j=0;
if(systemZaurus) {
for (int i = 0; i < result; i++) { //since Z is mono do normally
monoBuffer[i] = sound[i];
}
- qApp->processEvents();
length+=write(wav, monoBuffer, result);
} else { //ipaq /stereo inputs
for (int i = 0; i < result; i+=2) {
monoBuffer[j] = (sound[i]+sound[i+1])/2;
j++;
}
- qApp->processEvents();
length+=write(wav, monoBuffer, result/2);
}
- printf("%d\r",length);
- fflush(stdout);
+// printf("%d\r",length);
+// fflush(stdout);
}
} else { //AFMT_U8
// 8bit unsigned
unsigned short sound[512], monoBuffer[512];
while(recording) {
result = read(dsp, sound, 512); // 8192
- qApp->processEvents();
int j=0;
if(systemZaurus) {
for (int i = 0; i < result; i++) { //since Z is mono do normally
monoBuffer[i] = sound[i];
}
- qApp->processEvents();
length+=write(wav, monoBuffer, result);
} else { //ipaq /stereo inputs
for (int i = 0; i < result; i+=2) {
monoBuffer[j] = (sound[i]+sound[i+1])/2;
j++;
}
- qApp->processEvents();
length+=write(wav, monoBuffer, result/2);
}
length += result;
- printf("%d\r",length);
- fflush(stdout);
-
- qApp->processEvents();
+// printf("%d\r",length);
+// fflush(stdout);
}
qApp->processEvents();
}
} else {
signed short sound[512], monoBuffer[512];
while(recording) {
result = read(dsp, sound, 512); // 8192
- qApp->processEvents();
-
write(wav, sound, result);
length += result;
qApp->processEvents();
}
- printf("%d\r",length);
- fflush(stdout);
+// printf("%d\r",length);
+// fflush(stdout);
// qDebug("file has length of %d lasting %d seconds",
// length, (( length / speed) / channels) / 2 );
// medialplayer states wrong length in secs
}
value = length+36;
lseek(wav, 4, SEEK_SET);
write(wav, &value, 4);
lseek(wav, 40, SEEK_SET);
write(wav, &length, 4);
track.close();
if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
perror("ioctl(\"SNDCTL_DSP_RESET\")");
::close(dsp);
fileName = fileName.left(fileName.length()-4);
if(useAlerts)
QMessageBox::message("Vmemo"," Done recording\n"+ fileName);
qDebug("done recording "+fileName);
QSound::play(Resource::findSound("vmemoe"));
}