diff options
author | Simon Ser <simon.ser@intel.com> | 2019-05-14 11:06:12 +0300 |
---|---|---|
committer | Simon Ser <simon.ser@intel.com> | 2019-05-14 14:51:38 +0300 |
commit | 19dcce36a1c31394bc73cf728f50dbbdc6d01704 (patch) | |
tree | 101e2781d8d8cd4be2f7a0760e8b8a8f0e3f88f3 | |
parent | 512aad1e6a3c0725a92fb8ccd2f7162caa81a628 (diff) |
lib/igt_alsa: remove input support
This is not used anymore because the old audio tests have been removed.
Signed-off-by: Simon Ser <simon.ser@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
-rw-r--r-- | lib/igt_alsa.c | 192 | ||||
-rw-r--r-- | lib/igt_alsa.h | 9 |
2 files changed, 0 insertions, 201 deletions
diff --git a/lib/igt_alsa.c b/lib/igt_alsa.c index a478686a..28a866e0 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; }; /** @@ -250,40 +242,6 @@ int alsa_open_output(struct alsa *alsa, const char *device_name) } /** - * 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) { @@ -394,24 +334,6 @@ bool alsa_test_output_configuration(struct alsa *alsa, int channels, } /** - * 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 * @channels: The number of channels to test @@ -444,33 +366,6 @@ void alsa_configure_output(struct alsa *alsa, int channels, } /** - * 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 * @callback: The callback function to call to fill output data @@ -493,28 +388,6 @@ void alsa_register_output_callback(struct alsa *alsa, } /** - * 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 * @duration_ms: The maximum duration of the run in milliseconds, or -1 for an @@ -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 5c804b46..a10985ff 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 |