MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / read_thread

Function read_thread

framework/data_source/data_source_test.cpp:22–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20} mainCont;
21
22static void *read_thread(void *arg)
23{
24 mainCont *pHandle = (mainCont *) arg;
25 auto *pDownloader = pHandle->pDownloader;
26 int total_size = 0;
27 int ret;
28 int read_size = 1024;
29 auto *buffer = static_cast<uint8_t *>(malloc(static_cast<size_t>(read_size + 1)));
30
31 do {
32 ret = static_cast<int>(pDownloader->Read(buffer, read_size));
33
34 if (ret > 0) {
35 total_size += ret;
36
37 if (pHandle->outFd > 0) {
38 write(pHandle->outFd, buffer, static_cast<size_t>(ret));
39 }
40
41 // buffer[ret] = 0;
42 // printf("%s", buffer);
43 }
44 } while (ret > 0 && !pHandle->isCanceled);
45
46 // printf("\n");
47 if (ret < 0) {
48 printf("read error %d (%s)\n", ret, pDownloader->Get_error_info(ret).c_str());
49 }
50
51 printf("total_size is %d\n", total_size);
52 free(buffer);
53 pHandle->isEOS = true;
54 return nullptr;
55}
56
57static void *seek_thread
58(void *arg)

Callers

nothing calls this directly

Calls 2

ReadMethod · 0.45
Get_error_infoMethod · 0.45

Tested by

no test coverage detected