| View previous topic :: View next topic |
| Author |
Message |
Anonymous Guest
|
Posted: Thu Jan 04, 2007 2:22 pm Post subject: Multiple sources with different bitrates |
|
|
Hi,
I've created a multithreaded "source-server" that sends to different mounts on the Icecast server. Everything work ok if all sources sends with the same bitrate. If the sources sends at different bitrates the listening clients "overhear" other "channels" (mounts). What is wrong? Can't I do like this?
Regards Toni |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Jan 05, 2007 11:15 am Post subject: Update |
|
|
| Update: seems to be the same problem when sending with same bitrate but the problem is less frequent. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Jan 05, 2007 2:33 pm Post subject: Update again! |
|
|
I can get rid of the problem if I move the streamsource from different threads to different processes. Is there a threadsafety issue in libshout?
ANYBODY! if you know anything of this please share it! |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Fri Jan 05, 2007 2:48 pm Post subject: |
|
|
libshout does not do mixing. The only thing you have to do is use a shout_t for each stream. Anything else must be occurring before libshout gets hold of it.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Jan 05, 2007 11:18 pm Post subject: Que? |
|
|
| Every thread hold it's own shout_t var, what do u mean? |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Jan 05, 2007 11:35 pm Post subject: More info |
|
|
while( !m_StopRequest )
{
if( f )
{
read = fread( buff, 1, sizeof(buff), f );
total = total + read;
}
if (read > 0)
{
s.send(buff, read);
s.sync();
if( f && newsong )
{
newsong = false;
if( http )
server.updateSong( m_User, m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
else
{
md.add( "song", m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
s.set_metadata( &md );
}
}
}
else
{
f = m_PlayListHandler->getPlayList(m_User)->getNextStreamHandle();
//s.set_audio_info( SHOUT_AI_BITRATE, CzzString::Format( "%d", m_PlayListHandler->getPlayList(m_User)->getBitRate() ).c_str() );
newsong = true;
}
} |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Jan 05, 2007 11:38 pm Post subject: More info |
|
|
Extract of the code looks like this:
If in a thread = not OK, in it's own process = OK,.
f = m_PlayListHandler->getPlayList(m_User)->getNextStreamHandle();
while( !m_StopRequest )
{
if( f )
read = fread( buff, 1, sizeof(buff), f );
if (read > 0)
{
s.send(buff, read);
s.sync();
if( f && newsong )
{
newsong = false;
if( http )
server.updateSong( m_User, m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
else
{
md.add( "song", m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
s.set_metadata( &md );
}
}
}
else
{
f = m_PlayListHandler->getPlayList(m_User)->getNextStreamHandle();
newsong = true;
}
} |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Sat Jan 06, 2007 1:44 pm Post subject: |
|
|
To explain the problem by saying that I get "overhearing" between the channels was not a good way of putting it. The sound isn't mixed it's "chopped", for a split second you hear a different channel (mount) than the one you have choosen and in the next split second you hear the one choosen again. But like I said the problem only occurs when I stream in separate threads, if the code is moved to separate processes the problem disappear.
Toni |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Sat Jan 06, 2007 3:39 pm Post subject: |
|
|
we know per shout_t seperation works because apps like ices 0.4 and ices 2 work within the same process, in the latter case, with threads as well.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Sat Jan 06, 2007 4:01 pm Post subject: |
|
|
Is there anything other than setting up the connection to the icecast server and make calls to shout_send and shout_sync that you have to do when you stream in a thread?
Toni |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Sun Jan 07, 2007 3:22 pm Post subject: |
|
|
I've studied the source code for both ices-0.4 and ices-2. ice 0.4 is not threaded. Ices-2 doesn't use shout_send and shout_sync, it uses shout_send_raw and has it's own timing implementation. libshout shout_send and shout_sync doen't seem to work properly in a threaded environment. I had to leave my threaded solution for the "heavier" process solution
Toni |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Sun Jan 07, 2007 3:42 pm Post subject: |
|
|
What is your reasoning for shout_sync not being thread safe?, after all it doesn't deal with any stream data, it only sleeps for a duration. shout_send_raw is called by shout_send, the latter does timing checks for the shout_sync to work on.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Tue Jan 09, 2007 7:43 am Post subject: |
|
|
Finally found the solution . Came back to work and tested my multithreaded solution and couldn't repeat the problems. So after comparing my environments at home and in the office a found that I was using VS6SP3 at home and VS6SP6 at work. After installing VS6SP6 the problem goes away! |
|
| Back to top |
|
 |
|