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

Unified Diff: media/audio/openbsd/audio_manager_openbsd.cc

Issue 8499029: make pulseaudio available for all posix platforms because it's not linux only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: re-sync with the linux code Created 9 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
Index: media/audio/openbsd/audio_manager_openbsd.cc
diff --git a/media/audio/openbsd/audio_manager_openbsd.cc b/media/audio/openbsd/audio_manager_openbsd.cc
index cb18768463e0910f45280151843ec62bde76a923..8aff1621333bc29a92ee0cddaa921e76456d3df8 100644
--- a/media/audio/openbsd/audio_manager_openbsd.cc
+++ b/media/audio/openbsd/audio_manager_openbsd.cc
@@ -4,21 +4,74 @@
#include "media/audio/openbsd/audio_manager_openbsd.h"
+#include "base/command_line.h"
+#include "media/audio/audio_output_dispatcher.h"
+#include "media/audio/fake_audio_input_stream.h"
+#include "media/audio/fake_audio_output_stream.h"
+#if defined(USE_PULSEAUDIO)
+#include "media/audio/pulse/pulse_output.h"
+#endif
+#include "media/base/limits.h"
+#include "media/base/media_switches.h"
+
+#include <fcntl.h>
+
+// Maximum number of output streams that can be open simultaneously.
+static const size_t kMaxOutputStreams = 50;
+
// Implementation of AudioManager.
+static bool HasAudioHardware() {
+ int fd;
+ const char *file;
+
+ if ((file = getenv("AUDIOCTLDEVICE")) == 0 || *file == '\0')
+ file = "/dev/audioctl";
+
+ if ((fd = open(file, O_RDONLY)) < 0)
+ return false;
+
+ close(fd);
+ return true;
+}
+
bool AudioManagerOpenBSD::HasAudioOutputDevices() {
- NOTIMPLEMENTED();
- return false;
+ return HasAudioHardware();
}
bool AudioManagerOpenBSD::HasAudioInputDevices() {
- NOTIMPLEMENTED();
- return false;
+ return HasAudioHardware();
}
AudioOutputStream* AudioManagerOpenBSD::MakeAudioOutputStream(
const AudioParameters& params) {
- NOTIMPLEMENTED();
- return NULL;
+ // Early return for testing hook. Do this before checking for
+ // |initialized_|.
+ if (params.format == AudioParameters::AUDIO_MOCK) {
+ return FakeAudioOutputStream::MakeFakeStream(params);
+ }
+
+ if (!initialized()) {
+ return NULL;
+ }
+
+ // Don't allow opening more than |kMaxOutputStreams| streams.
+ if (active_streams_.size() >= kMaxOutputStreams) {
+ return NULL;
+ }
+
+ AudioOutputStream* stream;
scherkus (not reviewing) 2011/11/16 00:57:56 nit: I think it'd be clearer if it was written as:
Robert Nagy 2011/11/16 11:59:59 Done.
+#if defined(USE_PULSEAUDIO)
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) {
+ stream = new PulseAudioOutputStream(params, this, GetMessageLoop());
+ active_streams_.insert(stream);
+ return stream;
+ } else {
+#endif
+ NOTIMPLEMENTED();
+ return NULL;
+#if defined(USE_PULSEAUDIO)
+ }
+#endif
}
AudioInputStream* AudioManagerOpenBSD::MakeAudioInputStream(
@@ -41,6 +94,13 @@ void AudioManagerOpenBSD::UnMuteAll() {
NOTIMPLEMENTED();
}
+void AudioManagerOpenBSD::ReleaseOutputStream(AudioOutputStream* stream) {
+ if (stream) {
+ active_streams_.erase(stream);
+ delete stream;
+ }
+}
+
bool AudioManagerOpenBSD::IsRecordingInProgress() {
NOTIMPLEMENTED();
return false;

Powered by Google App Engine
This is Rietveld 408576698