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
403 ALOGE("Out worker not in standby before exiting");
454 // Call with in->lock held
647 struct generic_stream_in *in = (struct generic_stream_in *)stream;
648 return in->req_config.sample_rate;
709 // must be fixed in in_read
770 struct generic_stream_in *in = (struct generic_stream_in *)stream;
771 int size = get_input_buffer_size(in->req_config.sample_rate,
772 in->req_config.format,
773 in->req_config.channel_mask);
780 struct generic_stream_in *in = (struct generic_stream_in *)stream;
781 return in->req_config.channel_mask;
786 struct generic_stream_in *in = (struct generic_stream_in *)stream;
787 return in->req_config.format;
797 struct generic_stream_in *in = (struct generic_stream_in *)stream;
799 pthread_mutex_lock(&in->lock);
811 in->device,
812 in->dev);
813 pthread_mutex_unlock(&in->lock);
819 struct generic_stream_in *in = (struct generic_stream_in *)stream;
826 pthread_mutex_lock(&in->lock);
827 if (!in->standby) {
838 in->device = (int)val;
847 pthread_mutex_unlock(&in->lock);
854 struct generic_stream_in *in = (struct generic_stream_in *)stream;
863 str_parms_add_int(reply, AUDIO_PARAMETER_STREAM_ROUTING, in->device);
880 // Call with in->lock held
881 static void get_current_input_position(struct generic_stream_in *in,
891 if (in->standby) {
894 const int64_t first_us = (in->standby_exit_time.tv_sec * 1000000000LL +
895 in->standby_exit_time.tv_nsec) / 1000;
897 in_get_sample_rate(&in->stream.common) /
903 *position = in->standby_position + position_since_standby;
906 // Must be called with in->lock held
907 static void do_in_standby(struct generic_stream_in *in)
909 if (in->standby) {
912 in->worker_standby = true;
913 get_current_input_position(in, &in->standby_position, NULL);
914 in->standby = true;
919 struct generic_stream_in *in = (struct generic_stream_in *)stream;
920 pthread_mutex_lock(&in->lock);
921 do_in_standby(in);
922 pthread_mutex_unlock(&in->lock);
928 struct generic_stream_in *in = (struct generic_stream_in *)args;
937 pthread_mutex_lock(&in->lock);
938 while (in->worker_standby || restart) {
946 if (in->worker_exit) {
949 pthread_cond_wait(&in->worker_wake, &in->lock);
952 if (in->worker_exit) {
953 if (!in->worker_standby) {
954 ALOGE("In worker not in standby before exiting");
959 pthread_mutex_unlock(&in->lock);
964 PCM_IN | PCM_MONOTONIC, &in->pcm_config);
966 ALOGE("pcm_open(in) failed: %s: channels %d format %d rate %d",
968 in->pcm_config.channels,
969 in->pcm_config.format,
970 in->pcm_config.rate
972 pthread_mutex_unlock(&in->lock);
975 buffer_frames = in->pcm_config.period_size;
980 pthread_mutex_unlock(&in->lock);
984 pthread_mutex_unlock(&in->lock);
991 pthread_mutex_lock(&in->lock);
992 size_t frames_written = audio_vbuffer_write(&in->buffer, buffer, buffer_frames);
993 pthread_mutex_unlock(&in->lock);
1008 struct generic_stream_in *in = (struct generic_stream_in *)stream;
1009 struct generic_audio_device *adev = in->dev;
1016 pthread_mutex_lock(&in->lock);
1018 if (in->worker_standby) {
1019 in->worker_standby = false;
1021 pthread_cond_signal(&in->worker_wake);
1026 get_current_input_position(in, ¤t_position, ¤t_time);
1027 if (in->standby) {
1028 in->standby = false;
1029 in->standby_exit_time = current_time;
1030 in->standby_frames_read = 0;
1033 const int64_t frames_available = current_position - in->standby_position - in->standby_frames_read;
1041 pthread_mutex_unlock(&in->lock);
1047 pthread_mutex_lock(&in->lock);
1049 if (in->standby) {
1050 ALOGW("Input put to sleep while read in progress");
1053 in->standby_frames_read += frames;
1055 if (popcount(in->req_config.channel_mask) == 1 &&
1056 in->pcm_config.channels == 2) {
1058 if (in->stereo_to_mono_buf_size < bytes*2) {
1059 in->stereo_to_mono_buf = realloc(in->stereo_to_mono_buf,
1061 if (!in->stereo_to_mono_buf) {
1067 read_frames = audio_vbuffer_read(&in->buffer, in->stereo_to_mono_buf, frames);
1070 uint16_t *src = (uint16_t *)in->stereo_to_mono_buf;
1081 read_frames = audio_vbuffer_read(&in->buffer, buffer, frames);
1095 pthread_mutex_unlock(&in->lock);
1108 struct generic_stream_in *in = (struct generic_stream_in *)stream;
1109 pthread_mutex_lock(&in->lock);
1111 get_current_input_position(in, frames, ¤t_time);
1113 pthread_mutex_unlock(&in->lock);
1302 struct generic_stream_in *in = (struct generic_stream_in *)stream;
1303 pthread_mutex_lock(&in->lock);
1304 do_in_standby(in);
1306 in->worker_exit = true;
1307 pthread_cond_signal(&in->worker_wake);
1308 pthread_mutex_unlock(&in->lock);
1309 pthread_join(in->worker_thread, NULL);
1311 if (in->stereo_to_mono_buf != NULL) {
1312 free(in->stereo_to_mono_buf);
1313 in->stereo_to_mono_buf_size = 0;
1316 pthread_mutex_destroy(&in->lock);
1317 audio_vbuffer_destroy(&in->buffer);
1332 struct generic_stream_in *in;
1341 in = (struct generic_stream_in *)calloc(1, sizeof(struct generic_stream_in));
1342 if (!in) {
1347 in->stream.common.get_sample_rate = in_get_sample_rate;
1348 in->stream.common.set_sample_rate = in_set_sample_rate; // no op
1349 in->stream.common.get_buffer_size = in_get_buffer_size;
1350 in->stream.common.get_channels = in_get_channels;
1351 in->stream.common.get_format = in_get_format;
1352 in->stream.common.set_format = in_set_format; // no op
1353 in->stream.common.standby = in_standby;
1354 in->stream.common.dump = in_dump;
1355 in->stream.common.set_parameters = in_set_parameters;
1356 in->stream.common.get_parameters = in_get_parameters;
1357 in->stream.common.add_audio_effect = in_add_audio_effect; // no op
1358 in->stream.common.remove_audio_effect = in_remove_audio_effect; // no op
1359 in->stream.set_gain = in_set_gain; // no op
1360 in->stream.read = in_read;
1361 in->stream.get_input_frames_lost = in_get_input_frames_lost; // no op
1362 in->stream.get_capture_position = in_get_capture_position;
1364 pthread_mutex_init(&in->lock, (const pthread_mutexattr_t *) NULL);
1365 in->dev = adev;
1366 in->device = devices;
1367 memcpy(&in->req_config, config, sizeof(struct audio_config));
1368 memcpy(&in->pcm_config, &pcm_config_in, sizeof(struct pcm_config));
1369 in->pcm_config.rate = config->sample_rate;
1370 in->pcm_config.period_size = in->pcm_config.rate*IN_PERIOD_MS/1000;
1372 in->stereo_to_mono_buf = NULL;
1373 in->stereo_to_mono_buf_size = 0;
1375 in->standby = true;
1376 in->standby_position = 0;
1377 in->standby_exit_time.tv_sec = 0;
1378 in->standby_exit_time.tv_nsec = 0;
1379 in->standby_frames_read = 0;
1381 ret = audio_vbuffer_init(&in->buffer,
1382 in->pcm_config.period_size*in->pcm_config.period_count,
1383 in->pcm_config.channels *
1384 pcm_format_to_bits(in->pcm_config.format) >> 3);
1386 pthread_cond_init(&in->worker_wake, NULL);
1387 in->worker_standby = true;
1388 in->worker_exit = false;
1389 pthread_create(&in->worker_thread, NULL, in_read_worker, in);
1392 *stream_in = &in->stream;