summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-29 01:11:48 (UTC)
committer llornkcor <llornkcor>2002-06-29 01:11:48 (UTC)
commita5d9aa39940c14c477b9ef2887c8fd303fa6a0e4 (patch) (side-by-side diff)
tree471d9879766c1c39b5039478a23a20948b8d0325
parenta9e336965e1cccb41d3e9f5c31168c85cf4e7d36 (diff)
downloadopie-a5d9aa39940c14c477b9ef2887c8fd303fa6a0e4.zip
opie-a5d9aa39940c14c477b9ef2887c8fd303fa6a0e4.tar.gz
opie-a5d9aa39940c14c477b9ef2887c8fd303fa6a0e4.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 2d694d2..7965b59 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -212,192 +212,195 @@ VMemo::VMemo( QWidget *parent, const char *_name )
Config vmCfg("Vmemo");
vmCfg.setGroup("Defaults");
int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
qDebug("toggleKey %d", toggleKey);
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&)) );
if( toggleKey != -1 ) {
// QPEApplication::grabKeyboard();
QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
// e << 4096; // Key_Escape
// e << Key_F5; //4148
e << toggleKey;
e << QString("QPE/VMemo");
e << QString("toggleRecord()");
}
if( vmCfg.readNumEntry("hideIcon",0) == 1)
hide();
}
}
VMemo::~VMemo()
{
}
void VMemo::receive( const QCString &msg, const QByteArray &data )
{
qDebug("receive");
QDataStream stream( data, IO_ReadOnly );
if (msg == "toggleRecord()") {
if (recording) {
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 * )
{
startRecording();
}
void VMemo::mouseReleaseEvent( QMouseEvent * )
{
stopRecording();
}
bool VMemo::startRecording() {
if ( recording)
return FALSE;
Config config( "Vmemo" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert");
if(useAlerts) {
msgLabel = new QLabel( 0, "alertLabel" );
msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
msgLabel->show();
}
// if(useAlerts)
// QMessageBox::message("VMemo","Really Record?");//) ==1)
// return;
// } else {
// if (!systemZaurus )
// QSound::play(Resource::findSound("vmemob"));
// }
qDebug("Start recording engines");
recording = TRUE;
if (openDSP() == -1) {
// QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
// delete msgLabel;
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;
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 FALSE;
}
QArray<int> cats(1);
cats[0] = config.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();
// delete msgLabel;
return TRUE;
}
void VMemo::stopRecording() {
show();
qDebug("Stopped recording");
recording = FALSE;
if(useAlerts)
if( msgLabel) 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) {