Name: pulseaudio-modules-tizen
Summary: Pulseaudio modules for Tizen
-Version: 11.1.28
+Version: 11.1.29
Release: 0
Group: Multimedia/Audio
License: LGPL-2.1+
}
}
-/* device_string looks like "alsa:0,0"
+/* device_string looks like "alsa:0,0" or "tizen:0,0"
* in this case name is "0,0" */
static int device_string_get_name(const char *device_string, char *name) {
char *colon_p;
return 0;
}
-static int device_name_get_card(const char *device_name, char *card) {
- const char *name_p;
- char *card_p;
-
- if (!strchr(device_name, ',')) {
- pa_log_error("Failed to parse name : no comma");
- return -1;
- }
-
- name_p = device_name;
- card_p = card;
- while (*name_p != ',')
- *(card_p++) = *(name_p++);
- *card_p = '\0';
-
- return 0;
-}
-
-static int device_name_get_device(const char *device_name, char *device) {
- const char *comma_p;
- char *device_p;
-
- if (!(comma_p = strchr(device_name, ','))) {
- pa_log_error("Failed to parse name : no comma");
- return -1;
- }
-
- comma_p++;
- device_p = device;
- while (*comma_p != '\0')
- *(device_p++) = *(comma_p++);
- *device_p = '\0';
-
- return 0;
-}
-
static pa_proplist* pulse_device_get_proplist(pa_object *pdevice) {
if (pa_sink_isinstance(pdevice))
return PA_SINK(pdevice)->proplist;
return -1;
}
- if (device_class == DM_DEVICE_CLASS_ALSA) {
+ if (device_class == DM_DEVICE_CLASS_ALSA)
snprintf(target, DEVICE_PARAM_STRING_MAX, "device=hw:%s ", device_name);
- } else if (device_class == DM_DEVICE_CLASS_TIZEN) {
- char card[DEVICE_NAME_MAX];
- char device[DEVICE_NAME_MAX];
-
- device_name_get_card(device_name, card);
- device_name_get_device(device_name, device);
-
- snprintf(target, DEVICE_PARAM_STRING_MAX, "card=%s device=%s ", card, device);
- }
+ else if (device_class == DM_DEVICE_CLASS_TIZEN)
+ snprintf(target, DEVICE_PARAM_STRING_MAX, "device=%s ", device_name);
if (params)
strncat(target, params, DEVICE_PARAM_STRING_MAX - strlen(target));
PA_MODULE_USAGE(
"sink_name=<name of sink> "
"sink_properties=<properties for the sink> "
- "card=<card to use> "
- "device=<device to use> "
+ "device=<device to use, card comma device (e.g. 0,0)> "
"format=<sample format> "
"rate=<sample rate> "
"channels=<number of channels> "
/* Sink device consumes that amount of maximum buffer at every request */
#define DEFAULT_MAX_REQUEST_USEC (PA_USEC_PER_SEC * 0.032)
+#define DEVICE_NAME_MAX 30
+
struct userdata {
pa_core *core;
pa_module *module;
static const char* const valid_modargs[] = {
"sink_name",
"sink_properties",
- "card",
"device",
"format",
"rate",
pa_log_debug("Thread shutting down");
}
+static int parse_to_get_card(const char *modarg_device, char *card) {
+ const char *name_p;
+ char *card_p;
+
+ if (!strchr(modarg_device, ',')) {
+ pa_log_error("Failed to parse device argument : no comma");
+ return -1;
+ }
+
+ name_p = modarg_device;
+ card_p = card;
+ while (*name_p != ',')
+ *(card_p++) = *(name_p++);
+ *card_p = '\0';
+
+ return 0;
+}
+
+static int parse_to_get_device(const char *modarg_device, char *device) {
+ const char *comma_p;
+ char *device_p;
+
+ if (!(comma_p = strchr(modarg_device, ','))) {
+ pa_log_error("Failed to parse device argument : no comma");
+ return -1;
+ }
+
+ comma_p++;
+ device_p = device;
+ while (*comma_p != '\0')
+ *(device_p++) = *(comma_p++);
+ *device_p = '\0';
+
+ return 0;
+}
+
int pa__init(pa_module*m) {
struct userdata *u = NULL;
pa_sample_spec ss;
uint32_t alternate_sample_rate;
uint32_t block_msec;
uint32_t max_request_msec;
- const char *card, *device;
+ const char *modarg_device;
+ char card[DEVICE_NAME_MAX];
+ char device[DEVICE_NAME_MAX];
pa_assert(m);
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
- if (!(card = pa_modargs_get_value(ma, "card", NULL)) ||
- !(device = pa_modargs_get_value(ma, "device", NULL))) {
- pa_log_error("card or device are invalid");
+ if (!(modarg_device = pa_modargs_get_value(ma, "device", NULL))) {
+ pa_log_error("device is invalid");
+ goto fail;
+ }
+
+ if (parse_to_get_card(modarg_device, card) || parse_to_get_device(modarg_device, device)) {
+ pa_log_error("failed to parse device module argument, %s", modarg_device);
goto fail;
}
PA_MODULE_USAGE(
"source_name=<name of source> "
"source_properties=<properties for the source> "
- "card=<card to use> "
- "device=<device to use> "
+ "device=<device to use, card comma device (e.g. 0,0)> "
"format=<sample format> "
"rate=<sample rate> "
"channels=<number of channels> "
/* BLOCK_USEC should be less than amount of fragment_size * fragments */
#define BLOCK_USEC (PA_USEC_PER_SEC * 0.032)
+#define DEVICE_NAME_MAX 30
+
struct userdata {
pa_core *core;
pa_module *module;
static const char* const valid_modargs[] = {
"source_name",
"source_properties",
- "card",
"device",
"format",
"rate",
pa_log_debug("Thread shutting down");
}
+static int parse_to_get_card(const char *modarg_device, char *card) {
+ const char *name_p;
+ char *card_p;
+
+ if (!strchr(modarg_device, ',')) {
+ pa_log_error("Failed to parse device argument : no comma");
+ return -1;
+ }
+
+ name_p = modarg_device;
+ card_p = card;
+ while (*name_p != ',')
+ *(card_p++) = *(name_p++);
+ *card_p = '\0';
+
+ return 0;
+}
+
+static int parse_to_get_device(const char *modarg_device, char *device) {
+ const char *comma_p;
+ char *device_p;
+
+ if (!(comma_p = strchr(modarg_device, ','))) {
+ pa_log_error("Failed to parse device argument : no comma");
+ return -1;
+ }
+
+ comma_p++;
+ device_p = device;
+ while (*comma_p != '\0')
+ *(device_p++) = *(comma_p++);
+ *device_p = '\0';
+
+ return 0;
+}
+
int pa__init(pa_module*m) {
struct userdata *u = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
pa_source_new_data data;
uint32_t alternate_sample_rate;
- const char *card, *device;
+ const char *modarg_device;
+ char card[DEVICE_NAME_MAX];
+ char device[DEVICE_NAME_MAX];
pa_assert(m);
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
- if (!(card = pa_modargs_get_value(ma, "card", NULL)) ||
- !(device = pa_modargs_get_value(ma, "device", NULL))) {
- pa_log_error("card or device are invalid");
+ if (!(modarg_device = pa_modargs_get_value(ma, "device", NULL))) {
+ pa_log_error("device is invalid");
+ goto fail;
+ }
+
+ if (parse_to_get_card(modarg_device, card) || parse_to_get_device(modarg_device, device)) {
+ pa_log_error("failed to parse device module argument, %s", modarg_device);
goto fail;
}