diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-11-21 07:52:14 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-11-21 07:52:14 +0100 |
commit | 8895b894cedbda048bb5d9fdb6591737fd4165ff (patch) | |
tree | 035235d15f88241ee0e90c1154431bb4c345824c | |
parent | 77808453cd8e23b08dd15a997161195d5c482b4f (diff) | |
download | etisnoop-8895b894cedbda048bb5d9fdb6591737fd4165ff.tar.gz etisnoop-8895b894cedbda048bb5d9fdb6591737fd4165ff.tar.bz2 etisnoop-8895b894cedbda048bb5d9fdb6591737fd4165ff.zip |
fix segfault, dump dabp
-rw-r--r-- | dabplussnoop.cpp | 21 | ||||
-rw-r--r-- | dabplussnoop.h | 5 | ||||
-rw-r--r-- | faad_decoder.cpp | 7 |
3 files changed, 30 insertions, 3 deletions
diff --git a/dabplussnoop.cpp b/dabplussnoop.cpp index 54a6266..d41d311 100644 --- a/dabplussnoop.cpp +++ b/dabplussnoop.cpp @@ -53,6 +53,21 @@ void DabPlusSnoop::push(uint8_t* streamdata, size_t streamsize) // 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); } } @@ -135,6 +150,7 @@ bool DabPlusSnoop::decode() else if (m_dac_rate && !m_sbr_flag) num_aus = 6; // AAC core sampling rate 48 kHz +#if DPS_DEBUG printf( DPS_INDENT DPS_PREFIX "\n" DPS_INDENT "\tfirecode 0x%x\n" DPS_INDENT "\trfa %d\n" @@ -147,6 +163,7 @@ bool DabPlusSnoop::decode() header_firecode, rfa, m_dac_rate, m_sbr_flag, m_aac_channel_mode, m_ps_flag, m_mpeg_surround_config, num_aus); +#endif // ------ Parse au_start @@ -280,4 +297,8 @@ bool DabPlusSnoop::analyse_au(vector<vector<uint8_t> >& aus) void DabPlusSnoop::close() { m_faad_decoder.close(); + + if (m_raw_data_stream_fd) { + fclose(m_raw_data_stream_fd); + } } diff --git a/dabplussnoop.h b/dabplussnoop.h index b77e00e..7d7ee04 100644 --- a/dabplussnoop.h +++ b/dabplussnoop.h @@ -88,7 +88,8 @@ class DabPlusSnoop DabPlusSnoop() : m_index(0), m_subchannel_index(0), - m_data(0) {} + m_data(0), + m_raw_data_stream_fd(NULL) {} void set_subchannel_index(unsigned subchannel_index) { @@ -123,6 +124,8 @@ class DabPlusSnoop unsigned m_subchannel_index; std::vector<uint8_t> m_data; + + FILE* m_raw_data_stream_fd; }; #endif diff --git a/faad_decoder.cpp b/faad_decoder.cpp index 21b12fa..17024ca 100644 --- a/faad_decoder.cpp +++ b/faad_decoder.cpp @@ -37,9 +37,10 @@ using namespace std; FaadDecoder::FaadDecoder() : m_data_len(0), + m_fd(NULL), + m_aac(NULL), m_initialised(false) { - m_aac = NULL; } void FaadDecoder::open(string filename, bool ps_flag, bool aac_channel_mode, @@ -137,7 +138,7 @@ bool FaadDecoder::decode(vector<vector<uint8_t> > aus) memcpy(helpBuffer, d_header, 7 * sizeof(uint8_t)); memcpy(&helpBuffer[7], - &au[0], vh.aac_frame_length * sizeof (uint8_t)); + &au[0], au.size() * sizeof (uint8_t)); fwrite(helpBuffer, 1, vh.aac_frame_length, m_aac); @@ -178,11 +179,13 @@ bool FaadDecoder::decode(vector<vector<uint8_t> > aus) m_channels = hInfo.channels; size_t samples = hInfo.samples; +#if 0 printf("bytes consumed %d\n", (int)(hInfo.bytesconsumed)); printf("samplerate = %d, samples = %zu, channels = %d," " error = %d, sbr = %d\n", m_sample_rate, samples, m_channels, hInfo.error, hInfo.sbr); printf("header = %d\n", hInfo.header_type); +#endif if (hInfo.error != 0) { printf("FAAD Warning: %s\n", |