Unix Programming - using pthread to receive data on a socket and simultaneously

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2004 > using pthread to receive data on a socket and simultaneously





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author using pthread to receive data on a socket and simultaneously
kanchan

2004-11-13, 5:48 pm

Hi,
I am writing a client for a real time audio streaming server. I am
using pthread for that. I have one thread receiving data on a socket from
the server. After buffering some data, other thread wakes up (checking how
much data is in the buffer) to play the music. The problem is that when the
2nd thread is playing, the first thread is not able to receive data from
the server. If the server sends the data slow, then there will be breaks
in the audio. How do I solve this problem?

Thanks.
Ian

2004-11-13, 8:46 pm

kanchan wrote:
> Hi,
> I am writing a client for a real time audio streaming server. I am
> using pthread for that. I have one thread receiving data on a socket from
> the server. After buffering some data, other thread wakes up (checking how
> much data is in the buffer) to play the music. The problem is that when the
> 2nd thread is playing, the first thread is not able to receive data from
> the server. If the server sends the data slow, then there will be breaks
> in the audio. How do I solve this problem?
>

The player thread has to yield the CPU at some point to let the receiver
run. If this isn't happening, your player must be using 100% CPU.
Appears a bit excessive for a music player.

Ian
David Schwartz

2004-11-19, 5:51 pm


"kanchan" <kanchanc@gmail.com> wrote in message
news:239a4b2a.0411131451.5647bd78@posting.google.com...

> I am writing a client for a real time audio streaming server. I am
> using pthread for that. I have one thread receiving data on a socket from
> the server. After buffering some data, other thread wakes up (checking how
> much data is in the buffer) to play the music. The problem is that when
> the
> 2nd thread is playing, the first thread is not able to receive data from
> the server. If the server sends the data slow, then there will be breaks
> in the audio. How do I solve this problem?


There's probably something wrong with your code. Perhaps your thread is
holding a lock on the buffer while it's playing the music?

DS


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com