Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: media/audio/audio_device_thread.cc

Issue 2471733004: Revert of Make more media APIs aware of |delay| and |delay_timestamp| (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/audio_device_thread.h" 5 #include "media/audio/audio_device_thread.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 base::PlatformThread::Join(thread_handle_); 60 base::PlatformThread::Join(thread_handle_);
61 } 61 }
62 62
63 void AudioDeviceThread::ThreadMain() { 63 void AudioDeviceThread::ThreadMain() {
64 base::PlatformThread::SetName(thread_name_); 64 base::PlatformThread::SetName(thread_name_);
65 base::ThreadRestrictions::SetSingletonAllowed(true); 65 base::ThreadRestrictions::SetSingletonAllowed(true);
66 callback_->InitializeOnAudioThread(); 66 callback_->InitializeOnAudioThread();
67 67
68 uint32_t buffer_index = 0; 68 uint32_t buffer_index = 0;
69 while (true) { 69 while (true) {
70 Packet packet = {0, 0}; 70 uint32_t pending_data = 0;
71 size_t bytes_read = socket_.Receive(&packet, sizeof(packet)); 71 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data));
72 if (bytes_read != sizeof(packet)) 72 if (bytes_read != sizeof(pending_data))
73 break; 73 break;
74 74
75 // std::numeric_limits<int64_t>::max() is a special signal which is 75 // std::numeric_limits<uint32_t>::max() is a special signal which is
76 // returned after the browser stops the output device in response to a 76 // returned after the browser stops the output device in response to a
77 // renderer side request. 77 // renderer side request.
78 // 78 //
79 // Avoid running Process() for the paused signal, we still need to update 79 // Avoid running Process() for the paused signal, we still need to update
80 // the buffer index for synchronized buffers though. 80 // the buffer index for synchronized buffers though.
81 // 81 //
82 // See comments in AudioOutputController::DoPause() for details on why. 82 // See comments in AudioOutputController::DoPause() for details on why.
83 if (packet.pending_data != std::numeric_limits<int64_t>::max()) { 83 if (pending_data != std::numeric_limits<uint32_t>::max())
84 callback_->Process(packet.pending_data, 84 callback_->Process(pending_data);
85 base::TimeTicks() + base::TimeDelta::FromMicroseconds(
86 packet.data_timestamp_us));
87 }
88 85
89 // The usage of synchronized buffers differs between input and output cases. 86 // The usage of synchronized buffers differs between input and output cases.
90 // 87 //
91 // Input: Let the other end know that we have read data, so that it can 88 // Input: Let the other end know that we have read data, so that it can
92 // verify it doesn't overwrite any data before read. The |buffer_index| 89 // verify it doesn't overwrite any data before read. The |buffer_index|
93 // value is not used. For more details, see AudioInputSyncWriter::Write(). 90 // value is not used. For more details, see AudioInputSyncWriter::Write().
94 // 91 //
95 // Output: Let the other end know which buffer we just filled. The 92 // Output: Let the other end know which buffer we just filled. The
96 // |buffer_index| is used to ensure the other end is getting the buffer it 93 // |buffer_index| is used to ensure the other end is getting the buffer it
97 // expects. For more details on how this works see 94 // expects. For more details on how this works see
98 // AudioSyncReader::WaitUntilDataIsReady(). 95 // AudioSyncReader::WaitUntilDataIsReady().
99 ++buffer_index; 96 ++buffer_index;
100 size_t bytes_sent = socket_.Send(&buffer_index, sizeof(buffer_index)); 97 size_t bytes_sent = socket_.Send(&buffer_index, sizeof(buffer_index));
101 if (bytes_sent != sizeof(buffer_index)) 98 if (bytes_sent != sizeof(buffer_index))
102 break; 99 break;
103 } 100 }
104 } 101 }
105 102
106 } // namespace media. 103 } // namespace media.
OLDNEW
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698