提交 b7456178 编写于 作者: G Gymee 提交者: openharmony_ci

!2 【轻量级 PR】:define error codes with enum instead of const for simplicity and uniformity

Merge pull request !2 from Gymee/N/A
上级 8bfbd9c6
...@@ -41,12 +41,12 @@ ...@@ -41,12 +41,12 @@
namespace OHOS { namespace OHOS {
namespace Media { namespace Media {
constexpr int MODULE_MEDIA = 1; constexpr int32_t MODULE_MEDIA = 1;
constexpr int SUBSYS_MEDIA = 30; constexpr int32_t SUBSYS_MEDIA = 30;
using ErrCode = int32_t; using ErrCode = int32_t;
constexpr int SUBSYSTEM_BIT_NUM = 21; constexpr int32_t SUBSYSTEM_BIT_NUM = 21;
constexpr int MODULE_BIT_NUM = 16; constexpr int32_t MODULE_BIT_NUM = 16;
/** /**
* @brief Generates a start error code with a unique identifier based on specified subsystem and module bit numbers. * @brief Generates a start error code with a unique identifier based on specified subsystem and module bit numbers.
...@@ -64,41 +64,32 @@ constexpr ErrCode ErrCodeOffset(unsigned int subsystem, unsigned int module = 0) ...@@ -64,41 +64,32 @@ constexpr ErrCode ErrCodeOffset(unsigned int subsystem, unsigned int module = 0)
constexpr int32_t BASE_MEDIA_ERR_OFFSET = ErrCodeOffset(SUBSYS_MEDIA, MODULE_MEDIA); constexpr int32_t BASE_MEDIA_ERR_OFFSET = ErrCodeOffset(SUBSYS_MEDIA, MODULE_MEDIA);
/** Invalid data size that has been read */ enum MediaErrorCode : int32_t {
const int32_t ERR_INVALID_READ = -1; /** Invalid data size that has been read */
ERR_INVALID_READ = -1,
/** Success */ /** Success */
const int32_t SUCCESS = 0; SUCCESS = 0,
/** Fail */
/** Fail */ ERROR = BASE_MEDIA_ERR_OFFSET,
const int32_t ERROR = BASE_MEDIA_ERR_OFFSET; /** Status error */
ERR_ILLEGAL_STATE = BASE_MEDIA_ERR_OFFSET + 1,
/** Status error */ /** Invalid parameter */
const int32_t ERR_ILLEGAL_STATE = BASE_MEDIA_ERR_OFFSET + 1; ERR_INVALID_PARAM = BASE_MEDIA_ERR_OFFSET + 2,
/** Early media preparation */
/** Invalid parameter */ ERR_EARLY_PREPARE = BASE_MEDIA_ERR_OFFSET + 3,
const int32_t ERR_INVALID_PARAM = BASE_MEDIA_ERR_OFFSET + 2; /** No media source */
ERR_SOURCE_NOT_SET = BASE_MEDIA_ERR_OFFSET + 4,
/** Early media preparation */ /** Invalid operation */
const int32_t ERR_EARLY_PREPARE = BASE_MEDIA_ERR_OFFSET + 3; ERR_INVALID_OPERATION = BASE_MEDIA_ERR_OFFSET + 5,
/** No idle channel */
/** No media source */ ERR_NOFREE_CHANNEL = BASE_MEDIA_ERR_OFFSET + 6,
const int32_t ERR_SOURCE_NOT_SET = BASE_MEDIA_ERR_OFFSET + 4; /** Buffer reading failed */
ERR_READ_BUFFER = BASE_MEDIA_ERR_OFFSET + 7,
/** Invalid operation */ /** Device not started */
const int32_t ERR_INVALID_OPERATION = BASE_MEDIA_ERR_OFFSET + 5; ERR_NOT_STARTED = BASE_MEDIA_ERR_OFFSET + 8,
/** Unknown error */
/** No idle channel */ ERR_UNKNOWN = BASE_MEDIA_ERR_OFFSET + 200,
const int32_t ERR_NOFREE_CHANNEL = BASE_MEDIA_ERR_OFFSET + 6; };
/** Buffer reading failed */
const int32_t ERR_READ_BUFFER = BASE_MEDIA_ERR_OFFSET + 7;
/** Device not started */
const int32_t ERR_NOT_STARTED = BASE_MEDIA_ERR_OFFSET + 8;
/** Unknown error */
const int32_t ERR_UNKNOWN = BASE_MEDIA_ERR_OFFSET + 200;
} // namespace Media } // namespace Media
} // namespace OHOS } // namespace OHOS
#endif // MEDIA_ERRORS_H #endif // MEDIA_ERRORS_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册