# HG changeset patch # User reimar # Date 1105021928 0 # Node ID 1a882e2a419b284b9a8ca7abd966face51c8521c # Parent 889b6b99b1b85a4088c32f25da8e92b9a3b925a6 af_fmt2str fixes (remove trailing space, call with size of buffer, not size-1) diff -r 889b6b99b1b8 -r 1a882e2a419b libaf/af_format.c --- a/libaf/af_format.c Thu Jan 06 13:31:02 2005 +0000 +++ b/libaf/af_format.c Thu Jan 06 14:32:08 2005 +0000 @@ -164,6 +164,9 @@ i+=snprintf(&str[i],size-i,"int "); } } + // remove trailing space + if (i > 0 && str[i - 1] == ' ') + i--; str[i] = 0; // make sure it is 0 terminated. return str; } @@ -268,7 +271,7 @@ case(AF_FORMAT_MPEG2): case(AF_FORMAT_AC3): af_msg(AF_MSG_ERROR,"[format] Sample format %s not yet supported \n", - af_fmt2str(format,buf,255)); + af_fmt2str(format,buf,256)); return AF_ERROR; } return AF_OK; @@ -295,9 +298,9 @@ (AF_OK != check_format(af->data->format))) return AF_ERROR; - af_msg(AF_MSG_VERBOSE,"[format] Changing sample format from %sto %s \n", - af_fmt2str(((af_data_t*)arg)->format,buf1,255), - af_fmt2str(af->data->format,buf2,255)); + af_msg(AF_MSG_VERBOSE,"[format] Changing sample format from %s to %s\n", + af_fmt2str(((af_data_t*)arg)->format,buf1,256), + af_fmt2str(af->data->format,buf2,256)); af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; @@ -316,17 +319,17 @@ if ((data->format == AF_FORMAT_FLOAT_NE) && (af->data->format == AF_FORMAT_S16_NE)) { - af_msg(AF_MSG_VERBOSE,"[format] Accelerated %sto %sconversion\n", - af_fmt2str(((af_data_t*)arg)->format,buf1,255), - af_fmt2str(af->data->format,buf2,255)); + af_msg(AF_MSG_VERBOSE,"[format] Accelerated %s to %s conversion\n", + af_fmt2str(((af_data_t*)arg)->format,buf1,256), + af_fmt2str(af->data->format,buf2,256)); af->play = play_float_s16; } if ((data->format == AF_FORMAT_S16_NE) && (af->data->format == AF_FORMAT_FLOAT_NE)) { - af_msg(AF_MSG_VERBOSE,"[format] Accelerated %sto %sconversion\n", - af_fmt2str(((af_data_t*)arg)->format,buf1,255), - af_fmt2str(af->data->format,buf2,255)); + af_msg(AF_MSG_VERBOSE,"[format] Accelerated %s to %s conversion\n", + af_fmt2str(((af_data_t*)arg)->format,buf1,256), + af_fmt2str(af->data->format,buf2,256)); af->play = play_s16_float; } return AF_OK;