OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // THREAD SAFETY | 5 // THREAD SAFETY |
6 // | 6 // |
7 // The AlsaPcmOutputStream object's internal state is accessed by two threads: | 7 // The AlsaPcmOutputStream object's internal state is accessed by two threads: |
8 // | 8 // |
9 // client thread - creates the object and calls the public APIs. | 9 // client thread - creates the object and calls the public APIs. |
10 // message loop thread - executes all the internal tasks including querying | 10 // message loop thread - executes all the internal tasks including querying |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 NewRunnableMethod(this, &AlsaPcmOutputStream::StartTask)); | 343 NewRunnableMethod(this, &AlsaPcmOutputStream::StartTask)); |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 void AlsaPcmOutputStream::Stop() { | 347 void AlsaPcmOutputStream::Stop() { |
348 DCHECK_EQ(MessageLoop::current(), client_thread_loop_); | 348 DCHECK_EQ(MessageLoop::current(), client_thread_loop_); |
349 | 349 |
350 shared_data_.TransitionTo(kIsStopped); | 350 shared_data_.TransitionTo(kIsStopped); |
351 } | 351 } |
352 | 352 |
353 void AlsaPcmOutputStream::SetVolume(double left_level, double right_level) { | 353 void AlsaPcmOutputStream::SetVolume(double volume) { |
354 DCHECK_EQ(MessageLoop::current(), client_thread_loop_); | 354 DCHECK_EQ(MessageLoop::current(), client_thread_loop_); |
355 | 355 |
356 shared_data_.set_volume(static_cast<float>(left_level)); | 356 shared_data_.set_volume(static_cast<float>(volume)); |
357 } | 357 } |
358 | 358 |
359 void AlsaPcmOutputStream::GetVolume(double* left_level, double* right_level) { | 359 void AlsaPcmOutputStream::GetVolume(double* volume) { |
360 DCHECK_EQ(MessageLoop::current(), client_thread_loop_); | 360 DCHECK_EQ(MessageLoop::current(), client_thread_loop_); |
361 | 361 |
362 *left_level = *right_level = shared_data_.volume(); | 362 *volume = shared_data_.volume(); |
363 } | 363 } |
364 | 364 |
365 void AlsaPcmOutputStream::OpenTask(size_t packet_size) { | 365 void AlsaPcmOutputStream::OpenTask(size_t packet_size) { |
366 DCHECK_EQ(MessageLoop::current(), message_loop_); | 366 DCHECK_EQ(MessageLoop::current(), message_loop_); |
367 | 367 |
368 // Initialize the configuration variables. | 368 // Initialize the configuration variables. |
369 frames_per_packet_ = packet_size / bytes_per_frame_; | 369 frames_per_packet_ = packet_size / bytes_per_frame_; |
370 | 370 |
371 // Try to open the device. | 371 // Try to open the device. |
372 micros_per_packet_ = | 372 micros_per_packet_ = |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 } | 939 } |
940 | 940 |
941 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 941 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
942 // release ownership of the currently registered callback. | 942 // release ownership of the currently registered callback. |
943 void AlsaPcmOutputStream::SharedData::set_source_callback( | 943 void AlsaPcmOutputStream::SharedData::set_source_callback( |
944 AudioSourceCallback* callback) { | 944 AudioSourceCallback* callback) { |
945 DCHECK_EQ(MessageLoop::current(), state_transition_loop_); | 945 DCHECK_EQ(MessageLoop::current(), state_transition_loop_); |
946 AutoLock l(lock_); | 946 AutoLock l(lock_); |
947 source_callback_ = callback; | 947 source_callback_ = callback; |
948 } | 948 } |
OLD | NEW |