aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/microphone.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/conversation/microphone.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/conversation/microphone.c')
-rw-r--r--src/conversation/microphone.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/src/conversation/microphone.c b/src/conversation/microphone.c
index 01f8adb1e..5ab115c1f 100644
--- a/src/conversation/microphone.c
+++ b/src/conversation/microphone.c
@@ -34,7 +34,8 @@
34/** 34/**
35 * Internal data structures for the microphone. 35 * Internal data structures for the microphone.
36 */ 36 */
37struct Microphone { 37struct Microphone
38{
38 /** 39 /**
39 * Our configuration. 40 * Our configuration.
40 */ 41 */
@@ -67,21 +68,21 @@ struct Microphone {
67 * #GNUNET_SYSERR to stop further processing with error 68 * #GNUNET_SYSERR to stop further processing with error
68 */ 69 */
69static int 70static int
70process_record_messages(void *cls, 71process_record_messages (void *cls,
71 const struct GNUNET_MessageHeader *msg) 72 const struct GNUNET_MessageHeader *msg)
72{ 73{
73 struct Microphone *mic = cls; 74 struct Microphone *mic = cls;
74 const struct AudioMessage *am; 75 const struct AudioMessage *am;
75 76
76 if (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO) 77 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO)
77 { 78 {
78 GNUNET_break(0); 79 GNUNET_break (0);
79 return GNUNET_SYSERR; 80 return GNUNET_SYSERR;
80 } 81 }
81 am = (const struct AudioMessage *)msg; 82 am = (const struct AudioMessage *) msg;
82 mic->rdc(mic->rdc_cls, 83 mic->rdc (mic->rdc_cls,
83 ntohs(msg->size) - sizeof(struct AudioMessage), 84 ntohs (msg->size) - sizeof(struct AudioMessage),
84 &am[1]); 85 &am[1]);
85 return GNUNET_OK; 86 return GNUNET_OK;
86} 87}
87 88
@@ -94,30 +95,29 @@ process_record_messages(void *cls,
94 * @param rdc_cls closure for @a dc 95 * @param rdc_cls closure for @a dc
95 */ 96 */
96static int 97static int
97enable(void *cls, 98enable (void *cls,
98 GNUNET_MICROPHONE_RecordedDataCallback rdc, 99 GNUNET_MICROPHONE_RecordedDataCallback rdc,
99 void *rdc_cls) 100 void *rdc_cls)
100{ 101{
101 struct Microphone *mic = cls; 102 struct Microphone *mic = cls;
102 static char * const record_helper_argv[] = 103 static char *const record_helper_argv[] = {
103 {
104 "gnunet-helper-audio-record", 104 "gnunet-helper-audio-record",
105 NULL 105 NULL
106 }; 106 };
107 107
108 mic->rdc = rdc; 108 mic->rdc = rdc;
109 mic->rdc_cls = rdc_cls; 109 mic->rdc_cls = rdc_cls;
110 mic->record_helper = GNUNET_HELPER_start(GNUNET_NO, 110 mic->record_helper = GNUNET_HELPER_start (GNUNET_NO,
111 "gnunet-helper-audio-record", 111 "gnunet-helper-audio-record",
112 record_helper_argv, 112 record_helper_argv,
113 &process_record_messages, 113 &process_record_messages,
114 NULL, mic); 114 NULL, mic);
115 if (NULL == mic->record_helper) 115 if (NULL == mic->record_helper)
116 { 116 {
117 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 117 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
118 _("Could not start record audio helper\n")); 118 _ ("Could not start record audio helper\n"));
119 return GNUNET_SYSERR; 119 return GNUNET_SYSERR;
120 } 120 }
121 return GNUNET_OK; 121 return GNUNET_OK;
122} 122}
123 123
@@ -128,18 +128,18 @@ enable(void *cls,
128 * @param cls clsoure 128 * @param cls clsoure
129 */ 129 */
130static void 130static void
131disable(void *cls) 131disable (void *cls)
132{ 132{
133 struct Microphone *mic = cls; 133 struct Microphone *mic = cls;
134 134
135 if (NULL == mic->record_helper) 135 if (NULL == mic->record_helper)
136 { 136 {
137 GNUNET_break(0); 137 GNUNET_break (0);
138 return; 138 return;
139 } 139 }
140 GNUNET_break(GNUNET_OK == 140 GNUNET_break (GNUNET_OK ==
141 GNUNET_HELPER_kill(mic->record_helper, GNUNET_NO)); 141 GNUNET_HELPER_kill (mic->record_helper, GNUNET_NO));
142 GNUNET_HELPER_destroy(mic->record_helper); 142 GNUNET_HELPER_destroy (mic->record_helper);
143 mic->record_helper = NULL; 143 mic->record_helper = NULL;
144} 144}
145 145
@@ -150,12 +150,12 @@ disable(void *cls)
150 * @param cls clsoure 150 * @param cls clsoure
151 */ 151 */
152static void 152static void
153destroy(void *cls) 153destroy (void *cls)
154{ 154{
155 struct Microphone *mic = cls; 155 struct Microphone *mic = cls;
156 156
157 if (NULL != mic->record_helper) 157 if (NULL != mic->record_helper)
158 disable(mic); 158 disable (mic);
159} 159}
160 160
161 161
@@ -167,14 +167,15 @@ destroy(void *cls)
167 * @return NULL on error 167 * @return NULL on error
168 */ 168 */
169struct GNUNET_MICROPHONE_Handle * 169struct GNUNET_MICROPHONE_Handle *
170GNUNET_MICROPHONE_create_from_hardware(const struct GNUNET_CONFIGURATION_Handle *cfg) 170GNUNET_MICROPHONE_create_from_hardware (const struct
171 GNUNET_CONFIGURATION_Handle *cfg)
171{ 172{
172 struct GNUNET_MICROPHONE_Handle *microphone; 173 struct GNUNET_MICROPHONE_Handle *microphone;
173 struct Microphone *mic; 174 struct Microphone *mic;
174 175
175 mic = GNUNET_new(struct Microphone); 176 mic = GNUNET_new (struct Microphone);
176 mic->cfg = cfg; 177 mic->cfg = cfg;
177 microphone = GNUNET_new(struct GNUNET_MICROPHONE_Handle); 178 microphone = GNUNET_new (struct GNUNET_MICROPHONE_Handle);
178 microphone->cls = mic; 179 microphone->cls = mic;
179 microphone->enable_microphone = &enable; 180 microphone->enable_microphone = &enable;
180 microphone->disable_microphone = &disable; 181 microphone->disable_microphone = &disable;
@@ -189,10 +190,10 @@ GNUNET_MICROPHONE_create_from_hardware(const struct GNUNET_CONFIGURATION_Handle
189 * @param microphone microphone to destroy 190 * @param microphone microphone to destroy
190 */ 191 */
191void 192void
192GNUNET_MICROPHONE_destroy(struct GNUNET_MICROPHONE_Handle *microphone) 193GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone)
193{ 194{
194 microphone->destroy_microphone(microphone->cls); 195 microphone->destroy_microphone (microphone->cls);
195 GNUNET_free(microphone); 196 GNUNET_free (microphone);
196} 197}
197 198
198/* end of microphone.c */ 199/* end of microphone.c */