Commit 2da38e0c authored by Vinod Koul's avatar Vinod Koul Committed by Takashi Iwai

ALSA: compress: fix the struct alignment to 4 bytes

In 64bit systems the compiler can default align to 8bytes causing mis-match with
32bit usermode. Avoid this is future by ensuring all the structures shared with
usermode are packed and aligned to 4 bytes irrespective of arch used

[coding style fixes by tiwai]
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8d42fda9
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
struct snd_compressed_buffer { struct snd_compressed_buffer {
__u32 fragment_size; __u32 fragment_size;
__u32 fragments; __u32 fragments;
}; } __attribute__((packed, aligned(4)));
/** /**
* struct snd_compr_params: compressed stream params * struct snd_compr_params: compressed stream params
...@@ -51,7 +51,7 @@ struct snd_compr_params { ...@@ -51,7 +51,7 @@ struct snd_compr_params {
struct snd_compressed_buffer buffer; struct snd_compressed_buffer buffer;
struct snd_codec codec; struct snd_codec codec;
__u8 no_wake_mode; __u8 no_wake_mode;
}; } __attribute__((packed, aligned(4)));
/** /**
* struct snd_compr_tstamp: timestamp descriptor * struct snd_compr_tstamp: timestamp descriptor
...@@ -70,7 +70,7 @@ struct snd_compr_tstamp { ...@@ -70,7 +70,7 @@ struct snd_compr_tstamp {
__u32 pcm_frames; __u32 pcm_frames;
__u32 pcm_io_frames; __u32 pcm_io_frames;
__u32 sampling_rate; __u32 sampling_rate;
}; } __attribute__((packed, aligned(4)));
/** /**
* struct snd_compr_avail: avail descriptor * struct snd_compr_avail: avail descriptor
...@@ -80,7 +80,7 @@ struct snd_compr_tstamp { ...@@ -80,7 +80,7 @@ struct snd_compr_tstamp {
struct snd_compr_avail { struct snd_compr_avail {
__u64 avail; __u64 avail;
struct snd_compr_tstamp tstamp; struct snd_compr_tstamp tstamp;
} __attribute__((packed)); } __attribute__((packed, aligned(4)));
enum snd_compr_direction { enum snd_compr_direction {
SND_COMPRESS_PLAYBACK = 0, SND_COMPRESS_PLAYBACK = 0,
...@@ -107,7 +107,7 @@ struct snd_compr_caps { ...@@ -107,7 +107,7 @@ struct snd_compr_caps {
__u32 max_fragments; __u32 max_fragments;
__u32 codecs[MAX_NUM_CODECS]; __u32 codecs[MAX_NUM_CODECS];
__u32 reserved[11]; __u32 reserved[11];
}; } __attribute__((packed, aligned(4)));
/** /**
* struct snd_compr_codec_caps: query capability of codec * struct snd_compr_codec_caps: query capability of codec
...@@ -119,7 +119,7 @@ struct snd_compr_codec_caps { ...@@ -119,7 +119,7 @@ struct snd_compr_codec_caps {
__u32 codec; __u32 codec;
__u32 num_descriptors; __u32 num_descriptors;
struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS]; struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];
}; } __attribute__((packed, aligned(4)));
/** /**
* @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the
...@@ -140,7 +140,7 @@ enum { ...@@ -140,7 +140,7 @@ enum {
struct snd_compr_metadata { struct snd_compr_metadata {
__u32 key; __u32 key;
__u32 value[8]; __u32 value[8];
}; } __attribute__((packed, aligned(4)));
/** /**
* compress path ioctl definitions * compress path ioctl definitions
......
...@@ -268,7 +268,7 @@ struct snd_enc_vorbis { ...@@ -268,7 +268,7 @@ struct snd_enc_vorbis {
__u32 max_bit_rate; __u32 max_bit_rate;
__u32 min_bit_rate; __u32 min_bit_rate;
__u32 downmix; __u32 downmix;
}; } __attribute__((packed, aligned(4)));
/** /**
...@@ -284,7 +284,7 @@ struct snd_enc_real { ...@@ -284,7 +284,7 @@ struct snd_enc_real {
__u32 quant_bits; __u32 quant_bits;
__u32 start_region; __u32 start_region;
__u32 num_regions; __u32 num_regions;
}; } __attribute__((packed, aligned(4)));
/** /**
* struct snd_enc_flac * struct snd_enc_flac
...@@ -308,12 +308,12 @@ struct snd_enc_real { ...@@ -308,12 +308,12 @@ struct snd_enc_real {
struct snd_enc_flac { struct snd_enc_flac {
__u32 num; __u32 num;
__u32 gain; __u32 gain;
}; } __attribute__((packed, aligned(4)));
struct snd_enc_generic { struct snd_enc_generic {
__u32 bw; /* encoder bandwidth */ __u32 bw; /* encoder bandwidth */
__s32 reserved[15]; __s32 reserved[15];
}; } __attribute__((packed, aligned(4)));
union snd_codec_options { union snd_codec_options {
struct snd_enc_wma wma; struct snd_enc_wma wma;
...@@ -321,7 +321,7 @@ union snd_codec_options { ...@@ -321,7 +321,7 @@ union snd_codec_options {
struct snd_enc_real real; struct snd_enc_real real;
struct snd_enc_flac flac; struct snd_enc_flac flac;
struct snd_enc_generic generic; struct snd_enc_generic generic;
}; } __attribute__((packed, aligned(4)));
/** struct snd_codec_desc - description of codec capabilities /** struct snd_codec_desc - description of codec capabilities
* @max_ch: Maximum number of audio channels * @max_ch: Maximum number of audio channels
...@@ -358,7 +358,7 @@ struct snd_codec_desc { ...@@ -358,7 +358,7 @@ struct snd_codec_desc {
__u32 formats; __u32 formats;
__u32 min_buffer; __u32 min_buffer;
__u32 reserved[15]; __u32 reserved[15];
}; } __attribute__((packed, aligned(4)));
/** struct snd_codec /** struct snd_codec
* @id: Identifies the supported audio encoder/decoder. * @id: Identifies the supported audio encoder/decoder.
...@@ -399,6 +399,6 @@ struct snd_codec { ...@@ -399,6 +399,6 @@ struct snd_codec {
__u32 align; __u32 align;
union snd_codec_options options; union snd_codec_options options;
__u32 reserved[3]; __u32 reserved[3];
}; } __attribute__((packed, aligned(4)));
#endif #endif
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