Vuo  2.0.0
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
26 
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  json_object *idObject = VuoInteger_getJson(value.id);
57  json_object_object_add(js, "id", idObject);
58 
59  if (value.modelUid)
60  {
61  json_object *nameObject = VuoText_getJson(value.modelUid);
62  json_object_object_add(js, "modelUid", nameObject);
63  }
64 
65  if (value.name)
66  {
67  json_object *nameObject = VuoText_getJson(value.name);
68  json_object_object_add(js, "name", nameObject);
69  }
70 
71  json_object *channelCountObject = VuoInteger_getJson(value.channelCount);
72  json_object_object_add(js, "channelCount", channelCountObject);
73 
74  return js;
75 }
76 
81 {
82  if (value.id == -1)
83  {
84  if (VuoText_isEmpty(value.modelUid))
85  {
86  if (VuoText_isEmpty(value.name))
87  return strdup("The default audio input device");
88  else // have name
89  return VuoText_format("The first audio input device whose name contains \"%s\"", value.name);
90  }
91  else // have model
92  {
93  if (VuoText_isEmpty(value.name))
94  return VuoText_format("The first audio input device whose model contains \"%s\"", value.modelUid);
95  else // have name
96  return VuoText_format("The first audio input device of the same model as \"%s\"", value.name);
97  }
98  }
99  else // have ID
100  {
101  if (VuoText_isEmpty(value.name))
102  return VuoText_format("Audio input device #%lld", value.id);
103  else
104  // An actual detected audio input device (rather than abstract criteria).
105  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);
106  }
107 }
108 
113 {
114  return (value1.id == value2.id &&
115  VuoText_areEqual(value1.modelUid, value2.modelUid) &&
116  VuoText_areEqual(value1.name, value2.name) &&
117  value1.channelCount == value2.channelCount);
118 }
119 
125 {
126  return a.id < b.id;
127 }