diff options
Diffstat (limited to 'dabplussnoop.cpp')
-rw-r--r-- | dabplussnoop.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/dabplussnoop.cpp b/dabplussnoop.cpp index 7073e7f..eb79e15 100644 --- a/dabplussnoop.cpp +++ b/dabplussnoop.cpp @@ -45,30 +45,29 @@ using namespace std; void DabPlusSnoop::push(uint8_t* streamdata, size_t streamsize) { + // First dump to file + if (m_raw_data_stream_fd == NULL) { + stringstream dump_filename; + dump_filename << "stream-" << m_index << ".msc"; + + m_raw_data_stream_fd = fopen(dump_filename.str().c_str(), "w"); + + if (m_raw_data_stream_fd == NULL) { + perror("File open failed"); + } + } + + fwrite(streamdata, 1, streamsize, m_raw_data_stream_fd); + + // Try to decode audio size_t original_size = m_data.size(); m_data.resize(original_size + streamsize); - memcpy(&m_data[original_size], streamdata, streamsize); if (seek_valid_firecode()) { // m_data now points to a valid header if (decode()) { // We have been able to decode the AUs - - // First dump to file - if (m_raw_data_stream_fd == NULL) { - stringstream dump_filename; - dump_filename << "stream-" << m_index << ".dabp"; - - m_raw_data_stream_fd = fopen(dump_filename.str().c_str(), "w"); - - if (m_raw_data_stream_fd == NULL) { - perror("File open failed"); - } - } - - fwrite(&m_data[0], m_subchannel_index, 120, m_raw_data_stream_fd); - m_data.erase(m_data.begin(), m_data.begin() + m_subchannel_index * 120); } } |