From eaed2075d9d07e230779e2d5cc8cb509f43c98de Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Fri, 27 Dec 2013 16:24:44 +0100 Subject: Changes for JellyBean Signed-off-by: Paul Kocialkowski --- audio_in.c | 120 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'audio_in.c') diff --git a/audio_in.c b/audio_in.c index 618daf1..8d9db89 100644 --- a/audio_in.c +++ b/audio_in.c @@ -48,7 +48,7 @@ int audio_in_pcm_open(struct tinyalsa_audio_stream_in *stream_in) return -1; memset(&pcm_config, 0, sizeof(pcm_config)); - pcm_config.channels = popcount(stream_in->mixer_props->channels); + pcm_config.channels = popcount(stream_in->mixer_props->channel_mask); pcm_config.rate = stream_in->mixer_props->rate; switch(stream_in->mixer_props->format) { case AUDIO_FORMAT_PCM_16_BIT: @@ -58,7 +58,7 @@ int audio_in_pcm_open(struct tinyalsa_audio_stream_in *stream_in) pcm_config.format = PCM_FORMAT_S32_LE; break; default: - LOGE("Invalid format: 0x%x", stream_in->mixer_props->format); + ALOGE("Invalid format: 0x%x", stream_in->mixer_props->format); return -1; } pcm_config.period_size = stream_in->mixer_props->period_size; @@ -68,7 +68,7 @@ int audio_in_pcm_open(struct tinyalsa_audio_stream_in *stream_in) stream_in->mixer_props->device, PCM_IN, &pcm_config); if(pcm == NULL || !pcm_is_ready(pcm)) { - LOGE("Unable to open pcm device: %s", pcm_get_error(pcm)); + ALOGE("Unable to open pcm device: %s", pcm_get_error(pcm)); return -1; } @@ -122,17 +122,17 @@ int audio_in_resampler_open(struct tinyalsa_audio_stream_in *stream_in) rc = create_resampler(stream_in->mixer_props->rate, stream_in->rate, - popcount(stream_in->mixer_props->channels), + popcount(stream_in->mixer_props->channel_mask), RESAMPLER_QUALITY_DEFAULT, &stream_in->buffer_provider, &stream_in->resampler); if(rc < 0 || stream_in->resampler == NULL) { - LOGE("Failed to create resampler"); + ALOGE("Failed to create resampler"); return -1; } stream_in->buffer = malloc(stream_in->mixer_props->period_size * - popcount(stream_in->mixer_props->channels) * + popcount(stream_in->mixer_props->channel_mask) * audio_bytes_per_sample(stream_in->mixer_props->format)); return 0; @@ -168,16 +168,16 @@ int audio_in_get_next_buffer(struct resampler_buffer_provider *buffer_provider, if(stream_in->frames_left == 0) { if(stream_in->pcm == NULL || !pcm_is_ready(stream_in->pcm)) { - LOGE("pcm device is not ready"); + ALOGE("pcm device is not ready"); goto error_pcm; } rc = pcm_read(stream_in->pcm, stream_in->buffer, stream_in->mixer_props->period_size * - popcount(stream_in->mixer_props->channels) * + popcount(stream_in->mixer_props->channel_mask) * audio_bytes_per_sample(stream_in->mixer_props->format)); if(rc != 0) { - LOGE("pcm read failed!"); + ALOGE("pcm read failed!"); goto error_pcm; } @@ -189,7 +189,7 @@ int audio_in_get_next_buffer(struct resampler_buffer_provider *buffer_provider, buffer->raw = stream_in->buffer + (stream_in->mixer_props->period_size - stream_in->frames_left) * - popcount(stream_in->mixer_props->channels) * + popcount(stream_in->mixer_props->channel_mask) * audio_bytes_per_sample(stream_in->mixer_props->format); return 0; @@ -244,7 +244,7 @@ int audio_in_read_process(struct tinyalsa_audio_stream_in *stream_in, void *buff if(stream_in->resampler != NULL) { frames_out_resampler = frames_in; - size_out_resampler = frames_out_resampler * popcount(stream_in->mixer_props->channels) * audio_bytes_per_sample(stream_in->mixer_props->format); + size_out_resampler = frames_out_resampler * popcount(stream_in->mixer_props->channel_mask) * audio_bytes_per_sample(stream_in->mixer_props->format); buffer_out_resampler = calloc(1, size_out_resampler); frames_out = 0; @@ -262,17 +262,17 @@ int audio_in_read_process(struct tinyalsa_audio_stream_in *stream_in, void *buff buffer_in = buffer_out_resampler; } else { frames_out_read = frames_in; - size_out_read = frames_out_read * popcount(stream_in->mixer_props->channels) * audio_bytes_per_sample(stream_in->mixer_props->format); + size_out_read = frames_out_read * popcount(stream_in->mixer_props->channel_mask) * audio_bytes_per_sample(stream_in->mixer_props->format); buffer_out_read = calloc(1, size_out_read); if(stream_in->pcm == NULL || !pcm_is_ready(stream_in->pcm)) { - LOGE("pcm device is not ready"); + ALOGE("pcm device is not ready"); goto error; } rc = pcm_read(stream_in->pcm, buffer_out_read, size_out_read); if(rc != 0) { - LOGE("pcm read failed!"); + ALOGE("pcm read failed!"); goto error; } @@ -285,13 +285,13 @@ int audio_in_read_process(struct tinyalsa_audio_stream_in *stream_in, void *buff goto error; //FIXME: This is only for PCM 16 - if(popcount(stream_in->channels) < popcount(stream_in->mixer_props->channels)) { + if(popcount(stream_in->channel_mask) < popcount(stream_in->mixer_props->channel_mask)) { frames_out_channels = frames_in; size_out_channels = frames_out_channels * audio_stream_frame_size((struct audio_stream *) stream_in); buffer_out_channels = calloc(1, size_out_channels); - int channels_count_in = popcount(stream_in->mixer_props->channels); - int channels_count_out = popcount(stream_in->channels); + int channels_count_in = popcount(stream_in->mixer_props->channel_mask); + int channels_count_out = popcount(stream_in->channel_mask); int ratio = channels_count_in / channels_count_out; int16_t *byte_in = (int16_t *) buffer_in; @@ -312,8 +312,8 @@ int audio_in_read_process(struct tinyalsa_audio_stream_in *stream_in, void *buff frames_in = frames_out_channels; size_in = size_out_channels; buffer_in = buffer_out_channels; - } else if(popcount(stream_in->channels) != popcount(stream_in->mixer_props->channels)) { - LOGE("Asked for more channels than hardware can provide!"); + } else if(popcount(stream_in->channel_mask) != popcount(stream_in->mixer_props->channel_mask)) { + ALOGE("Asked for more channels than hardware can provide!"); goto error; } @@ -356,7 +356,7 @@ static int audio_in_set_sample_rate(struct audio_stream *stream, uint32_t rate) { struct tinyalsa_audio_stream_in *stream_in; - LOGD("%s(%p, %d)", __func__, stream, rate); + ALOGD("%s(%p, %d)", __func__, stream, rate); if(stream == NULL) return -1; @@ -399,7 +399,7 @@ static size_t audio_in_get_buffer_size(const struct audio_stream *stream) return size; } -static uint32_t audio_in_get_channels(const struct audio_stream *stream) +static audio_channel_mask_t audio_in_get_channels(const struct audio_stream *stream) { struct tinyalsa_audio_stream_in *stream_in; @@ -408,10 +408,10 @@ static uint32_t audio_in_get_channels(const struct audio_stream *stream) stream_in = (struct tinyalsa_audio_stream_in *) stream; - return stream_in->channels; + return stream_in->channel_mask; } -static int audio_in_get_format(const struct audio_stream *stream) +static audio_format_t audio_in_get_format(const struct audio_stream *stream) { struct tinyalsa_audio_stream_in *stream_in; @@ -423,11 +423,11 @@ static int audio_in_get_format(const struct audio_stream *stream) return stream_in->format; } -static int audio_in_set_format(struct audio_stream *stream, int format) +static int audio_in_set_format(struct audio_stream *stream, audio_format_t format) { struct tinyalsa_audio_stream_in *stream_in; - LOGD("%s(%p, %d)", __func__, stream, format); + ALOGD("%s(%p, %d)", __func__, stream, format); if(stream == NULL) return -1; @@ -453,7 +453,7 @@ static int audio_in_standby(struct audio_stream *stream) struct tinyalsa_audio_stream_in *stream_in; int rc; - LOGD("%s(%p)", __func__, stream); + ALOGD("%s(%p)", __func__, stream); if(stream == NULL) return -1; @@ -469,7 +469,7 @@ static int audio_in_standby(struct audio_stream *stream) if(!stream_in->standby) { rc = yamaha_mc1n2_audio_input_stop(stream_in->device->mc1n2_pdata); if(rc < 0) { - LOGE("Failed to set Yamaha-MC1N2-Audio route"); + ALOGE("Failed to set Yamaha-MC1N2-Audio route"); } } #endif @@ -483,7 +483,7 @@ static int audio_in_standby(struct audio_stream *stream) static int audio_in_dump(const struct audio_stream *stream, int fd) { - LOGD("%s(%p, %d)", __func__, stream, fd); + ALOGD("%s(%p, %d)", __func__, stream, fd); return 0; } @@ -496,7 +496,7 @@ static int audio_in_set_parameters(struct audio_stream *stream, const char *kvpa int value; int rc; - LOGD("%s(%p, %s)", __func__, stream, kvpairs); + ALOGD("%s(%p, %s)", __func__, stream, kvpairs); if(stream == NULL || kvpairs == NULL) return -1; @@ -539,7 +539,7 @@ error_params: static char *audio_in_get_parameters(const struct audio_stream *stream, const char *keys) { - LOGD("%s(%p, %s)", __func__, stream, keys); + ALOGD("%s(%p, %s)", __func__, stream, keys); return strdup(""); } @@ -548,7 +548,7 @@ static int audio_in_set_gain(struct audio_stream_in *stream, float gain) { struct tinyalsa_audio_stream_in *stream_in; - LOGD("%s(%p, %f)", __func__, stream, gain); + ALOGD("%s(%p, %f)", __func__, stream, gain); if(stream == NULL) return -1; @@ -586,13 +586,13 @@ static ssize_t audio_in_read(struct audio_stream_in *stream, #ifdef YAMAHA_MC1N2_AUDIO rc = yamaha_mc1n2_audio_input_start(stream_in->device->mc1n2_pdata); if(rc < 0) { - LOGE("Failed to set Yamaha-MC1N2-Audio route"); + ALOGE("Failed to set Yamaha-MC1N2-Audio route"); } #endif rc = audio_in_pcm_open(stream_in); if(rc < 0) { - LOGE("Unable to open pcm device"); + ALOGE("Unable to open pcm device"); goto error; } @@ -601,7 +601,7 @@ static ssize_t audio_in_read(struct audio_stream_in *stream, rc = audio_in_read_process(stream_in, buffer, (int) bytes); if(rc < 0) { - LOGE("Read and process failed!"); + ALOGE("Read and process failed!"); goto error; } @@ -625,14 +625,14 @@ static uint32_t audio_in_get_input_frames_lost(struct audio_stream_in *stream) static int audio_in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { - LOGD("%s(%p, %p)", __func__, stream, effect); + ALOGD("%s(%p, %p)", __func__, stream, effect); return 0; } static int audio_in_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { - LOGD("%s(%p, %p)", __func__, stream, effect); + ALOGD("%s(%p, %p)", __func__, stream, effect); return 0; } @@ -647,7 +647,7 @@ void audio_hw_close_input_stream(struct audio_hw_device *dev, struct tinyalsa_audio_stream_in *stream_in; struct tinyalsa_audio_device *tinyalsa_audio_device; - LOGD("%s(%p)", __func__, stream); + ALOGD("%s(%p)", __func__, stream); stream_in = (struct tinyalsa_audio_stream_in *) stream; @@ -676,18 +676,18 @@ void audio_hw_close_input_stream(struct audio_hw_device *dev, } int audio_hw_open_input_stream(struct audio_hw_device *dev, - uint32_t devices, int *format, uint32_t *channels, uint32_t *sample_rate, - audio_in_acoustics_t acoustics, struct audio_stream_in **stream_in) + audio_io_handle_t handle, audio_devices_t devices, + struct audio_config *config, struct audio_stream_in **stream_in) { struct tinyalsa_audio_device *tinyalsa_audio_device; struct tinyalsa_audio_stream_in *tinyalsa_audio_stream_in; struct audio_stream_in *stream; int rc; - LOGD("%s(%p, %d, %p, %p, %p, %d, %p)", - __func__, dev, devices, format, channels, sample_rate, acoustics, stream_in); + ALOGD("%s(%p, %d, %p, %p)", + __func__, dev, devices, config, stream_in); - if(dev == NULL || format == NULL || channels == NULL || sample_rate == NULL || stream_in == NULL) + if(dev == NULL || config == NULL || stream_in == NULL) return -EINVAL; tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev; @@ -728,49 +728,49 @@ int audio_hw_open_input_stream(struct audio_hw_device *dev, // Default values if(tinyalsa_audio_stream_in->mixer_props->rate == 0) tinyalsa_audio_stream_in->mixer_props->rate = 44100; - if(tinyalsa_audio_stream_in->mixer_props->channels == 0) - tinyalsa_audio_stream_in->mixer_props->channels = AUDIO_CHANNEL_IN_STEREO; + if(tinyalsa_audio_stream_in->mixer_props->channel_mask == 0) + tinyalsa_audio_stream_in->mixer_props->channel_mask = AUDIO_CHANNEL_IN_STEREO; if(tinyalsa_audio_stream_in->mixer_props->format == 0) tinyalsa_audio_stream_in->mixer_props->format = AUDIO_FORMAT_PCM_16_BIT; - if(*sample_rate == 0) + if(config->sample_rate == 0) tinyalsa_audio_stream_in->rate = tinyalsa_audio_stream_in->mixer_props->rate; else - tinyalsa_audio_stream_in->rate = *sample_rate; - if(*channels == 0) - tinyalsa_audio_stream_in->channels = - tinyalsa_audio_stream_in->mixer_props->channels; + tinyalsa_audio_stream_in->rate = config->sample_rate; + if(config->channel_mask == 0) + tinyalsa_audio_stream_in->channel_mask = + tinyalsa_audio_stream_in->mixer_props->channel_mask; else - tinyalsa_audio_stream_in->channels = *channels; - if(*format == 0) + tinyalsa_audio_stream_in->channel_mask = config->channel_mask; + if(config->format == 0) tinyalsa_audio_stream_in->format = tinyalsa_audio_stream_in->mixer_props->format; else - tinyalsa_audio_stream_in->format = *format; + tinyalsa_audio_stream_in->format = config->format; - tinyalsa_audio_stream_in->buffer_provider.get_next_buffer = + tinyalsa_audio_stream_in->buffer_provider.get_next_buffer = audio_in_get_next_buffer; - tinyalsa_audio_stream_in->buffer_provider.release_buffer = + tinyalsa_audio_stream_in->buffer_provider.release_buffer = audio_in_release_buffer; if(tinyalsa_audio_stream_in->rate != tinyalsa_audio_stream_in->mixer_props->rate) { rc = audio_in_resampler_open(tinyalsa_audio_stream_in); if(rc < 0) { - LOGE("Unable to open resampler!"); + ALOGE("Unable to open resampler!"); goto error_stream; } } - *sample_rate = (uint32_t) tinyalsa_audio_stream_in->rate; - *channels = (uint32_t) tinyalsa_audio_stream_in->channels; - *format = (uint32_t) tinyalsa_audio_stream_in->format; + config->sample_rate = tinyalsa_audio_stream_in->rate; + config->channel_mask = tinyalsa_audio_stream_in->channel_mask; + config->format = tinyalsa_audio_stream_in->format; pthread_mutex_lock(&tinyalsa_audio_device->lock); rc = tinyalsa_mixer_set_input_state(tinyalsa_audio_device->mixer, 1); if(rc < 0) { - LOGE("Unable to set input state"); + ALOGE("Unable to set input state"); pthread_mutex_unlock(&tinyalsa_audio_device->lock); goto error_stream; } @@ -783,7 +783,7 @@ int audio_hw_open_input_stream(struct audio_hw_device *dev, rc = audio_in_pcm_open(tinyalsa_audio_stream_in); if(rc < 0) { - LOGE("Unable to open pcm device"); + ALOGE("Unable to open pcm device"); pthread_mutex_unlock(&tinyalsa_audio_stream_in->lock); goto error_stream; } -- cgit v1.1