diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-11-15 16:14:11 +0100 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-11-15 16:14:11 +0100 | 
| commit | 85e65ee17160ade86b2179d27b387b27f7e4396f (patch) | |
| tree | 874cc798474247296003ed8855b3f6245bca15c4 /src/AVTInput.cpp | |
| parent | 86bc3fc5e0ed8cdf8db9bfa7f5488162022f0a85 (diff) | |
| download | ODR-SourceCompanion-85e65ee17160ade86b2179d27b387b27f7e4396f.tar.gz ODR-SourceCompanion-85e65ee17160ade86b2179d27b387b27f7e4396f.tar.bz2 ODR-SourceCompanion-85e65ee17160ade86b2179d27b387b27f7e4396f.zip | |
Fix PAD UDP send bug
Diffstat (limited to 'src/AVTInput.cpp')
| -rw-r--r-- | src/AVTInput.cpp | 26 | 
1 files changed, 15 insertions, 11 deletions
| diff --git a/src/AVTInput.cpp b/src/AVTInput.cpp index 3bf1bd6..2610b5c 100644 --- a/src/AVTInput.cpp +++ b/src/AVTInput.cpp @@ -57,7 +57,7 @@ AVTInput::AVTInput(const std::string& input_uri,      _jitterBufferSize(jitterBufferSize),      _output_packet(2048), -    _input_pad_packet(2048), +    _pad_packet(2048),      _ordered(5000, _jitterBufferSize),      _lastInfoFrameType(_typeCantExtract)  { } @@ -313,10 +313,12 @@ void AVTInput::_sendPADFrame()                  0xAD,                  static_cast<uint8_t>(frame.size())}); -        Socket::UDPPacket packet; -        packet.buffer = buf; -        copy(frame.begin(), frame.end(), back_inserter(packet.buffer)); -        _input_pad_socket.send(packet); +        // Always keep the same packet, as it contains the destination address. +        // This function only gets called from _interpretMessage(), which +        // only gets called after a successful packet reception. +        _pad_packet.buffer = move(buf); +        copy(frame.begin(), frame.end(), back_inserter(_pad_packet.buffer)); +        _input_pad_socket.send(_pad_packet);      }  } @@ -326,7 +328,7 @@ void AVTInput::_sendPADFrame()   * Command code : 1 Byte   *                  * 0x17 = Request for 1 PAD Frame   */ -void AVTInput::_interpretMessage(const uint8_t* data, size_t size) +void AVTInput::_interpretMessage(const uint8_t *data, size_t size)  {      if (size >= 2) {          if (data[0] == 0xFD) { @@ -341,12 +343,12 @@ void AVTInput::_interpretMessage(const uint8_t* data, size_t size)  bool AVTInput::_checkMessage()  { -    const auto packet = _input_pad_socket.receive(2048); -    if (packet.buffer.empty()) { +    _pad_packet = _input_pad_socket.receive(2048); +    if (_pad_packet.buffer.empty()) {          return false;      } -    _interpretMessage(packet.buffer.data(), packet.buffer.size()); +    _interpretMessage(_pad_packet.buffer.data(), _pad_packet.buffer.size());      return true;  } @@ -354,9 +356,11 @@ bool AVTInput::_checkMessage()  void AVTInput::_purgeMessages()  {      int nb = 0; -    while (not _input_pad_socket.receive(2048).buffer.empty()) { +    do { +        _pad_packet = _input_pad_socket.receive(2048);          nb++; -    } +    } while (not _pad_packet.buffer.empty()); +      if (nb>0) DEBUG("%d messages purged\n", nb);  } | 
