Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

audiodata.cpp

Go to the documentation of this file.
00001 
00006 #include <cassert>
00007 #include "audiodata.h"
00008 #include "except.h"
00009 
00010 #ifdef DEBUG
00011 #include <iostream>
00012 #endif
00013 
00014 AudioData::AudioData(int num, int min, Bitstream &bs)
00015 { 
00016   m_size = num;
00017   m_data = new char[num];
00018   
00019   //Read data, if at least min bytes was read (required audiodata), it's OK
00020   try {
00021     bs.ReadBytes(m_data, num);
00022   }
00023   catch(eEOF e)
00024   {
00025     int realnum = e.bytes_read();
00026     
00027     #ifdef DEBUG
00028     std::cout << "read " << realnum << " bytes, " << min << " needed" << std::endl;
00029     #endif
00030     
00031     if(realnum >= min)
00032       m_size = realnum;
00033     else
00034       throw e;
00035   }
00036 }
00037     
00038 AudioData::~AudioData()
00039 {
00040   delete[] m_data;
00041 }
00042   
00043 void AudioData::Write(Bitstream &bs) const
00044 {
00045   bs.WriteBytes(m_data, m_size);
00046 }
00047 
00048 void AudioData::Write(Bitstream &bs, int start, int end) const
00049 {
00050   assert(start <= end);
00051   assert(end <= m_size);
00052   bs.WriteBytes(m_data + start, end - start);
00053 }

Generated on Wed Sep 6 00:17:56 2006 for Kraken by  doxygen 1.4.4