Skip to content

Commit 46a9809

Browse files
author
Mike Lockwood
committed
Update USB audio HAL to use API
Also don't clear card and device when out_set_parameters is called to set other parameters. Change-Id: I4feda9f6a2e76cb45bbc8a8f8256bb1760302707 Signed-off-by: Mike Lockwood <[email protected]>
1 parent da4b0b2 commit 46a9809

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

modules/usbaudio/audio_hw.c

+18-17
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
156156
parms = str_parms_create_str(kvpairs);
157157
pthread_mutex_lock(&adev->lock);
158158

159-
adev->card = -1;
160-
adev->device = -1;
161-
162159
ret = str_parms_get_str(parms, "card", value, sizeof(value));
163160
if (ret >= 0)
164161
adev->card = atoi(value);
@@ -247,8 +244,10 @@ static int out_get_next_write_timestamp(const struct audio_stream_out *stream,
247244
}
248245

249246
static int adev_open_output_stream(struct audio_hw_device *dev,
250-
uint32_t devices, audio_format_t *format,
251-
uint32_t *channels, uint32_t *sample_rate,
247+
audio_io_handle_t handle,
248+
audio_devices_t devices,
249+
audio_output_flags_t flags,
250+
struct audio_config *config,
252251
struct audio_stream_out **stream_out)
253252
{
254253
struct audio_device *adev = (struct audio_device *)dev;
@@ -279,12 +278,15 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
279278

280279
out->dev = adev;
281280

282-
*format = out_get_format(&out->stream.common);
283-
*channels = out_get_channels(&out->stream.common);
284-
*sample_rate = out_get_sample_rate(&out->stream.common);
281+
config->format = out_get_format(&out->stream.common);
282+
config->channel_mask = out_get_channels(&out->stream.common);
283+
config->sample_rate = out_get_sample_rate(&out->stream.common);
285284

286285
out->standby = true;
287286

287+
adev->card = -1;
288+
adev->device = -1;
289+
288290
*stream_out = &out->stream;
289291
return 0;
290292

@@ -345,16 +347,15 @@ static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
345347
}
346348

347349
static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
348-
uint32_t sample_rate, audio_format_t format,
349-
int channel_count)
350+
const struct audio_config *config)
350351
{
351352
return 0;
352353
}
353354

354-
static int adev_open_input_stream(struct audio_hw_device *dev, uint32_t devices,
355-
audio_format_t *format, uint32_t *channel_mask,
356-
uint32_t *sample_rate,
357-
audio_in_acoustics_t acoustics,
355+
static int adev_open_input_stream(struct audio_hw_device *dev,
356+
audio_io_handle_t handle,
357+
audio_devices_t devices,
358+
struct audio_config *config,
358359
struct audio_stream_in **stream_in)
359360
{
360361
return -ENOSYS;
@@ -397,7 +398,7 @@ static int adev_open(const hw_module_t* module, const char* name,
397398
return -ENOMEM;
398399

399400
adev->hw_device.common.tag = HARDWARE_DEVICE_TAG;
400-
adev->hw_device.common.version = 0;
401+
adev->hw_device.common.version = AUDIO_DEVICE_API_VERSION_1_0;
401402
adev->hw_device.common.module = (struct hw_module_t *) module;
402403
adev->hw_device.common.close = adev_close;
403404

@@ -429,8 +430,8 @@ static struct hw_module_methods_t hal_module_methods = {
429430
struct audio_module HAL_MODULE_INFO_SYM = {
430431
.common = {
431432
.tag = HARDWARE_MODULE_TAG,
432-
.version_major = 1,
433-
.version_minor = 0,
433+
.module_api_version = AUDIO_MODULE_API_VERSION_0_1,
434+
.hal_api_version = HARDWARE_HAL_API_VERSION,
434435
.id = AUDIO_HARDWARE_MODULE_ID,
435436
.name = "USB audio HW HAL",
436437
.author = "The Android Open Source Project",

0 commit comments

Comments
 (0)