Revert "CRAS: add GetMinOutputBufferSize dbus API"

This reverts commit f1d6d8f6e9375240cbfbd3885a976b9d95694f23.

Reason for revert: break many CTS/GTS tests (b/64621074)

Original change's description:
> CRAS: add GetMinOutputBufferSize dbus API
>
> BUG=chromium:749345
> TEST=Add a board.ini in cras-config and see chrome read the
>      minimum output buffer size from the config.
>
> Change-Id: I85e511cf7ded092a2ec3848e0c62c15b3da2e578
> Reviewed-on: https://chromium-review.googlesource.com/605340
> Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org>
> Tested-by: Wu-Cheng Li <wuchengli@chromium.org>
> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
> Reviewed-by: Wu-Cheng Li <wuchengli@chromium.org>

Bug: chromium:749345,b:64621074
Change-Id: Ib9924b84d301cbfa6f68cc4370c7c29adb9c896e
Reviewed-on: https://chromium-review.googlesource.com/611750
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Kuang-che Wu <kcwu@chromium.org>
diff --git a/cras/README.dbus-api b/cras/README.dbus-api
index 384ef5d..819f068 100644
--- a/cras/README.dbus-api
+++ b/cras/README.dbus-api
@@ -58,10 +58,6 @@
 				boolean input_mute
 				boolean output_user_mute
 
-		void GetMinOutputBufferSize()
-
-			Returns the minimum output buffer size in bytes.
-
 		{dict},{dict},... GetNodes()
 
 			Returns information about nodes. A node can be either
diff --git a/cras/src/Makefile.am b/cras/src/Makefile.am
index 0beb4ff..9766d5e 100644
--- a/cras/src/Makefile.am
+++ b/cras/src/Makefile.am
@@ -83,7 +83,6 @@
 	dsp/eq2.c \
 	server/audio_thread.c \
 	server/buffer_share.c \
-	server/config/cras_board_config.c \
 	server/config/cras_card_config.c \
 	server/config/cras_device_blacklist.c \
 	server/cras.c \
@@ -710,11 +709,11 @@
 stream_list_unittest_LDADD = -lgtest -lpthread
 
 system_state_unittest_SOURCES = tests/system_state_unittest.cc \
-	server/cras_system_state.c common/cras_shm.c server/config/cras_board_config.c
+	server/cras_system_state.c common/cras_shm.c
 system_state_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
 	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server \
 	-I$(top_srcdir)/src/server/config
-system_state_unittest_LDADD = -lgtest -liniparser -lpthread -lrt
+system_state_unittest_LDADD = -lgtest -lrt -lpthread
 
 timing_unittest_SOURCES = \
 	common/cras_audio_format.c \
diff --git a/cras/src/common/cras_types.h b/cras/src/common/cras_types.h
index ec44d37..268a7a9 100644
--- a/cras/src/common/cras_types.h
+++ b/cras/src/common/cras_types.h
@@ -284,7 +284,6 @@
  *    capture_mute_locked - 0 = unlocked, 1 = locked.
  *    min_capture_gain - Min allowed capture gain in dBFS * 100.
  *    max_capture_gain - Max allowed capture gain in dBFS * 100.
- *    min_output_buffer_size - Minimum output buffer size in frames.
  *    num_streams_attached - Total number of streams since server started.
  *    num_output_devs - Number of available output devices.
  *    num_input_devs - Number of available input devices.
@@ -306,7 +305,7 @@
  *        isn't protected against concurrent updating, only one client should
  *        use it.
  */
