Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ErrorCodes.cs to provide all the AUDCLNT_E HRESULT values from audioclient.h #778

Merged
merged 4 commits into from
Apr 26, 2023

Conversation

JacqiPan
Copy link
Contributor

@JacqiPan JacqiPan commented May 12, 2021

Changes

  • Combined AudioClientErrors and ErrorCodes into one AudioClientErrorCode class for consistency. Currently both AudioClientErrors and ErrorCodes serve the same purpose, e.g. providing AUDCLNT_E error codes.

  • Added, renamed and calculated all AUDCLNT_E HRESULT definitions from audioclient.h

  • Renamed all implementations of AudioClientErrors and ErrorCodes to AudioClientErrorCode

winerror.h

#define MAKE_HRESULT(sev,fac,code) \
    ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
....

#define FACILITY_AUDCLNT                 2185

audioclient.h

#define AUDCLNT_ERR(n) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, n)
#define AUDCLNT_SUCCESS(n) MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_AUDCLNT, n)
#define AUDCLNT_E_NOT_INITIALIZED              AUDCLNT_ERR(0x001)
#define AUDCLNT_E_ALREADY_INITIALIZED          AUDCLNT_ERR(0x002)
#define AUDCLNT_E_WRONG_ENDPOINT_TYPE          AUDCLNT_ERR(0x003)
#define AUDCLNT_E_DEVICE_INVALIDATED           AUDCLNT_ERR(0x004)
#define AUDCLNT_E_NOT_STOPPED                  AUDCLNT_ERR(0x005)
#define AUDCLNT_E_BUFFER_TOO_LARGE             AUDCLNT_ERR(0x006)
#define AUDCLNT_E_OUT_OF_ORDER                 AUDCLNT_ERR(0x007)
#define AUDCLNT_E_UNSUPPORTED_FORMAT           AUDCLNT_ERR(0x008)
#define AUDCLNT_E_INVALID_SIZE                 AUDCLNT_ERR(0x009)
#define AUDCLNT_E_DEVICE_IN_USE                AUDCLNT_ERR(0x00a)
#define AUDCLNT_E_BUFFER_OPERATION_PENDING     AUDCLNT_ERR(0x00b)
#define AUDCLNT_E_THREAD_NOT_REGISTERED        AUDCLNT_ERR(0x00c)
#define AUDCLNT_E_NO_SINGLE_PROCESS        	   AUDCLNT_ERR(0x00d)
#define AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED   AUDCLNT_ERR(0x00e)
#define AUDCLNT_E_ENDPOINT_CREATE_FAILED       AUDCLNT_ERR(0x00f)
#define AUDCLNT_E_SERVICE_NOT_RUNNING          AUDCLNT_ERR(0x010)
#define AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED     AUDCLNT_ERR(0x011)
#define AUDCLNT_E_EXCLUSIVE_MODE_ONLY          AUDCLNT_ERR(0x012)
#define AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL AUDCLNT_ERR(0x013)
#define AUDCLNT_E_EVENTHANDLE_NOT_SET          AUDCLNT_ERR(0x014)
#define AUDCLNT_E_INCORRECT_BUFFER_SIZE        AUDCLNT_ERR(0x015)
#define AUDCLNT_E_BUFFER_SIZE_ERROR            AUDCLNT_ERR(0x016)
#define AUDCLNT_E_CPUUSAGE_EXCEEDED            AUDCLNT_ERR(0x017)
#define AUDCLNT_E_BUFFER_ERROR                 AUDCLNT_ERR(0x018)
#define AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED      AUDCLNT_ERR(0x019)
#define AUDCLNT_E_INVALID_DEVICE_PERIOD        AUDCLNT_ERR(0x020)
#define AUDCLNT_E_INVALID_STREAM_FLAG          AUDCLNT_ERR(0x021)
#define AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE AUDCLNT_ERR(0x022)
#define AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES     AUDCLNT_ERR(0x023)
#define AUDCLNT_E_OFFLOAD_MODE_ONLY            AUDCLNT_ERR(0x024)
#define AUDCLNT_E_NONOFFLOAD_MODE_ONLY         AUDCLNT_ERR(0x025)
#define AUDCLNT_E_RESOURCES_INVALIDATED        AUDCLNT_ERR(0x026)
#define AUDCLNT_E_RAW_MODE_UNSUPPORTED         AUDCLNT_ERR(0x027)
#define AUDCLNT_E_ENGINE_PERIODICITY_LOCKED    AUDCLNT_ERR(0x028)
#define AUDCLNT_E_ENGINE_FORMAT_LOCKED         AUDCLNT_ERR(0x029)
#define AUDCLNT_E_HEADTRACKING_ENABLED         AUDCLNT_ERR(0x030)
#define AUDCLNT_E_HEADTRACKING_UNSUPPORTED     AUDCLNT_ERR(0x040)

Summary

This change provides access to all the available AUDCLNT_E HRESULT error codes from audioclient.h whilst also providing consistency within the API.

JacqiPan and others added 4 commits May 12, 2021 15:56
- Merged AudioClientErrors and ErrorCodes into one AudioClientErrorCodes class. They both serve the same purpose

- Added, renamed and calculated all AUDCLNT_E_ HRESULT definitions from audioclient.h

- Renamed all implementations of AudioClientErrors and ErrorCodes within Wasapi to AudioClientErrorCodes
@JacqiPan JacqiPan closed this May 12, 2021
@JacqiPan JacqiPan deleted the Jacqueline-Patch branch May 12, 2021 14:37
@JacqiPan JacqiPan restored the Jacqueline-Patch branch May 12, 2021 14:37
@JacqiPan
Copy link
Contributor Author

JacqiPan commented May 12, 2021

Sorry, I renamed my branch. Still learning how to properly use Git and GitHub.

@JacqiPan JacqiPan reopened this May 12, 2021
@JacqiPan JacqiPan changed the title Updated Error Codes for consistency with audioclient.h Updated ErrorCodes.cs to provide all the AUDCLNT_E HRESULT codes from audioclient.h May 12, 2021
@JacqiPan JacqiPan changed the title Updated ErrorCodes.cs to provide all the AUDCLNT_E HRESULT codes from audioclient.h Updated ErrorCodes.cs to provide all the AUDCLNT_E HRESULT values from audioclient.h May 12, 2021
@markheath
Copy link
Contributor

Sorry for the long delay getting round to this (I don't have much time to work on NAudio these days), and thanks for the contribution

@markheath markheath merged commit 67c5f2a into naudio:master Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants