diff --git a/include/ehs/io/audio/AudioDevice_W32.h b/include/ehs/io/audio/AudioDevice_W32.h index 889b99b..cefa13c 100644 --- a/include/ehs/io/audio/AudioDevice_W32.h +++ b/include/ehs/io/audio/AudioDevice_W32.h @@ -33,8 +33,6 @@ namespace ehs AudioDevice& operator=(const AudioDevice& device); - void Release() override; - void OpenStream() override; void CloseStream() override; @@ -57,6 +55,8 @@ namespace ehs Str_8 GetName_8() const; + bool IsStreaming() const override; + bool IsValid() const override; static AudioDevice GetDefault(const AudioDeviceType type); diff --git a/src/io/audio/AudioDevice_W32.cpp b/src/io/audio/AudioDevice_W32.cpp index 802e196..7e751f4 100644 --- a/src/io/audio/AudioDevice_W32.cpp +++ b/src/io/audio/AudioDevice_W32.cpp @@ -68,34 +68,6 @@ namespace ehs return *this; } - void AudioDevice::Release() - { - if (captureClient) - { - captureClient->Release(); - captureClient = nullptr; - } - - if (playbackClient) - { - playbackClient->Release(); - playbackClient = nullptr; - } - - if (hdl) - { - HRESULT r = client->Stop(); - if (FAILED(r)) - { - EHS_LOG_INT(LogType::ERR, 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + "."); - return; - } - - hdl->Release(); - hdl = nullptr; - } - } - void AudioDevice::OpenStream() { if (streaming) @@ -298,7 +270,7 @@ namespace ehs void AudioDevice::CloseStream() { - if (!streaming) + if (!IsStreaming()) return; if (playbackClient) @@ -324,14 +296,15 @@ namespace ehs client->Release(); client = nullptr; - } - streaming = false; + hdl->Release(); + hdl = nullptr; + } } UInt_64 AudioDevice::GetAvailFrames() const { - if (!IsValid() || !streaming) + if (!IsValid() || !IsStreaming()) return 0; UInt_32 sampleSize = 0; @@ -484,6 +457,11 @@ namespace ehs return UTF::To_8(GetName_16()); } + bool AudioDevice::IsStreaming() const + { + return hdl && client && (playbackClient || captureClient); + } + bool AudioDevice::IsValid() const { return hdl;