-#define CRAS_SERVER_STATE_VERSION 3
+#define CRAS_SERVER_STATE_VERSION 2
 struct __attribute__ ((packed, aligned(4))) cras_server_state {
 	uint32_t state_version;
 	uint32_t volume;
@@ -322,7 +321,6 @@
 	int32_t capture_mute_locked;
 	int32_t min_capture_gain;
 	int32_t max_capture_gain;
-	int32_t min_output_buffer_size;
 	uint32_t num_streams_attached;
 	uint32_t num_output_devs;
 	uint32_t num_input_devs;
diff --git a/cras/src/server/config/cras_board_config.c b/cras/src/server/config/cras_board_config.c
deleted file mode 100644
index 567dd75..0000000
--- a/cras/src/server/config/cras_board_config.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright 2017 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <iniparser.h>
-#include <syslog.h>
-
-#include "cras_board_config.h"
-
-/* Allocate 63 chars + 1 for null where declared. */
-static const unsigned int MAX_INI_NAME_LEN = 63;
-static const unsigned int MAX_KEY_LEN = 63;
-static const int32_t DEFAULT_MIN_OUTPUT_BUFFER_SIZE = 512;
-
-#define CONFIG_NAME "board.ini"
-#define INI_KEY_NAME "output:min_output_buffer_size"
-
-
-void cras_board_config_get(const char *config_path,
-		struct cras_board_config *board_config)
-{
-	char ini_name[MAX_INI_NAME_LEN + 1];
-	char ini_key[MAX_KEY_LEN + 1];
-	dictionary *ini;
-
-	board_config->min_output_buffer_size = DEFAULT_MIN_OUTPUT_BUFFER_SIZE;
-	if (config_path == NULL)
-		return;
-
-	snprintf(ini_name, MAX_INI_NAME_LEN, "%s/%s", config_path,
-		CONFIG_NAME);
-	ini_name[MAX_INI_NAME_LEN] = '\0';
-	ini = iniparser_load(ini_name);
-	if (ini == NULL) {
-		syslog(LOG_DEBUG, "No ini file %s", ini_name);
-		return;
-	}
-
-	snprintf(ini_key, MAX_KEY_LEN, INI_KEY_NAME);
-	ini_key[MAX_KEY_LEN] = 0;
-	board_config->min_output_buffer_size =
-		iniparser_getint(ini, ini_key, DEFAULT_MIN_OUTPUT_BUFFER_SIZE);
-
-	iniparser_freedict(ini);
-	syslog(LOG_DEBUG, "Loaded ini file %s", ini_name);
-}
-
diff --git a/cras/src/server/config/cras_board_config.h b/cras/src/server/config/cras_board_config.h
deleted file mode 100644
index 45db9e2..0000000
--- a/cras/src/server/config/cras_board_config.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2017 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef CRAS_BOARD_CONFIG_H_
-#define CRAS_BOARD_CONFIG_H_
-
-#include <stdint.h>
-
-struct cras_board_config {
-	int32_t min_output_buffer_size;
-};
-
-/* Gets a configuration based on the config file specified.
- * Args:
- *    config_path - Path containing the config files.
- *    board_config - The returned configs.
- */
-void cras_board_config_get(const char *config_path,
-			   struct cras_board_config *board_config);
-
-#endif /* CRAS_BOARD_CONFIG_H_ */
diff --git a/cras/src/server/cras_dbus_control.c b/cras/src/server/cras_dbus_control.c
index c7804fe..2100224 100644
--- a/cras/src/server/cras_dbus_control.c
+++ b/cras/src/server/cras_dbus_control.c
@@ -63,9 +63,6 @@
     "      <arg name=\"input_mute\" type=\"b\" direction=\"out\"/>\n"   \
     "      <arg name=\"output_user_mute\" type=\"b\" direction=\"out\"/>\n"\
     "    </method>\n"                                                   \
-    "    <method name=\"GetMinOutputBufferSize\">\n"                    \
-    "      <arg name=\"buffer_size\" type=\"i\" direction=\"out\"/>\n"  \
-    "    </method>\n"                                                   \
     "    <method name=\"GetNodes\">\n"                                  \
     "      <arg name=\"nodes\" type=\"a{sv}\" direction=\"out\"/>\n"    \
     "    </method>\n"                                                   \
@@ -411,29 +408,6 @@
 	return DBUS_HANDLER_RESULT_HANDLED;
 }
 
