Diffstat (limited to 'core/applets/vmemo/vmemo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 7dd5b4b..622b1df 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -13,4 +13,8 @@ // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + extern "C" { #include "adpcm.h" @@ -30,5 +34,5 @@ typedef struct _waveheader { u_long chunk_type; /* 'WAVE' */ u_long sub_chunk; /* 'fmt ' */ - u_long sc_len; /* length of sub_chunk, =16 + u_long sc_len; /* length of sub_chunk, =16 (chunckSize) format len */ u_short format; /* should be 1 for PCM-code (formatTag) */ @@ -199,8 +203,8 @@ VMemo::VMemo( QWidget *parent, const char *_name ) setFixedHeight( 18 ); setFixedWidth( 14 ); - + t_timer = new QTimer( this ); connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); - + Config vmCfg("Vmemo"); vmCfg.setGroup("Defaults"); @@ -208,10 +212,10 @@ VMemo::VMemo( QWidget *parent, const char *_name ) useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); - qDebug("toggleKey %d", toggleKey); + odebug << "toggleKey " << toggleKey << "" << oendl; if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) systemZaurus=TRUE; - else + else systemZaurus=FALSE; - + myChannel = new QCopChannel( "QPE/VMemo", this ); connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), @@ -246,5 +250,5 @@ int VMemo::position() void VMemo::receive( const QCString &msg, const QByteArray &data ) { - qDebug("receive"); + odebug << "receive" << oendl; QDataStream stream( data, IO_ReadOnly ); @@ -268,5 +272,5 @@ void VMemo::mousePressEvent( QMouseEvent * me) { /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions mousePressEvent and mouseReleaseEvent with a NULL parameter. */ - + // if (!systemZaurus && me != NULL) // return; @@ -294,5 +298,5 @@ bool VMemo::startRecording() { } - qDebug("Start recording engines"); + odebug << "Start recording engines" << oendl; recording = TRUE; @@ -301,5 +305,5 @@ bool VMemo::startRecording() { return FALSE; } - + config.setGroup("Defaults"); @@ -319,5 +323,5 @@ bool VMemo::startRecording() { if(s) fileName=fileName.right(fileName.length()-s-2); - qDebug("pathname will be "+fileName); + odebug << "pathname will be "+fileName << oendl; if( fileName.left(1).find('/') == -1) @@ -326,12 +330,12 @@ bool VMemo::startRecording() { fileName+="/"; fName = "vm_"+ date+ ".wav"; - + fileName+=fName; - qDebug("filename is "+fileName); + odebug << "filename is "+fileName << oendl; // open tmp file here char *pointer; - pointer=tmpnam(NULL); - qDebug("Opening tmp file %s",pointer); - + pointer=tmpnam(NULL); + odebug << "Opening tmp file " << pointer << "" << oendl; + if(openWAV(pointer ) == -1) { @@ -350,10 +354,10 @@ bool VMemo::startRecording() { cmd.sprintf("mv %s "+fileName, pointer); // move tmp file to regular file here - + system(cmd.latin1()); QArray<int> cats(1); cats[0] = config.readNumEntry("Category", 0); - + QString dlName("vm_"); dlName += date; @@ -367,10 +371,10 @@ bool VMemo::startRecording() { } else return FALSE; - + } void VMemo::stopRecording() { show(); - qDebug("Stopped recording"); + odebug << "Stopped recording" << oendl; recording = FALSE; if(useAlerts) { @@ -389,5 +393,5 @@ int VMemo::openDSP() { Config cfg("Vmemo"); cfg.setGroup("Record"); - + speed = cfg.readNumEntry("SampleRate", 22050); channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) @@ -400,5 +404,5 @@ int VMemo::openDSP() { } - qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); + odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; if(systemZaurus) { @@ -408,10 +412,10 @@ int VMemo::openDSP() { dsp = open("/dev/dsp", O_RDONLY); } - + if(dsp == -1) { msgLabel->close(); msgLabel=0; delete msgLabel; - + perror("open(\"/dev/dsp\")"); errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); @@ -419,5 +423,5 @@ int VMemo::openDSP() { return -1; } - + if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); @@ -438,5 +442,5 @@ int VMemo::openDSP() { QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute - + return 1; } @@ -453,9 +457,9 @@ int VMemo::openWAV(const char *filename) { vmCfg.setGroup("Defaults"); useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); - + WaveHeader wh; wh.main_chunk = RIFF; - wh.length=0; + wh.length=0; wh.chunk_type = WAVE; wh.sub_chunk = FMT; @@ -464,16 +468,16 @@ int VMemo::openWAV(const char *filename) { wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; else - wh.format = PCM_CODE; + wh.format = PCM_CODE; wh.modus = channels; wh.sample_fq = speed; wh.byte_p_sec = speed * channels * resolution/8; - wh.byte_p_spl = channels * (resolution / 8); + wh.byte_p_spl = channels * (resolution / 8); wh.bit_p_spl = resolution; wh.data_chunk = DATA; - wh.data_length= 0; + 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; } @@ -484,5 +488,5 @@ bool VMemo::record() { QString msg; msg.sprintf("Recording format %d", format); - qDebug(msg); + odebug << msg << oendl; Config config("Vmemo"); config.setGroup("Record"); @@ -495,5 +499,5 @@ bool VMemo::record() { msg.sprintf("Recording format other"); - qDebug(msg); + odebug << msg << oendl; int bufsize=1024; @@ -514,5 +518,5 @@ bool VMemo::record() { if( result <= 0) { perror("recording error "); -// qDebug(currentFileName); +// odebug << currentFileName << oendl; QMessageBox::message(tr("Note"),tr("error recording")); recording=FALSE; @@ -541,5 +545,5 @@ bool VMemo::record() { return FALSE; } - // printf("%d\r",length); + // odebug << "" << length << "\r" << oendl; // fflush(stdout); qApp->processEvents(); @@ -560,6 +564,6 @@ bool VMemo::record() { track.close(); - qDebug("Track closed"); - + odebug << "Track closed" << oendl; + if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) perror("ioctl(\"SNDCTL_DSP_RESET\")"); @@ -574,5 +578,5 @@ bool VMemo::record() { QString currentFileName = fileName; QString currentFile = "vm_"+ date; - + float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; @@ -584,9 +588,9 @@ bool VMemo::record() { time.sprintf("%.2f", numberOfRecordedSeconds); cfgO.writeEntry( currentFileName, time ); - // qDebug("writing config numberOfRecordedSeconds "+time); + // odebug << "writing config numberOfRecordedSeconds "+time << oendl; cfgO.write(); - qDebug("done recording "+fileName); + odebug << "done recording "+fileName << oendl; Config cfg("qpe"); @@ -603,30 +607,30 @@ int VMemo::setToggleButton(int tog) { switch (tog) { case 0: - return -1; - break; + return -1; + break; case 1: - return 0; - break; + return 0; + break; case 2: return Key_F24; //was Escape - break; + break; case 3: return Key_Space; - break; + break; case 4: return Key_F12; - break; + break; case 5: return Key_F9; - break; + break; case 6: return Key_F10; - break; + break; case 7: return Key_F11; - break; + break; case 8: return Key_F13; - break; + break; }; } |