Article View: be.comp.programming
Article #15841linux streaming MP3 problem/question
From: noNO
Date: Fri, 11 Aug 2000 00:00
Date: Fri, 11 Aug 2000 00:00
69 lines
3092 bytes
3092 bytes
Hi,
In an effort to make a client/server pair for streaming MP3's over TCP/IP
(another one?!), I ran into a strange problem.
First, I've created a server and client that write and read one character at
a time. This worked fine, but was very slow. Next, I've adapted the server
software so that characters are first loaded in a string and then written to
the socket. This still worked fine with the 1 character read client. The
performance was better too, but still no good enhough.
When I tried to adapt the client to read more than one character a time, I
bumbed into the problem. Each time a file it streamed, it keeps changing in
size. The size changes arbitrary between 20 and 200 bytes over the original
size, never under the original size. When I play the file, many errors are
reported by the mp3 player (mpg123), but the player still manages to decode
to a somewhat recognisable song, but with many interruptions and a kind of
distortion. So not only is the file (slightly) bigger as it should be, it
is also (slightly) transformed during the process of streaming (or reading).
This is the server write bit:
if ( (fp = fopen( "/root/in", "r")) != NULL ) {
while ( !feof(fp) ) {
counter = 0;
for ( i = 0; i < DATAGRAM_SIZE; i++ ) {
if ( !feof(fp) ) {
message[i] = getc(fp);
counter++;
}
}
write(slaveSocket,
message,
counter);
}
fclose(fp);
} else {
fprintf(stdout, "Error opening file\n");
}
This is the client read bit:
while ( 0 < (status = read(clientSocket,
buffer, sizeof(buffer) - 1)))
{
for ( i = 0; i < (sizeof(buffer) - 1); i++ ) {
putc( buffer[i], stdout );
}
}
The read-one-character-at-a-time client works fine with the above server
bit. The read bit looks like this:
while ( 0 < (status = read(clientSocket,
buffer, 1)))
{
cr = buffer[0];
putc(cr, stdout);
}
Any suggestions to fix this strange behavior are very welcome, or is this
one for the X-Files?
Thanks a lot
Steven Devijver
(steven.devijver@cmpmail.com)
Please send replies via email too. thanks.
Technical Details
Message-ID:
<qmPk5.45$g%5.1708@nreader1.kpnqwest.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5392,7a09166187d02dc0,start X-Google-Attributes: gidf5392,public X-Google-Thread: 10c696,7a09166187d02dc0,start X-Google-Attributes: gid10c696,public X-Google-Thread: fcea4,7a09166187d02dc0,start X-Google-Attributes: gidfcea4,public From: "noNO" <nono@softhome.net> Subject: linux streaming MP3 problem/question Date: 2000/08/11 Message-ID: <qmPk5.45$g%5.1708@nreader1.kpnqwest.net> X-Deja-AN: 657091124 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Complaints-To: abuse@Belgium.EU.net X-Trace: nreader1.kpnqwest.net 965984790 195.207.174.3 (Fri, 11 Aug 2000 11:06:30 MET DST) Organization: KPNQwest customer news service X-MSMail-Priority: Normal NNTP-Posting-Date: Fri, 11 Aug 2000 11:06:30 MET DST Newsgroups: be.comp.programming,comp.os.linux.development.apps,comp.os.linux.development.system