Vuo  2.3.2
VuoAudioInputDevice.c
Go to the documentation of this file.
1 
10 #include "type.h"
11 #include "VuoAudioInputDevice.h"
12 
14 #ifdef VUO_COMPILER
16  "title" : "Audio Input Device",
17  "description" : "Information about an audio input device.",
18  "keywords" : [ ],
19  "version" : "1.0.0",
20  "dependencies" : [
21  "VuoInteger",
22  "VuoText"
23  ]
24  });
25 #endif
27 
40 {
41  return (VuoAudioInputDevice){
42  VuoJson_getObjectValue(VuoInteger, js, "id", -1),
43  VuoJson_getObjectValue(VuoText, js, "modelUid", NULL),
44  VuoJson_getObjectValue(VuoText, js, "name", NULL),
45  VuoJson_getObjectValue(VuoInteger, js, "channelCount", 0),
46  };
47 }
48 
53 {
54  json_object *js = json_object_new_object();
55 
56  if (value.id != -1)
57  {
58  json_object *idObject = VuoInteger_getJson(value.id);
59  json_object_object_add(js, "id", idObject);
60  }
61 
62  if (value.modelUid)
63  {
64  json_object *nameObject = VuoText_getJson(value.modelUid);
65  json_object_object_add(js, "modelUid", nameObject);
66  }
67 
68  if (value.name)
69  {
70  json_object *nameObject = VuoText_getJson(value.name);
71  json_object_object_add(js, "name", nameObject);
72  }
73 
74  if (value.channelCount)
75  {
76  json_object *channelCountObject = VuoInteger_getJson(value.channelCount);
77  json_object_object_add(js, "channelCount", channelCountObject);
78  }
79 
80  return js;
81 }
82 
87 {
88  if (value.id == -1)
89  {
90  if (VuoText_isEmpty(value.modelUid))
91  {
92  if (VuoText_isEmpty(value.name))
93  return strdup("The default audio input device");
94  else // have name
95  return VuoText_format("The first audio input device whose name contains \"%s\"", value.name);
96  }
97  else // have model
98  {
99  if (VuoText_isEmpty(value.name))
100  return VuoText_format("The first audio input device whose model contains \"%s\"", value.modelUid);
101  else // have name
102  return VuoText_format("The first audio input device of the same model as \"%s\"", value.name);
103  }
104  }
105  else // have ID
106  {
107  if (VuoText_isEmpty(value.name))
108  return VuoText_format("Audio input device #%lld", value.id);
109  else
110  // An actual detected audio input device (rather than abstract criteria).
111  return VuoText_format("Audio input device #%lld<br>Name: \"%s\"<br>Model: \"%s\"<br>%lld input channels", value.id, value.name, value.modelUid, value.channelCount);
112  }
113 }
114 
119 {
120  if (value.id == -1)
121  {
122  if (VuoText_isEmpty(value.modelUid))
123  {
124  if (VuoText_isEmpty(value.name))
125  return strdup("Default");
126  else // have name
127  return strdup(value.name);
128  }
129  else // have model
130  {
131  if (VuoText_isEmpty(value.name))
132  return strdup(value.modelUid);
133  else // have name
134  return strdup(value.name);
135  }
136  }
137  else // have ID
138  {
139  if (VuoText_isEmpty(value.name))
140  return VuoText_format("Device #%lld", value.id);
141  else
142  // An actual detected audio input device (rather than abstract criteria).
143  return strdup(value.name);
144  }
145 }
146 
151 {
152  return (value1.id == value2.id &&
153  VuoText_areEqual(value1.modelUid, value2.modelUid) &&
154  VuoText_areEqual(value1.name, value2.name) &&
155  value1.channelCount == value2.channelCount);
156 }
157 
163 {
164  return a.id < b.id;
165 }