Remove explicit 'enum codec_command_action' in codec API

Just use long so the compiler potentially doesn't complain about
use of other values not in the enum. It's also the type used
around the system for event ids.

Increase min codec API version.

No functional changes.

Change-Id: If4419b42912f5e4ef673adcdeb69313e503f94cc
This commit is contained in:
Michael Sevakis 2017-12-07 13:21:57 -05:00
parent 83e8e35a58
commit 6c868dd48f
46 changed files with 55 additions and 52 deletions

View file

@ -349,8 +349,7 @@ static void codec_configure_callback(int setting, intptr_t value)
dsp_configure(ci.dsp, setting, value); dsp_configure(ci.dsp, setting, value);
} }
static enum codec_command_action static long codec_get_command_callback(intptr_t *param)
codec_get_command_callback(intptr_t *param)
{ {
yield(); yield();
@ -361,7 +360,7 @@ static enum codec_command_action
be expected) */ be expected) */
while (1) while (1)
{ {
enum codec_command_action action = CODEC_ACTION_NULL; long action = CODEC_ACTION_NULL;
struct queue_event ev; struct queue_event ev;
queue_peek(&codec_queue, &ev); /* Find out what it is */ queue_peek(&codec_queue, &ev); /* Find out what it is */

View file

@ -173,7 +173,7 @@ enum codec_status codec_run(void)
/* The main decoding loop */ /* The main decoding loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -148,7 +148,7 @@ enum codec_status codec_run(void)
int consumed, packet_offset; int consumed, packet_offset;
int playback_on = -1; int playback_on = -1;
size_t resume_offset; size_t resume_offset;
enum codec_command_action action; long action;
intptr_t param; intptr_t param;
if (codec_init()) { if (codec_init()) {

View file

@ -72,7 +72,7 @@ enum codec_status codec_run(void)
uint32_t sbr_fac = 1; uint32_t sbr_fac = 1;
unsigned char c = 0; unsigned char c = 0;
void *ret; void *ret;
enum codec_command_action action; long action;
intptr_t param; intptr_t param;
bool empty_first_frame = false; bool empty_first_frame = false;

View file

@ -236,7 +236,7 @@ enum codec_status codec_run(void)
/* The main decoder loop */ /* The main decoder loop */
while (!endofstream) { while (!endofstream) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -305,7 +305,7 @@ enum codec_status codec_run(void)
endofstream = 0; endofstream = 0;
while (!endofstream) { while (!endofstream) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -207,7 +207,7 @@ enum codec_status ICODE_ATTR codec_run(void)
/* main encoding loop */ /* main encoding loop */
while (1) while (1)
{ {
enum codec_command_action action = ci->get_command(NULL); long action = ci->get_command(NULL);
if (action != CODEC_ACTION_NULL) if (action != CODEC_ACTION_NULL)
break; break;

View file

@ -109,7 +109,7 @@ enum codec_status codec_run(void)
/* The main decoding loop */ /* The main decoding loop */
while (i < demux_res.num_sample_byte_sizes) { while (i < demux_res.num_sample_byte_sizes) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -155,7 +155,7 @@ enum codec_status codec_run(void)
int res; int res;
int firstbyte; int firstbyte;
size_t resume_offset; size_t resume_offset;
enum codec_command_action action; long action;
intptr_t param; intptr_t param;
if (codec_init()) { if (codec_init()) {

View file

@ -107,7 +107,7 @@ enum codec_status codec_run(void)
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -50,7 +50,7 @@ enum codec_status codec_run(void)
int elapsed = 0; int elapsed = 0;
size_t resume_offset; size_t resume_offset;
intptr_t param; intptr_t param;
enum codec_command_action action; long action;
if (codec_init()) { if (codec_init()) {
DEBUGF("codec init failed\n"); DEBUGF("codec init failed\n");

View file

@ -61,7 +61,7 @@ enum codec_status codec_run(void)
int playback_on = -1; int playback_on = -1;
size_t resume_offset; size_t resume_offset;
intptr_t param; intptr_t param;
enum codec_command_action action; long action;
if (codec_init()) { if (codec_init()) {
DEBUGF("codec init failed\n"); DEBUGF("codec init failed\n");

View file

@ -270,7 +270,7 @@ enum codec_status codec_run(void)
endofstream = 0; endofstream = 0;
while (!endofstream) { while (!endofstream) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -97,7 +97,7 @@ next_track:
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -46,6 +46,8 @@
#include "gcc_extensions.h" #include "gcc_extensions.h"
#include "load_code.h" #include "load_code.h"
#include <limits.h>
#ifdef CODEC #ifdef CODEC
#if defined(DEBUG) || defined(SIMULATOR) #if defined(DEBUG) || defined(SIMULATOR)
#undef DEBUGF #undef DEBUGF
@ -72,12 +74,12 @@
#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define CODEC_API_VERSION 47 #define CODEC_API_VERSION 48
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define CODEC_MIN_API_VERSION 47 #define CODEC_MIN_API_VERSION 48
/* reasons for calling codec main entrypoint */ /* reasons for calling codec main entrypoint */
enum codec_entry_call_reason { enum codec_entry_call_reason {
@ -99,6 +101,8 @@ enum codec_command_action {
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
CODEC_ACTION_STREAM_FINISH = 2, CODEC_ACTION_STREAM_FINISH = 2,
#endif #endif
CODEC_ACTION_MIN = LONG_MIN,
CODEC_ACTION_MAX = LONG_MAX,
}; };
/* NOTE: To support backwards compatibility, only add new functions at /* NOTE: To support backwards compatibility, only add new functions at
@ -144,7 +148,7 @@ struct codec_api {
/* Configure different codec buffer parameters. */ /* Configure different codec buffer parameters. */
void (*configure)(int setting, intptr_t value); void (*configure)(int setting, intptr_t value);
/* Obtain command action on what to do next */ /* Obtain command action on what to do next */
enum codec_command_action (*get_command)(intptr_t *param); long (*get_command)(intptr_t *param);
/* Determine whether the track should be looped, if applicable. */ /* Determine whether the track should be looped, if applicable. */
bool (*loop_track)(void); bool (*loop_track)(void);

View file

@ -57,7 +57,7 @@ enum codec_status codec_run(void)
int scrambling_unit_size, num_units; int scrambling_unit_size, num_units;
size_t resume_offset; size_t resume_offset;
intptr_t param; intptr_t param;
enum codec_command_action action; long action;
if (codec_init()) { if (codec_init()) {
DEBUGF("codec init failed\n"); DEBUGF("codec init failed\n");

View file

@ -498,7 +498,7 @@ enum codec_status codec_run(void)
frame=0; frame=0;
buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE);
while (bytesleft) { while (bytesleft) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -86,7 +86,7 @@ next_track:
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -86,7 +86,7 @@ next_track:
/* The main decoder loop */ /* The main decoder loop */
while ( 1 ) { while ( 1 ) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -89,7 +89,7 @@ next_track:
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -1333,7 +1333,7 @@ enum codec_status codec_run(void)
old_patterntableposition = 0; old_patterntableposition = 0;
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -2961,7 +2961,7 @@ enum codec_status codec_run(void)
while (1) while (1)
{ {
intptr_t param; intptr_t param;
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action != CODEC_ACTION_NULL) if (action != CODEC_ACTION_NULL)
{ {

View file

@ -392,7 +392,7 @@ enum codec_status codec_run(void)
/* This is the decoding loop. */ /* This is the decoding loop. */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -148,7 +148,7 @@ enum codec_status codec_run(void)
/* This is the decoding loop. */ /* This is the decoding loop. */
do do
{ {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
return CODEC_OK; return CODEC_OK;

View file

@ -95,7 +95,7 @@ next_track:
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -314,7 +314,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason)
enum codec_status codec_run(void) enum codec_status codec_run(void)
{ {
int error = CODEC_ERROR; int error = CODEC_ERROR;
enum codec_command_action action; long action;
intptr_t param; intptr_t param;
ogg_sync_state oy; ogg_sync_state oy;
ogg_page og; ogg_page og;

View file

@ -63,7 +63,7 @@ enum codec_status codec_run(void)
unsigned char c = 0; /* channels */ unsigned char c = 0; /* channels */
int playback_on = -1; int playback_on = -1;
size_t resume_offset; size_t resume_offset;
enum codec_command_action action; long action;
intptr_t param; intptr_t param;
if (codec_init()) { if (codec_init()) {

View file

@ -101,7 +101,7 @@ next_track:
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -110,7 +110,7 @@ seek_start:
samplesdone = 0; samplesdone = 0;
buf = ci->request_buffer(&bytesleft, MAX_BUFFER_SIZE); buf = ci->request_buffer(&bytesleft, MAX_BUFFER_SIZE);
while (bytesleft) { while (bytesleft) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -1277,7 +1277,7 @@ enum codec_status codec_run(void)
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -446,7 +446,7 @@ enum codec_status codec_run(void)
endofstream = 0; endofstream = 0;
while (!endofstream) { while (!endofstream) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -453,7 +453,7 @@ static int play_track( void )
while ( 1 ) while ( 1 )
{ {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -405,7 +405,7 @@ enum codec_status codec_run(void)
unsigned long strtoffset; unsigned long strtoffset;
void *st = NULL; void *st = NULL;
int j = 0; int j = 0;
enum codec_command_action action; long action;
intptr_t param; intptr_t param;
memset(&bits, 0, sizeof(bits)); memset(&bits, 0, sizeof(bits));

View file

@ -104,7 +104,7 @@ enum codec_status codec_run(void)
while (!endofstream) while (!endofstream)
{ {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -135,7 +135,7 @@ enum codec_status codec_run(void)
/* The main decoder loop */ /* The main decoder loop */
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -206,7 +206,7 @@ enum codec_status codec_run(void)
previous_section = -1; previous_section = -1;
while (1) { while (1) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -159,7 +159,7 @@ enum codec_status codec_run(void)
endofstream = 0; endofstream = 0;
while (!endofstream) { while (!endofstream) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -396,7 +396,7 @@ enum codec_status codec_run(void)
endofstream = 0; endofstream = 0;
while (!endofstream) { while (!endofstream) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -400,7 +400,7 @@ enum codec_status codec_run(void)
endofstream = 0; endofstream = 0;
while (!endofstream) { while (!endofstream) {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -188,7 +188,7 @@ enum codec_status ICODE_ATTR codec_run(void)
/* main encoding loop */ /* main encoding loop */
while (1) while (1)
{ {
enum codec_command_action action = ci->get_command(NULL); long action = ci->get_command(NULL);
if (action != CODEC_ACTION_NULL) if (action != CODEC_ACTION_NULL)
break; break;

View file

@ -90,7 +90,7 @@ enum codec_status codec_run(void)
while (1) { while (1) {
int32_t nsamples; int32_t nsamples;
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -353,7 +353,7 @@ enum codec_status codec_run(void)
/* main encoding loop */ /* main encoding loop */
while (1) while (1)
{ {
enum codec_command_action action = ci->get_command(NULL); long action = ci->get_command(NULL);
if (action != CODEC_ACTION_NULL) if (action != CODEC_ACTION_NULL)
break; break;

2
lib/rbcodec/codecs/wma.c Executable file → Normal file
View file

@ -52,7 +52,7 @@ enum codec_status codec_run(void)
int audiobufsize; int audiobufsize;
int packetlength = 0; int packetlength = 0;
int errcount = 0; int errcount = 0;
enum codec_command_action action; long action;
intptr_t param; intptr_t param;
/* Remember the resume position - when the codec is opened, the /* Remember the resume position - when the codec is opened, the

View file

@ -93,7 +93,7 @@ restart_track:
while (pktcnt < wfx.numpackets) while (pktcnt < wfx.numpackets)
{ {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -120,7 +120,7 @@ restart_track:
while (pktcnt < wfx.numpackets) while (pktcnt < wfx.numpackets)
{ {
enum codec_command_action action = ci->get_command(&param); long action = ci->get_command(&param);
if (action == CODEC_ACTION_HALT) if (action == CODEC_ACTION_HALT)
break; break;

View file

@ -108,7 +108,7 @@ static const char *config = "";
static uint32_t playback_vol_factor = VOL_FACTOR_UNITY; static uint32_t playback_vol_factor = VOL_FACTOR_UNITY;
static int input_fd; static int input_fd;
static enum codec_command_action codec_action; static long codec_action;
static intptr_t codec_action_param = 0; static intptr_t codec_action_param = 0;
static unsigned long num_output_samples = 0; static unsigned long num_output_samples = 0;
static struct codec_api ci; static struct codec_api ci;
@ -606,9 +606,9 @@ static void ci_configure(int setting, intptr_t value)
} }
} }
static enum codec_command_action ci_get_command(intptr_t *param) static long ci_get_command(intptr_t *param)
{ {
enum codec_command_action ret = codec_action; long ret = codec_action;
*param = codec_action_param; *param = codec_action_param;
codec_action = CODEC_ACTION_NULL; codec_action = CODEC_ACTION_NULL;
return ret; return ret;