diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp index c59e1540788125837497d7cf131458a7ae1549d7..2ed60da34a5e9816b5bd9ae48cc0be42ffa53b15 100644 --- a/daemon/src/audio/audiorecord.cpp +++ b/daemon/src/audio/audiorecord.cpp @@ -44,18 +44,18 @@ struct wavhdr { char riff[4]; // "RIFF" - SINT32 file_size; // in bytes + int32_t file_size; // in bytes char wave[4]; // "WAVE" char fmt[4]; // "fmt " - SINT32 chunk_size; // in bytes (16 for PCM) - SINT16 format_tag; // 1=PCM, 2=ADPCM, 3=IEEE float, 6=A-Law, 7=Mu-Law - SINT16 num_chans; // 1=mono, 2=stereo - SINT32 sample_rate; - SINT32 bytes_per_sec; - SINT16 bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo - SINT16 bits_per_samp; + int32_t chunk_size; // in bytes (16 for PCM) + int16_t format_tag; // 1=PCM, 2=ADPCM, 3=IEEE float, 6=A-Law, 7=Mu-Law + int16_t num_chans; // 1=mono, 2=stereo + int32_t sample_rate; + int32_t bytes_per_sec; + int16_t bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo + int16_t bits_per_samp; char data[4]; // "data" - SINT32 data_length; // in bytes + int32_t data_length; // in bytes }; namespace { @@ -388,7 +388,7 @@ void AudioRecord::closeWavFile() DEBUG("Close wave file"); - SINT32 bytes = byteCounter_ * channels_; + int32_t bytes = byteCounter_ * channels_; // jump to data length if (fseek(fileHandle_, 40, SEEK_SET) != 0) @@ -397,7 +397,7 @@ void AudioRecord::closeWavFile() if (ferror(fileHandle_)) WARN("Can't reach offset 40 while closing"); - fwrite(&bytes, sizeof(SINT32), 1, fileHandle_); + fwrite(&bytes, sizeof(int32_t), 1, fileHandle_); if (ferror(fileHandle_)) WARN("Can't write bytes for data length "); diff --git a/daemon/src/audio/audiorecord.h b/daemon/src/audio/audiorecord.h index 9c7bbd8fae2b6a1a1f5c626337d4fba402476774..bcb6bf3de447f7adfb3114fc3586e88590a34bce 100644 --- a/daemon/src/audio/audiorecord.h +++ b/daemon/src/audio/audiorecord.h @@ -147,7 +147,7 @@ class AudioRecord { /** * Number of channels */ - SINT16 channels_; + int16_t channels_; /** * Number of byte recorded diff --git a/daemon/src/audio/sound/audiofile.cpp b/daemon/src/audio/sound/audiofile.cpp index e63ba064547b06c9d49303ce72db66b1cd9d10c2..1f4e606e15ebdc88a1c3b1e06a5c5c6b2d016aef 100644 --- a/daemon/src/audio/sound/audiofile.cpp +++ b/daemon/src/audio/sound/audiofile.cpp @@ -149,7 +149,7 @@ WaveFile::WaveFile(const std::string &fileName, unsigned int sampleRate) : Audio if (maxIteration == 0) throw AudioFileException("Could not find \"fmt \" chunk"); - SINT32 chunkSize; // fmt chunk size + int32_t chunkSize; // fmt chunk size fileStream.read(reinterpret_cast<char *>(&chunkSize), sizeof chunkSize); // Read fmt chunk size. unsigned short formatTag; // data compression tag fileStream.read(reinterpret_cast<char *>(&formatTag), sizeof formatTag); @@ -158,24 +158,24 @@ WaveFile::WaveFile(const std::string &fileName, unsigned int sampleRate) : Audio throw AudioFileException("File contains an unsupported data format type"); // Get number of channels from the header. - SINT16 chan; + int16_t chan; fileStream.read(reinterpret_cast<char *>(&chan), sizeof chan); if (chan > 2) throw AudioFileException("WaveFile: unsupported number of channels"); // Get file sample rate from the header. - SINT32 fileRate; + int32_t fileRate; fileStream.read(reinterpret_cast<char *>(&fileRate), sizeof fileRate); - SINT32 avgb; + int32_t avgb; fileStream.read(reinterpret_cast<char *>(&avgb), sizeof avgb); - SINT16 blockal; + int16_t blockal; fileStream.read(reinterpret_cast<char *>(&blockal), sizeof blockal); // Determine the data type - SINT16 dt; + int16_t dt; fileStream.read(reinterpret_cast<char *>(&dt), sizeof dt); if (dt != 8 && dt != 16 && dt != 32) @@ -189,11 +189,11 @@ WaveFile::WaveFile(const std::string &fileName, unsigned int sampleRate) : Audio fileStream.read(data, sizeof data / sizeof * data); // Samplerate converter initialized with 88200 sample long - const int rate = static_cast<SINT32>(sampleRate); + const int rate = static_cast<int32_t>(sampleRate); SamplerateConverter converter(std::max(fileRate, rate), chan); // Get length of data from the header. - SINT32 bytes; + int32_t bytes; fileStream.read(reinterpret_cast<char *>(&bytes), sizeof bytes); // sample frames, should not be longer than a minute diff --git a/daemon/src/sfl_types.h b/daemon/src/sfl_types.h index a8993a6199e6764fbab2fc88c748ae7d5c802e26..a95394493f7795a1854fd4650113379e37a870c0 100644 --- a/daemon/src/sfl_types.h +++ b/daemon/src/sfl_types.h @@ -35,20 +35,8 @@ #include <stdint.h> typedef int16_t SFLAudioSample; - -typedef int16_t SINT16; -typedef int32_t SINT32; #define SFL_DATA_FORMAT_MAX SHRT_MAX -/* -typedef struct { - int sample_rate; - size_t channels; - size_t sample_num; // number of multichannel samples - SFLAudioSample *samples; // buffer, must be able to hold at least channels*sample_num SFLAudioSamples -} SFLAudioBuffer; -*/ - static const size_t SIZEBUF = 400000; /** About 12 sec of buffering at 8000 Hz*/ #endif // SFL_TYPES_H_