2016-06-28 12:21:56 +02:00
|
|
|
/* Spa ALSA support
|
|
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Copyright © 2018 Wim Taymans
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2016-06-28 12:21:56 +02:00
|
|
|
*/
|
|
|
|
|
|
2022-09-20 15:13:16 +05:30
|
|
|
#include "config.h"
|
|
|
|
|
|
2017-11-13 09:41:41 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
2017-11-10 13:36:14 +01:00
|
|
|
#include <spa/support/plugin.h>
|
2021-09-23 14:25:32 +10:00
|
|
|
#include <spa/support/log.h>
|
2016-06-28 12:21:56 +02:00
|
|
|
|
2017-05-25 13:28:15 +02:00
|
|
|
extern const struct spa_handle_factory spa_alsa_source_factory;
|
|
|
|
|
extern const struct spa_handle_factory spa_alsa_sink_factory;
|
2019-09-20 13:04:14 +02:00
|
|
|
extern const struct spa_handle_factory spa_alsa_udev_factory;
|
2018-11-23 12:43:47 +01:00
|
|
|
extern const struct spa_handle_factory spa_alsa_device_factory;
|
2019-10-02 21:12:42 +02:00
|
|
|
extern const struct spa_handle_factory spa_alsa_seq_bridge_factory;
|
2020-05-15 19:42:15 +02:00
|
|
|
extern const struct spa_handle_factory spa_alsa_acp_device_factory;
|
2022-11-23 15:55:00 +01:00
|
|
|
#ifdef HAVE_ALSA_COMPRESS_OFFLOAD
|
|
|
|
|
extern const struct spa_handle_factory spa_alsa_compress_offload_sink_factory;
|
2022-09-20 15:13:16 +05:30
|
|
|
#endif
|
2016-06-28 12:21:56 +02:00
|
|
|
|
2021-09-23 14:25:32 +10:00
|
|
|
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.alsa");
|
|
|
|
|
struct spa_log_topic *alsa_log_topic = &log_topic;
|
|
|
|
|
|
2019-02-06 13:24:41 +01:00
|
|
|
SPA_EXPORT
|
2017-11-13 09:41:41 +01:00
|
|
|
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
2016-06-28 12:21:56 +02:00
|
|
|
{
|
2017-11-13 09:41:41 +01:00
|
|
|
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
|
|
|
|
spa_return_val_if_fail(index != NULL, -EINVAL);
|
2016-07-15 18:22:29 +02:00
|
|
|
|
2017-11-13 09:41:41 +01:00
|
|
|
switch (*index) {
|
2017-05-26 08:05:01 +02:00
|
|
|
case 0:
|
|
|
|
|
*factory = &spa_alsa_source_factory;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
*factory = &spa_alsa_sink_factory;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2019-09-20 13:04:14 +02:00
|
|
|
*factory = &spa_alsa_udev_factory;
|
2017-05-26 08:05:01 +02:00
|
|
|
break;
|
2018-11-23 12:43:47 +01:00
|
|
|
case 3:
|
|
|
|
|
*factory = &spa_alsa_device_factory;
|
|
|
|
|
break;
|
2019-09-19 16:57:00 +02:00
|
|
|
case 4:
|
2019-10-02 21:12:42 +02:00
|
|
|
*factory = &spa_alsa_seq_bridge_factory;
|
2019-09-19 16:57:00 +02:00
|
|
|
break;
|
2020-05-15 19:42:15 +02:00
|
|
|
case 5:
|
|
|
|
|
*factory = &spa_alsa_acp_device_factory;
|
|
|
|
|
break;
|
2022-11-23 15:55:00 +01:00
|
|
|
#ifdef HAVE_ALSA_COMPRESS_OFFLOAD
|
2022-09-20 15:13:16 +05:30
|
|
|
case 6:
|
2022-11-23 15:55:00 +01:00
|
|
|
*factory = &spa_alsa_compress_offload_sink_factory;
|
2022-09-20 15:13:16 +05:30
|
|
|
break;
|
|
|
|
|
#endif
|
2017-05-26 08:05:01 +02:00
|
|
|
default:
|
2017-11-13 09:41:41 +01:00
|
|
|
return 0;
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2017-11-13 09:41:41 +01:00
|
|
|
(*index)++;
|
|
|
|
|
return 1;
|
2016-06-28 12:21:56 +02:00
|
|
|
}
|