pull/7/head
Marcin Kondej 2015-07-29 18:44:52 +02:00
rodzic 9043b7d14a
commit 513d9e184e
3 zmienionych plików z 23 dodań i 20 usunięć

Wyświetl plik

@ -221,7 +221,7 @@
1437732332 /home/pi/new_transmitter/reader.h
"wave_reader.h"
1438162699 source:/home/pi/new_transmitter/transmitter.cpp
1438186683 source:/home/pi/new_transmitter/transmitter.cpp
"transmitter.h"
<exception>
<sstream>
@ -230,15 +230,14 @@
<unistd.h>
<sys/mman.h>
<fcntl.h>
<iostream>
1438166435 /home/pi/new_transmitter/stdin_reader.h
1438188016 /home/pi/new_transmitter/stdin_reader.h
<vector>
<fcntl.h>
"audio_format.h"
"error_reporter.h"
1438166282 source:/home/pi/new_transmitter/stdin_reader.cpp
1438186912 source:/home/pi/new_transmitter/stdin_reader.cpp
"stdin_reader.h"
<exception>
<sstream>

Wyświetl plik

@ -1,22 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="README.md" open="1" top="0" tabpos="6">
<File name="README.md" open="0" top="0" tabpos="6">
<Cursor position="897" topLine="0" />
</File>
<File name="main.cpp" open="1" top="0" tabpos="4">
<File name="main.cpp" open="0" top="0" tabpos="4">
<Cursor position="151" topLine="0" />
</File>
<File name="transmitter.cpp" open="1" top="1" tabpos="2">
<Cursor position="5921" topLine="152" />
<File name="stdin_reader.cpp" open="1" top="0" tabpos="2">
<Cursor position="1771" topLine="33" />
</File>
<File name="transmitter.h" open="1" top="0" tabpos="3">
<File name="stdin_reader.h" open="1" top="0" tabpos="3">
<Cursor position="1902" topLine="35" />
</File>
<File name="transmitter.cpp" open="1" top="1" tabpos="4">
<Cursor position="4471" topLine="23" />
</File>
<File name="transmitter.h" open="0" top="0" tabpos="3">
<Cursor position="2353" topLine="29" />
</File>
<File name="wave_reader.cpp" open="1" top="0" tabpos="1">
<Cursor position="6374" topLine="142" />
<Cursor position="6374" topLine="109" />
</File>
<File name="wave_reader.h" open="1" top="0" tabpos="5">
<File name="wave_reader.h" open="0" top="0" tabpos="5">
<Cursor position="294" topLine="0" />
</File>
</CodeBlocks_layout_file>

Wyświetl plik

@ -36,6 +36,8 @@
#include <sstream>
#include <unistd.h>
#include <iostream>
using std::exception;
using std::ostringstream;
@ -67,7 +69,6 @@ StdinReader::StdinReader()
StdinReader::~StdinReader()
{
doStop = true;
pthread_join(thread, NULL);
}
@ -106,7 +107,7 @@ void StdinReader::readStdin(void *params)
vector<float> *StdinReader::getFrames(unsigned int frameCount)
{
unsigned int bytesToRead, bufferSize, bytesPerFrame, offset, zeroOffset, restBytes;
unsigned int bytesToRead, bufferSize, bytesPerFrame, offset;
vector<float> *frames = new vector<float>();
while (isReading) {
@ -114,20 +115,17 @@ vector<float> *StdinReader::getFrames(unsigned int frameCount)
}
isPreparingFrames = true;
bufferSize = 0;
bufferSize = buffer.size();
bytesPerFrame = (BITS_PER_SAMPLE >> 3) * CHANNELS;
bytesToRead = frameCount * bytesPerFrame;
restBytes = bufferSize % bytesPerFrame;
if (bytesToRead > bufferSize) {
bytesToRead = bufferSize - restBytes;
bytesToRead = bufferSize - bufferSize % bytesPerFrame;
frameCount = bytesToRead / bytesPerFrame;
}
zeroOffset = bufferSize - bytesToRead - restBytes;
for (unsigned int i = 0; i < frameCount; i++) {
offset = zeroOffset + bytesPerFrame * i;
offset = bytesPerFrame * i;
if (CHANNELS != 1) {
if (BITS_PER_SAMPLE != 8) {
frames->push_back(((int)(signed char)buffer[offset + 1] + (int)(signed char)buffer[offset + 3]) / (float)0x100);
@ -143,7 +141,7 @@ vector<float> *StdinReader::getFrames(unsigned int frameCount)
}
}
buffer.clear();
buffer.erase(buffer.begin(), buffer.begin() + bytesToRead);
isPreparingFrames = false;
return frames;