OSDN Git Service

Fix audio_config size difference between 32 and 64 bit.
authorChinyue Chen <chinyue@google.com>
Wed, 13 Sep 2017 09:24:16 +0000 (17:24 +0800)
committerChinyue Chen <chinyue@google.com>
Thu, 14 Sep 2017 08:50:48 +0000 (16:50 +0800)
The audioserver is built in 32 bit by default and does not exchange data
correctly with 64 bit Apps. The CL fixes the alignment and size_t issue.

Bug: 64699517
Test: Verify audio and soundtrigger HAL working on Eve.
Change-Id: Iec2b07e9b53b278147609c26a480890d409bdaa5

audio/include/system/audio.h
audio/include/system/sound_trigger.h

index e683d60..bfeb5ee 100644 (file)
@@ -225,6 +225,7 @@ typedef uint32_t audio_devices_t;
  * hardware playback
  * The version and size fields must be initialized by the caller by using
  * one of the constants defined here.
+ * Must be aligned to transmit as raw memory through Binder.
  */
 typedef struct {
     uint16_t version;                   // version of the info structure
@@ -240,7 +241,7 @@ typedef struct {
     uint32_t bit_width;
     uint32_t offload_buffer_size;       // offload fragment size
     audio_usage_t usage;
-} audio_offload_info_t;
+} __attribute__((aligned(8))) audio_offload_info_t;
 
 #define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \
             ((((maj) & 0xff) << 8) | ((min) & 0xff))
@@ -267,13 +268,14 @@ static const audio_offload_info_t AUDIO_INFO_INITIALIZER = {
 /* common audio stream configuration parameters
  * You should memset() the entire structure to zero before use to
  * ensure forward compatibility
+ * Must be aligned to transmit as raw memory through Binder.
  */
-struct audio_config {
+struct __attribute__((aligned(8))) audio_config {
     uint32_t sample_rate;
     audio_channel_mask_t channel_mask;
     audio_format_t  format;
     audio_offload_info_t offload_info;
-    size_t frame_count;
+    uint32_t frame_count;
 };
 typedef struct audio_config audio_config_t;
 
index c5156d9..6182ff3 100644 (file)
@@ -137,8 +137,9 @@ struct sound_trigger_generic_sound_model {
 
 /*
  * Generic recognition event sent via recognition callback
+ * Must be aligned to transmit as raw memory through Binder.
  */
-struct sound_trigger_recognition_event {
+struct __attribute__((aligned(8))) sound_trigger_recognition_event {
     int                              status;            /* recognition status e.g.
                                                            RECOGNITION_STATUS_SUCCESS */
     sound_trigger_sound_model_type_t type;              /* event type, same as sound model type.