Sample rate 0 means a route-dependent rate
Remove check for primary _output_ [sic] sampling rate for fast capture.
Clean up AudioRecord handling of frame count and sample rate.
Clean up AudioTrack handling of notification period updates.
Make AudioRecord and AudioTrack more similar in order of operation, comments, and whitespace.
Bug: 25641253
Bug: 21019153
Change-Id: I24a6677945987fc39a9bf93f70357e4bc7410f98
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 521557d..b0bc2d0 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -145,7 +145,7 @@
* Parameters:
*
* inputSource: Select the audio input to record from (e.g. AUDIO_SOURCE_DEFAULT).
- * sampleRate: Data sink sampling rate in Hz.
+ * sampleRate: Data sink sampling rate in Hz. Zero means to use the source sample rate.
* format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
* 16 bits per sample).
* channelMask: Channel mask, such that audio_is_input_channel(channelMask) is true.
@@ -258,6 +258,7 @@
bool stopped() const;
/* Return the sink sample rate for this record track in Hz.
+ * If specified as zero in constructor or set(), this will be the source sample rate.
* Unlike AudioTrack, the sample rate is const after initialization, so doesn't need a lock.
*/
uint32_t getSampleRate() const { return mSampleRate; }
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index a4b8571..e0fb603 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -167,7 +167,10 @@
*
* streamType: Select the type of audio stream this track is attached to
* (e.g. AUDIO_STREAM_MUSIC).
- * sampleRate: Data source sampling rate in Hz.
+ * sampleRate: Data source sampling rate in Hz. Zero means to use the sink sample rate.
+ * A non-zero value must be specified if AUDIO_OUTPUT_FLAG_DIRECT is set.
+ * 0 will not work with current policy implementation for direct output
+ * selection where an exact match is needed for sampling rate.
* format: Audio format. For mixed tracks, any PCM format supported by server is OK.
* For direct and offloaded tracks, the possible format(s) depends on the
* output sink.
@@ -395,11 +398,14 @@
status_t setAuxEffectSendLevel(float level);
void getAuxEffectSendLevel(float* level) const;
- /* Set source sample rate for this track in Hz, mostly used for games' sound effects
+ /* Set source sample rate for this track in Hz, mostly used for games' sound effects.
+ * Zero is not permitted.
*/
status_t setSampleRate(uint32_t sampleRate);
- /* Return current source sample rate in Hz */
+ /* Return current source sample rate in Hz.
+ * If specified as zero in constructor or set(), this will be the sink sample rate.
+ */
uint32_t getSampleRate() const;
/* Return the original source sample rate in Hz. This corresponds to the sample rate