summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-15 02:40:16 (UTC)
committer llornkcor <llornkcor>2002-02-15 02:40:16 (UTC)
commitb429144b79049fcc25dfff5a9a38415451399e58 (patch) (side-by-side diff)
treee6a6bf929667e3c5a521145809b2615bb4b0c6e9
parente5ac946b3ced52f4aba73dfc64398bb3d8245734 (diff)
downloadopie-b429144b79049fcc25dfff5a9a38415451399e58.zip
opie-b429144b79049fcc25dfff5a9a38415451399e58.tar.gz
opie-b429144b79049fcc25dfff5a9a38415451399e58.tar.bz2
forgot length in header
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 25ee476..bba55a3 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -262,96 +262,97 @@ int VMemo::openDSP()
}
else
dsp = open("/dev/dsp", O_RDWR);
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;
}
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;
}
return 1;
}
int VMemo::openWAV(const char *filename)
{
qDebug("Creating %s ",filename);
track.setName(filename);
if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw))
{
qDebug("Could not open file");
return -1;
}
wav=track.handle();
WaveHeader wh;
wh.main_chunk = RIFF;// RIFF
+ wh.length=0; /* filelen */
wh.chunk_type = WAVE;//WAVE
wh.sub_chunk = FMT;// fmt
wh.sc_len = 16;// format length = 16
wh.format = PCM_CODE;// PCM
wh.modus = channels;// channels
wh.sample_fq = speed;//samplerate
wh.byte_p_sec = speed * channels * resolution/8;// av bytes per second
wh.byte_p_spl = channels * (resolution / 8); //block align
wh.bit_p_spl = resolution;//bits per sample 8, or 16
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;
}
void VMemo::record(void)
{
int length=0, result, value;
char sound[8192];
qWarning("VMemo::record()");
while(recording)
{
result = read(dsp, sound, 512); // 8192
qApp->processEvents();
write(wav, sound, result);
qApp->processEvents();
length += result;
qApp->processEvents();
// printf("%d\r",length);
// fflush(stdout);
}
qWarning("VMemo::record() -> Done recording");
qWarning("VMemo::record() -> Closing dsp");
value = length+36;
lseek(wav, 4, SEEK_SET);
write(wav, &value, 4);
lseek(wav, 40, SEEK_SET);
write(wav, &length, 4);
// qDebug("File length %d, samplecount %d", value, length);
track.close();