Check return result of fwrite, [APM]

Description:
This cl added checking return result of fwrite which makes it compile
on ChromeOS/ARM.

BUG=issue:541
TEST=Build on all platforms
Review URL: https://webrtc-codereview.appspot.com/583009

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2302 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
leozwang@webrtc.org 2012-05-25 19:20:35 +00:00
parent f14575fd8e
commit 1755a57cbc
3 changed files with 36 additions and 12 deletions

View File

@ -686,8 +686,14 @@ static void ProcessBlock(aec_t* aec) {
int16_t farend[PART_LEN]; int16_t farend[PART_LEN];
int16_t* farend_ptr = NULL; int16_t* farend_ptr = NULL;
WebRtc_ReadBuffer(aec->far_time_buf, (void**) &farend_ptr, farend, 1); WebRtc_ReadBuffer(aec->far_time_buf, (void**) &farend_ptr, farend, 1);
fwrite(farend_ptr, sizeof(int16_t), PART_LEN, aec->farFile); if (fwrite(farend_ptr, sizeof(int16_t),
fwrite(nearend_ptr, sizeof(int16_t), PART_LEN, aec->nearFile); PART_LEN, aec->farFile) != PART_LEN) {
return -1;
}
if (fwrite(nearend_ptr, sizeof(int16_t),
PART_LEN, aec->nearFile) != PART_LEN) {
return -1;
}
} }
#endif #endif
@ -844,8 +850,14 @@ static void ProcessBlock(aec_t* aec) {
WEBRTC_SPL_WORD16_MIN); WEBRTC_SPL_WORD16_MIN);
} }
fwrite(eInt16, sizeof(int16_t), PART_LEN, aec->outLinearFile); if (fwrite(eInt16, sizeof(int16_t),
fwrite(output, sizeof(int16_t), PART_LEN, aec->outFile); PART_LEN, aec->outLinearFile) != PART_LEN) {
return -1;
}
if (fwrite(output, sizeof(int16_t),
PART_LEN, aec->outFile) != PART_LEN) {
return -1;
}
} }
#endif #endif
} }

View File

@ -404,7 +404,10 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst, const WebRtc_Word16 *nearend,
} }
#ifdef WEBRTC_AEC_DEBUG_DUMP #ifdef WEBRTC_AEC_DEBUG_DUMP
fwrite(&aecpc->skew, sizeof(aecpc->skew), 1, aecpc->skewFile); if (fwrite(&aecpc->skew, sizeof(aecpc->skew),
1, aecpc->skewFile) != 1) {
return -1;
}
#endif #endif
} }
} }
@ -537,8 +540,13 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst, const WebRtc_Word16 *nearend,
{ {
int16_t far_buf_size_ms = (int16_t) (aecpc->aec->system_delay / int16_t far_buf_size_ms = (int16_t) (aecpc->aec->system_delay /
(sampMsNb * aecpc->aec->mult)); (sampMsNb * aecpc->aec->mult));
fwrite(&far_buf_size_ms, 2, 1, aecpc->bufFile); if (fwrite(&far_buf_size_ms, 2, 1, aecpc->bufFile) != 1) {
fwrite(&(aecpc->knownDelay), sizeof(aecpc->knownDelay), 1, aecpc->delayFile); return -1;
}
if (fwrite(&(aecpc->knownDelay), sizeof(aecpc->knownDelay),
1, aecpc->delayFile) != 1) {
return -1;
}
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
* *
* Use of this source code is governed by a BSD-style license * Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source * that can be found in the LICENSE file in the root of the source
@ -1887,7 +1887,10 @@ int WebRtcNsx_ProcessCore(NsxInst_t* inst, short* speechFrame, short* speechFram
assert(inst->magnLen == inst->anaLen2 + 1); assert(inst->magnLen == inst->anaLen2 + 1);
#ifdef NS_FILEDEBUG #ifdef NS_FILEDEBUG
fwrite(spframe, sizeof(short), inst->blockLen10ms, inst->infile); if (fwrite(spframe, sizeof(short),
inst->blockLen10ms, inst->infile) != inst->blockLen10ms) {
return -1;
}
#endif #endif
// Check that initialization has been done // Check that initialization has been done
@ -2364,7 +2367,10 @@ int WebRtcNsx_ProcessCore(NsxInst_t* inst, short* speechFrame, short* speechFram
WebRtcNsx_DataSynthesis(inst, outFrame); WebRtcNsx_DataSynthesis(inst, outFrame);
#ifdef NS_FILEDEBUG #ifdef NS_FILEDEBUG
fwrite(outframe, sizeof(short), inst->blockLen10ms, inst->outfile); if (fwrite(outframe, sizeof(short),
inst->blockLen10ms, inst->outfile) != inst->blockLen10ms) {
return -1;
}
#endif #endif
//for H band: //for H band:
@ -2440,5 +2446,3 @@ int WebRtcNsx_ProcessCore(NsxInst_t* inst, short* speechFrame, short* speechFram
return 0; return 0;
} }