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

Side by Side Diff: media/audio/mac/audio_input_mac.h

Issue 233823003: Defer input stream start around suspend and resume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests. Created 6 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/mac/audio_auhal_mac.cc ('k') | media/audio/mac/audio_input_mac.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 #ifndef MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ 5 #ifndef MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_
6 #define MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ 6 #define MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_
7 7
8 #include <AudioToolbox/AudioFormat.h> 8 #include <AudioToolbox/AudioFormat.h>
9 #include <AudioToolbox/AudioQueue.h> 9 #include <AudioToolbox/AudioQueue.h>
10 10
11 #include "base/cancelable_callback.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "media/audio/audio_io.h" 14 #include "media/audio/audio_io.h"
14 #include "media/audio/audio_parameters.h" 15 #include "media/audio/audio_parameters.h"
15 16
16 namespace media { 17 namespace media {
17 18
18 class AudioManagerBase; 19 class AudioManagerMac;
19 20
20 // Implementation of AudioInputStream for Mac OS X using the audio queue service 21 // Implementation of AudioInputStream for Mac OS X using the audio queue service
21 // present in OS 10.5 and later. Design reflects PCMQueueOutAudioOutputStream. 22 // present in OS 10.5 and later. Design reflects PCMQueueOutAudioOutputStream.
22 class PCMQueueInAudioInputStream : public AudioInputStream { 23 class PCMQueueInAudioInputStream : public AudioInputStream {
23 public: 24 public:
24 // Parameters as per AudioManager::MakeAudioInputStream. 25 // Parameters as per AudioManager::MakeAudioInputStream.
25 PCMQueueInAudioInputStream(AudioManagerBase* manager, 26 PCMQueueInAudioInputStream(AudioManagerMac* manager,
26 const AudioParameters& params); 27 const AudioParameters& params);
27 virtual ~PCMQueueInAudioInputStream(); 28 virtual ~PCMQueueInAudioInputStream();
28 29
29 // Implementation of AudioInputStream. 30 // Implementation of AudioInputStream.
30 virtual bool Open() OVERRIDE; 31 virtual bool Open() OVERRIDE;
31 virtual void Start(AudioInputCallback* callback) OVERRIDE; 32 virtual void Start(AudioInputCallback* callback) OVERRIDE;
32 virtual void Stop() OVERRIDE; 33 virtual void Stop() OVERRIDE;
33 virtual void Close() OVERRIDE; 34 virtual void Close() OVERRIDE;
34 virtual double GetMaxVolume() OVERRIDE; 35 virtual double GetMaxVolume() OVERRIDE;
35 virtual void SetVolume(double volume) OVERRIDE; 36 virtual void SetVolume(double volume) OVERRIDE;
(...skipping 23 matching lines...) Expand all
59 // Handles callback from OS. Will be called on OS internal thread. 60 // Handles callback from OS. Will be called on OS internal thread.
60 void HandleInputBuffer(AudioQueueRef audio_queue, 61 void HandleInputBuffer(AudioQueueRef audio_queue,
61 AudioQueueBufferRef audio_buffer, 62 AudioQueueBufferRef audio_buffer,
62 const AudioTimeStamp* start_time, 63 const AudioTimeStamp* start_time,
63 UInt32 num_packets, 64 UInt32 num_packets,
64 const AudioStreamPacketDescription* packet_desc); 65 const AudioStreamPacketDescription* packet_desc);
65 66
66 static const int kNumberBuffers = 3; 67 static const int kNumberBuffers = 3;
67 68
68 // Manager that owns this stream, used for closing down. 69 // Manager that owns this stream, used for closing down.
69 AudioManagerBase* manager_; 70 AudioManagerMac* manager_;
70 // We use the callback mostly to periodically supply the recorded audio data. 71 // We use the callback mostly to periodically supply the recorded audio data.
71 AudioInputCallback* callback_; 72 AudioInputCallback* callback_;
72 // Structure that holds the stream format details such as bitrate. 73 // Structure that holds the stream format details such as bitrate.
73 AudioStreamBasicDescription format_; 74 AudioStreamBasicDescription format_;
74 // Handle to the OS audio queue object. 75 // Handle to the OS audio queue object.
75 AudioQueueRef audio_queue_; 76 AudioQueueRef audio_queue_;
76 // Size of each of the buffers in |audio_buffers_| 77 // Size of each of the buffers in |audio_buffers_|
77 uint32 buffer_size_bytes_; 78 uint32 buffer_size_bytes_;
78 // True iff Start() has been called successfully. 79 // True iff Start() has been called successfully.
79 bool started_; 80 bool started_;
80 // Used to determine if we need to slow down |callback_| calls. 81 // Used to determine if we need to slow down |callback_| calls.
81 base::TimeTicks last_fill_; 82 base::TimeTicks last_fill_;
83 // Used to defer Start() to workaround http://crbug.com/160920.
84 base::CancelableClosure deferred_start_cb_;
82 85
83 DISALLOW_COPY_AND_ASSIGN(PCMQueueInAudioInputStream); 86 DISALLOW_COPY_AND_ASSIGN(PCMQueueInAudioInputStream);
84 }; 87 };
85 88
86 } // namespace media 89 } // namespace media
87 90
88 #endif // MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ 91 #endif // MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_
OLDNEW
« no previous file with comments | « media/audio/mac/audio_auhal_mac.cc ('k') | media/audio/mac/audio_input_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698