OSDN Git Service

WASAPIの排他モード・共有モードを切り替えられるようにした。
[winaudioj/async.git] / async / wasapi.h
index 4801cf5..6da1501 100644 (file)
@@ -49,7 +49,7 @@ struct device_manager
 };
 
 
-/// WASAPI\8f\88\97\9d\83N\83\89\83X
+/// WASAPI\8f\88\97\9d\83N\83\89\83X(\8b¤\97L\81E\83^\83C\83}\81[\83\82\81[\83h)
 struct wasapi_shared_timer : public audio_base
 {
   explicit wasapi_shared_timer(::WAVEFORMATEXTENSIBLE& wfx);
@@ -89,5 +89,43 @@ private:
   // \83o\83b\83t\83@\92\86\82Ì\8bæ\90Ø\82è\90\94\81i\83\8c\83C\83e\83\93\83V\8e\9e\8aÔ\82ª\89½\8cÂ\82 \82é\82©\81j
   static const uint32_t periods_per_buffer_ = 4;
 };
+
+/// WASAPI\8f\88\97\9d\83N\83\89\83X(\94r\91¼\81E\83^\83C\83}\81[\83\82\81[\83h)
+struct wasapi_exclusive_timer : public audio_base
+{
+  explicit wasapi_exclusive_timer(::WAVEFORMATEXTENSIBLE& wfx);
+  virtual ~wasapi_exclusive_timer();
+
+  bool is_enabled () const {return is_enabled_;}
+  /// \83T\83E\83\93\83h\8dÄ\90\8f\88\97\9d
+  void play_buffer(BYTE* buffer);
+  void stop();
+  void reset();
+
+  uint32_t get_buffer_byte_size () const { return buffer_size_ * num_of_frames_;}
+  win32_error_exception* const result() {return exception_holder_.get(); }
+
+private:
+  IMMDeviceEnumeratorPtr device_enumerator_;
+  IMMDevicePtr current_device_;
+  IAudioClientPtr audio_client_;
+  IAudioRenderClientPtr audio_render_client_;
+  IAudioClockAdjustmentPtr audio_clock_adjustment_;
+  //handle_holder buffer_control_event_;
+  WAVEFORMATEXTENSIBLE mix_format_;
+  bool is_enabled_;
+  bool is_start_;
+  boost::shared_ptr<win32_error_exception> exception_holder_;
+  boost::uint32_t num_of_frames_;
+  boost::uint32_t buffer_size_;
+  uint64_t position_;
+
+  // \8dÄ\90\83\8c\83C\83e\83\93\83V
+  static const uint32_t latency_ms_ = 10;/* ms */
+  // \83o\83b\83t\83@\92\86\82Ì\8bæ\90Ø\82è\90\94\81i\83\8c\83C\83e\83\93\83V\8e\9e\8aÔ\82ª\89½\8cÂ\82 \82é\82©\81j
+  static const uint32_t periods_per_buffer_ = 4;
+};
+
 }