MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / record

Function record

Samples/NiAudioSample/NiAudioSample.cpp:192–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192XnStatus record(Context& context, AudioGenerator* aGens, XnUInt32 nNodes)
193{
194 XnStatus nRetVal = XN_STATUS_OK;
195
196 // open files
197 XN_FILE_HANDLE aFiles[nSupportedNodes];
198
199 for (XnUInt32 i = 0; i < nNodes; ++i)
200 {
201 XnChar strFileName[XN_FILE_MAX_PATH];
202 sprintf(strFileName, "audio.%s.pcm", aGens[i].GetName());
203 nRetVal = xnOSOpenFile(strFileName, XN_OS_FILE_WRITE, &aFiles[i]);
204 CHECK_RC(nRetVal, "Open file");
205 }
206
207 printf ("Press any key to exit...\n");
208
209 // drop data till now
210 context.WaitAnyUpdateAll();
211
212 while (!xnOSWasKeyboardHit())
213 {
214 // Read audio chunk
215 nRetVal = context.WaitAnyUpdateAll();
216 if (nRetVal != XN_STATUS_OK)
217 {
218 printf("Waiting for new data failed: %s\n", xnGetStatusString(nRetVal));
219 }
220
221 // check which node has new data
222 for (XnUInt32 i = 0; i < nNodes; ++i)
223 {
224 if (aGens[i].IsDataNew())
225 {
226 nRetVal = xnOSWriteFile(aFiles[i], aGens[i].GetAudioBuffer(), aGens[i].GetDataSize());
227 CHECK_RC(nRetVal, "Write to file");
228 }
229 }
230 }
231
232 // close files
233 for (XnUInt32 i = 0; i < nNodes; ++i)
234 {
235 xnOSCloseFile(&aFiles[i]);
236 }
237
238 return (XN_STATUS_OK);
239}
240
241int main(int argc, char* argv[])
242{

Callers 1

mainFunction · 0.85

Calls 10

xnGetStatusStringFunction · 0.85
GetNameMethod · 0.80
WaitAnyUpdateAllMethod · 0.80
xnOSOpenFileFunction · 0.50
xnOSWasKeyboardHitFunction · 0.50
xnOSWriteFileFunction · 0.50
xnOSCloseFileFunction · 0.50
IsDataNewMethod · 0.45
GetAudioBufferMethod · 0.45
GetDataSizeMethod · 0.45

Tested by

no test coverage detected