Lines Matching refs:in
246 static void do_in_standby(struct stream_in *in) in do_in_standby() argument
248 struct audio_device *adev = in->dev; in do_in_standby()
250 if (!in->standby) { in do_in_standby()
251 pcm_close(in->pcm); in do_in_standby()
252 in->pcm = NULL; in do_in_standby()
254 if (in->resampler) { in do_in_standby()
255 release_resampler(in->resampler); in do_in_standby()
256 in->resampler = NULL; in do_in_standby()
258 if (in->buffer) { in do_in_standby()
259 free(in->buffer); in do_in_standby()
260 in->buffer = NULL; in do_in_standby()
262 in->standby = true; in do_in_standby()
296 struct stream_in *in = adev->active_in; in start_output_stream() local
297 pthread_mutex_lock(&in->lock); in start_output_stream()
299 (in->pcm_config->rate % 8000) != 0) || in start_output_stream()
301 (in->pcm_config->rate % 11025) != 0)) in start_output_stream()
302 do_in_standby(in); in start_output_stream()
303 pthread_mutex_unlock(&in->lock); in start_output_stream()
337 static int start_input_stream(struct stream_in *in) in start_input_stream() argument
339 struct audio_device *adev = in->dev; in start_input_stream()
350 in->pcm_config = &pcm_config_sco; in start_input_stream()
353 in->pcm_config = in->pcm_config_non_sco; in start_input_stream()
366 if (((in->pcm_config->rate % 8000 == 0) && in start_input_stream()
368 ((in->pcm_config->rate % 11025 == 0) && in start_input_stream()
374 in->pcm = pcm_open(PCM_CARD, device, PCM_IN, in->pcm_config); in start_input_stream()
376 if (in->pcm && !pcm_is_ready(in->pcm)) { in start_input_stream()
377 ALOGE("pcm_open(in) failed: %s", pcm_get_error(in->pcm)); in start_input_stream()
378 pcm_close(in->pcm); in start_input_stream()
386 if (in_get_sample_rate(&in->stream.common) != in->pcm_config->rate) { in start_input_stream()
387 in->buf_provider.get_next_buffer = get_next_buffer; in start_input_stream()
388 in->buf_provider.release_buffer = release_buffer; in start_input_stream()
390 ret = create_resampler(in->pcm_config->rate, in start_input_stream()
391 in_get_sample_rate(&in->stream.common), in start_input_stream()
394 &in->buf_provider, in start_input_stream()
395 &in->resampler); in start_input_stream()
397 in->buffer_size = pcm_frames_to_bytes(in->pcm, in start_input_stream()
398 in->pcm_config->period_size); in start_input_stream()
399 in->buffer = malloc(in->buffer_size); in start_input_stream()
400 in->frames_in = 0; in start_input_stream()
402 adev->active_in = in; in start_input_stream()
410 struct stream_in *in; in get_next_buffer() local
415 in = (struct stream_in *)((char *)buffer_provider - in get_next_buffer()
418 if (in->pcm == NULL) { in get_next_buffer()
421 in->read_status = -ENODEV; in get_next_buffer()
425 if (in->frames_in == 0) { in get_next_buffer()
426 in->read_status = pcm_read(in->pcm, in get_next_buffer()
427 (void*)in->buffer, in get_next_buffer()
428 in->buffer_size); in get_next_buffer()
429 if (in->read_status != 0) { in get_next_buffer()
430 ALOGE("get_next_buffer() pcm_read error %d", in->read_status); in get_next_buffer()
433 return in->read_status; in get_next_buffer()
435 in->frames_in = in->pcm_config->period_size; in get_next_buffer()
436 if (in->pcm_config->channels == 2) { in get_next_buffer()
440 for (i = 1; i < in->frames_in; i++) in get_next_buffer()
441 in->buffer[i] = in->buffer[i * 2]; in get_next_buffer()
445 buffer->frame_count = (buffer->frame_count > in->frames_in) ? in get_next_buffer()
446 in->frames_in : buffer->frame_count; in get_next_buffer()
447 buffer->i16 = in->buffer + (in->pcm_config->period_size - in->frames_in); in get_next_buffer()
449 return in->read_status; in get_next_buffer()
456 struct stream_in *in; in release_buffer() local
461 in = (struct stream_in *)((char *)buffer_provider - in release_buffer()
464 in->frames_in -= buffer->frame_count; in release_buffer()
469 static ssize_t read_frames(struct stream_in *in, void *buffer, ssize_t frames) in read_frames() argument
475 if (in->resampler != NULL) { in read_frames()
476 in->resampler->resample_from_provider(in->resampler, in read_frames()
478 frames_wr * audio_stream_in_frame_size(&in->stream)), in read_frames()
485 get_next_buffer(&in->buf_provider, &buf); in read_frames()
488 frames_wr * audio_stream_in_frame_size(&in->stream), in read_frames()
490 buf.frame_count * audio_stream_in_frame_size(&in->stream)); in read_frames()
493 release_buffer(&in->buf_provider, &buf); in read_frames()
497 if (in->read_status != 0) in read_frames()
498 return in->read_status; in read_frames()
828 struct stream_in *in = (struct stream_in *)stream; in in_get_sample_rate() local
830 return in->requested_rate; in in_get_sample_rate()
840 struct stream_in *in = (struct stream_in *)stream; in in_get_buffer_size() local
848 size = (in->pcm_config->period_size * in_get_sample_rate(stream)) / in in_get_buffer_size()
849 in->pcm_config->rate; in in_get_buffer_size()
852 return size * audio_stream_in_frame_size(&in->stream); in in_get_buffer_size()
872 struct stream_in *in = (struct stream_in *)stream; in in_standby() local
874 pthread_mutex_lock(&in->dev->lock); in in_standby()
875 pthread_mutex_lock(&in->lock); in in_standby()
876 do_in_standby(in); in in_standby()
877 pthread_mutex_unlock(&in->lock); in in_standby()
878 pthread_mutex_unlock(&in->dev->lock); in in_standby()
890 struct stream_in *in = (struct stream_in *)stream; in in_set_parameters() local
891 struct audio_device *adev = in->dev; in in_set_parameters()
911 pthread_mutex_lock(&in->lock); in in_set_parameters()
912 do_in_standby(in); in in_set_parameters()
913 pthread_mutex_unlock(&in->lock); in in_set_parameters()
941 struct stream_in *in = (struct stream_in *)stream; in in_read() local
942 struct audio_device *adev = in->dev; in in_read()
952 pthread_mutex_lock(&in->lock); in in_read()
953 if (in->standby) { in in_read()
954 ret = start_input_stream(in); in in_read()
956 in->standby = 0; in in_read()
965 } else */if (in->resampler != NULL) { in in_read()
966 ret = read_frames(in, buffer, frames_rq); in in_read()
967 } else if (in->pcm_config->channels == 2) { in in_read()
975 ret = pcm_read(in->pcm, in->buffer, bytes * 2); in in_read()
979 in_buffer[i] = in->buffer[i * 2]; in in_read()
981 ret = pcm_read(in->pcm, buffer, bytes); in in_read()
999 pthread_mutex_unlock(&in->lock); in in_read()
1201 struct stream_in *in; in adev_open_input_stream() local
1212 in = (struct stream_in *)calloc(1, sizeof(struct stream_in)); in adev_open_input_stream()
1213 if (!in) in adev_open_input_stream()
1216 in->stream.common.get_sample_rate = in_get_sample_rate; in adev_open_input_stream()
1217 in->stream.common.set_sample_rate = in_set_sample_rate; in adev_open_input_stream()
1218 in->stream.common.get_buffer_size = in_get_buffer_size; in adev_open_input_stream()
1219 in->stream.common.get_channels = in_get_channels; in adev_open_input_stream()
1220 in->stream.common.get_format = in_get_format; in adev_open_input_stream()
1221 in->stream.common.set_format = in_set_format; in adev_open_input_stream()
1222 in->stream.common.standby = in_standby; in adev_open_input_stream()
1223 in->stream.common.dump = in_dump; in adev_open_input_stream()
1224 in->stream.common.set_parameters = in_set_parameters; in adev_open_input_stream()
1225 in->stream.common.get_parameters = in_get_parameters; in adev_open_input_stream()
1226 in->stream.common.add_audio_effect = in_add_audio_effect; in adev_open_input_stream()
1227 in->stream.common.remove_audio_effect = in_remove_audio_effect; in adev_open_input_stream()
1228 in->stream.set_gain = in_set_gain; in adev_open_input_stream()
1229 in->stream.read = in_read; in adev_open_input_stream()
1230 in->stream.get_input_frames_lost = in_get_input_frames_lost; in adev_open_input_stream()
1232 in->dev = adev; in adev_open_input_stream()
1233 in->standby = true; in adev_open_input_stream()
1234 in->requested_rate = config->sample_rate; in adev_open_input_stream()
1236 in->pcm_config = (config->sample_rate == IN_SAMPLING_RATE) && (flags & AUDIO_INPUT_FLAG_FAST) ? in adev_open_input_stream()
1238 in->pcm_config_non_sco = in->pcm_config; in adev_open_input_stream()
1240 *stream_in = &in->stream; in adev_open_input_stream()
1247 struct stream_in *in = (struct stream_in *)stream; in adev_close_input_stream() local