This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgPau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/13830 ) Change subject: uhd: Avoid reallocation of buffers every read ...................................................................... uhd: Avoid reallocation of buffers every read Buffer size is based on num of chans and rxBuffer size is based on num of chans and rx_spp, and both are available and set during open(), so no need to waste time allocating and freeing them everytime we read from the device. Change-Id: I8c881c9c303c80f323825d85a924d74b76d2ce47 --- M Transceiver52M/device/uhd/UHDDevice.cpp M Transceiver52M/device/uhd/UHDDevice.h 2 files changed, 10 insertions(+), 15 deletions(-) Approvals: Jenkins Builder: Verified Harald Welte: Looks good to me, approved diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index 34ffd57..6214666 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -516,6 +516,11 @@ for (size_t i = 0; i < rx_buffers.size(); i++) rx_buffers[i] = new smpl_buf(buf_len, rx_rate); + // Create vector buffer + pkt_bufs = std::vector<std::vector<short> >(chans, std::vector<short>(2 * rx_spp)); + for (size_t i = 0; i < pkt_bufs.size(); i++) + pkt_ptrs.push_back(&pkt_bufs[i].front()); + // Initialize and shadow gain values init_gains(); @@ -549,13 +554,6 @@ size_t num_smpls; float timeout = UHD_RESTART_TIMEOUT; - std::vector<std::vector<short> > - pkt_bufs(chans, std::vector<short>(2 * rx_spp)); - - std::vector<short *> pkt_ptrs; - for (size_t i = 0; i < pkt_bufs.size(); i++) - pkt_ptrs.push_back(&pkt_bufs[i].front()); - ts_initial = 0; while (!ts_initial || (num_pkts-- > 0)) { num_smpls = rx_stream->recv(pkt_ptrs, rx_spp, md, @@ -720,14 +718,6 @@ return 0; } - // Create vector buffer - std::vector<std::vector<short> > - pkt_bufs(chans, std::vector<short>(2 * rx_spp)); - - std::vector<short *> pkt_ptrs; - for (size_t i = 0; i < pkt_bufs.size(); i++) - pkt_ptrs.push_back(&pkt_bufs[i].front()); - // Receive samples from the usrp until we have enough while (rx_buffers[0]->avail_smpls(timestamp) < len) { thread_enable_cancel(false); diff --git a/Transceiver52M/device/uhd/UHDDevice.h b/Transceiver52M/device/uhd/UHDDevice.h index f5d0b33..05a5914 100644 --- a/Transceiver52M/device/uhd/UHDDevice.h +++ b/Transceiver52M/device/uhd/UHDDevice.h @@ -152,6 +152,11 @@ TIMESTAMP ts_initial, ts_offset; std::vector<smpl_buf *> rx_buffers; + /* Sample buffers used to receive samples from UHD: */ + std::vector<std::vector<short> > pkt_bufs; + /* Used to call UHD API: Buffer pointer of each elem in pkt_ptrs will + point to corresponding buffer of vector pkt_bufs. */ + std::vector<short *> pkt_ptrs; void init_gains(); void set_channels(bool swap); -- To view, visit https://gerrit.osmocom.org/13830 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I8c881c9c303c80f323825d85a924d74b76d2ce47 Gerrit-Change-Number: 13830 Gerrit-PatchSet: 2 Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de> Gerrit-Reviewer: tnt <tnt at 246tNt.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190503/5d1dacf1/attachment.htm>