[igt-dev] [PATCH i-g-t] lib/igt_alsa: remove input support

Simon Ser simon.ser at intel.com
Tue May 14 08:06:12 UTC 2019


This is not used anymore because the old audio tests have been removed.

Signed-off-by: Simon Ser <simon.ser at intel.com>
---
 lib/igt_alsa.c | 192 -------------------------------------------------
 lib/igt_alsa.h |   9 ---
 2 files changed, 201 deletions(-)

diff --git a/lib/igt_alsa.c b/lib/igt_alsa.c
index a478686a3fd7..28a866e0ee74 100644
--- a/lib/igt_alsa.c
+++ b/lib/igt_alsa.c
@@ -53,14 +53,6 @@ struct alsa {
 	int (*output_callback)(void *data, short *buffer, int samples);
 	void *output_callback_data;
 	int output_samples_trigger;
-
-	snd_pcm_t *input_handle;
-	int input_sampling_rate;
-	int input_channels;
-
-	int (*input_callback)(void *data, short *buffer, int samples);
-	void *input_callback_data;
-	int input_samples_trigger;
 };

 /**
@@ -249,40 +241,6 @@ int alsa_open_output(struct alsa *alsa, const char *device_name)
 	return 0;
 }

-/**
- * alsa_open_input:
- * @alsa: The target alsa structure
- * @device_name: The name of the input device to open
- *
- * Open the ALSA input device whose name matches the provided name prefix.
- *
- * Returns: An integer equal to zero for success and negative for failure
- */
-int alsa_open_input(struct alsa *alsa, const char *device_name)
-{
-	snd_pcm_t *handle;
-	char *identifier;
-	int ret;
-
-	identifier = alsa_resolve_indentifier(device_name, 0);
-
-	ret = snd_pcm_open(&handle, device_name, SND_PCM_STREAM_CAPTURE,
-			   SND_PCM_NONBLOCK);
-	if (ret < 0)
-		goto complete;
-
-	igt_debug("Opened input %s\n", identifier);
-
-	alsa->input_handle = handle;
-
-	ret = 0;
-
-complete:
-	free(identifier);
-
-	return ret;
-}
-
 /**
  * alsa_close_output:
  * @alsa: The target alsa structure
@@ -308,24 +266,6 @@ void alsa_close_output(struct alsa *alsa)
 	alsa->output_callback = NULL;
 }

-/**
- * alsa_close_output:
- * @alsa: The target alsa structure
- *
- * Close the open ALSA input.
- */
-void alsa_close_input(struct alsa *alsa)
-{
-	snd_pcm_t *handle = alsa->input_handle;
-	if (!handle)
-		return;
-
-	snd_pcm_close(handle);
-	alsa->input_handle = NULL;
-
-	alsa->input_callback = NULL;
-}
-
 static bool alsa_test_configuration(snd_pcm_t *handle, int channels,
 			     int sampling_rate)
 {
@@ -393,24 +333,6 @@ bool alsa_test_output_configuration(struct alsa *alsa, int channels,
 	return true;
 }

-/**
- * alsa_test_input_configuration:
- * @alsa: The target alsa structure
- * @channels: The number of channels to test
- * @sampling_rate: The sampling rate to test
- *
- * Test the input configuration specified by @channels and @sampling_rate
- * for the input device.
- *
- * Returns: A boolean indicating whether the test succeeded
- */
-bool alsa_test_input_configuration(struct alsa *alsa, int channels,
-				   int sampling_rate)
-{
-	return alsa_test_configuration(alsa->input_handle, channels,
-				       sampling_rate);
-}
-
 /**
  * alsa_configure_output:
  * @alsa: The target alsa structure
@@ -443,33 +365,6 @@ void alsa_configure_output(struct alsa *alsa, int channels,
 	alsa->output_sampling_rate = sampling_rate;
 }

-/**
- * alsa_configure_input:
- * @alsa: The target alsa structure
- * @channels: The number of channels to test
- * @sampling_rate: The sampling rate to test
- *
- * Configure the input device with the configuration specified by @channels
- * and @sampling_rate.
- */
-void alsa_configure_input(struct alsa *alsa, int channels,
-			  int sampling_rate)
-{
-	snd_pcm_t *handle;
-	int ret;
-
-	handle = alsa->input_handle;
-
-	ret = snd_pcm_set_params(handle, SND_PCM_FORMAT_S16_LE,
-				 SND_PCM_ACCESS_RW_INTERLEAVED, channels,
-				 sampling_rate, 0, 0);
-	igt_assert(ret >= 0);
-
-	alsa->input_channels = channels;
-	alsa->input_sampling_rate = sampling_rate;
-
-}
-
 /**
  * alsa_register_output_callback:
  * @alsa: The target alsa structure
@@ -492,28 +387,6 @@ void alsa_register_output_callback(struct alsa *alsa,
 	alsa->output_samples_trigger = samples_trigger;
 }

-/**
- * alsa_register_input_callback:
- * @alsa: The target alsa structure
- * @callback: The callback function to call when input data is available
- * @callback_data: The data pointer to pass to the callback function
- * @samples_trigger: The required number of samples to trigger the callback
- *
- * Register a callback function to be called when input data is available during
- * a run. The callback is called when @samples_trigger samples are available.
- *
- * The callback should return an integer equal to zero for success, negative for
- * failure and positive to indicate that the run should stop.
- */
-void alsa_register_input_callback(struct alsa *alsa,
-				  int (*callback)(void *data, short *buffer, int samples),
-				  void *callback_data, int samples_trigger)
-{
-	alsa->input_callback = callback;
-	alsa->input_callback_data = callback_data;
-	alsa->input_samples_trigger = samples_trigger;
-}
-
 /**
  * alsa_run:
  * @alsa: The target alsa structure
@@ -530,18 +403,12 @@ int alsa_run(struct alsa *alsa, int duration_ms)
 {
 	snd_pcm_t *handle;
 	short *output_buffer = NULL;
-	short *input_buffer = NULL;
 	int output_limit;
 	int output_total = 0;
 	int output_counts[alsa->output_handles_count];
 	bool output_ready = false;
 	int output_channels;
 	int output_trigger;
-	int input_limit;
-	int input_total = 0;
-	int input_count = 0;
-	int input_channels;
-	int input_trigger;
 	bool reached;
 	int index;
 	int count;
@@ -555,14 +422,6 @@ int alsa_run(struct alsa *alsa, int duration_ms)
 	output_buffer = malloc(sizeof(short) * output_channels *
 			       output_trigger);

-	if (alsa->input_callback) {
-		input_limit = alsa->input_sampling_rate * duration_ms / 1000;
-		input_trigger = alsa->input_samples_trigger;
-		input_channels = alsa->input_channels;
-		input_buffer = malloc(sizeof(short) * input_channels *
-				      input_trigger);
-	}
-
 	do {
 		reached = true;

@@ -627,63 +486,12 @@ int alsa_run(struct alsa *alsa, int duration_ms)
 				output_total += output_trigger;

 		}
-
-		if (alsa->input_callback &&
-		    (input_limit < 0 || input_total < input_limit)) {
-			reached = false;
-
-			if (input_count == input_trigger) {
-				input_count = 0;
-
-				ret = alsa->input_callback(alsa->input_callback_data,
-							   input_buffer,
-							   input_trigger);
-				if (ret != 0)
-					goto complete;
-			}
-
-			handle = alsa->input_handle;
-
-			ret = snd_pcm_avail(handle);
-			if (input_count < input_trigger &&
-			    (ret > 0 || input_total == 0)) {
-				index = input_count * input_channels;
-				count = input_trigger - input_count;
-				avail = snd_pcm_avail(handle);
-
-				count = avail > 0 && avail < count ? avail :
-					count;
-
-				ret = snd_pcm_readi(handle,
-						    &input_buffer[index],
-						    count);
-				if (ret == -EAGAIN) {
-					ret = 0;
-				} else if (ret < 0) {
-					ret = snd_pcm_recover(handle, ret, 0);
-					if (ret < 0) {
-						igt_debug("snd_pcm_recover after snd_pcm_readi failed");
-						goto complete;
-					}
-				}
-
-				input_count += ret;
-				input_total += ret;
-			} else if (input_count < input_trigger && ret < 0) {
-				ret = snd_pcm_recover(handle, ret, 0);
-				if (ret < 0) {
-					igt_debug("snd_pcm_recover failed");
-					goto complete;
-				}
-			}
-		}
 	} while (!reached);

 	ret = 0;

 complete:
 	free(output_buffer);
-	free(input_buffer);

 	return ret;
 }
diff --git a/lib/igt_alsa.h b/lib/igt_alsa.h
index 5c804b46ace4..a10985ff777f 100644
--- a/lib/igt_alsa.h
+++ b/lib/igt_alsa.h
@@ -36,23 +36,14 @@ struct alsa;
 bool alsa_has_exclusive_access(void);
 struct alsa *alsa_init(void);
 int alsa_open_output(struct alsa *alsa, const char *device_name);
-int alsa_open_input(struct alsa *alsa, const char *device_name);
 void alsa_close_output(struct alsa *alsa);
-void alsa_close_input(struct alsa *alsa);
 bool alsa_test_output_configuration(struct alsa *alsa, int channels,
 				    int sampling_rate);
-bool alsa_test_input_configuration(struct alsa *alsa, int channels,
-				   int sampling_rate);
 void alsa_configure_output(struct alsa *alsa, int channels,
 			   int sampling_rate);
-void alsa_configure_input(struct alsa *alsa, int channels,
-			  int sampling_rate);
 void alsa_register_output_callback(struct alsa *alsa,
 				   int (*callback)(void *data, short *buffer, int samples),
 				   void *callback_data, int samples_trigger);
-void alsa_register_input_callback(struct alsa *alsa,
-				  int (*callback)(void *data, short *buffer, int samples),
-				  void *callback_data, int samples_trigger);
 int alsa_run(struct alsa *alsa, int duration_ms);

 #endif
--
2.21.0



More information about the igt-dev mailing list