MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / first_payload

Method first_payload

DSView/pv/data/dsosnapshot.cpp:125–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count,
126 GSList *channels, bool instant, bool isFile)
127{
128 assert(channels);
129
130 bool channel_changed = false;
131 uint16_t channel_num = 0;
132 _is_file = isFile;
133
134 for (const GSList *l = channels; l; l = l->next) {
135 sr_channel *const probe = (sr_channel*)l->data;
136
137 if (probe->type == SR_CHANNEL_DSO) {
138 if (probe->enabled || isFile){
139 channel_num++;
140 if (!channel_changed){
141 channel_changed = !has_data(probe->index);
142 }
143 }
144 }
145 }
146
147 assert(channel_num != 0);
148
149 _instant = instant;
150 bool isOk = true;
151
152 if (total_sample_count != _total_sample_count
153 || channel_num != _channel_num
154 || channel_changed
155 || isFile){
156
157 std::lock_guard<std::mutex> lock(_mutex);
158
159 free_data();
160
161 _ch_index.clear();
162 _total_sample_count = total_sample_count;
163 _channel_num = channel_num;
164
165 for (const GSList *l = channels; l; l = l->next) {
166 sr_channel *const probe = (sr_channel*)l->data;
167
168 if (probe->type == SR_CHANNEL_DSO && (probe->enabled || isFile)) {
169
170 uint8_t *chan_buffer = (uint8_t*)malloc(total_sample_count + 1);
171 if (chan_buffer == NULL){
172 isOk = false;
173 dsv_err("DsoSnapshot::first_payload, Malloc memory failed!");
174 break;
175 }
176 _ch_data.push_back(chan_buffer);
177 _ch_index.push_back(probe->index);
178 }
179 }
180
181 if (isOk) {
182 free_envelop();

Callers 3

feed_in_logicMethod · 0.45
feed_in_dsoMethod · 0.45
feed_in_analogMethod · 0.45

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected