author | llornkcor <llornkcor> | 2002-02-14 02:13:19 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-14 02:13:19 (UTC) |
commit | 9c6a0c5da964dae08f3d9299fa5a47446f9977e2 (patch) (side-by-side diff) | |
tree | daa708f7da56a32bad5f7ecfd57191abb7ae6990 | |
parent | a3b4e55734b9a1d2b1f2f7278caa165138dd2aa2 (diff) | |
download | opie-9c6a0c5da964dae08f3d9299fa5a47446f9977e2.zip opie-9c6a0c5da964dae08f3d9299fa5a47446f9977e2.tar.gz opie-9c6a0c5da964dae08f3d9299fa5a47446f9977e2.tar.bz2 |
added runtime check for zaurus kernel
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 32 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 2 |
2 files changed, 21 insertions, 13 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 6f04c66..6bd1622 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -1,32 +1,33 @@ /**************************************************************************************94x78** ** ** 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$ */ +#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> typedef struct _waveheader { u_long main_chunk; /* 'RIFF' */ u_long length; /* filelen */ u_long chunk_type; /* 'WAVE' */ @@ -123,69 +124,79 @@ static char * vmemo_xpm[] = { " ./:@<[)", " }. .|]1;;2 ", " #-$;^/3&;;4@ ", ".$;;#5:67;89 ", ":%;0%&ab;8. ", "@cd%e!fg49 ", " h0,!_;2@ ", " ))))) "}; VMemo::VMemo( QWidget *parent, const char *name ) : QWidget( parent, name ) { setFixedHeight( 18 ); setFixedWidth( 14 ); recording = FALSE; + + struct utsname name; //check for embedix kernel running on the zaurus, if lineo change string, this break + if (uname(&name) != -1) { + QString release=name.release; + if(release.find("embedix",0,TRUE) !=-1) { + systemZaurus=TRUE; + printf("System release: %s\n", name.release); + } else + systemZaurus=FALSE; + } + } VMemo::~VMemo() { } void VMemo::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); } void VMemo::mousePressEvent( QMouseEvent * ) { qWarning("VMemo::mousePress()"); QSound::play(Resource::findSound("vmemob")); recording = TRUE; qWarning("VMemo::mousePress() -> Starting to record"); if (openDSP() == -1) { // ### Display an error box qWarning("VMemo::mousePress() -> DSP error"); recording = FALSE; return; } Config vmCfg("VMemo"); vmCfg.setGroup("Defaults"); QDateTime dt = QDateTime::currentDateTime(); - -#if defined(QT_QWS_EBX) //if zaurus - QString fileName(vmCfg.readEntry("Dir", "/mnt/cf/")); // zaurus does not have /mnt/ramfs -#else - QString fileName(vmCfg.readEntry("Dir", "/mnt/ramfs/")); -#endif + QString fileName; + if(systemZaurus) + fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs + else + fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); fileName += "vm_"; fileName += dt.toString(); fileName += ".wav"; // No spaces in the filename fileName.replace(QRegExp("'"),""); fileName.replace(QRegExp(" "),"_"); fileName.replace(QRegExp(":"),"."); fileName.replace(QRegExp(","),""); if(openWAV(fileName.latin1()) == -1) { // ### Display an error box qWarning("VMemo::mousePress() -> WAV error"); close(dsp); @@ -219,39 +230,36 @@ int VMemo::openDSP() Config cfg("Sound"); cfg.setGroup("Record"); speed = cfg.readNumEntry("SampleRate", 11025); channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) if (cfg.readNumEntry("SixteenBit", 1)) { format = AFMT_S16_LE; resolution = 16; } else { format = AFMT_U8; resolution = 8; } -#if defined(QT_QWS_EBX) //if zaurus - //dsp = open("/dev/dsp1", O_RDONLY); //on the Zaurus this needs to be /dev/dsp1 !!!! - dsp = open("/dev/dsp1", O_RDWR); //on the Zaurus this needs to be /dev/dsp1 !!!! -#else - //dsp = open("/dev/dsp", O_RDONLY); + if(systemZaurus) + dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 + else dsp = open("/dev/dsp", O_RDWR); -#endif qWarning("speed = %i", speed); if(dsp == -1) { perror("open(\"/dev/dsp\")"); return -1; } if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); return -1; } if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); return -1; diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h index 9ce08f2..ee375b0 100644 --- a/core/applets/vmemo/vmemo.h +++ b/core/applets/vmemo/vmemo.h @@ -28,23 +28,23 @@ class VMemo : public QWidget public: VMemo( QWidget *parent, const char *name = NULL); ~VMemo(); QFile track; public slots: void record(); void mousePressEvent( QMouseEvent * ); void mouseReleaseEvent( QMouseEvent * ); private: void paintEvent( QPaintEvent* ); int openDSP(); int openWAV(const char *filename); QPixmap vmemoPixmap; - + bool systemZaurus; int dsp, wav, rate, speed, channels, format, resolution; bool recording; }; #endif // __VMEMO_H__ |