summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/legacy/audio_hw.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/audio/legacy/audio_hw.c b/audio/legacy/audio_hw.c
index 57c5afe..6152035 100644
--- a/audio/legacy/audio_hw.c
+++ b/audio/legacy/audio_hw.c
@@ -263,7 +263,7 @@ static size_t get_input_buffer_size(uint32_t sample_rate, int format, int channe
263 size = (pcm_config_capture.period_size * sample_rate) / pcm_config_capture.rate; 263 size = (pcm_config_capture.period_size * sample_rate) / pcm_config_capture.rate;
264 size = ((size + 15) / 16) * 16; 264 size = ((size + 15) / 16) * 16;
265 265
266 return size * channel_count * sizeof(int16_t); 266 return size * channel_count * audio_bytes_per_sample(format);
267} 267}
268 268
269/* 269/*
@@ -698,8 +698,9 @@ static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
698 698
699static size_t out_get_buffer_size(const struct audio_stream *stream) 699static size_t out_get_buffer_size(const struct audio_stream *stream)
700{ 700{
701 const struct audio_stream_out *s = (const struct audio_stream_out *)stream;
701 uint32_t frames = ((PLAYBACK_PERIOD_SIZE + 15) / 16) * 16; 702 uint32_t frames = ((PLAYBACK_PERIOD_SIZE + 15) / 16) * 16;
702 size_t bytes = frames * audio_stream_frame_size(stream); 703 size_t bytes = frames * audio_stream_out_frame_size(s);
703 704
704 ALOGVV("out_get_buffer_size() stream=%p frames=%u bytes=%u", stream, frames, bytes); 705 ALOGVV("out_get_buffer_size() stream=%p frames=%u bytes=%u", stream, frames, bytes);
705 706
@@ -832,10 +833,11 @@ static int out_set_volume(struct audio_stream_out *stream, float left,
832static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, 833static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
833 size_t bytes) 834 size_t bytes)
834{ 835{
836 const struct audio_stream_out *s = (const struct audio_stream_out *)stream;
835 struct j6_stream_out *out = (struct j6_stream_out *)(stream); 837 struct j6_stream_out *out = (struct j6_stream_out *)(stream);
836 struct j6_audio_device *adev = out->dev; 838 struct j6_audio_device *adev = out->dev;
837 struct timespec now; 839 struct timespec now;
838 const size_t frame_size = audio_stream_frame_size(&stream->common); 840 const size_t frame_size = audio_stream_out_frame_size(s);
839 const size_t frames = bytes / frame_size; 841 const size_t frames = bytes / frame_size;
840 uint32_t rate = out->config.rate; 842 uint32_t rate = out->config.rate;
841 uint32_t write_usecs = frames * 1000000 / rate; 843 uint32_t write_usecs = frames * 1000000 / rate;
@@ -1157,13 +1159,14 @@ static void release_buffer(struct resampler_buffer_provider *buffer_provider,
1157 */ 1159 */
1158static ssize_t read_frames(struct j6_stream_in *in, void *buffer, ssize_t frames) 1160static ssize_t read_frames(struct j6_stream_in *in, void *buffer, ssize_t frames)
1159{ 1161{
1162 const struct audio_stream_in *s = (const struct audio_stream_in *)in;
1160 ssize_t frames_wr = 0; 1163 ssize_t frames_wr = 0;
1161 size_t frame_size; 1164 size_t frame_size;
1162 1165
1163 ALOGVV("read_frames() stream=%p frames=%u", in, frames); 1166 ALOGVV("read_frames() stream=%p frames=%u", in, frames);
1164 1167
1165 if (in->remix) 1168 if (in->remix)
1166 frame_size = audio_stream_frame_size(&in->stream.common); 1169 frame_size = audio_stream_in_frame_size(s);
1167 else 1170 else
1168 frame_size = in->hw_frame_size; 1171 frame_size = in->hw_frame_size;
1169 1172
@@ -1187,9 +1190,10 @@ static ssize_t read_frames(struct j6_stream_in *in, void *buffer, ssize_t frames
1187static ssize_t in_read(struct audio_stream_in *stream, void* buffer, 1190static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
1188 size_t bytes) 1191 size_t bytes)
1189{ 1192{
1193 const struct audio_stream_in *s = (const struct audio_stream_in *)stream;
1190 struct j6_stream_in *in = (struct j6_stream_in *)(stream); 1194 struct j6_stream_in *in = (struct j6_stream_in *)(stream);
1191 struct j6_audio_device *adev = in->dev; 1195 struct j6_audio_device *adev = in->dev;
1192 const size_t frame_size = audio_stream_frame_size(&stream->common); 1196 const size_t frame_size = audio_stream_in_frame_size(stream);
1193 const size_t frames = bytes / frame_size; 1197 const size_t frames = bytes / frame_size;
1194 uint32_t rate = in_get_sample_rate(&stream->common); 1198 uint32_t rate = in_get_sample_rate(&stream->common);
1195 uint32_t read_usecs = frames * 1000000 / rate; 1199 uint32_t read_usecs = frames * 1000000 / rate;
@@ -1571,19 +1575,6 @@ static int adev_dump(const audio_hw_device_t *device, int fd)
1571 return 0; 1575 return 0;
1572} 1576}
1573 1577
1574/*
1575 * should not be needed for API version 2.0 but AudioFlinger uses it to find
1576 * suitable hw device, so we keep it
1577 */
1578static uint32_t adev_get_supported_devices(const struct audio_hw_device *dev)
1579{
1580 uint32_t devices = SUPPORTED_IN_DEVICES | SUPPORTED_OUT_DEVICES;
1581
1582 ALOGV("adev_get_supported_devices() devices=0x%08x", devices);
1583
1584 return devices;
1585}
1586
1587static int adev_close(hw_device_t *device) 1578static int adev_close(hw_device_t *device)
1588{ 1579{
1589 struct j6_audio_device *adev = (struct j6_audio_device *)device; 1580 struct j6_audio_device *adev = (struct j6_audio_device *)device;
@@ -1617,7 +1608,6 @@ static int adev_open(const hw_module_t* module, const char* name,
1617 adev->device.common.module = (struct hw_module_t *) module; 1608 adev->device.common.module = (struct hw_module_t *) module;
1618 adev->device.common.close = adev_close; 1609 adev->device.common.close = adev_close;
1619 1610
1620 adev->device.get_supported_devices = adev_get_supported_devices;
1621 adev->device.init_check = adev_init_check; 1611 adev->device.init_check = adev_init_check;
1622 adev->device.set_voice_volume = adev_set_voice_volume; 1612 adev->device.set_voice_volume = adev_set_voice_volume;
1623 adev->device.set_master_volume = adev_set_master_volume; 1613 adev->device.set_master_volume = adev_set_master_volume;