summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp
index fc0130c..360b884 100644
--- a/noncore/multimedia/opierec/wavFile.cpp
+++ b/noncore/multimedia/opierec/wavFile.cpp
@@ -153,7 +153,5 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) {
153 153
154 write( fd,hdr, sizeof(*hdr)); 154 write( fd,hdr, sizeof(*hdr));
155 odebug << "writing header: bitrate " << wavResolution 155 odebug << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl;
156 << ", samplerate " << wavSampleRate
157 << ", channels " << wavChannels << oendl;
158 return true; 156 return true;
159} 157}
@@ -178,18 +176,18 @@ int WavFile::parseWavHeader(int fd) {
178 176
179 if (read(fd, string, 4) < 4) { 177 if (read(fd, string, 4) < 4) {
180 odebug << " Could not read from sound file.\n" << oendl; 178 odebug << " Could not read from sound file." << oendl;
181 return -1; 179 return -1;
182 } 180 }
183 if (strncmp(string, "RIFF", 4)) { 181 if (strncmp(string, "RIFF", 4)) {
184 odebug << " not a valid WAV file.\n" << oendl; 182 odebug << " not a valid WAV file." << oendl;
185 return -1; 183 return -1;
186 } 184 }
187 lseek(fd, 4, SEEK_CUR); 185 lseek(fd, 4, SEEK_CUR);
188 if (read(fd, string, 4) < 4) { 186 if (read(fd, string, 4) < 4) {
189 odebug << "Could not read from sound file.\n" << oendl; 187 odebug << "Could not read from sound file." << oendl;
190 return -1; 188 return -1;
191 } 189 }
192 if (strncmp(string, "WAVE", 4)) { 190 if (strncmp(string, "WAVE", 4)) {
193 odebug << "not a valid WAV file.\n" << oendl; 191 odebug << "not a valid WAV file." << oendl;
194 return -1; 192 return -1;
195 } 193 }
@@ -198,10 +196,10 @@ int WavFile::parseWavHeader(int fd) {
198 while (!found) { 196 while (!found) {
199 if (read(fd, string, 4) < 4) { 197 if (read(fd, string, 4) < 4) {
200 odebug << "Could not read from sound file.\n" << oendl; 198 odebug << "Could not read from sound file." << oendl;
201 return -1; 199 return -1;
202 } 200 }
203 if (strncmp(string, "fmt ", 4)) { 201 if (strncmp(string, "fmt ", 4)) {
204 if (read(fd, &longdata, 4) < 4) { 202 if (read(fd, &longdata, 4) < 4) {
205 odebug << "Could not read from sound file.\n" << oendl; 203 odebug << "Could not read from sound file." << oendl;
206 return -1; 204 return -1;
207 } 205 }
@@ -210,9 +208,9 @@ int WavFile::parseWavHeader(int fd) {
210 lseek(fd, 4, SEEK_CUR); 208 lseek(fd, 4, SEEK_CUR);
211 if (read(fd, &fmt, 2) < 2) { 209 if (read(fd, &fmt, 2) < 2) {
212 odebug << "Could not read format chunk.\n" << oendl; 210 odebug << "Could not read format chunk." << oendl;
213 return -1; 211 return -1;
214 } 212 }
215 if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { 213 if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) {
216 odebug << "Wave file contains unknown format. Unable to continue.\n" << oendl; 214 odebug << "Wave file contains unknown format. Unable to continue." << oendl;
217 return -1; 215 return -1;
218 } 216 }
@@ -221,5 +219,5 @@ int WavFile::parseWavHeader(int fd) {
221 odebug << "compressionFormat is " << fmt << "" << oendl; 219 odebug << "compressionFormat is " << fmt << "" << oendl;
222 if (read(fd, &ch, 2) < 2) { 220 if (read(fd, &ch, 2) < 2) {
223 odebug << "Could not read format chunk.\n" << oendl; 221 odebug << "Could not read format chunk." << oendl;
224 return -1; 222 return -1;
225 } else { 223 } else {
@@ -228,5 +226,5 @@ int WavFile::parseWavHeader(int fd) {
228 } 226 }
229 if (read(fd, &samplerrate, 4) < 4) { 227 if (read(fd, &samplerrate, 4) < 4) {
230 odebug << "Could not read from format chunk.\n" << oendl; 228 odebug << "Could not read from format chunk." << oendl;
231 return -1; 229 return -1;
232 } else { 230 } else {
@@ -237,5 +235,5 @@ int WavFile::parseWavHeader(int fd) {
237 lseek(fd, 6, SEEK_CUR); 235 lseek(fd, 6, SEEK_CUR);
238 if (read(fd, &bitrate, 2) < 2) { 236 if (read(fd, &bitrate, 2) < 2) {
239 odebug << "Could not read format chunk.\n" << oendl; 237 odebug << "Could not read format chunk." << oendl;
240 return -1; 238 return -1;
241 } else { 239 } else {
@@ -250,5 +248,5 @@ int WavFile::parseWavHeader(int fd) {
250 while (!found) { 248 while (!found) {
251 if (read(fd, string, 4) < 4) { 249 if (read(fd, string, 4) < 4) {
252 odebug << "Could not read from sound file.\n" << oendl; 250 odebug << "Could not read from sound file." << oendl;
253 return -1; 251 return -1;
254 } 252 }
@@ -256,5 +254,5 @@ int WavFile::parseWavHeader(int fd) {
256 if (strncmp(string, "data", 4)) { 254 if (strncmp(string, "data", 4)) {
257 if (read(fd, &longdata, 4)<4) { 255 if (read(fd, &longdata, 4)<4) {
258 odebug << "Could not read from sound file.\n" << oendl; 256 odebug << "Could not read from sound file." << oendl;
259 return -1; 257 return -1;
260 } 258 }
@@ -263,9 +261,9 @@ int WavFile::parseWavHeader(int fd) {
263 } else { 261 } else {
264 if (read(fd, &longdata, 4) < 4) { 262 if (read(fd, &longdata, 4) < 4) {
265 odebug << "Could not read from sound file.\n" << oendl; 263 odebug << "Could not read from sound file." << oendl;
266 return -1; 264 return -1;
267 } else { 265 } else {
268 wavNumberSamples = longdata; 266 wavNumberSamples = longdata;
269 odebug << "file hase length of " << (int)longdata << "\n" 267 odebug << "file hase length of " << (int)longdata << ""
270 << "lasting " 268 << "lasting "
271 << (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) 269 << (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8))