Commit 7a903c93 authored by Rafaël Carré's avatar Rafaël Carré

fdkaac error strings: compactify

parent 590285cc
...@@ -141,35 +141,22 @@ struct encoder_sys_t ...@@ -141,35 +141,22 @@ struct encoder_sys_t
HANDLE_AACENCODER handle; HANDLE_AACENCODER handle;
}; };
static const char *aac_get_errorstring(AACENC_ERROR erraac) static const char *fdkaac_error(AACENC_ERROR erraac)
{ {
switch (erraac) { switch (erraac) {
case AACENC_OK: case AACENC_OK: return "No error";
return "No error"; case AACENC_INVALID_HANDLE: return "Invalid handle";
case AACENC_INVALID_HANDLE: case AACENC_MEMORY_ERROR: return "Memory allocation error";
return "Invalid handle"; case AACENC_UNSUPPORTED_PARAMETER: return "Unsupported parameter";
case AACENC_MEMORY_ERROR: case AACENC_INVALID_CONFIG: return "Invalid config";
return "Memory allocation error"; case AACENC_INIT_ERROR: return "Initialization error";
case AACENC_UNSUPPORTED_PARAMETER: case AACENC_INIT_AAC_ERROR: return "AAC library initialization error";
return "Unsupported parameter"; case AACENC_INIT_SBR_ERROR: return "SBR library initialization error";
case AACENC_INVALID_CONFIG: case AACENC_INIT_TP_ERROR: return "Transport library initialization error";
return "Invalid config"; case AACENC_INIT_META_ERROR: return "Metadata library initialization error";
case AACENC_INIT_ERROR: case AACENC_ENCODE_ERROR: return "Encoding error";
return "Initialization error"; case AACENC_ENCODE_EOF: return "End of file";
case AACENC_INIT_AAC_ERROR: default: return "Unknown error";
return "AAC library initialization error";
case AACENC_INIT_SBR_ERROR:
return "SBR library initialization error";
case AACENC_INIT_TP_ERROR:
return "Transport library initialization error";
case AACENC_INIT_META_ERROR:
return "Metadata library initialization error";
case AACENC_ENCODE_ERROR:
return "Encoding error";
case AACENC_ENCODE_EOF:
return "End of file";
default:
return "Unknown error";
} }
} }
...@@ -240,7 +227,7 @@ static int OpenEncoder(vlc_object_t *p_this) ...@@ -240,7 +227,7 @@ static int OpenEncoder(vlc_object_t *p_this)
AACENC_ERROR erraac; AACENC_ERROR erraac;
erraac = aacEncOpen(&p_sys->handle, 0, p_enc->fmt_in.audio.i_channels); erraac = aacEncOpen(&p_sys->handle, 0, p_enc->fmt_in.audio.i_channels);
if (erraac != AACENC_OK) { if (erraac != AACENC_OK) {
msg_Err(p_enc, "Unable to open encoder: %s", aac_get_errorstring(erraac)); msg_Err(p_enc, "Unable to open encoder: %s", fdkaac_error(erraac));
free(p_sys); free(p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -248,7 +235,7 @@ static int OpenEncoder(vlc_object_t *p_this) ...@@ -248,7 +235,7 @@ static int OpenEncoder(vlc_object_t *p_this)
#define SET_PARAM(P, V) do { \ #define SET_PARAM(P, V) do { \
AACENC_ERROR err = aacEncoder_SetParam(p_sys->handle, AACENC_ ## P, V); \ AACENC_ERROR err = aacEncoder_SetParam(p_sys->handle, AACENC_ ## P, V); \
if (err != AACENC_OK) { \ if (err != AACENC_OK) { \
msg_Err(p_enc, "Couldn't set " #P " to value %d: %s", V, aac_get_errorstring(err)); \ msg_Err(p_enc, "Couldn't set " #P " to value %d: %s", V, fdkaac_error(err)); \
goto error; \ goto error; \
} \ } \
} while(0) } while(0)
...@@ -286,14 +273,14 @@ static int OpenEncoder(vlc_object_t *p_this) ...@@ -286,14 +273,14 @@ static int OpenEncoder(vlc_object_t *p_this)
erraac = aacEncEncode(p_sys->handle, NULL, NULL, NULL, NULL); erraac = aacEncEncode(p_sys->handle, NULL, NULL, NULL, NULL);
if (erraac != AACENC_OK) { if (erraac != AACENC_OK) {
msg_Err(p_enc, "Unable to initialize the encoder: %s", aac_get_errorstring(erraac)); msg_Err(p_enc, "Unable to initialize the encoder: %s", fdkaac_error(erraac));
goto error; goto error;
} }
AACENC_InfoStruct info = { 0 }; AACENC_InfoStruct info = { 0 };
erraac = aacEncInfo(p_sys->handle, &info); erraac = aacEncInfo(p_sys->handle, &info);
if (erraac != AACENC_OK) { if (erraac != AACENC_OK) {
msg_Err(p_enc, "Unable to get the encoder info: %s", aac_get_errorstring(erraac)); msg_Err(p_enc, "Unable to get the encoder info: %s", fdkaac_error(erraac));
goto error; goto error;
} }
...@@ -398,7 +385,7 @@ static block_t *EncodeAudio(encoder_t *p_enc, block_t *p_aout_buf) ...@@ -398,7 +385,7 @@ static block_t *EncodeAudio(encoder_t *p_enc, block_t *p_aout_buf)
if (erraac == AACENC_ENCODE_EOF) { if (erraac == AACENC_ENCODE_EOF) {
msg_Info(p_enc, "Encoding final bytes (EOF)"); msg_Info(p_enc, "Encoding final bytes (EOF)");
} else { } else {
msg_Err(p_enc, "Encoding failed: %s", aac_get_errorstring(erraac)); msg_Err(p_enc, "Encoding failed: %s", fdkaac_error(erraac));
block_Release(p_block); block_Release(p_block);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment