|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2025 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: // ! 8: // サウンドのホストデバイス ! 9: // ! 10: ! 11: #pragma once ! 12: ! 13: #include "hostdevice.h" ! 14: #include "spscqueue.h" ! 15: ! 16: class SoundDriver; ! 17: ! 18: class HostSoundDevice : public HostDevice ! 19: { ! 20: using inherited = HostDevice; ! 21: using PlayQueue = SPSCQueue<const int16 *, 4>; ! 22: friend class SoundDriver; ! 23: ! 24: // 統計情報 ! 25: struct stat_t { ! 26: uint64 write_blk; ! 27: }; ! 28: ! 29: public: ! 30: HostSoundDevice(Device *parent_); ! 31: ~HostSoundDevice() override; ! 32: ! 33: void SetLogLevel(int loglevel_) override; ! 34: bool Create2() override; ! 35: ! 36: // ドライバ名を返す。 ! 37: const std::string& GetDriverName(); ! 38: ! 39: // 再生(を指示) ! 40: bool Play(const int16 *blk); ! 41: ! 42: // 出力キューが空なら true を返す。 ! 43: bool IsQEmpty() const { return playq.Length() == 0; } ! 44: ! 45: private: ! 46: bool SelectDriver(bool startup) override; ! 47: void CreateNone(); ! 48: void CreateWav(); ! 49: void CreateNetBSD(); ! 50: void CreateSndIO(); ! 51: void CreateALSA(); ! 52: ! 53: // 外部への書き出し(再生) ! 54: void Write() override; ! 55: ! 56: // 外部からの読み込み (未対応) ! 57: int Read() override; ! 58: ! 59: DECLARE_MONITOR_CALLBACK(MonitorUpdate); ! 60: ! 61: std::unique_ptr<SoundDriver> driver {}; ! 62: ! 63: // ホストの(入)出力周波数 [Hz] ! 64: uint32 freq {}; ! 65: ! 66: // 1ブロックのバイト数 ! 67: size_t bytes_per_blk {}; ! 68: ! 69: // キュー ! 70: PlayQueue playq {}; ! 71: ! 72: // 統計情報 ! 73: struct stat_t stat {}; ! 74: ! 75: Monitor *monitor {}; ! 76: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.