Chromium Code Reviews| Index: webkit/media/audio_decoder.cc |
| =================================================================== |
| --- webkit/media/audio_decoder.cc (revision 160749) |
| +++ webkit/media/audio_decoder.cc (working copy) |
| @@ -40,7 +40,6 @@ |
| size_t number_of_channels = reader.channels(); |
| double file_sample_rate = reader.sample_rate(); |
| - double duration = reader.duration().InSecondsF(); |
| size_t number_of_frames = static_cast<size_t>(reader.number_of_frames()); |
|
DaleCurtis
2012/10/12 22:42:02
Unnecessary static_cast.
Chris Rogers
2012/10/12 23:22:29
Done.
DaleCurtis
2012/10/13 01:10:35
Doesn't look changed in the latest patch set?
|
| // Apply sanity checks to make sure crazy values aren't coming out of |
| @@ -51,14 +50,6 @@ |
| file_sample_rate > media::limits::kMaxSampleRate) |
| return false; |
| - DVLOG(1) << "Decoding file data -" |
| - << " data: " << data |
| - << " data size: " << data_size |
| - << " duration: " << duration |
| - << " number of frames: " << number_of_frames |
| - << " sample rate: " << file_sample_rate |
| - << " number of channels: " << number_of_channels; |
| - |
| // Allocate and configure the output audio channel data. |
| destination_bus->initialize(number_of_channels, |
| number_of_frames, |
| @@ -75,7 +66,26 @@ |
| number_of_frames, audio_data); |
| // Decode the audio file data. |
| - return reader.Read(audio_bus.get()); |
| + size_t actual_frames = static_cast<size_t>(reader.Read(audio_bus.get())); |
|
DaleCurtis
2012/10/12 22:42:02
This only works for down sizing and not up sizing
Chris Rogers
2012/10/12 23:22:29
Added TODO that this case is still not handled. T
|
| + |
| + // Adjust WebKit's bus to account for the actual file length |
| + // and valid data read. |
| + if (actual_frames != number_of_frames) { |
| + DCHECK_LE(actual_frames, number_of_frames); |
|
DaleCurtis
2012/10/12 22:42:02
2 space indent.
Chris Rogers
2012/10/12 23:22:29
Done.
|
| + destination_bus->resize(actual_frames); |
| + } |
| + |
| + double duration = actual_frames / file_sample_rate; |
| + |
| + DVLOG(1) << "Decoded file data -" |
| + << " data: " << data |
| + << " data size: " << data_size |
| + << " duration: " << duration |
| + << " number of frames: " << actual_frames |
| + << " sample rate: " << file_sample_rate |
| + << " number of channels: " << number_of_channels; |
| + |
| + return actual_frames > 0; |
| } |
| } // namespace webkit_media |