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
59 /* duration in ms of volume ramp applied when starting capture to remove plop */
223 OUT_DEVICE_TAB_SIZE, /* number of rows in route_configs[][] */
233 IN_SOURCE_TAB_SIZE, /* number of lines in route_configs[][] */
431 * in stream
432 * out stream(s) in enum output_type order
434 * TODO investigate whether we ever actually take both in stream and out stream
760 /* anticipate level measurement in case we start capture later */
768 static int start_input_stream(struct stream_in *in)
770 struct audio_device *adev = in->dev;
772 in->pcm = pcm_open(PCM_CARD, PCM_DEVICE, PCM_IN, in->config);
774 if (in->pcm && !pcm_is_ready(in->pcm)) {
775 ALOGE("pcm_open() failed: %s", pcm_get_error(in->pcm));
776 pcm_close(in->pcm);
781 if (in->resampler)
782 in->resampler->reset(in->resampler);
784 in->frames_in = 0;
785 adev->input_source = in->input_source;
786 adev->in_device = in->device;
787 adev->in_channel_mask = in->channel_mask;
789 eS305_SetActiveIoHandle(in->io_handle);
792 if (in->device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET)
796 in->ramp_frames = (CAPTURE_START_RAMP_MS * in->requested_rate) / 1000;
797 in->ramp_step = (uint16_t)(USHRT_MAX / in->ramp_frames);
798 in->ramp_vol = 0;;
831 struct stream_in *in;
837 in = (struct stream_in *)((char *)buffer_provider -
840 if (in->pcm == NULL) {
843 in->read_status = -ENODEV;
847 if (in->frames_in == 0) {
848 in->read_status = pcm_read(in->pcm,
849 (void*)in->buffer,
850 pcm_frames_to_bytes(in->pcm, in->config->period_size));
851 if (in->read_status != 0) {
852 ALOGE("get_next_buffer() pcm_read error %d", in->read_status);
855 return in->read_status;
858 in->frames_in = in->config->period_size;
860 /* Do stereo to mono conversion in place by discarding right channel */
861 if (in->channel_mask == AUDIO_CHANNEL_IN_MONO)
862 for (i = 1; i < in->frames_in; i++)
863 in->buffer[i] = in->buffer[i * 2];
866 buffer->frame_count = (buffer->frame_count > in->frames_in) ?
867 in->frames_in : buffer->frame_count;
868 buffer->i16 = in->buffer +
869 (in->config->period_size - in->frames_in) *
870 audio_channel_count_from_in_mask(in->channel_mask);
872 return in->read_status;
879 struct stream_in *in;
884 in = (struct stream_in *)((char *)buffer_provider -
887 in->frames_in -= buffer->frame_count;
892 static ssize_t read_frames(struct stream_in *in, void *buffer, ssize_t frames)
895 size_t frame_size = audio_stream_in_frame_size(&in->stream);
899 if (in->resampler != NULL) {
900 in->resampler->resample_from_provider(in->resampler,
909 get_next_buffer(&in->buf_provider, &buf);
917 release_buffer(&in->buf_provider, &buf);
919 /* in->read_status is updated by getNextBuffer() also called by
920 * in->resampler->resample_from_provider() */
921 if (in->read_status != 0)
922 return in->read_status;
1041 /* unlock order is irrelevant, but for cleanliness we unlock in reverse order */
1089 * device changes when in SPDIF mode */
1132 /* the last entry in supported_channel_masks[] is always 0 */
1279 // We are just interested in the frames pending for playback in the kernel buffer here,
1289 // It would be unusual for this value to be negative, but check just in case ...
1306 struct stream_in *in = (struct stream_in *)stream;
1308 return in->requested_rate;
1318 struct stream_in *in = (struct stream_in *)stream;
1320 return in->channel_mask;
1326 struct stream_in *in = (struct stream_in *)stream;
1328 return get_input_buffer_size(in->requested_rate,
1331 (in->flags & AUDIO_INPUT_FLAG_FAST) != 0);
1344 /* must be called with in stream and hw device mutex locked */
1345 static void do_in_standby(struct stream_in *in)
1347 struct audio_device *adev = in->dev;
1349 if (!in->standby) {
1350 pcm_close(in->pcm);
1351 in->pcm = NULL;
1353 if (in->device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET)
1356 in->dev->input_source = AUDIO_SOURCE_DEFAULT;
1357 in->dev->in_device = AUDIO_DEVICE_NONE;
1358 in->dev->in_channel_mask = 0;
1360 in->standby = true;
1363 in->dev->bubble_level->stop_polling(adev->bubble_level);
1371 struct stream_in *in = (struct stream_in *)stream;
1373 pthread_mutex_lock(&in->lock);
1374 pthread_mutex_lock(&in->dev->lock);
1376 do_in_standby(in);
1378 pthread_mutex_unlock(&in->dev->lock);
1379 pthread_mutex_unlock(&in->lock);
1391 struct stream_in *in = (struct stream_in *)stream;
1392 struct audio_device *adev = in->dev;
1401 pthread_mutex_lock(&in->lock);
1408 if ((in->input_source != val) && (val != 0)) {
1409 in->input_source = val;
1410 apply_now = !in->standby;
1420 if ((in->device != val) && (val != 0)) {
1423 (in->device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET)) {
1424 do_in_standby(in);
1426 in->device = val;
1427 apply_now = !in->standby;
1432 adev->input_source = in->input_source;
1433 adev->in_device = in->device;
1438 pthread_mutex_unlock(&in->lock);
1455 static void in_apply_ramp(struct stream_in *in, int16_t *buffer, size_t frames)
1458 uint16_t vol = in->ramp_vol;
1459 uint16_t step = in->ramp_step;
1461 frames = (frames < in->ramp_frames) ? frames : in->ramp_frames;
1463 if (in->channel_mask == AUDIO_CHANNEL_IN_MONO)
1478 in->ramp_vol = vol;
1479 in->ramp_frames -= frames;
1486 struct stream_in *in = (struct stream_in *)stream;
1487 struct audio_device *adev = in->dev;
1496 pthread_mutex_lock(&in->lock);
1497 if (in->standby) {
1499 ret = start_input_stream(in);
1503 in->standby = false;
1506 /*if (in->num_preprocessors != 0)
1507 ret = process_frames(in, buffer, frames_rq);
1509 ret = read_frames(in, buffer, frames_rq);
1514 if (in->ramp_frames > 0)
1515 in_apply_ramp(in, buffer, frames_rq);
1529 pthread_mutex_unlock(&in->lock);
1541 struct stream_in *in = (struct stream_in *)stream;
1545 pthread_mutex_lock(&in->lock);
1546 pthread_mutex_lock(&in->dev->lock);
1548 eS305_AddEffect(&descr, in->io_handle);
1550 pthread_mutex_unlock(&in->dev->lock);
1551 pthread_mutex_unlock(&in->lock);
1560 struct stream_in *in = (struct stream_in *)stream;
1564 pthread_mutex_lock(&in->lock);
1565 pthread_mutex_lock(&in->dev->lock);
1567 eS305_RemoveEffect(&descr, in->io_handle);
1569 pthread_mutex_unlock(&in->dev->lock);
1570 pthread_mutex_unlock(&in->lock);
1774 struct stream_in *in;
1786 in = (struct stream_in *)calloc(1, sizeof(struct stream_in));
1787 if (!in)
1790 in->stream.common.get_sample_rate = in_get_sample_rate;
1791 in->stream.common.set_sample_rate = in_set_sample_rate;
1792 in->stream.common.get_buffer_size = in_get_buffer_size;
1793 in->stream.common.get_channels = in_get_channels;
1794 in->stream.common.get_format = in_get_format;
1795 in->stream.common.set_format = in_set_format;
1796 in->stream.common.standby = in_standby;
1797 in->stream.common.dump = in_dump;
1798 in->stream.common.set_parameters = in_set_parameters;
1799 in->stream.common.get_parameters = in_get_parameters;
1800 in->stream.common.add_audio_effect = in_add_audio_effect;
1801 in->stream.common.remove_audio_effect = in_remove_audio_effect;
1802 in->stream.set_gain = in_set_gain;
1803 in->stream.read = in_read;
1804 in->stream.get_input_frames_lost = in_get_input_frames_lost;
1806 in->dev = adev;
1807 in->standby = true;
1808 in->requested_rate = config->sample_rate;
1809 in->input_source = AUDIO_SOURCE_DEFAULT;
1811 in->device = devices & ~AUDIO_DEVICE_BIT_IN;
1812 in->io_handle = handle;
1813 in->channel_mask = config->channel_mask;
1814 in->flags = flags;
1817 in->config = pcm_config;
1819 in->buffer = malloc(pcm_config->period_size * pcm_config->channels
1820 * audio_stream_in_frame_size(&in->stream));
1822 if (!in->buffer) {
1827 if (in->requested_rate != pcm_config->rate) {
1828 in->buf_provider.get_next_buffer = get_next_buffer;
1829 in->buf_provider.release_buffer = release_buffer;
1832 in->requested_rate,
1833 audio_channel_count_from_in_mask(in->channel_mask),
1835 &in->buf_provider,
1836 &in->resampler);
1843 *stream_in = &in->stream;
1847 free(in->buffer);
1849 free(in);
1856 struct stream_in *in = (struct stream_in *)stream;
1859 if (in->resampler) {
1860 release_resampler(in->resampler);
1861 in->resampler = NULL;
1863 free(in->buffer);