summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-21 22:26:31 (UTC)
committer llornkcor <llornkcor>2002-09-21 22:26:31 (UTC)
commitb570ab8d46fc134f16d5959861869e36af50bd38 (patch) (side-by-side diff)
tree5aaaa321728b7b2f8f21c11b173d3f35b4ae4dcf
parentf4a389bf66404f7c7474c4ef27491f5910da550b (diff)
downloadopie-b570ab8d46fc134f16d5959861869e36af50bd38.zip
opie-b570ab8d46fc134f16d5959861869e36af50bd38.tar.gz
opie-b570ab8d46fc134f16d5959861869e36af50bd38.tar.bz2
close alert is dsp error
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 4c07b3a..226f058 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -264,99 +264,96 @@ void VMemo::receive( const QCString &msg, const QByteArray &data ) {
fromToggle = TRUE;
stopRecording();
} else {
fromToggle = TRUE;
startRecording();
}
}
}
void VMemo::paintEvent( QPaintEvent* ) {
QPainter p(this);
p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
}
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;
// }
if(!recording)
startRecording();
else
stopRecording();
}
void VMemo::mouseReleaseEvent( QMouseEvent * ) {
}
bool VMemo::startRecording() {
Config config( "Vmemo" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert",1);
if(useAlerts) {
msgLabel = new QLabel( 0, "alertLabel" );
msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
msgLabel->show();
}
qDebug("Start recording engines");
recording = TRUE;
if (openDSP() == -1) {
recording = FALSE;
- msgLabel=0;
- delete msgLabel;
-
return FALSE;
}
config.setGroup("Defaults");
QDateTime dt = QDateTime::currentDateTime();
QString fName;
config.setGroup( "System" );
fName = QPEApplication::documentDir() ;
fileName = config.readEntry("RecLocation", fName);
int s;
s=fileName.find(':');
if(s)
fileName=fileName.right(fileName.length()-s-2);
qDebug("pathname will be "+fileName);
if( fileName.left(1).find('/') == -1)
fileName="/"+fileName;
if( fileName.right(1).find('/') == -1)
fileName+="/";
fName = "vm_"+ dt.toString()+ ".wav";
fileName+=fName;
// No spaces in the filename
fileName.replace(QRegExp("'"),"");
fileName.replace(QRegExp(" "),"_");
fileName.replace(QRegExp(":"),".");
fileName.replace(QRegExp(","),"");
qDebug("filename is "+fileName);
// open tmp file here
char *pointer;
pointer=tmpnam(NULL);
qDebug("Opening tmp file %s",pointer);
if(openWAV(pointer ) == -1) {
// if(openWAV(fileName.latin1()) == -1) {
QString err("Could not open the temp file\n");
err += fileName;
QMessageBox::critical(0, "vmemo", err, "Abort");
::close(dsp);
return FALSE;
}
if( record() ) {
@@ -382,96 +379,100 @@ bool VMemo::startRecording() {
l.setCategories(cats);
l.writeLink();
return TRUE;
} else
return FALSE;
}
void VMemo::stopRecording() {
show();
qDebug("Stopped recording");
recording = FALSE;
if(useAlerts) {
msgLabel->close();
msgLabel=0;
delete msgLabel;
}
t_timer->stop();
Config cfg("Vmemo");
cfg.setGroup("Defaults");
if( cfg.readNumEntry("hideIcon",0) == 1 )
hide();
}
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)
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_RDONLY); //Zaurus needs /dev/dsp1
channels=1; //zaurus has one input channel
} else {
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);
QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
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;
}
if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
perror("ioctl(\"SNDCTL_DSP_SPEED\")");
return -1;
}
if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
perror("ioctl(\"SOUND_PCM_READ_RATE\")");
return -1;
}
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute
return 1;
}
int VMemo::openWAV(const char *filename) {
track.setName(filename);
if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
errorMsg=filename;
return -1;
}
wav=track.handle();
Config vmCfg("Vmemo");
vmCfg.setGroup("Defaults");
useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
WaveHeader wh;
wh.main_chunk = RIFF;
wh.length=0;
wh.chunk_type = WAVE;
wh.sub_chunk = FMT;
wh.sc_len = 16;
if(useADPCM)