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

Side by Side Diff: media/audio/win/wavein_input_win.h

Issue 8770005: Adds input device selection on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebased Created 9 years 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/win/audio_manager_win.cc ('k') | media/audio/win/wavein_input_win.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_WIN_WAVEIN_INPUT_WIN_H_ 5 #ifndef MEDIA_AUDIO_WIN_WAVEIN_INPUT_WIN_H_
6 #define MEDIA_AUDIO_WIN_WAVEIN_INPUT_WIN_H_ 6 #define MEDIA_AUDIO_WIN_WAVEIN_INPUT_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <mmsystem.h> 9 #include <mmsystem.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/win/scoped_handle.h" 13 #include "base/win/scoped_handle.h"
14 #include "media/audio/audio_io.h" 14 #include "media/audio/audio_io.h"
15 #include "media/audio/audio_parameters.h" 15 #include "media/audio/audio_parameters.h"
16 16
17 class AudioManagerWin; 17 class AudioManagerWin;
18 18
19 class PCMWaveInAudioInputStream : public AudioInputStream { 19 class PCMWaveInAudioInputStream : public AudioInputStream {
20 public: 20 public:
21 // The ctor takes all the usual parameters, plus |manager| which is the 21 // The ctor takes all the usual parameters, plus |manager| which is the
22 // the audio manager who is creating this object and |device_id| which 22 // the audio manager who is creating this object and |device_id| which
23 // is provided by the operating system. 23 // is provided by the operating system.
24 PCMWaveInAudioInputStream(AudioManagerWin* manager, 24 PCMWaveInAudioInputStream(AudioManagerWin* manager,
25 const AudioParameters& params, 25 const AudioParameters& params,
26 int num_buffers, 26 int num_buffers,
27 UINT device_id); 27 const std::string& device_id);
28 virtual ~PCMWaveInAudioInputStream(); 28 virtual ~PCMWaveInAudioInputStream();
29 29
30 // Implementation of AudioInputStream. 30 // Implementation of AudioInputStream.
31 virtual bool Open() OVERRIDE; 31 virtual bool Open() OVERRIDE;
32 virtual void Start(AudioInputCallback* callback) OVERRIDE; 32 virtual void Start(AudioInputCallback* callback) OVERRIDE;
33 virtual void Stop() OVERRIDE; 33 virtual void Stop() OVERRIDE;
34 virtual void Close() OVERRIDE; 34 virtual void Close() OVERRIDE;
35 35
36 private: 36 private:
37 enum State { 37 enum State {
(...skipping 16 matching lines...) Expand all
54 54
55 // Allocates and prepares the memory that will be used for recording. 55 // Allocates and prepares the memory that will be used for recording.
56 void SetupBuffers(); 56 void SetupBuffers();
57 57
58 // Deallocates the memory allocated in SetupBuffers. 58 // Deallocates the memory allocated in SetupBuffers.
59 void FreeBuffers(); 59 void FreeBuffers();
60 60
61 // Sends a buffer to the audio driver for recording. 61 // Sends a buffer to the audio driver for recording.
62 void QueueNextPacket(WAVEHDR* buffer); 62 void QueueNextPacket(WAVEHDR* buffer);
63 63
64 // Converts the stored device id string into an unsigned integer which
65 // can be used by waveInOpen() to open the specified capture device.
66 bool GetDeviceId(UINT* device_index);
67
64 // Reader beware. Visual C has stronger guarantees on volatile vars than 68 // Reader beware. Visual C has stronger guarantees on volatile vars than
65 // most people expect. In fact, it has release semantics on write and 69 // most people expect. In fact, it has release semantics on write and
66 // acquire semantics on reads. See the msdn documentation. 70 // acquire semantics on reads. See the msdn documentation.
67 volatile State state_; 71 volatile State state_;
68 72
69 // The audio manager that created this input stream. We notify it when 73 // The audio manager that created this input stream. We notify it when
70 // we close so it can release its own resources. 74 // we close so it can release its own resources.
71 AudioManagerWin* manager_; 75 AudioManagerWin* manager_;
72 76
73 // We use the callback mostly to periodically give the recorded audio data. 77 // We use the callback mostly to periodically give the recorded audio data.
74 AudioInputCallback* callback_; 78 AudioInputCallback* callback_;
75 79
76 // The number of buffers of size |buffer_size_| each to use. 80 // The number of buffers of size |buffer_size_| each to use.
77 const int num_buffers_; 81 const int num_buffers_;
78 82
79 // The size in bytes of each audio buffer. 83 // The size in bytes of each audio buffer.
80 uint32 buffer_size_; 84 uint32 buffer_size_;
81 85
82 // Channels, 1 or 2. 86 // Channels, 1 or 2.
83 const int channels_; 87 const int channels_;
84 88
85 // The id assigned by the operating system to the selected wave output 89 // Contains the unique name of the selected endpoint device.
86 // hardware device. Usually this is just -1 which means 'default device'. 90 // Note that AudioManagerBase::kDefaultDeviceId represents the default
87 UINT device_id_; 91 // device role and is not a valid ID as such.
92 std::string device_id_;
88 93
89 // Windows native structure to encode the format parameters. 94 // Windows native structure to encode the format parameters.
90 WAVEFORMATEX format_; 95 WAVEFORMATEX format_;
91 96
92 // Handle to the instance of the wave device. 97 // Handle to the instance of the wave device.
93 HWAVEIN wavein_; 98 HWAVEIN wavein_;
94 99
95 // Pointer to the first allocated audio buffer. This object owns it. 100 // Pointer to the first allocated audio buffer. This object owns it.
96 WAVEHDR* buffer_; 101 WAVEHDR* buffer_;
97 102
98 // An event that is signaled when the callback thread is ready to stop. 103 // An event that is signaled when the callback thread is ready to stop.
99 base::win::ScopedHandle stopped_event_; 104 base::win::ScopedHandle stopped_event_;
100 105
101 DISALLOW_COPY_AND_ASSIGN(PCMWaveInAudioInputStream); 106 DISALLOW_COPY_AND_ASSIGN(PCMWaveInAudioInputStream);
102 }; 107 };
103 108
104 #endif // MEDIA_AUDIO_WIN_WAVEIN_INPUT_WIN_H_ 109 #endif // MEDIA_AUDIO_WIN_WAVEIN_INPUT_WIN_H_
OLDNEW
« no previous file with comments | « media/audio/win/audio_manager_win.cc ('k') | media/audio/win/wavein_input_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698