Adapt the pipe size based on the sample rate.
Behavior is unchanged for the default sample rate (48kHz), size
is adjusted by the ratio relative to the default rate.
Bug: 141604269
Test: atest AudioHostTest#testTwoChannelCapturingMediaConversion
Change-Id: I0ba45af18ef02dc0ef77d480e1203d2cd1db9864
We no longer set force_pipe_creation after the removal of
legacy code for in-pipe conversions, so we remove it.
Test: TreeHugger
Bug: 141604269
Change-Id: I82393ba0ad3142aa75d482cc6b0edbaeebbd8116
Old hacky uses of this HAL required channel and sample
rate conversion, which were never expected when this HAL
is used for its real application as the backend for
dynamic audio policies. In that context conversions are
performed in audio_flinger in the mixer.
Bug: 141604269
Test: atest AudioHostTest#testTwoChannelCapturing
Change-Id: I333e981fb3db403ab2da6f77debe49bc7d132ebc
IStream.getCapturePosition becomes mandatory in
audio HAL V7. The legacy implementation must
provide it for the default HAL implementation.
Bug: 161253754
Test: atest VtsHalAudioV7_0TargetTest
Change-Id: I2f2094f0499ba85f53f291e0a269211981b4c9d8
This applies to the following types:
- audio_gain_mode_t;
- audio_flags_mask_t;
- audio_channel_representation_t;
- audio_channel_mask_t;
- audio_devices_t.
Enum types are distinct thus proper overloading on the type
is possible in C++. Also, assignments to enum types are
less prone to errors.
Bug: 169889714
Test: basic audio functionality
Change-Id: I8f1e6fa2bbad8900fdae66f01ac70c75953fd62c
Merged-In: I8f1e6fa2bbad8900fdae66f01ac70c75953fd62c
Fix the implementation to conform to VTS expectations.
out_get_next_write_timestamp must return "NOT_SUPPORTED" (-ENOSYS)
as it is not supported.
adev_get_input_buffer_size must return a non-zero
buffer size for supported formats, regardless of whether
there are any opened streams at the moment.
Bug: 141847510
Test: atest VtsHalAudioV6_0TargetTest
Change-Id: I322bf8cf42415fddb028c9cd10db0ac82089ce85
Do not block in out_write() when the peer input is in standby to avoid
remaining stuck when writing to the blocking mono pipe.
Bug: 141878993
Test: atest AudioHostTest#testTwoChannelCapturing
Change-Id: Ie92d59529ac1018a6785c3ac31696dcccdbb204a
Force mono pipe shutdown when all input stream clients are closed
so that a pending write is not stuck waiting for available buffer.
Bug: 119057550
Test: abort search on BLE remote
Merged-In: I4391e73874e502da5000b1746436fb61bb2fe869
Change-Id: I4391e73874e502da5000b1746436fb61bb2fe869
In remote submix audio HAL, Add null check on Pipe sink pointer
in out_get_presentation_position() and out_get_render_position().
Bug: 117183072
Test: manual test with capture from BLE remote mic.
Change-Id: I05aa87f414c69bcd08c7692918e6a215077b7ea2
Since rework of presentationTimestamp in AudioFlinger, it is expecting
to drain correctly before stopping an output.
When a MIX RECORDER is set,
1/ Dynamic Policy Mix is registered
2/ Extraction Sink Port is made available
3/ Player is started on this sink
4/ Extraction source port is connected upon start Output
4/ Capture may be launched on the source to be rerouted
5/ All Capture are stopped, player is stopped
6/ Extraction source port shall be disconnected on stopOutput
Step 6 does not happen as the track is never set as drained.
Upon capture stop, rxSink MonoPipe is put in shutdown state. Any further
write will discard the buffer. However, frames written shall be
incremented of these frame discarded to be able to set the track as
drained.
This CL fixes this issue.
Test: AudioPolicyEmulatorTests --gtest_filter=RecordInjectionSourceMatch/DynamicPolicyMixRecordInjectionTest.RecordingInjection/*
Bug: 130356101
Change-Id: I861c4867991da8bcc1090be56d64e69646d58dc2
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
Force mono pipe shutdown when all input stream clients are closed
so that a pending write is not stuck waiting for available buffer.
Bug: 119057550
Test: abort search on BLE remote
Change-Id: I4391e73874e502da5000b1746436fb61bb2fe869
Revert "r_submix: Fix logspam on pipe corruption"
This reverts commit ab5b51838c.
Revert "r_submix: Use intermediate pipe in non-blocking mode"
This reverts commit 1df8a0039f.
Reason: breaks Android Auto projected mode
Bug: 74142786
Test: with Android Auto head unit simulator
Change-Id: I8e1bc146a131cb5b1ab88cf242b03a6b02a84339
Revert "r_submix: Fix logspam on pipe corruption"
This reverts commit ab5b51838c.
Revert "r_submix: Use intermediate pipe in non-blocking mode"
This reverts commit 1df8a0039f.
Reason: breaks Android Auto projected mode
Bug: 74142786
Test: with Android Auto head unit simulator
Change-Id: I8e1bc146a131cb5b1ab88cf242b03a6b02a84339
Prevent logging an error message on every attempt to write
if the FIFO backing up the MonoPipe got corrupted. This condition
can be detected by checking for -EIO error code.
Bug: 74067530
Test: make audio_utils_fifo_base::mIsShutdown to be set by default,
run r_submix_tests and observe logcat
Change-Id: I5d67997e902e834f04c10f9ffb39b16cba9c5739
Switch the pipe into non-blocking mode to prevent stalling
when attempting to close it.
Simulate circular buffer behavior by flushing old data if
there is no more space in the pipe.
This removes the need for "exiting=1" parameter.
Bug: 73175392
Test: r_submix_tests
Change-Id: Iff89980af71112892ff262030e471ae736b1f62a
Add simple tests to verify remote submix behavior regarding
blocking writes. Currently one of the tests fails (does not finish),
this needs to be fixed.
Also fixed some minor issues in remote submix module code.
Bug: 73175392
Test: r_submix_tests
Change-Id: Ic88d0c385c0102e35b4f751f9c5cd8a6488949c8
* Remove unused local variables.
* Remove or comment out unused static functions.
* Fix trivial bugs found by unused value warnings.
Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I99389b883c89551850180d25241a35a40bb77b26
Count number of frames that have been written, reset on standby.
The presentation position is the number of written frames minus
the frames still in the pipe (they were written but not presented).
Bug 21198864
Change-Id: I00ef10f56a825555e7a970cce1504a9bd3744e04
When reading from a pipe, the output may have been previously
closed, therefore the output state should only be read if it
is still available.
This fixes a race condition observed between in_read() (which
accesses the output stream) and adev_close_output_stream()
(which sets the output reference to NULL).
No issue with out_write() which checks the input reference.
Bug 16009464
Change-Id: I979bc12c8fe91fad9b6f6c9e0be107c1bacae360
The implementation for "remote submix" supported only one pipe
to capture the output of a mix.
This CL adds support for multiple pipes to support capturing
multiple audio routes.
The structure for the r_submix audio device holds an array
of route configurations (route_config), each referencing
the input and output of the pipe dedicated to this route.
Each route is associated to a unique address. Standby
status is maintained per stream.
Bug 16009464
Change-Id: Ie164c4ad2a6d8138f825484e7faf29a974ccf82e
The "remote submix" HAL uses a MonoPipe instance to "pipe" audio
from the sink of this virtual device HAL to its source.
The life-cycle of this pipe is:
- creation when either the input or output stream is open
- destruction when both input and output are closed.
Changes are:
Fix test for pipe destruction: destroy pipe when both
input and output streams are NULL.
Count how many read errors went into the logs and cap them
so as not to spam the logs when the pipe is not properly
set up. Less 'I' logs, 'D' logs instead.
When opening input stream, check for non-null sink before
checking if it's shutdown.
Bug 16653334
Bug 17111907
Change-Id: I634b4192b00f9b74a5109f42242423e9c8cb4c7c
Pass device address (and audio source for inputs) to
open_output_stream() and open_input_stream() audio HAL functions.
Bug: 14815883.
Change-Id: I5535677db3f3027917a31a7ed5c0a4c6bc013639
When channel conversion is enabled and the pipe is opened with less channels
(e.g 1) than the output stream's channels (e.g 2) the input stream's buffer
size was calculated incorrectly which resulted in the input stream buffer size
being larger than the output stream buffer size in terms of time. This
changes the pipe size to take into the account maximum frame size so the
output stream buffer size will be greater or equal to the input stream buffer
size.
In addition, if the pipe is created when the input stream is opened and the
output stream is opened at a different sample rate (e.g input = 8KHz,
output = 48Khz) the pipe will incorrectly rate limit writes to the pipe
resulting in gaps of silence in the data read from the pipe by the input
stream.
Bug: 15291446
Change-Id: I01480edff7ef3a199f509866c1e95ecd4c437a92
As described in If592270a17e08c5852b00b730bb9c5166c746ad2 the audio mixer
doesn't work correctly when sending data to an output device that supports
a sample rate that is more than 2x different to the source data rate.
This modifies the remote submix module to resample data from the pipe
when it's read from the input stream.
Bug: 11273000
Change-Id: I9c4b3710bcebf3a2df045965dfdafdd9855b0b25
In order to aid debugging of issues with streaming data in the submix HAL
this change introduces a compile time option to log the input and output
streams to files for offline inspection.
Bug: 11273000
Change-Id: Ib2d929d7ba66f63b719e6996df9016f73c9080aa
The AudioFlinger service currently will only open stereo streams from
mono AudioTracks since all mixing is performed in stereo and then sent
to the HAL stream. In order to allow a process to record a mono stream
from the submix HAL, this change implements channel conversion in
the submix HAL so that it's possible to open the output stream in stereo
and the input stream in mono.
Bug: 11273000
Change-Id: I840ce0be3cf7e5bc8a4c6de63a70d5408d60b716
Since it's possible to open an output stream on the submix HAL before the input
stream is open, writes to the output stream that fill the shared pipe result in
indefinitely blocking the thread writing to the stream. This change modifies
the behavior of writes to a submix output stream such that if a write would
result in blocking the thread and an input isn't open, the pipe is flushed
of the appropriate amount of data such that the write will not block.
Bug: 11273000
Change-Id: Ic81c50e4b44b777273191a1bc8cdf52181c3d2a0
This change is primarily being made as a short term solution to allow an input
audio stream received over the network to be fed into an audio input stream (e.g
the MIC stream) when a physical audio input device isn't present.
This makes both the input and output streams owners of the pipe so that
creation order no longer matters. In addition, it works around a memory leak
caused by applications that never close input streams.
Bug: 11273000
Change-Id: I5a3fb0b6f2148c113b2f3050b72ff2a8979a3e6d
This modifies the submix module to allow the internal buffer to be any NBAIO
format. This is useful when sending audio of arbitrary formats between
processes. AudioFlinger continues to enforce format restrictions as specified
by the device specific audio_policy.conf so the submix streams will have the
same restrictions as before.
Bug: 11273000
Change-Id: I2cd4ff383c5c75e491ab22bc1949c835f04e230f
This change stores the period size (fraction of the pipe buffer size)
in the submix device's configuration which is then used to calculate
the input and output stream buffer size.
In addition, accessors for the input / output stream format have been
modified to use the pipe format in the device configuration rather than
returning hard coded values.
Bug: 11273000
Change-Id: I9c14f8d549f4b4a6d7f77a9aeab4edfa5ba6bd1a
This change cleans up casting from contained to container structures.
Such that if..
struct child {
struct parent;
int child_data;
};
is changed to...
struct child {
int child_data;
struct parent;
};
functions that cast from "parent" to "child" will continue to function
correctly.
Change-Id: I88d70930d4d4df2e291239e562971b07d8b92f94
Along with the following minor changes:
* Fixed all referenced variable compiler warnings.
* Ordered headers in alphabetical order.
Change-Id: I122ef67d25b78056a60b85baf897005293a9efa0
Fix a few 64-bit warnings and set -Wno-unused-parameter, which makes
the directory warnings-clean on 32-bit and 64-bit.
Remove LOCAL_32_BIT_ONLY.
Change-Id: I6a2183b5bb0cdf438a04de967995da7b1e2e3854