hal: fix incompatible APIs
Avoid usage of deprecated API audio_stream_frame_size() Update open_input_stream() and open_output_stream() APIs to match the updated signature. Change-Id: I70f9142d53d562b2ce0a286ef2900938fc066876
This commit is contained in:
parent
2703c36053
commit
c3bc08123e
101
hal/audio_hw.c
101
hal/audio_hw.c
|
@ -1148,7 +1148,7 @@ static bool allow_hdmi_channel_config(struct audio_device *adev)
|
|||
ret = false;
|
||||
break;
|
||||
} else if (is_offload_usecase(usecase->id) &&
|
||||
popcount(usecase->stream.out->channel_mask) > 2) {
|
||||
audio_channel_count_from_out_mask(usecase->stream.out->channel_mask) > 2) {
|
||||
ALOGD("%s: multi-channel(%x) compress offload playback is active, "
|
||||
"no change in HDMI channels", __func__, usecase->stream.out->channel_mask);
|
||||
ret = false;
|
||||
|
@ -1434,7 +1434,8 @@ static size_t out_get_buffer_size(const struct audio_stream *stream)
|
|||
else if(out->usecase == USECASE_COMPRESS_VOIP_CALL)
|
||||
return voice_extn_compress_voip_out_get_buffer_size(out);
|
||||
|
||||
return out->config.period_size * audio_stream_frame_size(stream);
|
||||
return out->config.period_size *
|
||||
audio_stream_out_frame_size((const struct audio_stream_out *)stream);
|
||||
}
|
||||
|
||||
static uint32_t out_get_channels(const struct audio_stream *stream)
|
||||
|
@ -1870,7 +1871,7 @@ exit:
|
|||
out->standby = true;
|
||||
}
|
||||
out_standby(&out->stream.common);
|
||||
usleep(bytes * 1000000 / audio_stream_frame_size(&out->stream.common) /
|
||||
usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) /
|
||||
out_get_sample_rate(&out->stream.common));
|
||||
|
||||
}
|
||||
|
@ -2080,7 +2081,8 @@ static size_t in_get_buffer_size(const struct audio_stream *stream)
|
|||
else if(audio_extn_compr_cap_usecase_supported(in->usecase))
|
||||
return audio_extn_compr_cap_get_buffer_size(in->config.format);
|
||||
|
||||
return in->config.period_size * audio_stream_frame_size(stream);
|
||||
return in->config.period_size *
|
||||
audio_stream_in_frame_size((const struct audio_stream_in *)stream);
|
||||
}
|
||||
|
||||
static uint32_t in_get_channels(const struct audio_stream *stream)
|
||||
|
@ -2170,7 +2172,7 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
|
|||
(in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
|
||||
(voice_extn_compress_voip_is_format_supported(in->format)) &&
|
||||
(in->config.rate == 8000 || in->config.rate == 16000) &&
|
||||
(popcount(in->channel_mask) == 1)) {
|
||||
(audio_channel_count_from_in_mask(in->channel_mask) == 1)) {
|
||||
err = voice_extn_compress_voip_open_input_stream(in);
|
||||
if (err != 0) {
|
||||
ALOGE("%s: Compress voip input cannot be opened, error:%d",
|
||||
|
@ -2265,7 +2267,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
|
|||
}
|
||||
|
||||
if (in->pcm) {
|
||||
if (audio_extn_ssr_get_enabled() && popcount(in->channel_mask) == 6)
|
||||
if (audio_extn_ssr_get_enabled() &&
|
||||
audio_channel_count_from_in_mask(in->channel_mask) == 6)
|
||||
ret = audio_extn_ssr_read(stream, buffer, bytes);
|
||||
else if (audio_extn_compr_cap_usecase_supported(in->usecase))
|
||||
ret = audio_extn_compr_cap_read(in, buffer, bytes);
|
||||
|
@ -2300,7 +2303,7 @@ exit:
|
|||
memset(buffer, 0, bytes);
|
||||
in_standby(&in->stream.common);
|
||||
ALOGV("%s: read failed status %d- sleeping for buffer duration", __func__, ret);
|
||||
usleep(bytes * 1000000 / audio_stream_frame_size(&in->stream.common) /
|
||||
usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) /
|
||||
in_get_sample_rate(&in->stream.common));
|
||||
}
|
||||
return bytes;
|
||||
|
@ -2363,7 +2366,8 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
|
|||
audio_devices_t devices,
|
||||
audio_output_flags_t flags,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_out **stream_out)
|
||||
struct audio_stream_out **stream_out,
|
||||
const char *address __unused)
|
||||
{
|
||||
struct audio_device *adev = (struct audio_device *)dev;
|
||||
struct stream_out *out;
|
||||
|
@ -2389,9 +2393,6 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&out->lock, (const pthread_mutexattr_t *) NULL);
|
||||
pthread_cond_init(&out->cond, (const pthread_condattr_t *) NULL);
|
||||
|
||||
if (devices == AUDIO_DEVICE_NONE)
|
||||
devices = AUDIO_DEVICE_OUT_SPEAKER;
|
||||
|
||||
|
@ -2430,7 +2431,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
|
|||
out->usecase = USECASE_AUDIO_PLAYBACK_MULTI_CH;
|
||||
out->config = pcm_config_hdmi_multi;
|
||||
out->config.rate = config->sample_rate;
|
||||
out->config.channels = popcount(out->channel_mask);
|
||||
out->config.channels = audio_channel_count_from_out_mask(out->channel_mask);
|
||||
out->config.period_size = HDMI_MULTI_PERIOD_BYTES / (out->config.channels * 2);
|
||||
} else if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
|
||||
(out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX)) &&
|
||||
|
@ -2500,7 +2501,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
|
|||
out->compr_config.codec->bit_rate =
|
||||
config->offload_info.bit_rate;
|
||||
out->compr_config.codec->ch_in =
|
||||
popcount(config->channel_mask);
|
||||
audio_channel_count_from_out_mask(config->channel_mask);
|
||||
out->compr_config.codec->ch_out = out->compr_config.codec->ch_in;
|
||||
out->bit_width = PCM_OUTPUT_BIT_WIDTH;
|
||||
|
||||
|
@ -2609,6 +2610,9 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
|
|||
/* out->muted = false; by calloc() */
|
||||
/* out->written = 0; by calloc() */
|
||||
|
||||
pthread_mutex_init(&out->lock, (const pthread_mutexattr_t *) NULL);
|
||||
pthread_cond_init(&out->cond, (const pthread_condattr_t *) NULL);
|
||||
|
||||
config->format = out->stream.common.get_format(&out->stream.common);
|
||||
config->channel_mask = out->stream.common.get_channels(&out->stream.common);
|
||||
config->sample_rate = out->stream.common.get_sample_rate(&out->stream.common);
|
||||
|
@ -2642,8 +2646,7 @@ static void adev_close_output_stream(struct audio_hw_device *dev,
|
|||
if(ret != 0)
|
||||
ALOGE("%s: Compress voip output cannot be closed, error:%d",
|
||||
__func__, ret);
|
||||
}
|
||||
else
|
||||
} else
|
||||
out_standby(&stream->common);
|
||||
|
||||
if (is_offload_usecase(out->usecase)) {
|
||||
|
@ -2665,13 +2668,14 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
|
|||
char *str;
|
||||
char value[32];
|
||||
int val;
|
||||
int ret = 0, err;
|
||||
int ret;
|
||||
int status = 0;
|
||||
|
||||
ALOGD("%s: enter: %s", __func__, kvpairs);
|
||||
parms = str_parms_create_str(kvpairs);
|
||||
|
||||
err = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value));
|
||||
if (err >= 0) {
|
||||
ret = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value));
|
||||
if (ret >= 0) {
|
||||
char *snd_card_status = value+2;
|
||||
if (strstr(snd_card_status, "OFFLINE")) {
|
||||
struct listnode *node;
|
||||
|
@ -2699,16 +2703,16 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
|
|||
}
|
||||
|
||||
pthread_mutex_lock(&adev->lock);
|
||||
ret = voice_set_parameters(adev, parms);
|
||||
if (ret != 0)
|
||||
status = voice_set_parameters(adev, parms);
|
||||
if (status != 0)
|
||||
goto done;
|
||||
|
||||
ret = platform_set_parameters(adev->platform, parms);
|
||||
if (ret != 0)
|
||||
status = platform_set_parameters(adev->platform, parms);
|
||||
if (status != 0)
|
||||
goto done;
|
||||
|
||||
err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
|
||||
if (err >= 0) {
|
||||
ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
|
||||
if (ret >= 0) {
|
||||
/* When set to false, HAL should disable EC and NS */
|
||||
if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
|
||||
adev->bluetooth_nrec = true;
|
||||
|
@ -2716,16 +2720,16 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
|
|||
adev->bluetooth_nrec = false;
|
||||
}
|
||||
|
||||
err = str_parms_get_str(parms, "screen_state", value, sizeof(value));
|
||||
if (err >= 0) {
|
||||
ret = str_parms_get_str(parms, "screen_state", value, sizeof(value));
|
||||
if (ret >= 0) {
|
||||
if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
|
||||
adev->screen_off = false;
|
||||
else
|
||||
adev->screen_off = true;
|
||||
}
|
||||
|
||||
err = str_parms_get_int(parms, "rotation", &val);
|
||||
if (err >= 0) {
|
||||
ret = str_parms_get_int(parms, "rotation", &val);
|
||||
if (ret >= 0) {
|
||||
bool reverse_speakers = false;
|
||||
switch(val) {
|
||||
// FIXME: note that the code below assumes that the speakers are in the correct placement
|
||||
|
@ -2740,17 +2744,20 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
|
|||
break;
|
||||
default:
|
||||
ALOGE("%s: unexpected rotation of %d", __func__, val);
|
||||
status = -EINVAL;
|
||||
}
|
||||
if (adev->speaker_lr_swap != reverse_speakers) {
|
||||
adev->speaker_lr_swap = reverse_speakers;
|
||||
// only update the selected device if there is active pcm playback
|
||||
struct audio_usecase *usecase;
|
||||
struct listnode *node;
|
||||
list_for_each(node, &adev->usecase_list) {
|
||||
usecase = node_to_item(node, struct audio_usecase, list);
|
||||
if (usecase->type == PCM_PLAYBACK) {
|
||||
select_devices(adev, usecase->id);
|
||||
break;
|
||||
if (status == 0) {
|
||||
if (adev->speaker_lr_swap != reverse_speakers) {
|
||||
adev->speaker_lr_swap = reverse_speakers;
|
||||
// only update the selected device if there is active pcm playback
|
||||
struct audio_usecase *usecase;
|
||||
struct listnode *node;
|
||||
list_for_each(node, &adev->usecase_list) {
|
||||
usecase = node_to_item(node, struct audio_usecase, list);
|
||||
if (usecase->type == PCM_PLAYBACK) {
|
||||
select_devices(adev, usecase->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2769,8 +2776,8 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
|
|||
done:
|
||||
str_parms_destroy(parms);
|
||||
pthread_mutex_unlock(&adev->lock);
|
||||
ALOGV("%s: exit with code(%d)", __func__, ret);
|
||||
return ret;
|
||||
ALOGV("%s: exit with code(%d)", __func__, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
static char* adev_get_parameters(const struct audio_hw_device *dev,
|
||||
|
@ -2885,7 +2892,7 @@ static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
|
|||
static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
|
||||
const struct audio_config *config)
|
||||
{
|
||||
int channel_count = popcount(config->channel_mask);
|
||||
int channel_count = audio_channel_count_from_in_mask(config->channel_mask);
|
||||
|
||||
return get_input_buffer_size(config->sample_rate, config->format, channel_count);
|
||||
}
|
||||
|
@ -2894,12 +2901,15 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
|
|||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_in **stream_in)
|
||||
struct audio_stream_in **stream_in,
|
||||
audio_input_flags_t flags __unused,
|
||||
const char *address __unused,
|
||||
audio_source_t source __unused)
|
||||
{
|
||||
struct audio_device *adev = (struct audio_device *)dev;
|
||||
struct stream_in *in;
|
||||
int ret = 0, buffer_size, frame_size;
|
||||
int channel_count = popcount(config->channel_mask);
|
||||
int channel_count = audio_channel_count_from_in_mask(config->channel_mask);
|
||||
|
||||
|
||||
*stream_in = NULL;
|
||||
|
@ -2964,7 +2974,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
|
|||
audio_extn_compr_cap_init(adev, in);
|
||||
} else {
|
||||
in->config.channels = channel_count;
|
||||
frame_size = audio_stream_frame_size((struct audio_stream *)in);
|
||||
frame_size = audio_stream_in_frame_size(&in->stream);
|
||||
buffer_size = get_input_buffer_size(config->sample_rate,
|
||||
config->format,
|
||||
channel_count);
|
||||
|
@ -3004,7 +3014,8 @@ static void adev_close_input_stream(struct audio_hw_device *dev,
|
|||
} else
|
||||
in_standby(&stream->common);
|
||||
|
||||
if (audio_extn_ssr_get_enabled() && (popcount(in->channel_mask) == 6)) {
|
||||
if (audio_extn_ssr_get_enabled() &&
|
||||
(audio_channel_count_from_in_mask(in->channel_mask) == 6)) {
|
||||
audio_extn_ssr_deinit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue