mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-07 00:20:09 +00:00
Define SPA_FALLTHROUGH to make fall-through annotations work for all compilers
This is needed for example for Clang compiler which uses different annotations than GCC. It will make WebRTC to happily use PipeWire since the spa library is header-only and WebRTC defaults to use Clang with -Wimplicit-fallthrough.
This commit is contained in:
parent
406b99c4c5
commit
743cf58fb7
|
@ -497,7 +497,7 @@ static int set_default_channels(struct spa_audio_info_raw *info)
|
|||
case 7:
|
||||
info->position[5] = SPA_AUDIO_CHANNEL_SL;
|
||||
info->position[6] = SPA_AUDIO_CHANNEL_SR;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 5:
|
||||
info->position[3] = SPA_AUDIO_CHANNEL_RL;
|
||||
info->position[4] = SPA_AUDIO_CHANNEL_RR;
|
||||
|
@ -508,17 +508,17 @@ static int set_default_channels(struct spa_audio_info_raw *info)
|
|||
case 8:
|
||||
info->position[6] = SPA_AUDIO_CHANNEL_SL;
|
||||
info->position[7] = SPA_AUDIO_CHANNEL_SR;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 6:
|
||||
info->position[4] = SPA_AUDIO_CHANNEL_RL;
|
||||
info->position[5] = SPA_AUDIO_CHANNEL_RR;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 4:
|
||||
info->position[3] = SPA_AUDIO_CHANNEL_LFE;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 3:
|
||||
info->position[2] = SPA_AUDIO_CHANNEL_FC;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 2:
|
||||
info->position[0] = SPA_AUDIO_CHANNEL_FL;
|
||||
info->position[1] = SPA_AUDIO_CHANNEL_FR;
|
||||
|
|
|
@ -228,7 +228,7 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
|
|||
m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
|
||||
m->map[3] = PA_CHANNEL_POSITION_REAR_LEFT;
|
||||
m->map[4] = PA_CHANNEL_POSITION_REAR_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 2:
|
||||
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
|
||||
|
@ -262,20 +262,20 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
|
|||
case 8:
|
||||
m->map[6] = PA_CHANNEL_POSITION_SIDE_LEFT;
|
||||
m->map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 6:
|
||||
m->map[5] = PA_CHANNEL_POSITION_LFE;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 5:
|
||||
m->map[4] = PA_CHANNEL_POSITION_FRONT_CENTER;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 4:
|
||||
m->map[2] = PA_CHANNEL_POSITION_REAR_LEFT;
|
||||
m->map[3] = PA_CHANNEL_POSITION_REAR_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 2:
|
||||
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
|
||||
|
@ -308,44 +308,44 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
|
|||
m->map[15] = PA_CHANNEL_POSITION_TOP_REAR_LEFT;
|
||||
m->map[16] = PA_CHANNEL_POSITION_TOP_REAR_CENTER;
|
||||
m->map[17] = PA_CHANNEL_POSITION_TOP_REAR_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 15:
|
||||
m->map[12] = PA_CHANNEL_POSITION_TOP_FRONT_LEFT;
|
||||
m->map[13] = PA_CHANNEL_POSITION_TOP_FRONT_CENTER;
|
||||
m->map[14] = PA_CHANNEL_POSITION_TOP_FRONT_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 12:
|
||||
m->map[11] = PA_CHANNEL_POSITION_TOP_CENTER;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 11:
|
||||
m->map[9] = PA_CHANNEL_POSITION_SIDE_LEFT;
|
||||
m->map[10] = PA_CHANNEL_POSITION_SIDE_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 9:
|
||||
m->map[8] = PA_CHANNEL_POSITION_REAR_CENTER;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 8:
|
||||
m->map[6] = PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER;
|
||||
m->map[7] = PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 6:
|
||||
m->map[4] = PA_CHANNEL_POSITION_REAR_LEFT;
|
||||
m->map[5] = PA_CHANNEL_POSITION_REAR_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 4:
|
||||
m->map[3] = PA_CHANNEL_POSITION_LFE;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 3:
|
||||
m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 2:
|
||||
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
|
||||
|
@ -366,20 +366,20 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
|
|||
case 8:
|
||||
m->map[6] = PA_CHANNEL_POSITION_REAR_LEFT;
|
||||
m->map[7] = PA_CHANNEL_POSITION_REAR_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 6:
|
||||
m->map[4] = PA_CHANNEL_POSITION_SIDE_LEFT;
|
||||
m->map[5] = PA_CHANNEL_POSITION_SIDE_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 4:
|
||||
m->map[3] = PA_CHANNEL_POSITION_LFE;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 3:
|
||||
m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
case 2:
|
||||
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
|
||||
|
|
|
@ -994,7 +994,7 @@ static void node_event_info(void *object, const struct pw_node_info *info)
|
|||
switch (id) {
|
||||
case SPA_PARAM_EnumFormat:
|
||||
clear_node_formats(g);
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_PARAM_Props:
|
||||
case SPA_PARAM_Format:
|
||||
do_enum = true;
|
||||
|
|
|
@ -587,6 +587,7 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, va_list args)
|
|||
if (type == 0)
|
||||
goto exit;
|
||||
spa_pod_builder_control(builder, offset, type);
|
||||
SPA_FALLTHROUGH
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -420,11 +420,11 @@ do { \
|
|||
case 'a': \
|
||||
va_arg(args, void*); \
|
||||
va_arg(args, void*); \
|
||||
/* fallthrough */ \
|
||||
SPA_FALLTHROUGH \
|
||||
case 'p': \
|
||||
case 'y': \
|
||||
va_arg(args, void*); \
|
||||
/* fallthrough */ \
|
||||
SPA_FALLTHROUGH \
|
||||
case 'b': \
|
||||
case 'I': \
|
||||
case 'i': \
|
||||
|
|
|
@ -36,6 +36,30 @@ extern "C" {
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch
|
||||
* cases that fall through without a break or return statement. SPA_FALLTHROUGH
|
||||
* is only needed on cases that have code:
|
||||
*
|
||||
* switch (foo) {
|
||||
* case 1: // These cases have no code. No fallthrough annotations are needed.
|
||||
* case 2:
|
||||
* case 3:
|
||||
* foo = 4; // This case has code, so a fallthrough annotation is needed:
|
||||
* SPA_FALLTHROUGH;
|
||||
* default:
|
||||
* return foo;
|
||||
* }
|
||||
*/
|
||||
#if defined(__clang__) && __cplusplus >= 201103L
|
||||
/* clang's fallthrough annotations are only available starting in C++11. */
|
||||
# define SPA_FALLTHROUGH [[clang::fallthrough]];
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 7
|
||||
#define SPA_FALLTHROUGH __attribute__ ((fallthrough));
|
||||
#else
|
||||
# define SPA_FALLTHROUGH /* FALLTHROUGH */
|
||||
#endif
|
||||
|
||||
#define SPA_FLAG_MASK(field,mask,flag) (((field) & (mask)) == (flag))
|
||||
#define SPA_FLAG_IS_SET(field,flag) SPA_FLAG_MASK(field,flag,flag)
|
||||
#define SPA_FLAG_SET(field,flag) ((field) |= (flag))
|
||||
|
|
|
@ -1114,7 +1114,7 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
|
|||
}
|
||||
pa_log_warn("Could not recover alsa device from SUSPENDED state, trying to restart PCM");
|
||||
}
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
|
||||
default:
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
|
||||
#define PA_CHANNELS_MAX 64
|
||||
|
||||
#define PA_CHANNEL_MAP_SNPRINT_MAX 336
|
||||
|
@ -161,17 +163,17 @@ static inline pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsign
|
|||
case 8:
|
||||
m->map[6] = PA_CHANNEL_POSITION_SIDE_LEFT;
|
||||
m->map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 6:
|
||||
m->map[5] = PA_CHANNEL_POSITION_LFE;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 5:
|
||||
m->map[4] = PA_CHANNEL_POSITION_FRONT_CENTER;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 4:
|
||||
m->map[2] = PA_CHANNEL_POSITION_REAR_LEFT;
|
||||
m->map[3] = PA_CHANNEL_POSITION_REAR_RIGHT;
|
||||
/* Fall through */
|
||||
SPA_FALLTHROUGH
|
||||
case 2:
|
||||
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
|
||||
m->map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
|
||||
|
|
|
@ -18,6 +18,6 @@ acp_lib = static_library(
|
|||
'acp',
|
||||
acp_sources,
|
||||
c_args : acp_c_args,
|
||||
include_directories : [configinc],
|
||||
include_directories : [configinc, spa_inc ],
|
||||
dependencies : [ alsa_dep, mathlib, ]
|
||||
)
|
||||
|
|
|
@ -516,7 +516,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
break;
|
||||
case SPA_NODE_COMMAND_Suspend:
|
||||
configure_format(this, 0, NULL);
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_NODE_COMMAND_Pause:
|
||||
this->started = false;
|
||||
break;
|
||||
|
|
|
@ -808,7 +808,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
|
||||
case SPA_NODE_COMMAND_Suspend:
|
||||
clean_convert(this);
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_NODE_COMMAND_Pause:
|
||||
this->started = false;
|
||||
break;
|
||||
|
|
|
@ -172,17 +172,17 @@ static uint64_t default_mask(uint32_t channels)
|
|||
case 8:
|
||||
mask |= _MASK(RL);
|
||||
mask |= _MASK(RR);
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case 5:
|
||||
case 6:
|
||||
mask |= _MASK(SL);
|
||||
mask |= _MASK(SR);
|
||||
if ((channels & 1) == 0)
|
||||
mask |= _MASK(LFE);
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case 3:
|
||||
mask |= _MASK(FC);
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case 2:
|
||||
mask |= _MASK(FL);
|
||||
mask |= _MASK(FR);
|
||||
|
@ -466,7 +466,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
this->started = true;
|
||||
break;
|
||||
case SPA_NODE_COMMAND_Suspend:
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_NODE_COMMAND_Pause:
|
||||
this->started = false;
|
||||
break;
|
||||
|
|
|
@ -248,7 +248,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
this->started = true;
|
||||
break;
|
||||
case SPA_NODE_COMMAND_Suspend:
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_NODE_COMMAND_Pause:
|
||||
this->started = false;
|
||||
break;
|
||||
|
|
|
@ -348,7 +348,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
this->started = true;
|
||||
break;
|
||||
case SPA_NODE_COMMAND_Suspend:
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_NODE_COMMAND_Pause:
|
||||
this->started = false;
|
||||
break;
|
||||
|
|
|
@ -262,7 +262,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
update_rate_match(this);
|
||||
break;
|
||||
case SPA_NODE_COMMAND_Suspend:
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_NODE_COMMAND_Pause:
|
||||
resample_reset(&this->resample);
|
||||
this->started = false;
|
||||
|
|
|
@ -330,7 +330,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
this->started = true;
|
||||
break;
|
||||
case SPA_NODE_COMMAND_Suspend:
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case SPA_NODE_COMMAND_Pause:
|
||||
this->started = false;
|
||||
break;
|
||||
|
|
|
@ -229,12 +229,12 @@ static int do_negotiate(struct pw_impl_link *this)
|
|||
case -EIO:
|
||||
current = NULL;
|
||||
res = 0;
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case 1:
|
||||
break;
|
||||
case 0:
|
||||
res = -EBADF;
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
default:
|
||||
error = spa_aprintf("error get output format: %s", spa_strerror(res));
|
||||
goto error;
|
||||
|
@ -263,12 +263,12 @@ static int do_negotiate(struct pw_impl_link *this)
|
|||
case -EIO:
|
||||
current = NULL;
|
||||
res = 0;
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
case 1:
|
||||
break;
|
||||
case 0:
|
||||
res = -EBADF;
|
||||
/* fallthrough */
|
||||
SPA_FALLTHROUGH
|
||||
default:
|
||||
error = spa_aprintf("error get input format: %s", spa_strerror(res));
|
||||
goto error;
|
||||
|
|
Loading…
Reference in a new issue