Lines Matching refs:out
171 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_sample_rate() local
172 return out->req_config.sample_rate; in out_get_sample_rate()
180 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_buffer_size() local
181 int size = out->pcm_config.period_size * in out_get_buffer_size()
182 audio_stream_out_frame_size(&out->stream); in out_get_buffer_size()
188 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_channels() local
189 return out->req_config.channel_mask; in out_get_channels()
193 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_format() local
194 return out->req_config.format; in out_get_format()
202 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_dump() local
203 pthread_mutex_lock(&out->lock); in out_dump()
214 out->bus_address, in out_dump()
219 out->device, in out_dump()
220 out->amplitude_ratio, in out_dump()
221 out->enabled_channels, in out_dump()
222 out->dev); in out_dump()
223 pthread_mutex_unlock(&out->lock); in out_dump()
228 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_set_parameters() local
232 pthread_mutex_lock(&out->lock); in out_set_parameters()
233 if (!out->standby) { in out_set_parameters()
241 out->device = (int)val; in out_set_parameters()
246 pthread_mutex_unlock(&out->lock); in out_set_parameters()
251 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_parameters() local
260 pthread_mutex_lock(&out->lock); in out_get_parameters()
261 str_parms_add_int(reply, AUDIO_PARAMETER_STREAM_ROUTING, out->device); in out_get_parameters()
262 pthread_mutex_unlock(&out->lock); in out_get_parameters()
274 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_latency() local
275 return (out->pcm_config.period_size * 1000) / out->pcm_config.rate; in out_get_latency()
297 struct generic_stream_out *out = (struct generic_stream_out *)args; in out_write_worker() local
306 if (strstr(out->bus_address, AUDIO_ZONE_KEYWORD)) { in out_write_worker()
307 zone_id = get_zone_id_from_address(out->bus_address); in out_write_worker()
310 out->bus_address, DEFAULT_ZONE_TO_LEFT_SPEAKER); in out_write_worker()
314 ALOGD("Out worker:%s zone id %d", out->bus_address, zone_id); in out_write_worker()
317 pthread_mutex_lock(&out->lock); in out_write_worker()
318 while (out->worker_standby || restart) { in out_write_worker()
326 if (out->worker_exit) { in out_write_worker()
329 pthread_cond_wait(&out->worker_wake, &out->lock); in out_write_worker()
332 if (out->worker_exit) { in out_write_worker()
333 if (!out->worker_standby) { in out_write_worker()
334 ALOGE("Out worker:%s not in standby before exiting", out->bus_address); in out_write_worker()
339 while (!shutdown && audio_vbuffer_live(&out->buffer) == 0) { in out_write_worker()
340 pthread_cond_wait(&out->worker_wake, &out->lock); in out_write_worker()
344 pthread_mutex_unlock(&out->lock); in out_write_worker()
350 PCM_OUT | PCM_MONOTONIC, &out->pcm_config); in out_write_worker()
354 out->bus_address, in out_write_worker()
355 out->pcm_config.channels, in out_write_worker()
356 out->pcm_config.format, in out_write_worker()
357 out->pcm_config.rate); in out_write_worker()
358 pthread_mutex_unlock(&out->lock); in out_write_worker()
361 buffer_frames = out->pcm_config.period_size; in out_write_worker()
366 pthread_mutex_unlock(&out->lock); in out_write_worker()
370 int frames = audio_vbuffer_read(&out->buffer, buffer, buffer_frames); in out_write_worker()
371 pthread_mutex_unlock(&out->lock); in out_write_worker()
373 if (is_zone_selected_to_play(&out->dev->device, zone_id)) { in out_write_worker()
374 int write_error = ext_pcm_write(ext_pcm, out->bus_address, in out_write_worker()
378 ext_pcm_get_error(ext_pcm), out->bus_address); in out_write_worker()
381 ALOGV("pcm_write succeed address %s", out->bus_address); in out_write_worker()
393 static void get_current_output_position(struct generic_stream_out *out, in get_current_output_position() argument
402 if (out->standby) { in get_current_output_position()
405 const int64_t first_us = (out->underrun_time.tv_sec * 1000000000LL + in get_current_output_position()
406 out->underrun_time.tv_nsec) / 1000; in get_current_output_position()
408 out_get_sample_rate(&out->stream.common) / in get_current_output_position()
414 *position = out->underrun_position + position_since_underrun; in get_current_output_position()
418 if (*position > out->frames_written) { in get_current_output_position()
421 *position, out->frames_written); in get_current_output_position()
423 *position = out->frames_written; in get_current_output_position()
424 out->underrun_position = *position; in get_current_output_position()
425 out->underrun_time = curtime; in get_current_output_position()
426 out->frames_total_buffered = 0; in get_current_output_position()
431 static void out_apply_gain(struct generic_stream_out *out, const void *buffer, size_t bytes) { in out_apply_gain() argument
435 if ((i % 2) && !(out->enabled_channels & RIGHT_CHANNEL)) { in out_apply_gain()
437 } else if (!(i % 2) && !(out->enabled_channels & LEFT_CHANNEL)) { in out_apply_gain()
440 float multiplied = int16_buffer[i] * out->amplitude_ratio; in out_apply_gain()
449 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_write() local
450 ALOGV("%s: to device %s", __func__, out->bus_address); in out_write()
453 pthread_mutex_lock(&out->lock); in out_write()
455 if (out->worker_standby) { in out_write()
456 out->worker_standby = false; in out_write()
462 get_current_output_position(out, ¤t_position, ¤t_time); in out_write()
465 if (out->standby) { in out_write()
466 out->standby = false; in out_write()
467 out->underrun_time = current_time; in out_write()
468 out->frames_rendered = 0; in out_write()
469 out->frames_total_buffered = 0; in out_write()
473 if (out->dev->main_mute) { in out_write()
476 out_apply_gain(out, buffer, bytes); in out_write()
477 frames_written = audio_vbuffer_write(&out->buffer, buffer, frames); in out_write()
478 pthread_cond_signal(&out->worker_wake); in out_write()
482 out->frames_written += frames; in out_write()
483 out->frames_rendered += frames; in out_write()
484 out->frames_total_buffered += frames; in out_write()
491 int frames_sleep = out->frames_total_buffered < out->buffer.frame_count ? 0 : frames; in out_write()
498 uint64_t time_since_last_write_us = now_us - out->last_write_time_us; in out_write()
504 out->last_write_time_us = now_us + sleep_time_us; in out_write()
506 pthread_mutex_unlock(&out->lock); in out_write()
526 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_presentation_position() local
528 pthread_mutex_lock(&out->lock); in out_get_presentation_position()
529 get_current_output_position(out, frames, timestamp); in out_get_presentation_position()
530 pthread_mutex_unlock(&out->lock); in out_get_presentation_position()
539 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_get_render_position() local
540 pthread_mutex_lock(&out->lock); in out_get_render_position()
541 *dsp_frames = out->frames_rendered; in out_get_render_position()
542 pthread_mutex_unlock(&out->lock); in out_get_render_position()
547 static void do_out_standby(struct generic_stream_out *out) { in do_out_standby() argument
550 if (out->standby) { in do_out_standby()
554 get_current_output_position(out, &out->underrun_position, NULL); in do_out_standby()
555 frames_sleep = out->frames_written - out->underrun_position; in do_out_standby()
562 out_get_sample_rate(&out->stream.common); in do_out_standby()
564 pthread_mutex_unlock(&out->lock); in do_out_standby()
566 pthread_mutex_lock(&out->lock); in do_out_standby()
568 out->worker_standby = true; in do_out_standby()
569 out->standby = true; in do_out_standby()
573 struct generic_stream_out *out = (struct generic_stream_out *)stream; in out_standby() local
574 pthread_mutex_lock(&out->lock); in out_standby()
575 do_out_standby(out); in out_standby()
576 pthread_mutex_unlock(&out->lock); in out_standby()
1096 struct generic_stream_out *out; in adev_open_output_stream() local
1106 out = (struct generic_stream_out *)calloc(1, sizeof(struct generic_stream_out)); in adev_open_output_stream()
1108 if (!out) in adev_open_output_stream()
1111 out->stream.common.get_sample_rate = out_get_sample_rate; in adev_open_output_stream()
1112 out->stream.common.set_sample_rate = out_set_sample_rate; in adev_open_output_stream()
1113 out->stream.common.get_buffer_size = out_get_buffer_size; in adev_open_output_stream()
1114 out->stream.common.get_channels = out_get_channels; in adev_open_output_stream()
1115 out->stream.common.get_format = out_get_format; in adev_open_output_stream()
1116 out->stream.common.set_format = out_set_format; in adev_open_output_stream()
1117 out->stream.common.standby = out_standby; in adev_open_output_stream()
1118 out->stream.common.dump = out_dump; in adev_open_output_stream()
1119 out->stream.common.set_parameters = out_set_parameters; in adev_open_output_stream()
1120 out->stream.common.get_parameters = out_get_parameters; in adev_open_output_stream()
1121 out->stream.common.add_audio_effect = out_add_audio_effect; in adev_open_output_stream()
1122 out->stream.common.remove_audio_effect = out_remove_audio_effect; in adev_open_output_stream()
1123 out->stream.get_latency = out_get_latency; in adev_open_output_stream()
1124 out->stream.set_volume = out_set_volume; in adev_open_output_stream()
1125 out->stream.write = out_write; in adev_open_output_stream()
1126 out->stream.get_render_position = out_get_render_position; in adev_open_output_stream()
1127 out->stream.get_presentation_position = out_get_presentation_position; in adev_open_output_stream()
1128 out->stream.get_next_write_timestamp = out_get_next_write_timestamp; in adev_open_output_stream()
1130 pthread_mutex_init(&out->lock, (const pthread_mutexattr_t *) NULL); in adev_open_output_stream()
1131 out->dev = adev; in adev_open_output_stream()
1132 out->device = devices; in adev_open_output_stream()
1133 memcpy(&out->req_config, config, sizeof(struct audio_config)); in adev_open_output_stream()
1134 memcpy(&out->pcm_config, &pcm_config_out, sizeof(struct pcm_config)); in adev_open_output_stream()
1135 out->pcm_config.rate = config->sample_rate; in adev_open_output_stream()
1136 out->pcm_config.period_size = out->pcm_config.rate * get_out_period_ms() / 1000; in adev_open_output_stream()
1138 out->standby = true; in adev_open_output_stream()
1139 out->underrun_position = 0; in adev_open_output_stream()
1140 out->underrun_time.tv_sec = 0; in adev_open_output_stream()
1141 out->underrun_time.tv_nsec = 0; in adev_open_output_stream()
1142 out->last_write_time_us = 0; in adev_open_output_stream()
1143 out->frames_total_buffered = 0; in adev_open_output_stream()
1144 out->frames_written = 0; in adev_open_output_stream()
1145 out->frames_rendered = 0; in adev_open_output_stream()
1156 ret = audio_vbuffer_init(&out->buffer, in adev_open_output_stream()
1157 out->pcm_config.period_size*out->pcm_config.period_count*2, in adev_open_output_stream()
1158 out->pcm_config.channels * in adev_open_output_stream()
1159 pcm_format_to_bits(out->pcm_config.format) >> 3); in adev_open_output_stream()
1161 pthread_cond_init(&out->worker_wake, NULL); in adev_open_output_stream()
1162 out->worker_standby = true; in adev_open_output_stream()
1163 out->worker_exit = false; in adev_open_output_stream()
1164 pthread_create(&out->worker_thread, NULL, out_write_worker, out); in adev_open_output_stream()
1167 out->enabled_channels = BOTH_CHANNELS; in adev_open_output_stream()
1169 out->bus_address = strdup(address); in adev_open_output_stream()
1170 hashmapPut(adev->out_bus_stream_map, (void*)out->bus_address, out); in adev_open_output_stream()
1172 out->gain_stage = (struct audio_gain) { in adev_open_output_stream()
1177 out->amplitude_ratio = 1.0; in adev_open_output_stream()
1179 out->enabled_channels = strstr(out->bus_address, AUDIO_ZONE_KEYWORD) in adev_open_output_stream()
1182 out->bus_address, out->enabled_channels == RIGHT_CHANNEL ? "Right" : "Left"); in adev_open_output_stream()
1185 *stream_out = &out->stream; in adev_open_output_stream()
1186 ALOGD("%s bus: %s", __func__, out->bus_address); in adev_open_output_stream()
1195 struct generic_stream_out *out = (struct generic_stream_out *)stream; in adev_close_output_stream() local
1196 ALOGD("%s bus:%s", __func__, out->bus_address); in adev_close_output_stream()
1197 pthread_mutex_lock(&out->lock); in adev_close_output_stream()
1198 do_out_standby(out); in adev_close_output_stream()
1200 out->worker_exit = true; in adev_close_output_stream()
1201 pthread_cond_signal(&out->worker_wake); in adev_close_output_stream()
1202 pthread_mutex_unlock(&out->lock); in adev_close_output_stream()
1204 pthread_join(out->worker_thread, NULL); in adev_close_output_stream()
1205 pthread_mutex_destroy(&out->lock); in adev_close_output_stream()
1206 audio_vbuffer_destroy(&out->buffer); in adev_close_output_stream()
1208 if (out->bus_address) { in adev_close_output_stream()
1209 hashmapRemove(adev->out_bus_stream_map, (void*)out->bus_address); in adev_close_output_stream()
1210 free((void*)out->bus_address); in adev_close_output_stream()
1435 struct generic_stream_out *out = hashmapGet(adev->out_bus_stream_map, (void*)bus_address); in adev_set_audio_port_config() local
1436 if (out) { in adev_set_audio_port_config()
1437 pthread_mutex_lock(&out->lock); in adev_set_audio_port_config()
1438 int gainIndex = (config->gain.values[0] - out->gain_stage.min_value) / in adev_set_audio_port_config()
1439 out->gain_stage.step_value; in adev_set_audio_port_config()
1440 int totalSteps = (out->gain_stage.max_value - out->gain_stage.min_value) / in adev_set_audio_port_config()
1441 out->gain_stage.step_value; in adev_set_audio_port_config()
1442 int minDb = out->gain_stage.min_value / 100; in adev_set_audio_port_config()
1443 int maxDb = out->gain_stage.max_value / 100; in adev_set_audio_port_config()
1445 out->amplitude_ratio = pow(10, in adev_set_audio_port_config()
1447 pthread_mutex_unlock(&out->lock); in adev_set_audio_port_config()
1449 __func__, out->amplitude_ratio, bus_address); in adev_set_audio_port_config()