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. | |
505 | 501 |
506 int frames_filled = source_->OnMoreData( | 502 int frames_filled = source_->OnMoreData( |
507 audio_bus_.get(), AudioBuffersState(0, audio_delay_bytes)); | 503 audio_bus_.get(), audio_delay_bytes); |
508 uint32 num_filled_bytes = frames_filled * format_.Format.nBlockAlign; | 504 uint32 num_filled_bytes = frames_filled * format_.Format.nBlockAlign; |
509 DCHECK_LE(num_filled_bytes, packet_size_bytes_); | 505 DCHECK_LE(num_filled_bytes, packet_size_bytes_); |
510 | 506 |
511 // Note: If this ever changes to output raw float the data must be | 507 // Note: If this ever changes to output raw float the data must be |
512 // clipped and sanitized since it may come from an untrusted | 508 // clipped and sanitized since it may come from an untrusted |
513 // source such as NaCl. | 509 // source such as NaCl. |
514 const int bytes_per_sample = format_.Format.wBitsPerSample >> 3; | 510 const int bytes_per_sample = format_.Format.wBitsPerSample >> 3; |
515 audio_bus_->Scale(volume_); | 511 audio_bus_->Scale(volume_); |
516 audio_bus_->ToInterleaved( | 512 audio_bus_->ToInterleaved( |
517 frames_filled, bytes_per_sample, audio_data); | 513 frames_filled, bytes_per_sample, audio_data); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 616 |
621 // Ensure that we don't quit the main thread loop immediately next | 617 // Ensure that we don't quit the main thread loop immediately next |
622 // time Start() is called. | 618 // time Start() is called. |
623 ResetEvent(stop_render_event_.Get()); | 619 ResetEvent(stop_render_event_.Get()); |
624 } | 620 } |
625 | 621 |
626 source_ = NULL; | 622 source_ = NULL; |
627 } | 623 } |
628 | 624 |
629 } // namespace media | 625 } // namespace media |
OLD | NEW |