summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-29 12:18:47 (UTC)
committer llornkcor <llornkcor>2002-07-29 12:18:47 (UTC)
commitb4827a8b268af9d1485455cdf727f564047f396e (patch) (side-by-side diff)
treee4cfe0063c4130337d46bce247e0430bf37ce70d
parentb79ef334c6d13beb4fe7fff1e6985c081081a2f6 (diff)
downloadopie-b4827a8b268af9d1485455cdf727f564047f396e.zip
opie-b4827a8b268af9d1485455cdf727f564047f396e.tar.gz
opie-b4827a8b268af9d1485455cdf727f564047f396e.tar.bz2
fix bug number 140
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 035965e..0c792c6 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -461,48 +461,49 @@ int VMemo::openDSP() {
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();
+ 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)
wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE;
else
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.bit_p_spl = resolution;
wh.data_chunk = DATA;
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;
@@ -510,91 +511,91 @@ int VMemo::openWAV(const char *filename) {
bool VMemo::record() {
int length=0, result, value;
QString msg;
msg.sprintf("Recording format %d", format);
qDebug(msg);
Config config("Vmemo");
config.setGroup("Record");
int sRate=config.readNumEntry("SizeLimit", 30);
if(sRate > 0)
t_timer->start( sRate * 1000+1000, TRUE);
// if(systemZaurus) {
// } else { // 16 bit only capabilities
msg.sprintf("Recording format other");
qDebug(msg);
int bufsize=1024;
int bytesWritten=0;
signed short sound[1024], monoBuffer[1024];
char abuf[bufsize/2];
short sbuf[bufsize];
+ useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
while(recording) {
if(useADPCM)
result = read( dsp, sbuf, bufsize); // 8192
else
result = read(dsp, sound, 1024); // 8192
if( result <= 0) {
perror("recording error ");
// qDebug(currentFileName);
QMessageBox::message(tr("Note"),tr("error recording"));
recording=FALSE;
break;
return FALSE;
}
if(useADPCM) {
adpcm_coder( sbuf, abuf, result/2, &encoder_state);
bytesWritten = ::write(wav, abuf, result/4);
} else {
for (int i = 0; i < result; i++) { //since Z is mono do normally
monoBuffer[i] = sound[i];
}
length+=write(wav, monoBuffer, result);
}
length +=bytesWritten;
if(length<0) {
recording=false;
perror("dev/dsp's is a lookin' messy");
QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
break;
return FALSE;
}
// printf("%d\r",length);
// fflush(stdout);
qApp->processEvents();
}
// qDebug("file has length of %d lasting %d seconds",
// length, (( length / speed) / channels) / 2 );
- // medialplayer states wrong length in secs
// }
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<//
value = length+36;
lseek(wav, 4, SEEK_SET);
write(wav, &value, 4);
lseek(wav, 40, SEEK_SET);
write(wav, &length, 4);
track.close();
qDebug("Track closed");
if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
perror("ioctl(\"SNDCTL_DSP_RESET\")");
::close(dsp);
fileName = fileName.left(fileName.length()-4);
// if(useAlerts)
// QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
qDebug("done recording "+fileName);