Lines Matching defs:in
5 * you may not use this file except in compliance with the License.
10 * Unless required by applicable law or agreed to in writing, software
60 /* minimum sleep time in out_write() when write threshold is not reached */
246 static void do_in_standby(struct stream_in *in)
248 struct audio_device *adev = in->dev;
250 if (!in->standby) {
251 pcm_close(in->pcm);
252 in->pcm = NULL;
254 if (in->resampler) {
255 release_resampler(in->resampler);
256 in->resampler = NULL;
258 if (in->buffer) {
259 free(in->buffer);
260 in->buffer = NULL;
262 in->standby = true;
274 * Due to the lack of sample rate converters in the SoC,
296 struct stream_in *in = adev->active_in;
297 pthread_mutex_lock(&in->lock);
299 (in->pcm_config->rate % 8000) != 0) ||
301 (in->pcm_config->rate % 11025) != 0))
302 do_in_standby(in);
303 pthread_mutex_unlock(&in->lock);
337 static int start_input_stream(struct stream_in *in)
339 struct audio_device *adev = in->dev;
344 * Due to the lack of sample rate converters in the SoC,
350 in->pcm_config = &pcm_config_sco;
353 in->pcm_config = in->pcm_config_non_sco;
366 if (((in->pcm_config->rate % 8000 == 0) &&
368 ((in->pcm_config->rate % 11025 == 0) &&
374 in->pcm = pcm_open(PCM_CARD, device, PCM_IN, in->pcm_config);
376 if (in->pcm && !pcm_is_ready(in->pcm)) {
377 ALOGE("pcm_open(in) failed: %s", pcm_get_error(in->pcm));
378 pcm_close(in->pcm);
386 if (in_get_sample_rate(&in->stream.common) != in->pcm_config->rate) {
387 in->buf_provider.get_next_buffer = get_next_buffer;
388 in->buf_provider.release_buffer = release_buffer;
390 ret = create_resampler(in->pcm_config->rate,
391 in_get_sample_rate(&in->stream.common),
394 &in->buf_provider,
395 &in->resampler);
397 in->buffer_size = pcm_frames_to_bytes(in->pcm,
398 in->pcm_config->period_size);
399 in->buffer = malloc(in->buffer_size);
400 in->frames_in = 0;
402 adev->active_in = in;
410 struct stream_in *in;
415 in = (struct stream_in *)((char *)buffer_provider -
418 if (in->pcm == NULL) {
421 in->read_status = -ENODEV;
425 if (in->frames_in == 0) {
426 in->read_status = pcm_read(in->pcm,
427 (void*)in->buffer,
428 in->buffer_size);
429 if (in->read_status != 0) {
430 ALOGE("get_next_buffer() pcm_read error %d", in->read_status);
433 return in->read_status;
435 in->frames_in = in->pcm_config->period_size;
436 if (in->pcm_config->channels == 2) {
440 for (i = 1; i < in->frames_in; i++)
441 in->buffer[i] = in->buffer[i * 2];
445 buffer->frame_count = (buffer->frame_count > in->frames_in) ?
446 in->frames_in : buffer->frame_count;
447 buffer->i16 = in->buffer + (in->pcm_config->period_size - in->frames_in);
449 return in->read_status;
456 struct stream_in *in;
461 in = (struct stream_in *)((char *)buffer_provider -
464 in->frames_in -= buffer->frame_count;
469 static ssize_t read_frames(struct stream_in *in, void *buffer, ssize_t frames)
475 if (in->resampler != NULL) {
476 in->resampler->resample_from_provider(in->resampler,
478 frames_wr * audio_stream_in_frame_size(&in->stream)),
485 get_next_buffer(&in->buf_provider, &buf);
488 frames_wr * audio_stream_in_frame_size(&in->stream),
490 buf.frame_count * audio_stream_in_frame_size(&in->stream));
493 release_buffer(&in->buf_provider, &buf);
495 /* in->read_status is updated by getNextBuffer() also called by
496 * in->resampler->resample_from_provider() */
497 if (in->read_status != 0)
498 return in->read_status;
658 /* detect changes in screen ON/OFF state and adapt buffer size
703 /* do not allow more than out->cur_write_threshold frames in kernel
759 /* In case of underrun, don't sleep since we want to catch up asap */
813 // It would be unusual for this value to be negative, but check just in case ...
828 struct stream_in *in = (struct stream_in *)stream;
830 return in->requested_rate;
840 struct stream_in *in = (struct stream_in *)stream;
848 size = (in->pcm_config->period_size * in_get_sample_rate(stream)) /
849 in->pcm_config->rate;
852 return size * audio_stream_in_frame_size(&in->stream);
872 struct stream_in *in = (struct stream_in *)stream;
874 pthread_mutex_lock(&in->dev->lock);
875 pthread_mutex_lock(&in->lock);
876 do_in_standby(in);
877 pthread_mutex_unlock(&in->lock);
878 pthread_mutex_unlock(&in->dev->lock);
890 struct stream_in *in = (struct stream_in *)stream;
891 struct audio_device *adev = in->dev;
911 pthread_mutex_lock(&in->lock);
912 do_in_standby(in);
913 pthread_mutex_unlock(&in->lock);
941 struct stream_in *in = (struct stream_in *)stream;
942 struct audio_device *adev = in->dev;
952 pthread_mutex_lock(&in->lock);
953 if (in->standby) {
954 ret = start_input_stream(in);
956 in->standby = 0;
963 /*if (in->num_preprocessors != 0) {
964 ret = process_frames(in, buffer, frames_rq);
965 } else */if (in->resampler != NULL) {
966 ret = read_frames(in, buffer, frames_rq);
967 } else if (in->pcm_config->channels == 2) {
975 ret = pcm_read(in->pcm, in->buffer, bytes * 2);
979 in_buffer[i] = in->buffer[i * 2];
981 ret = pcm_read(in->pcm, buffer, bytes);
999 pthread_mutex_unlock(&in->lock);
1201 struct stream_in *in;
1212 in = (struct stream_in *)calloc(1, sizeof(struct stream_in));
1213 if (!in)
1216 in->stream.common.get_sample_rate = in_get_sample_rate;
1217 in->stream.common.set_sample_rate = in_set_sample_rate;
1218 in->stream.common.get_buffer_size = in_get_buffer_size;
1219 in->stream.common.get_channels = in_get_channels;
1220 in->stream.common.get_format = in_get_format;
1221 in->stream.common.set_format = in_set_format;
1222 in->stream.common.standby = in_standby;
1223 in->stream.common.dump = in_dump;
1224 in->stream.common.set_parameters = in_set_parameters;
1225 in->stream.common.get_parameters = in_get_parameters;
1226 in->stream.common.add_audio_effect = in_add_audio_effect;
1227 in->stream.common.remove_audio_effect = in_remove_audio_effect;
1228 in->stream.set_gain = in_set_gain;
1229 in->stream.read = in_read;
1230 in->stream.get_input_frames_lost = in_get_input_frames_lost;
1232 in->dev = adev;
1233 in->standby = true;
1234 in->requested_rate = config->sample_rate;
1236 in->pcm_config = (config->sample_rate == IN_SAMPLING_RATE) && (flags & AUDIO_INPUT_FLAG_FAST) ?
1238 in->pcm_config_non_sco = in->pcm_config;
1240 *stream_in = &in->stream;
1247 struct stream_in *in = (struct stream_in *)stream;