summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoja Hsu <mojahsu@google.com>2016-11-08 15:25:25 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-12-02 01:03:56 -0800
commitc84eb15a0fbd4a6b336d11438836b644fefc2679 (patch)
treef66a6172b5bfadfcf377e4b9a77c63a84ee9571c
parent45023e169de613cff33623eafe24d83d02ac4181 (diff)
downloadadhd-c84eb15a0fbd4a6b336d11438836b644fefc2679.tar.gz
CRAS: dbus_control - Add serial number for USB device for stable id
Get additional sys attribute for "serial" which is serial number in udev. Add it into the stable_id_new calcuation and keep stable_id for backward compitable. BUG=chromium:661861 TEST=Plug 2 same type USB speakers into chromebook. execute "dbus-send --system --type=method_call --print-reply --dest=org.chromium.cras /org/chromium/cras org.chromium.cras.Control.GetNodes" Check if we have the same stable_id but different stable_id_new for the 2 speakers. pass make check for unit test. Change-Id: Iefefe383fd6143dd7c28fdba3cf3f3872c2dd726 Reviewed-on: https://chromium-review.googlesource.com/407723 Commit-Ready: Hsu Wei-Cheng <mojahsu@chromium.org> Tested-by: Hsu Wei-Cheng <mojahsu@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
-rw-r--r--cras/README.dbus-api4
-rw-r--r--cras/src/common/cras_iodev_info.h6
-rw-r--r--cras/src/common/cras_types.h3
-rw-r--r--cras/src/server/cras_a2dp_iodev.c1
-rw-r--r--cras/src/server/cras_alsa_card.c3
-rw-r--r--cras/src/server/cras_alsa_io.c28
-rw-r--r--cras/src/server/cras_alsa_io.h4
-rw-r--r--cras/src/server/cras_bt_io.c3
-rw-r--r--cras/src/server/cras_dbus_control.c4
-rw-r--r--cras/src/server/cras_hfp_iodev.c1
-rw-r--r--cras/src/server/cras_iodev.h3
-rw-r--r--cras/src/server/cras_iodev_list.c1
-rw-r--r--cras/src/server/cras_loopback_iodev.c2
-rw-r--r--cras/src/server/cras_udev.c12
-rw-r--r--cras/src/tests/alsa_card_unittest.cc5
-rw-r--r--cras/src/tests/alsa_io_unittest.cc326
16 files changed, 224 insertions, 182 deletions
diff --git a/cras/README.dbus-api b/cras/README.dbus-api
index 0e96c438..819f068b 100644
--- a/cras/README.dbus-api
+++ b/cras/README.dbus-api
@@ -96,6 +96,10 @@ Methods void SetOutputVolume(int32 volume)
uint64 StableDeviceId
The stable ID does not change due to
device plug/unplug or reboot.
+ uint64 StableDeviceIdNew
+ The new stable ID. Keeping both stable
+ ID and stable ID new is for backward
+ compatibility.
boolean Active
Whether this node is currently used
for output/input. There is one active
diff --git a/cras/src/common/cras_iodev_info.h b/cras/src/common/cras_iodev_info.h
index 06c3ac6d..9b1dbb5f 100644
--- a/cras/src/common/cras_iodev_info.h
+++ b/cras/src/common/cras_iodev_info.h
@@ -19,11 +19,14 @@
* idx - iodev index.
* name - Name displayed to the user.
* stable_id - ID that does not change due to device plug/unplug or reboot.
+ * stable_id_new - New stable_id, it will be deprecated and be put on
+ * stable_id.
*/
struct __attribute__ ((__packed__)) cras_iodev_info {
uint32_t idx;
char name[CRAS_IODEV_NAME_BUFFER_SIZE];
uint32_t stable_id;
+ uint32_t stable_id_new;
};
/* Identifying information about an ionode on an iodev.
@@ -36,6 +39,8 @@ struct __attribute__ ((__packed__)) cras_iodev_info {
* capture_gain - per-node capture gain/attenuation (in 100*dBFS)
* left_right_swapped - Set true if left and right channels are swapped.
* stable_id - ID that does not change due to device plug/unplug or reboot.
+ * stable_id_new - New stable_id, it will be deprecated and be put on
+ * stable_id.
* mic_positions - Positions of the mic array.
* type - Type displayed to the user.
* name - Name displayed to the user.
@@ -52,6 +57,7 @@ struct __attribute__ ((__packed__)) cras_ionode_info {
int32_t left_right_swapped;
uint32_t type_enum;
uint32_t stable_id;
+ uint32_t stable_id_new;
char mic_positions[CRAS_NODE_MIC_POS_BUFFER_SIZE];
char type[CRAS_NODE_TYPE_BUFFER_SIZE];
char name[CRAS_NODE_NAME_BUFFER_SIZE];
diff --git a/cras/src/common/cras_types.h b/cras/src/common/cras_types.h
index 2321b6cb..0034b876 100644
--- a/cras/src/common/cras_types.h
+++ b/cras/src/common/cras_types.h
@@ -326,6 +326,7 @@ enum cras_notify_device_action { /* Must match gavd action definitions. */
* lowered priority.
* usb_vendor_id - vendor ID if the device is on the USB bus.
* usb_product_id - product ID if the device is on the USB bus.
+ * usb_serial_number - serial number if the device is on the USB bus.
* usb_desc_checksum - the checksum of the USB descriptors if the device
* is on the USB bus.
*/
@@ -333,11 +334,13 @@ enum CRAS_ALSA_CARD_TYPE {
ALSA_CARD_TYPE_INTERNAL,
ALSA_CARD_TYPE_USB,
};
+#define USB_SERIAL_NUMBER_BUFFER_SIZE 64
struct __attribute__ ((__packed__)) cras_alsa_card_info {
enum CRAS_ALSA_CARD_TYPE card_type;
uint32_t card_index;
uint32_t usb_vendor_id;
uint32_t usb_product_id;
+ char usb_serial_number[USB_SERIAL_NUMBER_BUFFER_SIZE];
uint32_t usb_desc_checksum;
};
diff --git a/cras/src/server/cras_a2dp_iodev.c b/cras/src/server/cras_a2dp_iodev.c
index 3a94c22b..2be9196d 100644
--- a/cras/src/server/cras_a2dp_iodev.c
+++ b/cras/src/server/cras_a2dp_iodev.c
@@ -477,6 +477,7 @@ struct cras_iodev *a2dp_iodev_create(struct cras_bt_transport *transport)
cras_bt_device_object_path(device),
strlen(cras_bt_device_object_path(device)),
strlen(cras_bt_device_object_path(device)));
+ iodev->info.stable_id_new = iodev->info.stable_id;
iodev->open_dev = open_dev;
iodev->frames_queued = frames_queued;
diff --git a/cras/src/server/cras_alsa_card.c b/cras/src/server/cras_alsa_card.c
index 7cdb822c..e7c24f63 100644
--- a/cras/src/server/cras_alsa_card.c
+++ b/cras/src/server/cras_alsa_card.c
@@ -117,7 +117,8 @@ struct cras_iodev *create_iodev_for_device(
alsa_card->hctl,
direction,
info->usb_vendor_id,
- info->usb_product_id);
+ info->usb_product_id,
+ info->usb_serial_number);
if (new_dev->iodev == NULL) {
syslog(LOG_ERR, "Couldn't create alsa_iodev for %u:%u\n",
info->card_index, device_index);
diff --git a/cras/src/server/cras_alsa_io.c b/cras/src/server/cras_alsa_io.c
index 23b57549..131d40dc 100644
--- a/cras/src/server/cras_alsa_io.c
+++ b/cras/src/server/cras_alsa_io.c
@@ -995,6 +995,10 @@ static struct alsa_output_node *new_output(struct alsa_io *aio,
output->base.stable_id = SuperFastHash(name,
strlen(name),
aio->base.info.stable_id);
+ output->base.stable_id_new = SuperFastHash(name,
+ strlen(name),
+ aio->base.info.stable_id_new
+ );
output->mixer_output = cras_output;
strncpy(output->base.name, name, sizeof(output->base.name) - 1);
set_node_initial_state(&output->base, aio->card_type);
@@ -1067,6 +1071,9 @@ static struct alsa_input_node *new_input(struct alsa_io *aio,
input->base.stable_id = SuperFastHash(name,
strlen(name),
aio->base.info.stable_id);
+ input->base.stable_id_new = SuperFastHash(name,
+ strlen(name),
+ aio->base.info.stable_id_new);
input->mixer_input = cras_input;
strncpy(input->base.name, name, sizeof(input->base.name) - 1);
set_node_initial_state(&input->base, aio->card_type);
@@ -1306,7 +1313,8 @@ static void set_iodev_name(struct cras_iodev *dev,
size_t device_index,
enum CRAS_ALSA_CARD_TYPE card_type,
size_t usb_vid,
- size_t usb_pid)
+ size_t usb_pid,
+ char *usb_serial_number)
{
snprintf(dev->info.name,
sizeof(dev->info.name),
@@ -1330,6 +1338,7 @@ static void set_iodev_name(struct cras_iodev *dev,
dev->info.stable_id = SuperFastHash((const char *)&device_index,
sizeof(device_index),
dev->info.stable_id);
+ dev->info.stable_id_new = dev->info.stable_id;
break;
case ALSA_CARD_TYPE_USB:
dev->info.stable_id = SuperFastHash((const char *)&usb_vid,
@@ -1338,9 +1347,17 @@ static void set_iodev_name(struct cras_iodev *dev,
dev->info.stable_id = SuperFastHash((const char *)&usb_pid,
sizeof(usb_pid),
dev->info.stable_id);
+ dev->info.stable_id_new =
+ SuperFastHash(usb_serial_number,
+ strlen(usb_serial_number),
+ dev->info.stable_id);
+ break;
+ default:
+ dev->info.stable_id_new = dev->info.stable_id;
break;
}
- syslog(LOG_DEBUG, "Stable ID=%08x", dev->info.stable_id);
+ syslog(LOG_DEBUG, "Stable ID=%08x, New Stable ID=%08x",
+ dev->info.stable_id, dev->info.stable_id_new);
}
static int get_fixed_rate(struct alsa_io *aio)
@@ -1591,7 +1608,8 @@ struct cras_iodev *alsa_iodev_create(size_t card_index,
snd_hctl_t *hctl,
enum CRAS_STREAM_DIRECTION direction,
size_t usb_vid,
- size_t usb_pid)
+ size_t usb_pid,
+ char *usb_serial_number)
{
struct alsa_io *aio;
struct cras_iodev *iodev;
@@ -1682,7 +1700,7 @@ struct cras_iodev *alsa_iodev_create(size_t card_index,
aio->enable_htimestamp =
ucm_get_enable_htimestamp_flag(ucm);
- }
+ }
err = update_supported_formats(iodev);
if (err < 0 || iodev->supported_rates[0] == 0 ||
@@ -1694,7 +1712,7 @@ struct cras_iodev *alsa_iodev_create(size_t card_index,
set_iodev_name(iodev, card_name, dev_name, card_index, device_index,
- card_type, usb_vid, usb_pid);
+ card_type, usb_vid, usb_pid, usb_serial_number);
aio->jack_list =
cras_alsa_jack_list_create(
diff --git a/cras/src/server/cras_alsa_io.h b/cras/src/server/cras_alsa_io.h
index 09006c3d..3dc1f814 100644
--- a/cras/src/server/cras_alsa_io.h
+++ b/cras/src/server/cras_alsa_io.h
@@ -30,6 +30,7 @@ struct ucm_section;
* direction - input or output.
* usb_vid - vendor ID of USB device.
* usb_pid - product ID of USB device.
+ * usb_serial_number - serial number of USB device.
* Returns:
* A pointer to the newly created iodev if successful, NULL otherwise.
*/
@@ -45,7 +46,8 @@ struct cras_iodev *alsa_iodev_create(size_t card_index,
snd_hctl_t *hctl,
enum CRAS_STREAM_DIRECTION direction,
size_t usb_vid,
- size_t usb_pid);
+ size_t usb_pid,
+ char *usb_serial_number);
/* Complete initializeation of this iodev with the legacy method.
* Add IO nodes and find jacks for this iodev with magic sauce, then choose
diff --git a/cras/src/server/cras_bt_io.c b/cras/src/server/cras_bt_io.c
index db724aba..1363d90d 100644
--- a/cras/src/server/cras_bt_io.c
+++ b/cras/src/server/cras_bt_io.c
@@ -68,6 +68,7 @@ static struct cras_ionode *add_profile_dev(struct cras_iodev *bt_iodev,
n->base.type = CRAS_NODE_TYPE_BLUETOOTH;
n->base.volume = 100;
n->base.stable_id = dev->info.stable_id;
+ n->base.stable_id_new = dev->info.stable_id_new;
n->base.max_software_gain = 0;
gettimeofday(&n->base.plugged_time, NULL);
@@ -328,6 +329,7 @@ struct cras_iodev *cras_bt_io_create(struct cras_bt_device *device,
iodev->direction = dev->direction;
strcpy(iodev->info.name, dev->info.name);
iodev->info.stable_id = dev->info.stable_id;
+ iodev->info.stable_id_new = dev->info.stable_id_new;
iodev->open_dev = open_dev;
iodev->frames_queued = frames_queued;
@@ -356,6 +358,7 @@ struct cras_iodev *cras_bt_io_create(struct cras_bt_device *device,
cras_bt_device_object_path(device),
strlen(cras_bt_device_object_path(device)),
strlen(cras_bt_device_object_path(device)));
+ active->base.stable_id_new = active->base.stable_id;
active->profile = profile;
active->profile_dev = dev;
gettimeofday(&active->base.plugged_time, NULL);
diff --git a/cras/src/server/cras_dbus_control.c b/cras/src/server/cras_dbus_control.c
index 0f2a20c4..21002249 100644
--- a/cras/src/server/cras_dbus_control.c
+++ b/cras/src/server/cras_dbus_control.c
@@ -420,6 +420,7 @@ static dbus_bool_t append_node_dict(DBusMessageIter *iter,
dbus_uint64_t id;
const char *dev_name = dev->name;
dbus_uint64_t stable_dev_id = node->stable_id;
+ dbus_uint64_t stable_dev_id_new = node->stable_id_new;
const char *node_type = node->type;
const char *node_name = node->name;
const char *mic_positions = node->mic_positions;
@@ -450,6 +451,9 @@ static dbus_bool_t append_node_dict(DBusMessageIter *iter,
if (!append_key_value(&dict, "StableDeviceId", DBUS_TYPE_UINT64,
DBUS_TYPE_UINT64_AS_STRING, &stable_dev_id))
return FALSE;
+ if (!append_key_value(&dict, "StableDeviceIdNew", DBUS_TYPE_UINT64,
+ DBUS_TYPE_UINT64_AS_STRING, &stable_dev_id_new))
+ return FALSE;
if (!append_key_value(&dict, "Type", DBUS_TYPE_STRING,
DBUS_TYPE_STRING_AS_STRING, &node_type))
return FALSE;
diff --git a/cras/src/server/cras_hfp_iodev.c b/cras/src/server/cras_hfp_iodev.c
index 9743a330..10314e63 100644
--- a/cras/src/server/cras_hfp_iodev.c
+++ b/cras/src/server/cras_hfp_iodev.c
@@ -240,6 +240,7 @@ struct cras_iodev *hfp_iodev_create(
cras_bt_device_object_path(device),
strlen(cras_bt_device_object_path(device)),
strlen(cras_bt_device_object_path(device)));
+ iodev->info.stable_id_new = iodev->info.stable_id;
iodev->open_dev= open_dev;
iodev->frames_queued = frames_queued;
diff --git a/cras/src/server/cras_iodev.h b/cras/src/server/cras_iodev.h
index 2ffe1b74..11923b26 100644
--- a/cras/src/server/cras_iodev.h
+++ b/cras/src/server/cras_iodev.h
@@ -66,6 +66,8 @@ enum CRAS_IODEV_STATE {
* gain.
* max_software_gain - The maximum software gain in dBm if needed.
* stable_id - id for node that doesn't change after unplug/plug.
+ * stable_id_new - New stable_id, it will be deprecated and be put on
+ * stable_id.
*/
struct cras_ionode {
struct cras_iodev *dev;
@@ -83,6 +85,7 @@ struct cras_ionode {
int software_volume_needed;
long max_software_gain;
unsigned int stable_id;
+ unsigned int stable_id_new;
struct cras_ionode *prev, *next;
};
diff --git a/cras/src/server/cras_iodev_list.c b/cras/src/server/cras_iodev_list.c
index 4d87d685..7378a7a6 100644
--- a/cras/src/server/cras_iodev_list.c
+++ b/cras/src/server/cras_iodev_list.c
@@ -234,6 +234,7 @@ static int fill_node_list(struct iodev_list *list,
node_info->capture_gain = node->capture_gain;
node_info->left_right_swapped = node->left_right_swapped;
node_info->stable_id = node->stable_id;
+ node_info->stable_id_new = node->stable_id_new;
strcpy(node_info->mic_positions, node->mic_positions);
strcpy(node_info->name, node->name);
strcpy(node_info->active_hotword_model,
diff --git a/cras/src/server/cras_loopback_iodev.c b/cras/src/server/cras_loopback_iodev.c
index ead33f12..ff33acaf 100644
--- a/cras/src/server/cras_loopback_iodev.c
+++ b/cras/src/server/cras_loopback_iodev.c
@@ -255,6 +255,7 @@ static struct cras_iodev *create_loopback_iodev(enum CRAS_LOOPBACK_TYPE type)
iodev->info.stable_id = SuperFastHash(iodev->info.name,
strlen(iodev->info.name),
strlen(iodev->info.name));
+ iodev->info.stable_id_new = iodev->info.stable_id;
iodev->supported_rates = loopback_supported_rates;
iodev->supported_channel_counts = loopback_supported_channel_counts;
@@ -305,6 +306,7 @@ struct cras_iodev *loopback_iodev_create(enum CRAS_LOOPBACK_TYPE type)
node->plugged = 1;
node->volume = 100;
node->stable_id = iodev->info.stable_id;
+ node->stable_id_new = iodev->info.stable_id_new;
node->software_volume_needed = 0;
node->max_software_gain = 0;
strcpy(node->name, loopdev_names[type]);
diff --git a/cras/src/server/cras_udev.c b/cras/src/server/cras_udev.c
index f95b21b1..02ff766b 100644
--- a/cras/src/server/cras_udev.c
+++ b/cras/src/server/cras_udev.c
@@ -264,12 +264,20 @@ static void fill_usb_card_info(struct cras_alsa_card_info *card_info,
sysattr = udev_device_get_sysattr_value(dev, "idProduct");
if (sysattr)
card_info->usb_product_id = strtol(sysattr, NULL, 16);
+ sysattr = udev_device_get_sysattr_value(dev, "serial");
+ if (sysattr) {
+ strncpy(card_info->usb_serial_number, sysattr,
+ USB_SERIAL_NUMBER_BUFFER_SIZE - 1);
+ card_info->usb_serial_number[USB_SERIAL_NUMBER_BUFFER_SIZE - 1]
+ = '\0';
+ }
card_info->usb_desc_checksum = calculate_desc_checksum(dev);
- syslog(LOG_ERR, "USB card: vendor:%04x, product:%04x, checksum:%08x",
+ syslog(LOG_ERR, "USB card: vendor:%04x, product:%04x, serial num:%s, "
+ "checksum:%08x",
card_info->usb_vendor_id, card_info->usb_product_id,
- card_info->usb_desc_checksum);
+ card_info->usb_serial_number, card_info->usb_desc_checksum);
}
static void device_add_alsa(struct udev_device *dev,
diff --git a/cras/src/tests/alsa_card_unittest.cc b/cras/src/tests/alsa_card_unittest.cc
index 127cb86a..7dc72475 100644
--- a/cras/src/tests/alsa_card_unittest.cc
+++ b/cras/src/tests/alsa_card_unittest.cc
@@ -831,8 +831,9 @@ struct cras_iodev *alsa_iodev_create(size_t card_index,
snd_use_case_mgr_t *ucm,
snd_hctl_t *hctl,
enum CRAS_STREAM_DIRECTION direction,
- size_t usb_vid,
- size_t usb_pid) {
+ size_t usb_vid,
+ size_t usb_pid,
+ char *usb_serial_number) {
struct cras_iodev *result = NULL;
if (cras_alsa_iodev_create_called < cras_alsa_iodev_create_return_size)
result = cras_alsa_iodev_create_return[cras_alsa_iodev_create_called];
diff --git a/cras/src/tests/alsa_io_unittest.cc b/cras/src/tests/alsa_io_unittest.cc
index b70db7c7..a7d1fe0f 100644
--- a/cras/src/tests/alsa_io_unittest.cc
+++ b/cras/src/tests/alsa_io_unittest.cc
@@ -245,15 +245,31 @@ static cras_volume_curve fake_curve = {
.get_dBFS = fake_get_dBFS,
};
+static struct cras_iodev *alsa_iodev_create_with_default_parameters(
+ size_t card_index,
+ const char *dev_id,
+ enum CRAS_ALSA_CARD_TYPE card_type,
+ int is_first,
+ struct cras_alsa_mixer *mixer,
+ snd_use_case_mgr_t *ucm,
+ enum CRAS_STREAM_DIRECTION direction) {
+ return alsa_iodev_create(card_index, test_card_name, 0, test_dev_name,
+ dev_id, card_type, is_first,
+ mixer, ucm, fake_hctl,
+ direction, 0, 0, (char *)"123");
+}
+
namespace {
TEST(AlsaIoInit, InitializeInvalidDirection) {
struct alsa_io *aio;
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_NUM_DIRECTIONS, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, NULL,
+ CRAS_NUM_DIRECTIONS);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, NULL,
+ CRAS_NUM_DIRECTIONS);
ASSERT_EQ(aio, (void *)NULL);
}
@@ -262,11 +278,9 @@ TEST(AlsaIoInit, InitializePlayback) {
struct cras_alsa_mixer * const fake_mixer = (struct cras_alsa_mixer*)2;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0,
- test_dev_name, test_dev_id,
- ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, test_dev_id, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_PLAYBACK, aio->alsa_stream);
EXPECT_EQ(1, cras_alsa_fill_properties_called);
@@ -290,10 +304,9 @@ TEST(AlsaIoInit, DefaultNodeInternalCard) {
struct cras_alsa_mixer * const fake_mixer = (struct cras_alsa_mixer*)2;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
ASSERT_STREQ("(default)", aio->base.active_node->name);
@@ -302,10 +315,9 @@ TEST(AlsaIoInit, DefaultNodeInternalCard) {
ASSERT_EQ((void *)output_should_wake, (void *)aio->base.output_should_wake);
alsa_iodev_destroy((struct cras_iodev *)aio);
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
ASSERT_STREQ("Speaker", aio->base.active_node->name);
@@ -314,10 +326,8 @@ TEST(AlsaIoInit, DefaultNodeInternalCard) {
ASSERT_EQ((void *)output_should_wake, (void *)aio->base.output_should_wake);
alsa_iodev_destroy((struct cras_iodev *)aio);
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, NULL, CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
ASSERT_STREQ("(default)", aio->base.active_node->name);
@@ -326,10 +336,8 @@ TEST(AlsaIoInit, DefaultNodeInternalCard) {
ASSERT_EQ((void *)output_should_wake, (void *)aio->base.output_should_wake);
alsa_iodev_destroy((struct cras_iodev *)aio);
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, NULL, CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
ASSERT_STREQ("Internal Mic", aio->base.active_node->name);
@@ -344,10 +352,8 @@ TEST(AlsaIoInit, DefaultNodeUSBCard) {
struct cras_alsa_mixer * const fake_mixer = (struct cras_alsa_mixer*)2;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_USB, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_USB, 1, fake_mixer, NULL, CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
ASSERT_STREQ("(default)", aio->base.active_node->name);
@@ -357,10 +363,8 @@ TEST(AlsaIoInit, DefaultNodeUSBCard) {
EXPECT_EQ(1, cras_iodev_set_node_attr_value);
alsa_iodev_destroy((struct cras_iodev *)aio);
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_USB, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_USB, 1, fake_mixer, NULL, CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
ASSERT_STREQ("(default)", aio->base.active_node->name);
@@ -377,10 +381,10 @@ TEST(AlsaIoInit, OpenPlayback) {
struct alsa_io *aio;
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 0,
+ fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
aio = (struct alsa_io *)iodev;
@@ -410,28 +414,26 @@ TEST(AlsaIoInit, UsbCardAutoPlug) {
struct cras_iodev *iodev;
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
EXPECT_EQ(0, cras_iodev_set_node_attr_called);
alsa_iodev_destroy(iodev);
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_USB, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL, ALSA_CARD_TYPE_USB,
+ 0, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
EXPECT_EQ(0, cras_iodev_set_node_attr_called);
alsa_iodev_destroy(iodev);
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_USB, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL, ALSA_CARD_TYPE_USB,
+ 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
// Should assume USB devs are plugged when they appear.
EXPECT_EQ(1, cras_iodev_set_node_attr_called);
@@ -446,10 +448,9 @@ TEST(AlsaIoInit, UsbCardUseSoftwareVolume) {
alsa_mixer_get_dB_range_value = 1000;
alsa_mixer_get_output_dB_range_value = 1000;
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_USB, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL, ALSA_CARD_TYPE_USB,
+ 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
EXPECT_EQ(1, alsa_mixer_get_dB_range_called);
EXPECT_EQ(1, alsa_mixer_get_output_dB_range_called);
@@ -459,10 +460,9 @@ TEST(AlsaIoInit, UsbCardUseSoftwareVolume) {
alsa_mixer_get_dB_range_value = 3000;
alsa_mixer_get_output_dB_range_value = 2000;
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_USB, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL, ALSA_CARD_TYPE_USB,
+ 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
EXPECT_EQ(1, alsa_mixer_get_dB_range_called);
EXPECT_EQ(1, alsa_mixer_get_output_dB_range_called);
@@ -478,10 +478,10 @@ TEST(AlsaIoInit, UseSoftwareGain) {
ResetStubData();
ucm_get_max_software_gain_ret_value = 0;
ucm_get_max_software_gain_value = 2000;
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
EXPECT_EQ(1, iodev->active_node->software_volume_needed);
EXPECT_EQ(2000, iodev->active_node->max_software_gain);
@@ -497,10 +497,10 @@ TEST(AlsaIoInit, UseSoftwareGain) {
ucm_get_max_software_gain_value = 1;
cras_alsa_mixer_get_minimum_capture_gain_ret_value = -500;
cras_alsa_mixer_get_maximum_capture_gain_ret_value = 500;
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
EXPECT_EQ(0, iodev->active_node->software_volume_needed);
EXPECT_EQ(0, iodev->active_node->max_software_gain);
@@ -517,10 +517,9 @@ TEST(AlsaIoInit, RouteBasedOnJackCallback) {
struct cras_alsa_mixer * const fake_mixer = (struct cras_alsa_mixer*)2;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_NE(aio, (void *)NULL);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_PLAYBACK, aio->alsa_stream);
@@ -548,10 +547,8 @@ TEST(AlsaIoInit, RouteBasedOnInputJackCallback) {
struct cras_alsa_mixer * const fake_mixer = (struct cras_alsa_mixer*)2;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, NULL, CRAS_STREAM_INPUT);
ASSERT_NE(aio, (void *)NULL);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_CAPTURE, aio->alsa_stream);
@@ -577,10 +574,8 @@ TEST(AlsaIoInit, InitializeCapture) {
struct alsa_io *aio;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, NULL, CRAS_STREAM_INPUT);
ASSERT_NE(aio, (void *)NULL);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_CAPTURE, aio->alsa_stream);
@@ -595,10 +590,10 @@ TEST(AlsaIoInit, OpenCapture) {
struct cras_audio_format format;
struct alsa_io *aio;
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 0,
+ fake_mixer, NULL,
+ CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
aio = (struct alsa_io *)iodev;
@@ -633,10 +628,10 @@ TEST(AlsaIoInit, OpenCaptureSetCaptureGainWithSoftwareGain) {
ucm_get_max_software_gain_ret_value = 0;
ucm_get_max_software_gain_value = 2000;
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 0,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
cras_iodev_set_format(iodev, &format);
@@ -667,10 +662,10 @@ TEST(AlsaIoInit, UpdateActiveNode) {
struct cras_alsa_mixer * const fake_mixer = (struct cras_alsa_mixer*)2;
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 0,
+ fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
iodev->update_active_node(iodev, 0, 1);
@@ -683,10 +678,10 @@ TEST(AlsaIoInit, StartDevice) {
int rc;
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- NULL, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 0,
+ NULL, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
// Return right away if it is already running.
@@ -709,10 +704,10 @@ TEST(AlsaIoInit, ResumeDevice) {
int rc;
ResetStubData();
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- NULL, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 0,
+ NULL, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
// Attempt to resume if the device is suspended.
@@ -731,10 +726,9 @@ TEST(AlsaIoInit, DspNameDefault) {
ResetStubData();
ucm_get_dsp_name_default_value = "hello";
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_PLAYBACK, aio->alsa_stream);
EXPECT_EQ(1, ucm_get_dsp_name_default_called);
@@ -753,10 +747,9 @@ TEST(AlsaIoInit, DspNameJackOverride) {
ResetStubData();
ucm_get_dsp_name_default_value = "default_dsp";
cras_alsa_jack_get_dsp_name_value = "override_dsp";
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_PLAYBACK, aio->alsa_stream);
EXPECT_EQ(1, ucm_get_dsp_name_default_called);
@@ -791,10 +784,9 @@ TEST(AlsaIoInit, NodeTypeOverride) {
const struct cras_alsa_jack *jack = (struct cras_alsa_jack*)4;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
// Add the jack node.
cras_alsa_jack_list_create_cb(jack, 1, cras_alsa_jack_list_create_cb_data);
@@ -814,10 +806,9 @@ TEST(AlsaIoInit, SwapMode) {
// Stub replies that swap mode does not exist.
ucm_swap_mode_exists_ret_value = 0;
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
aio->base.set_swap_mode_for_node((cras_iodev*)aio, fake_node, 1);
@@ -827,10 +818,9 @@ TEST(AlsaIoInit, SwapMode) {
// Stub replies that swap mode exists.
ucm_swap_mode_exists_ret_value = 1;
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
// Enable swap mode.
aio->base.set_swap_mode_for_node((cras_iodev*)aio, fake_node, 1);
@@ -854,10 +844,9 @@ TEST(AlsaOutputNode, SystemSettingsWhenInactive) {
outputs[1] = reinterpret_cast<struct mixer_control *>(4);
cras_alsa_mixer_list_outputs_outputs = outputs;
cras_alsa_mixer_list_outputs_outputs_length = ARRAY_SIZE(outputs);
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_PLAYBACK, aio->alsa_stream);
EXPECT_EQ(1, cras_alsa_mixer_list_outputs_called);
@@ -893,10 +882,9 @@ TEST(AlsaOutputNode, TwoOutputs) {
outputs[1] = reinterpret_cast<struct mixer_control *>(4);
cras_alsa_mixer_list_outputs_outputs = outputs;
cras_alsa_mixer_list_outputs_outputs_length = ARRAY_SIZE(outputs);
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(SND_PCM_STREAM_PLAYBACK, aio->alsa_stream);
EXPECT_EQ(1, cras_alsa_mixer_list_outputs_called);
@@ -941,10 +929,9 @@ TEST(AlsaOutputNode, TwoJacksHeadphoneLineout) {
cras_alsa_mixer_get_control_name_values[output] = "Headphone";
// Create the iodev
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_NE(iodev, (void *)NULL);
aio = reinterpret_cast<struct alsa_io *>(iodev);
@@ -1000,10 +987,10 @@ TEST(AlsaOutputNode, OutputsFromUCM) {
ucm_get_dma_period_for_dev_ret = 1000;
// Create the IO device.
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_NE(iodev, (void *)NULL);
aio = reinterpret_cast<struct alsa_io *>(iodev);
@@ -1078,10 +1065,10 @@ TEST(AlsaOutputNode, OutputNoControlsUCM) {
ResetStubData();
// Create the IO device.
- iodev = alsa_iodev_create(1, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(1, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_NE(iodev, (void *)NULL);
aio = reinterpret_cast<struct alsa_io *>(iodev);
@@ -1118,18 +1105,18 @@ TEST(AlsaOutputNode, OutputFromJackUCM) {
ResetStubData();
// Create the IO device.
- iodev = alsa_iodev_create(1, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(1, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_NE(iodev, (void *)NULL);
aio = reinterpret_cast<struct alsa_io *>(iodev);
// Node without controls or jacks.
cras_alsa_jack_list_add_jack_for_section_result_jack =
- reinterpret_cast<struct cras_alsa_jack *>(1);
+ reinterpret_cast<struct cras_alsa_jack *>(1);
section = ucm_section_create("Headphone", 0, CRAS_STREAM_OUTPUT,
- jack_name, "hctl");
+ jack_name, "hctl");
ASSERT_EQ(0, alsa_iodev_ucm_add_nodes_and_jacks(iodev, section));
EXPECT_EQ(1, cras_alsa_mixer_get_control_for_section_called);
EXPECT_EQ(1, cras_iodev_add_node_called);
@@ -1167,10 +1154,10 @@ TEST(AlsaOutputNode, InputsFromUCM) {
cras_alsa_mixer_get_control_name_values[inputs[1]] = "Mic";
// Create the IO device.
- iodev = alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(0, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_INPUT);
ASSERT_NE(iodev, (void *)NULL);
aio = reinterpret_cast<struct alsa_io *>(iodev);
@@ -1247,10 +1234,10 @@ TEST(AlsaOutputNode, InputNoControlsUCM) {
ResetStubData();
// Create the IO device.
- iodev = alsa_iodev_create(1, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(1, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_INPUT);
ASSERT_NE(iodev, (void *)NULL);
aio = reinterpret_cast<struct alsa_io *>(iodev);
@@ -1288,10 +1275,10 @@ TEST(AlsaOutputNode, InputFromJackUCM) {
ResetStubData();
// Create the IO device.
- iodev = alsa_iodev_create(1, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ iodev = alsa_iodev_create_with_default_parameters(1, NULL,
+ ALSA_CARD_TYPE_INTERNAL, 1,
+ fake_mixer, fake_ucm,
+ CRAS_STREAM_INPUT);
ASSERT_NE(iodev, (void *)NULL);
aio = reinterpret_cast<struct alsa_io *>(iodev);
@@ -1334,10 +1321,9 @@ TEST(AlsaOutputNode, AutoUnplugOutputNode) {
cras_alsa_mixer_get_control_name_values[outputs[1]] = "Headphone";
auto_unplug_output_node_ret = 1;
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(1, cras_alsa_mixer_list_outputs_called);
EXPECT_EQ(2, cras_alsa_mixer_get_control_name_called);
@@ -1379,10 +1365,9 @@ TEST(AlsaOutputNode, AutoUnplugInputNode) {
cras_alsa_mixer_get_control_name_values[inputs[1]] = "Mic";
auto_unplug_input_node_ret = 1;
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_INPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_ucm,
+ CRAS_STREAM_INPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
EXPECT_EQ(1, cras_alsa_mixer_list_inputs_called);
EXPECT_EQ(2, cras_alsa_mixer_get_control_name_called);
@@ -1585,10 +1570,9 @@ TEST(AlsaIoInit, HDMIJackUpdateInvalidUTF8MonitorName) {
const struct cras_alsa_jack *jack = (struct cras_alsa_jack*)4;
ResetStubData();
- aio = (struct alsa_io *)alsa_iodev_create(0, test_card_name, 0, test_dev_name,
- NULL, ALSA_CARD_TYPE_INTERNAL, 0,
- fake_mixer, fake_ucm, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ aio = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, fake_ucm,
+ CRAS_STREAM_OUTPUT);
ASSERT_EQ(0, alsa_iodev_legacy_complete_init((struct cras_iodev *)aio));
// Prepare the stub data such that the jack will be identified as an
@@ -1620,11 +1604,11 @@ class AlsaVolumeMuteSuite : public testing::Test {
cras_alsa_mixer_list_outputs_outputs_length = 1;
cras_alsa_mixer_get_control_name_values[output_control_] = "Speaker";
cras_alsa_mixer_list_outputs_outputs_length = 1;
- aio_output_ = (struct alsa_io *)alsa_iodev_create(
- 0, test_card_name, 0, test_dev_name, NULL,
+ aio_output_ = (struct alsa_io *)alsa_iodev_create_with_default_parameters(
+ 0, NULL,
ALSA_CARD_TYPE_INTERNAL, 1,
- fake_mixer, NULL, fake_hctl,
- CRAS_STREAM_OUTPUT, 0, 0);
+ fake_mixer, NULL,
+ CRAS_STREAM_OUTPUT);
alsa_iodev_legacy_complete_init((struct cras_iodev *)aio_output_);
struct cras_ionode *node;