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 // THREAD SAFETY | 5 // THREAD SAFETY |
6 // | 6 // |
7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used | 7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used |
8 // from the audio thread. We DCHECK on this assumption whenever we can. | 8 // from the audio thread. We DCHECK on this assumption whenever we can. |
9 // | 9 // |
10 // SEMANTICS OF Close() | 10 // SEMANTICS OF Close() |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "media/audio/linux/alsa_output.h" | 35 #include "media/audio/linux/alsa_output.h" |
36 | 36 |
37 #include <algorithm> | 37 #include <algorithm> |
38 | 38 |
39 #include "base/bind.h" | 39 #include "base/bind.h" |
40 #include "base/debug/trace_event.h" | 40 #include "base/debug/trace_event.h" |
41 #include "base/logging.h" | 41 #include "base/logging.h" |
42 #include "base/message_loop.h" | 42 #include "base/message_loop.h" |
43 #include "base/stl_util.h" | 43 #include "base/stl_util.h" |
44 #include "base/time.h" | 44 #include "base/time.h" |
45 #include "media/audio/audio_util.h" | |
46 #include "media/audio/linux/alsa_util.h" | 45 #include "media/audio/linux/alsa_util.h" |
47 #include "media/audio/linux/alsa_wrapper.h" | 46 #include "media/audio/linux/alsa_wrapper.h" |
48 #include "media/audio/linux/audio_manager_linux.h" | 47 #include "media/audio/linux/audio_manager_linux.h" |
49 #include "media/base/channel_mixer.h" | 48 #include "media/base/channel_mixer.h" |
50 #include "media/base/data_buffer.h" | 49 #include "media/base/data_buffer.h" |
51 #include "media/base/seekable_buffer.h" | 50 #include "media/base/seekable_buffer.h" |
52 | 51 |
53 namespace media { | 52 namespace media { |
54 | 53 |
55 // Set to 0 during debugging if you want error messages due to underrun | 54 // Set to 0 during debugging if you want error messages due to underrun |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 AudioBus* output_bus = audio_bus_.get(); | 371 AudioBus* output_bus = audio_bus_.get(); |
373 if (channel_mixer_) { | 372 if (channel_mixer_) { |
374 output_bus = mixed_audio_bus_.get(); | 373 output_bus = mixed_audio_bus_.get(); |
375 channel_mixer_->Transform(audio_bus_.get(), output_bus); | 374 channel_mixer_->Transform(audio_bus_.get(), output_bus); |
376 // Adjust packet size for downmix. | 375 // Adjust packet size for downmix. |
377 packet_size = packet_size / bytes_per_frame_ * bytes_per_output_frame_; | 376 packet_size = packet_size / bytes_per_frame_ * bytes_per_output_frame_; |
378 } | 377 } |
379 | 378 |
380 // Note: If this ever changes to output raw float the data must be clipped | 379 // Note: If this ever changes to output raw float the data must be clipped |
381 // and sanitized since it may come from an untrusted source such as NaCl. | 380 // and sanitized since it may come from an untrusted source such as NaCl. |
| 381 output_bus->AdjustVolume(volume_); |
382 output_bus->ToInterleaved( | 382 output_bus->ToInterleaved( |
383 frames_filled, bytes_per_sample_, packet->GetWritableData()); | 383 frames_filled, bytes_per_sample_, packet->GetWritableData()); |
384 | 384 |
385 media::AdjustVolume(packet->GetWritableData(), | |
386 packet_size, | |
387 output_bus->channels(), | |
388 bytes_per_sample_, | |
389 volume_); | |
390 | |
391 if (packet_size > 0) { | 385 if (packet_size > 0) { |
392 packet->SetDataSize(packet_size); | 386 packet->SetDataSize(packet_size); |
393 // Add the packet to the buffer. | 387 // Add the packet to the buffer. |
394 buffer_->Append(packet); | 388 buffer_->Append(packet); |
395 } else { | 389 } else { |
396 *source_exhausted = true; | 390 *source_exhausted = true; |
397 } | 391 } |
398 } | 392 } |
399 } | 393 } |
400 | 394 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 } | 758 } |
765 | 759 |
766 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 760 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
767 // release ownership of the currently registered callback. | 761 // release ownership of the currently registered callback. |
768 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { | 762 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { |
769 DCHECK(IsOnAudioThread()); | 763 DCHECK(IsOnAudioThread()); |
770 source_callback_ = callback; | 764 source_callback_ = callback; |
771 } | 765 } |
772 | 766 |
773 } // namespace media | 767 } // namespace media |
OLD | NEW |