зеркало из https://github.com/mozilla/marytts.git
o Fix missing header (unistd.h needed for close())
o Fix verbose and slow way to append to a std::string by using the method that is meant for that. Looks like someone in the past was confused with c++ strings that can hold binary data vs. c strings that are NUL terminated and did some laborious workaround. o Remove leftover debugging code of the c++/c confusion. o While at it: fix a couple of trailing spaces. o Makefile fixes.
This commit is contained in:
Родитель
2ba1877736
Коммит
9f433da39a
|
@ -35,11 +35,10 @@ ICULIBS=-Wl,-R,$(ICUDIR)/lib -L$(ICUDIR)/lib -licuuc -licui18n -ldl
|
|||
all: MaryDemo
|
||||
|
||||
MaryDemo: MaryClient.o MaryDemo.o
|
||||
$(CC) $(CFLAGS) *.o -o MaryDemo $(LIBS)
|
||||
$(CC) $(CFLAGS) $^ -o MaryDemo $(LIBS)
|
||||
|
||||
%.o: %.cc
|
||||
$(CC) $(CFLAGS) $(RFLAGS) -o $@ -c $<
|
||||
|
||||
clean:
|
||||
rm -rf *.o ./MaryDemo
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "MaryClient.h"
|
||||
|
||||
|
@ -138,7 +139,6 @@ MaryClient::maryQuery( int server_port,
|
|||
|
||||
// receive the request id
|
||||
char id [32] = "";
|
||||
|
||||
if (recv (maryInfoSocket, id, 32, 0) == -1)
|
||||
{
|
||||
return -2;
|
||||
|
@ -207,18 +207,15 @@ MaryClient::maryQuery( int server_port,
|
|||
|
||||
//cout << "Reading result" << endl;
|
||||
|
||||
unsigned int total_bytes = 0;
|
||||
int recv_bytes = 0;
|
||||
char data [1024] = "";
|
||||
char data [1024];
|
||||
|
||||
result [0] = '\0';
|
||||
result.clear();
|
||||
|
||||
// receive the request result
|
||||
do
|
||||
{
|
||||
data [0] = '\0';
|
||||
|
||||
recv_bytes = recv (maryDataSocket, data, 1024, 0);
|
||||
recv_bytes = recv (maryDataSocket, data, sizeof(data), 0);
|
||||
|
||||
if (recv_bytes == -1)
|
||||
{
|
||||
|
@ -226,31 +223,10 @@ MaryClient::maryQuery( int server_port,
|
|||
}
|
||||
else if (recv_bytes > 0)
|
||||
{
|
||||
//cout << "("<<recv_bytes<<")" << endl;
|
||||
total_bytes += recv_bytes;
|
||||
data [recv_bytes] = '\0';
|
||||
|
||||
if (maryOutFormat == "AUDIO")
|
||||
{
|
||||
for (unsigned int i=0; i<recv_bytes; i++)
|
||||
{
|
||||
result += data [i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result += data;
|
||||
}
|
||||
result.append(data, recv_bytes);
|
||||
}
|
||||
} while (recv_bytes != 0);
|
||||
|
||||
if (result.size () != total_bytes)
|
||||
{
|
||||
cerr << "error: total bytes received != result bytes!" << endl;
|
||||
cerr << " total bytes received = " << total_bytes << endl;
|
||||
cerr << " result bytes = " << result.size () << endl;
|
||||
}
|
||||
|
||||
// receive the request error
|
||||
do
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче