$OpenBSD: patch-media_audio_openbsd_sndio_output_h,v 1.2 2011/06/08 20:36:56 robert Exp $
--- media/audio/openbsd/sndio_output.h.orig	Wed Jun  8 09:58:36 2011
+++ media/audio/openbsd/sndio_output.h	Wed Jun  8 17:03:54 2011
@@ -0,0 +1,85 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_AUDIO_OPENBSD_AUDIO_OUTPUT_OPENBSD_H_
+#define MEDIA_AUDIO_OPENBSD_AUDIO_OUTPUT_OPENBSD_H_
+
+#include <sndio.h>
+
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread.h"
+#include "base/time.h"
+#include "media/audio/audio_io.h"
+#include "media/audio/audio_parameters.h"
+
+class AudioManagerOpenBSD;
+
+// Implementation of AudioOuputStream for OpenBSD OS X using the audio queue service
+// present in OS 10.5 and later. Audioqueue is the successor to the SoundManager
+// services but it is supported in 64 bits.
+class PCMQueueOutAudioOutputStream :
+	public AudioOutputStream,
+	public base::RefCountedThreadSafe<PCMQueueOutAudioOutputStream> {
+ public:
+  // The ctor takes all the usual parameters, plus |manager| which is the
+  // the audio manager who is creating this object.
+  PCMQueueOutAudioOutputStream(AudioManagerOpenBSD* manager,
+                               AudioParameters params);
+  // The dtor is typically called by the AudioManager only and it is usually
+  // triggered by calling AudioOutputStream::Close().
+  virtual ~PCMQueueOutAudioOutputStream();
+
+  // Implementation of AudioOutputStream.
+  virtual bool Open();
+  virtual void Close();
+  virtual void Start(AudioSourceCallback* callback);
+  virtual void Stop();
+  virtual void SetVolume(double volume);
+  virtual void GetVolume(double* volume);
+
+ private:
+  // Give RefCountedThreadSafe access our destructor.
+  friend class base::RefCountedThreadSafe<PCMQueueOutAudioOutputStream>;
+
+  // Called when an error occurs.
+  void HandleError(int err);
+
+  static void RenderCallback(void* p_this);
+  void DoCallback();
+  static void onmove_callback(void *data, int);
+
+  struct sio_hdl *sndio_hdl_;
+  struct sio_par sndio_par_;
+
+  // Pointer to the object that will provide the audio samples.
+  AudioSourceCallback* source_;
+  // Our creator, the audio manager needs to be notified when we close.
+  AudioManagerOpenBSD* manager_;
+  // Packet size in bytes.
+  uint32 packet_size_;
+  // Number of bytes for making a silence buffer.
+  int silence_bytes_;
+  // Volume level from 0 to 1.
+  float volume_;
+
+  int32 hw_pos_;
+  int32 sw_pos_;
+
+  uint8 *buffer_;
+  uint32 buffer_size_;
+  uint32 buffer_avail_;
+  uint32 used_;
+  uint32 filled_;
+
+  base::Thread thread_;
+  base::Time last_callback_time_;
+  int callback_interval_ms_;
+
+  DISALLOW_COPY_AND_ASSIGN(PCMQueueOutAudioOutputStream);
+};
+
+#endif  // MEDIA_AUDIO_OPENBSD_AUDIO_OUTPUT_OPENBSD_H_
