| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/audio/win/audio_low_latency_output_win.h" | 5 #include "media/audio/win/audio_low_latency_output_win.h" |
| 6 | 6 |
| 7 #include <Functiondiscoverykeys_devpkey.h> | 7 #include <Functiondiscoverykeys_devpkey.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 num_written_frames_ + packet_size_frames_; | 491 num_written_frames_ + packet_size_frames_; |
| 492 | 492 |
| 493 // Derive the actual delay value which will be fed to the | 493 // Derive the actual delay value which will be fed to the |
| 494 // render client using the OnMoreData() callback. | 494 // render client using the OnMoreData() callback. |
| 495 audio_delay_bytes = (pos_last_sample_written_frames - | 495 audio_delay_bytes = (pos_last_sample_written_frames - |
| 496 pos_sample_playing_frames) * format_.Format.nBlockAlign; | 496 pos_sample_playing_frames) * format_.Format.nBlockAlign; |
| 497 } | 497 } |
| 498 | 498 |
| 499 // Read a data packet from the registered client source and | 499 // Read a data packet from the registered client source and |
| 500 // deliver a delay estimate in the same callback to the client. | 500 // deliver a delay estimate in the same callback to the client. |
| 501 // A time stamp is also stored in the AudioBuffersState. This |
| 502 // time stamp can be used at the client side to compensate for |
| 503 // the delay between the usage of the delay value and the time |
| 504 // of generation. |
| 501 | 505 |
| 502 int frames_filled = source_->OnMoreData( | 506 int frames_filled = source_->OnMoreData( |
| 503 audio_bus_.get(), audio_delay_bytes); | 507 audio_bus_.get(), AudioBuffersState(0, audio_delay_bytes)); |
| 504 uint32 num_filled_bytes = frames_filled * format_.Format.nBlockAlign; | 508 uint32 num_filled_bytes = frames_filled * format_.Format.nBlockAlign; |
| 505 DCHECK_LE(num_filled_bytes, packet_size_bytes_); | 509 DCHECK_LE(num_filled_bytes, packet_size_bytes_); |
| 506 | 510 |
| 507 // Note: If this ever changes to output raw float the data must be | 511 // Note: If this ever changes to output raw float the data must be |
| 508 // clipped and sanitized since it may come from an untrusted | 512 // clipped and sanitized since it may come from an untrusted |
| 509 // source such as NaCl. | 513 // source such as NaCl. |
| 510 const int bytes_per_sample = format_.Format.wBitsPerSample >> 3; | 514 const int bytes_per_sample = format_.Format.wBitsPerSample >> 3; |
| 511 audio_bus_->Scale(volume_); | 515 audio_bus_->Scale(volume_); |
| 512 audio_bus_->ToInterleaved( | 516 audio_bus_->ToInterleaved( |
| 513 frames_filled, bytes_per_sample, audio_data); | 517 frames_filled, bytes_per_sample, audio_data); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 620 |
| 617 // Ensure that we don't quit the main thread loop immediately next | 621 // Ensure that we don't quit the main thread loop immediately next |
| 618 // time Start() is called. | 622 // time Start() is called. |
| 619 ResetEvent(stop_render_event_.Get()); | 623 ResetEvent(stop_render_event_.Get()); |
| 620 } | 624 } |
| 621 | 625 |
| 622 source_ = NULL; | 626 source_ = NULL; |
| 623 } | 627 } |
| 624 | 628 |
| 625 } // namespace media | 629 } // namespace media |
| OLD | NEW |