-static DBusHandlerResult handle_get_min_output_buffer_size(
-	DBusConnection *conn,
-	DBusMessage *message,
-	void *arg)
-{
-	DBusMessage *reply;
-	dbus_uint32_t serial = 0;
-	dbus_int32_t buffer_size;
-
-	reply = dbus_message_new_method_return(message);
-
-	buffer_size = cras_system_get_min_output_buffer_size();
-	dbus_message_append_args(reply,
-				 DBUS_TYPE_INT32, &buffer_size,
-				 DBUS_TYPE_INVALID);
-
-	dbus_connection_send(conn, reply, &serial);
-
-	dbus_message_unref(reply);
-
-	return DBUS_HANDLER_RESULT_HANDLED;
-}
-
 /* Appends the information about a node to the dbus message. Returns
  * false if not enough memory. */
 static dbus_bool_t append_node_dict(DBusMessageIter *iter,
@@ -818,10 +792,6 @@
 		return handle_get_volume_state(conn, message, arg);
 	} else if (dbus_message_is_method_call(message,
 					       CRAS_CONTROL_INTERFACE,
-					       "GetMinOutputBufferSize")) {
-		return handle_get_min_output_buffer_size(conn, message, arg);
-	} else if (dbus_message_is_method_call(message,
-					       CRAS_CONTROL_INTERFACE,
 					       "GetNodes")) {
 		return handle_get_nodes(conn, message, arg);
 	} else if (dbus_message_is_method_call(message,
diff --git a/cras/src/server/cras_system_state.c b/cras/src/server/cras_system_state.c
index e32b46f..3483ebc 100644
--- a/cras/src/server/cras_system_state.c
+++ b/cras/src/server/cras_system_state.c
@@ -13,7 +13,6 @@
 #include <syslog.h>
 
 #include "cras_alsa_card.h"
-#include "cras_board_config.h"
 #include "cras_config.h"
 #include "cras_device_blacklist.h"
 #include "cras_observer.h"
@@ -72,7 +71,6 @@
 {
 	struct cras_server_state *exp_state;
 	int rc;
-	struct cras_board_config board_config;
 
 	state.shm_size = sizeof(*exp_state);
 
@@ -93,10 +91,6 @@
 	if (state.shm_fd_ro < 0)
 		exit(state.shm_fd_ro);
 
-	/* Read board config. */
-	memset(&board_config, 0, sizeof(board_config));
-	cras_board_config_get(device_config_dir, &board_config);
-
 	/* Initial system state. */
 	exp_state->state_version = CRAS_SERVER_STATE_VERSION;
 	exp_state->volume = CRAS_MAX_SYSTEM_VOLUME;
@@ -112,7 +106,6 @@
 	exp_state->min_capture_gain = DEFAULT_MIN_CAPTURE_GAIN;
 	exp_state->max_capture_gain = DEFAULT_MAX_CAPTURE_GAIN;
 	exp_state->num_streams_attached = 0;
-	exp_state->min_output_buffer_size = board_config.min_output_buffer_size;
 
 	if ((rc = pthread_mutex_init(&state.update_lock, 0) != 0)) {
 		syslog(LOG_ERR, "Fatal: system state mutex init");
@@ -324,11 +317,6 @@
 	return state.exp_state->max_capture_gain;
 }
 
-int cras_system_get_min_output_buffer_size()
-{
-	return state.exp_state->min_output_buffer_size;
-}
-
 int cras_system_add_alsa_card(struct cras_alsa_card_info *alsa_card_info)
 {
 	struct card_list *card;
diff --git a/cras/src/server/cras_system_state.h b/cras/src/server/cras_system_state.h
index 36e6b98..f0bb98a 100644
--- a/cras/src/server/cras_system_state.h
+++ b/cras/src/server/cras_system_state.h
@@ -107,9 +107,6 @@
 /* Returns the min value allowed for capture gain in dB * 100. */
 long cras_system_get_max_capture_gain();
 
-/* Returns the min value allowed for output buffer size in frames. */
-int cras_system_get_min_output_buffer_size();
-
 /* Adds a card at the given index to the system.  When a new card is found
  * (through a udev event notification) this will add the card to the system,
  * causing its devices to become available for playback/capture.
diff --git a/cras/src/tests/system_state_unittest.cc b/cras/src/tests/system_state_unittest.cc
index 00c4dfb..5816b77 100644
--- a/cras/src/tests/system_state_unittest.cc
+++ b/cras/src/tests/system_state_unittest.cc
@@ -45,7 +45,7 @@
   add_callback_called = 0;
   rm_callback_called = 0;
   alert_pending_called = 0;
-  device_config_dir = NULL;
+  device_config_dir = reinterpret_cast<char *>(3);
   cras_alsa_card_config_dir = NULL;
   cras_observer_notify_output_volume_called = 0;
   cras_observer_notify_output_mute_called = 0;