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

Unified Diff: media/audio/win/audio_manager_win.cc

Issue 5350003: Move audio output number limit to AudioManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/win/audio_manager_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_manager_win.cc
diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc
index 4a361727d281d468029cf7a747b55bd44c1c3bbf..dee14c5a149a1fc693db0a582245d03c99b25829 100644
--- a/media/audio/win/audio_manager_win.cc
+++ b/media/audio/win/audio_manager_win.cc
@@ -34,6 +34,9 @@ DEFINE_GUID(AM_KSCATEGORY_AUDIO, 0x6994ad04, 0x93ef, 0x11d0,
namespace {
+// Maximum number of output streams that can be open simultaneously.
+const size_t kMaxOutputStreams = 50;
+
// Up to 8 channels can be passed to the driver.
// This should work, given the right drivers, but graceful error handling is
// needed.
@@ -91,6 +94,13 @@ string16 GetDeviceAndDriverInfo(HDEVINFO device_info,
} // namespace
+AudioManagerWin::AudioManagerWin()
+ : num_output_streams_(0) {
+}
+
+AudioManagerWin::~AudioManagerWin() {
+}
+
bool AudioManagerWin::HasAudioOutputDevices() {
return (::waveOutGetNumDevs() != 0);
}
@@ -108,11 +118,18 @@ AudioOutputStream* AudioManagerWin::MakeAudioOutputStream(
if (!params.IsValid() || (params.channels > kWinMaxChannels))
return NULL;
+ // Limit the number of audio streams opened.
+ if (num_output_streams_ >= kMaxOutputStreams) {
+ return NULL;
+ }
+
if (params.format == AudioParameters::AUDIO_MOCK) {
return FakeAudioOutputStream::MakeFakeStream(params);
} else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) {
+ num_output_streams_++;
return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER);
} else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
+ num_output_streams_++;
// TODO(cpu): waveout cannot hit 20ms latency. Use other method.
return new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER);
}
@@ -135,13 +152,13 @@ AudioInputStream* AudioManagerWin::MakeAudioInputStream(
}
void AudioManagerWin::ReleaseOutputStream(PCMWaveOutAudioOutputStream* stream) {
- if (stream)
- delete stream;
+ DCHECK(stream);
+ num_output_streams_--;
+ delete stream;
}
void AudioManagerWin::ReleaseInputStream(PCMWaveInAudioInputStream* stream) {
- if (stream)
- delete stream;
+ delete stream;
}
void AudioManagerWin::MuteAll() {
@@ -150,9 +167,6 @@ void AudioManagerWin::MuteAll() {
void AudioManagerWin::UnMuteAll() {
}
-AudioManagerWin::~AudioManagerWin() {
-}
-
string16 AudioManagerWin::GetAudioInputDeviceModel() {
// Get the default audio capture device and its device interface name.
DWORD device_id = 0;
« no previous file with comments | « media/audio/win/audio_manager_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698