engine: common: soundlib: reformat everything using uncrustify

This commit is contained in:
Alibek Omarov 2024-12-02 18:58:50 +03:00
parent eb64ffcec9
commit 2d52dae69c
4 changed files with 156 additions and 134 deletions

View file

@ -80,11 +80,13 @@ static void Sound_ScanOpusComments( const OggOpusFile *of )
const OpusTags *tags = op_tags( of, -1 );
if( tags )
{
if(( value = opus_tags_query( tags, "LOOPSTART", 0 ))) {
if(( value = opus_tags_query( tags, "LOOPSTART", 0 )))
{
sound.loopstart = Q_atoi( value );
SetBits( sound.flags, SOUND_LOOPED );
}
else if(( value = opus_tags_query( tags, "LOOP_START", 0 ))) {
else if(( value = opus_tags_query( tags, "LOOP_START", 0 )))
{
sound.loopstart = Q_atoi( value );
SetBits( sound.flags, SOUND_LOOPED );
}
@ -141,13 +143,15 @@ qboolean Sound_LoadOggOpus( const char *name, const byte *buffer, fs_offset_t fi
OggFilestream_Init( &file, name, buffer, filesize );
of = op_open_callbacks( &file, &op_callbacks_membuf, NULL, 0, &ret );
if( !of ) {
if( !of )
{
Con_DPrintf( S_ERROR "%s: failed to load (%s): %s\n", __func__, file.name, Opus_GetErrorDesc( ret ));
return false;
}
opusHead = op_head( of, -1 );
if( opusHead->channel_count < 1 || opusHead->channel_count > 2 ) {
if( opusHead->channel_count < 1 || opusHead->channel_count > 2 )
{
Con_DPrintf( S_ERROR "%s: failed to load (%s): unsuppored channels count\n", __func__, file.name );
return false;
}
@ -163,7 +167,8 @@ qboolean Sound_LoadOggOpus( const char *name, const byte *buffer, fs_offset_t fi
sound.wav = (byte *)Mem_Calloc( host.soundpool, sound.size );
// skip undesired samples before playing sound
if(( ret = op_pcm_seek( of, opusHead->pre_skip )) < 0 ) {
if(( ret = op_pcm_seek( of, opusHead->pre_skip )) < 0 )
{
Con_DPrintf( S_ERROR "%s: failed to pre-skip (%s): %s\n", __func__, file.name, Opus_GetErrorDesc( ret ));
return false;
}
@ -173,7 +178,8 @@ qboolean Sound_LoadOggOpus( const char *name, const byte *buffer, fs_offset_t fi
while(( ret = op_read( of, (opus_int16 *)( sound.wav + written ), ( sound.size - written ) / sound.width, NULL )) != 0 )
{
if( ret < 0 ) {
if( ret < 0 )
{
Con_DPrintf( S_ERROR "%s: failed to read (%s): %s\n", __func__, file.name, Opus_GetErrorDesc( ret ));
return false;
}
@ -193,7 +199,8 @@ stream_t *Stream_OpenOggOpus( const char *filename )
ctx = (opus_streaming_ctx_t *)Mem_Calloc( host.soundpool, sizeof( opus_streaming_ctx_t ));
ctx->file = FS_Open( filename, "rb", false );
if( !ctx->file ) {
if( !ctx->file )
{
Mem_Free( ctx );
return NULL;
}
@ -213,7 +220,8 @@ stream_t *Stream_OpenOggOpus( const char *filename )
}
opusHead = op_head( ctx->of, -1 );
if( opusHead->channel_count < 1 || opusHead->channel_count > 2 ) {
if( opusHead->channel_count < 1 || opusHead->channel_count > 2 )
{
Con_DPrintf( S_ERROR "%s: failed to load (%s): unsuppored channels count\n", __func__, filename );
op_free( ctx->of );
FS_Close( ctx->file );
@ -223,7 +231,8 @@ stream_t *Stream_OpenOggOpus( const char *filename )
}
// skip undesired samples before playing sound
if(( ret = op_pcm_seek( ctx->of, opusHead->pre_skip )) < 0 ) {
if(( ret = op_pcm_seek( ctx->of, opusHead->pre_skip )) < 0 )
{
Con_DPrintf( S_ERROR "%s: failed to pre-skip (%s): %s\n", __func__, filename, Opus_GetErrorDesc( ret ));
op_free( ctx->of );
FS_Close( ctx->file );
@ -267,7 +276,8 @@ int Stream_ReadOggOpus( stream_t *stream, int needBytes, void *buffer )
// check remaining size
if( bytesWritten + stream->pos > needBytes )
outsize = ( needBytes - bytesWritten );
else outsize = stream->pos;
else
outsize = stream->pos;
// copy raw sample to output buffer
data = (byte *)buffer + bytesWritten;
@ -290,7 +300,8 @@ int Stream_SetPosOggOpus( stream_t *stream, int newpos )
{
int ret;
opus_streaming_ctx_t *ctx = (opus_streaming_ctx_t *)stream->ptr;
if(( ret = op_raw_seek( ctx->of, newpos )) == 0 ) {
if(( ret = op_raw_seek( ctx->of, newpos )) == 0 )
{
stream->buffsize = 0; // flush any previous data
return true;
}

View file

@ -107,11 +107,13 @@ static void Sound_ScanVorbisComments( OggVorbis_File *vf )
vorbis_comment *vc = ov_comment( vf, -1 );
if( vc )
{
if(( value = vorbis_comment_query( vc, "LOOPSTART", 0 ))) {
if(( value = vorbis_comment_query( vc, "LOOPSTART", 0 )))
{
sound.loopstart = Q_atoi( value );
SetBits( sound.flags, SOUND_LOOPED );
}
else if(( value = vorbis_comment_query( vc, "LOOP_START", 0 ))) {
else if(( value = vorbis_comment_query( vc, "LOOP_START", 0 )))
{
sound.loopstart = Q_atoi( value );
SetBits( sound.flags, SOUND_LOOPED );
}
@ -131,13 +133,15 @@ qboolean Sound_LoadOggVorbis( const char *name, const byte *buffer, fs_offset_t
return false;
OggFilestream_Init( &file, name, buffer, filesize );
if(( ret = ov_open_callbacks( &file, &vorbisFile, NULL, 0, ov_callbacks_membuf )) < 0 ) {
if(( ret = ov_open_callbacks( &file, &vorbisFile, NULL, 0, ov_callbacks_membuf )) < 0 )
{
Con_DPrintf( S_ERROR "%s: failed to load (%s): %s\n", __func__, file.name, Vorbis_GetErrorDesc( ret ));
return false;
}
info = ov_info( &vorbisFile, -1 );
if( info->channels < 1 || info->channels > 2 ) {
if( info->channels < 1 || info->channels > 2 )
{
Con_DPrintf( S_ERROR "%s: failed to load (%s): unsuppored channels count\n", __func__, file.name );
return false;
}
@ -155,7 +159,8 @@ qboolean Sound_LoadOggVorbis( const char *name, const byte *buffer, fs_offset_t
while(( ret = ov_read( &vorbisFile, (char *)sound.wav + written, sound.size - written, 0, sound.width, 1, &section )) != 0 )
{
if( ret < 0 ) {
if( ret < 0 )
{
Con_DPrintf( S_ERROR "%s: failed to load (%s): %s\n", __func__, file.name, Vorbis_GetErrorDesc( ret ));
return false;
}
@ -175,7 +180,8 @@ stream_t *Stream_OpenOggVorbis( const char *filename )
ctx = (vorbis_streaming_ctx_t *)Mem_Calloc( host.soundpool, sizeof( vorbis_streaming_ctx_t ));
ctx->file = FS_Open( filename, "rb", false );
if (!ctx->file) {
if( !ctx->file )
{
Mem_Free( ctx );
return NULL;
}
@ -194,7 +200,8 @@ stream_t *Stream_OpenOggVorbis( const char *filename )
}
info = ov_info( &ctx->vf, -1 );
if( info->channels < 1 || info->channels > 2 ) {
if( info->channels < 1 || info->channels > 2 )
{
Con_DPrintf( S_ERROR "%s: failed to load (%s): unsuppored channels count\n", __func__, filename );
FS_Close( ctx->file );
Mem_Free( stream );
@ -226,10 +233,12 @@ int Stream_ReadOggVorbis( stream_t *stream, int needBytes, void *buffer )
if( !stream->buffsize )
{
stream->pos = ov_read( &ctx->vf, (char *)stream->temp, OUTBUF_SIZE, 0, stream->width, 1, &section );
if( stream->pos == 0 ) {
if( stream->pos == 0 )
{
break; // end of file
}
else if( stream->pos < 0 ) {
else if( stream->pos < 0 )
{
Con_DPrintf( S_ERROR "%s: error during read: %s\n", __func__, Vorbis_GetErrorDesc( stream->pos ));
}
}
@ -237,7 +246,8 @@ int Stream_ReadOggVorbis( stream_t *stream, int needBytes, void *buffer )
// check remaining size
if( bytesWritten + stream->pos > needBytes )
outsize = ( needBytes - bytesWritten );
else outsize = stream->pos;
else
outsize = stream->pos;
// copy raw sample to output buffer
data = (byte *)buffer + bytesWritten;
@ -260,7 +270,8 @@ int Stream_SetPosOggVorbis( stream_t *stream, int newpos )
{
int ret;
vorbis_streaming_ctx_t *ctx = (vorbis_streaming_ctx_t *)stream->ptr;
if(( ret = ov_raw_seek_lap( &ctx->vf, newpos )) == 0 ) {
if(( ret = ov_raw_seek_lap( &ctx->vf, newpos )) == 0 )
{
stream->buffsize = 0; // flush any previous data
return true;
}