diff options
author | John Grossman <johngro@google.com> | 2011-08-29 10:56:08 -0700 |
---|---|---|
committer | John Grossman <johngro@google.com> | 2011-08-31 11:49:34 -0700 |
commit | e14fb4f6fb58bbb08ff737d1b17018610c3ac97d (patch) | |
tree | 5ac6dc10f28e405d3d5aed6f44570e10d4cee115 | |
parent | a6fa57f7ef2cb09261628283118351b769565439 (diff) | |
download | hardware_libhardware_legacy-e14fb4f6fb58bbb08ff737d1b17018610c3ac97d.zip hardware_libhardware_legacy-e14fb4f6fb58bbb08ff737d1b17018610c3ac97d.tar.gz hardware_libhardware_legacy-e14fb4f6fb58bbb08ff737d1b17018610c3ac97d.tar.bz2 |
Add an implementation of get_next_write_timestamp.
Add a default implementation of get_next_write_timestamp to the C <--> C++
legacy audio HAL implementation allowing HALs using the legacy C++
AudioStreamOut to overload and implement get_next_write_timestamp. Default
implementation returns INVALID_OPERATION to indicate that the functionality is
not supported.
Change-Id: I2f32858197696cb46ba6b96f30acc08e0b737a3f
-rw-r--r-- | audio/AudioHardwareInterface.cpp | 7 | ||||
-rw-r--r-- | audio/audio_hw_hal.cpp | 9 | ||||
-rw-r--r-- | include/hardware_legacy/AudioHardwareInterface.h | 7 |
3 files changed, 23 insertions, 0 deletions
diff --git a/audio/AudioHardwareInterface.cpp b/audio/AudioHardwareInterface.cpp index 4997a6a..c116669 100644 --- a/audio/AudioHardwareInterface.cpp +++ b/audio/AudioHardwareInterface.cpp @@ -73,6 +73,12 @@ AudioStreamOut::~AudioStreamOut() { } +// default implementation is unsupported +status_t AudioStreamOut::getNextWriteTimestamp(int64_t *timestamp) +{ + return INVALID_OPERATION; +} + AudioStreamIn::~AudioStreamIn() {} AudioHardwareBase::AudioHardwareBase() @@ -125,6 +131,7 @@ size_t AudioHardwareBase::getInputBufferSize(uint32_t sampleRate, int format, in return 320; } +// default implementation is unsupported status_t AudioHardwareBase::getMasterVolume(float *volume) { return INVALID_OPERATION; diff --git a/audio/audio_hw_hal.cpp b/audio/audio_hw_hal.cpp index f249f88..dd56c80 100644 --- a/audio/audio_hw_hal.cpp +++ b/audio/audio_hw_hal.cpp @@ -162,6 +162,14 @@ static int out_get_render_position(const struct audio_stream_out *stream, return out->legacy_out->getRenderPosition(dsp_frames); } +static int out_get_next_write_timestamp(const struct audio_stream_out *stream, + int64_t *timestamp) +{ + const struct legacy_stream_out *out = + reinterpret_cast<const struct legacy_stream_out *>(stream); + return out->legacy_out->getNextWriteTimestamp(timestamp); +} + static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { return 0; @@ -433,6 +441,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->stream.set_volume = out_set_volume; out->stream.write = out_write; out->stream.get_render_position = out_get_render_position; + out->stream.get_next_write_timestamp = out_get_next_write_timestamp; *stream_out = &out->stream; return 0; diff --git a/include/hardware_legacy/AudioHardwareInterface.h b/include/hardware_legacy/AudioHardwareInterface.h index 425b0a5..87f933c 100644 --- a/include/hardware_legacy/AudioHardwareInterface.h +++ b/include/hardware_legacy/AudioHardwareInterface.h @@ -109,6 +109,13 @@ public: // return the number of audio frames written by the audio dsp to DAC since // the output has exited standby virtual status_t getRenderPosition(uint32_t *dspFrames) = 0; + + /** + * get the local time at which the next write to the audio driver will be + * presented + */ + virtual status_t getNextWriteTimestamp(int64_t *timestamp); + }; /** |