Reland "Trim down FileWrapper class to be merely a wrapper owning a FILE*"
This is a reland of 80b95de7651caa0cfeb684ffc200860989f667dc Original change's description: > Trim down FileWrapper class to be merely a wrapper owning a FILE* > > Bug: webrtc:6463 > Change-Id: If71e2f3a75dc1863bc805ab71de1e2d33294f805 > Reviewed-on: https://webrtc-review.googlesource.com/c/117881 > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > Reviewed-by: Alex Loiko <aleloi@webrtc.org> > Commit-Queue: Niels Moller <nisse@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#26311} Bug: webrtc:6463 Change-Id: I12154ef65744c1b7811974a1d871e05ed3fbbc27 Reviewed-on: https://webrtc-review.googlesource.com/c/118660 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26337}
This commit is contained in:
@ -39,16 +39,14 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<FileWrapper> pcm_file(FileWrapper::Create());
|
||||
pcm_file->OpenFile(argv[1], true);
|
||||
if (!pcm_file->is_open()) {
|
||||
FileWrapper pcm_file = FileWrapper::OpenReadOnly(argv[1]);
|
||||
if (!pcm_file.is_open()) {
|
||||
printf("\nThe %s could not be opened.\n\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::unique_ptr<FileWrapper> dat_file(FileWrapper::Create());
|
||||
dat_file->OpenFile(argv[2], false);
|
||||
if (!dat_file->is_open()) {
|
||||
FileWrapper dat_file = FileWrapper::OpenWriteOnly(argv[2]);
|
||||
if (!dat_file.is_open()) {
|
||||
printf("\nThe %s could not be opened.\n\n", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
@ -73,7 +71,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Read first buffer from the PCM test file.
|
||||
size_t file_samples_read = ReadInt16FromFileToFloatBuffer(
|
||||
pcm_file.get(), audio_buffer_length, audio_buffer.get());
|
||||
&pcm_file, audio_buffer_length, audio_buffer.get());
|
||||
for (int time = 0; file_samples_read > 0; time += chunk_size_ms) {
|
||||
// Pad the rest of the buffer with zeros.
|
||||
for (size_t i = file_samples_read; i < audio_buffer_length; ++i) {
|
||||
@ -91,19 +89,19 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Read next buffer from the PCM test file.
|
||||
file_samples_read = ReadInt16FromFileToFloatBuffer(
|
||||
pcm_file.get(), audio_buffer_length, audio_buffer.get());
|
||||
&pcm_file, audio_buffer_length, audio_buffer.get());
|
||||
}
|
||||
|
||||
size_t floats_written =
|
||||
WriteFloatBufferToFile(dat_file.get(), send_times.size(), &send_times[0]);
|
||||
WriteFloatBufferToFile(&dat_file, send_times.size(), &send_times[0]);
|
||||
|
||||
if (floats_written == 0) {
|
||||
printf("\nThe send times could not be written to DAT file\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pcm_file->CloseFile();
|
||||
dat_file->CloseFile();
|
||||
pcm_file.Close();
|
||||
dat_file.Close();
|
||||
|
||||
return lost_packets;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user