author | llornkcor <llornkcor> | 2002-04-27 04:33:57 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-27 04:33:57 (UTC) |
commit | e2f3288d468508f2cf7c0a327044963ca4b1b54a (patch) (side-by-side diff) | |
tree | d149829fdc65a58b6feb200868bd0f28c5f37cd0 | |
parent | 8ca9c8dad17ccaee9b0b8132324176c2a8e40526 (diff) | |
download | opie-e2f3288d468508f2cf7c0a327044963ca4b1b54a.zip opie-e2f3288d468508f2cf7c0a327044963ca4b1b54a.tar.gz opie-e2f3288d468508f2cf7c0a327044963ca4b1b54a.tar.bz2 |
bug fix
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 4b668de..ec46340 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -1,124 +1,124 @@ /************************************************************************************ ** ** 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. ** ************************************************************************************/ /* * $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> -#include <string.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 (chunckSize) format len */ u_short format; /* should be 1 for PCM-code (formatTag) */ u_short modus; /* 1 Mono, 2 Stereo (channels) */ u_long sample_fq; /* samples per second (samplesPerSecond) */ u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ u_long data_chunk; /* 'data' */ u_long data_length;/* samplecount */ } WaveHeader; #define RIFF 0x46464952 #define WAVE 0x45564157 #define FMT 0x20746D66 #define DATA 0x61746164 #define PCM_CODE 1 #define WAVE_MONO 1 #define WAVE_STEREO 2 #include "vmemo.h" #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpainter.h> #include <qdatetime.h> #include <qsound.h> #include <qfile.h> #include <qmessagebox.h> int seq = 0; /* XPM */ static char * vmemo_xpm[] = { "16 16 102 2", " c None", ". c #60636A", "+ c #6E6E72", "@ c #68696E", "# c #4D525C", "$ c #6B6C70", "% c #E3E3E8", "& c #EEEEF2", "* c #EAEAEF", "= c #CACAD0", "- c #474A51", "; c #171819", "> c #9B9B9F", ", c #EBEBF0", "' c #F4F4F7", ") c #F1F1F5", "! c #DEDEE4", "~ c #57575C", "{ c #010101", "] c #A2A2A6", "^ c #747477", "/ c #B5B5B8", "( c #AEAEB2", "_ c #69696D", ": c #525256", "< c #181C24", "[ c #97979B", "} c #A7A7AC", "| c #B0B0B4", "1 c #C8C8D1", "2 c #75757B", "3 c #46464A", "4 c #494A4F", "5 c #323234", "6 c #909095", "7 c #39393B", "8 c #757578", "9 c #87878E", "0 c #222224", "a c #414144", "b c #6A6A6E", "c c #020C16", "d c #6B6B6F", "e c #68686D", "f c #5B5B60", "g c #8A8A8F", "h c #6B6B6E", "i c #ADADB2", "j c #828289", "k c #3E3E41", @@ -200,193 +200,193 @@ VMemo::VMemo( QWidget *parent, const char *_name ) recording = FALSE; struct utsname name; /* check for embedix kernel running on the zaurus*/ if (uname(&name) != -1) { QString release=name.release; if(release.find("embedix",0,TRUE) !=-1) systemZaurus=TRUE; else { systemZaurus=FALSE; myChannel = new QCopChannel( "QPE/VMemo", this ); connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); // // Register the REC key press, for ipaq only QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); e << 4096; e << QString("QPE/VMemo"); e << QString("toggleRecord()"); } } } VMemo::~VMemo() { } void VMemo::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if (msg == "toggleRecord()") { if (recording) 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 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(); QString fName; Config cfg( "Sound" ); cfg.setGroup( "System" ); fName = QPEApplication::documentDir() ; fileName = cfg.readEntry("RecLocation", fName); int s; s=fileName.find(':'); if(s) fileName=fileName.right(fileName.length()-s-2); qDebug("filename will be "+fileName); - if( !fileName.right(1).find('/') == -1) + if( fileName.right(1).find('/') == -1) fileName+="/"; // if(systemZaurus) // fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs // else // fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); fName = "vm_"+ dt.toString()+ ".wav"; fileName+=fName; qDebug("filename is "+fileName); // No spaces in the filename fileName.replace(QRegExp("'"),""); fileName.replace(QRegExp(" "),"_"); fileName.replace(QRegExp(":"),"."); fileName.replace(QRegExp(","),""); if(openWAV(fileName.latin1()) == -1) { QString err("Could not open the output file\n"); err += fileName; QMessageBox::critical(0, "VMemo", err, "Abort"); close(dsp); return; } QArray<int> cats(1); cats[0] = vmCfg.readNumEntry("Category", 0); QString dlName("vm_"); dlName += dt.toString(); DocLnk l; l.setFile(fileName); l.setName(dlName); l.setType("audio/x-wav"); l.setCategories(cats); l.writeLink(); record(); } void VMemo::mouseReleaseEvent( QMouseEvent * ) { recording = FALSE; } int VMemo::openDSP() { Config cfg("Sound"); cfg.setGroup("Record"); speed = cfg.readNumEntry("SampleRate", 22050); channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) if (cfg.readNumEntry("SixteenBit", 1)==1) { format = AFMT_S16_LE; resolution = 16; } else { format = AFMT_U8; resolution = 8; } qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); if(systemZaurus) { dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 channels=1; //zaurus has one input channel } else { dsp = open("/dev/dsp", O_RDWR); } if(dsp == -1) { perror("open(\"/dev/dsp\")"); errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); return -1; } if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); errorMsg="ioctl(\"SNDCTL_DSP_SETFMT\")\n%d\n"+(QString)strerror(errno),format; return -1; } if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); errorMsg="ioctl(\"SNDCTL_DSP_CHANNELS\")\n%d\n"+(QString)strerror(errno),channels; return -1; } if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { perror("ioctl(\"SNDCTL_DSP_SPEED\")"); errorMsg="ioctl(\"SNDCTL_DSP_SPEED\")\n%d\n"+(QString)strerror(errno),speed; return -1; } if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { perror("ioctl(\"SOUND_PCM_READ_RATE\")"); errorMsg="ioctl(\"SOUND_PCM_READ_RATE\")\n%d\n"+(QString)strerror(errno),rate; return -1; } |