![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Hobbyist Programmer
|
Re: Streaming Audio over network
What are the problems?
|
|
|
|
|
|
#12 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 249
Rep Power: 4
![]() |
Re: Streaming Audio over network
The playback is extremely choppy, it is as if each chunk is playing several times before moving on to the next chunk in the list.
|
|
|
|
|
|
#13 |
|
Hobbyist Programmer
|
Re: Streaming Audio over network
Have you thought about making it so it has to have 5 items in the list before it's able to play? or something of that sort and when it plays an item it removes it, once the list is empty it puts it on hold.
|
|
|
|
|
|
#14 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 816
Rep Power: 4
![]() |
Re: Streaming Audio over network
You need to change your queueing code a bit. consider this code:
DWORD WINAPI FillOutput(LPVOID lpParameter)
{
char data[1024];
int addrlen=sizeof(sin);
while(true)
{
if(Out < MAX_BUFFERS)
{
for(b=0; b<=(MAX_BUFFERS-Out); b++)
{
recvfrom(client,data,sizeof(data),0,(struct sockaddr*)&sin,&addrlen);
strcpy(OutQueue[b].data,data);
Out++;
}
}
}
return 0;
}What you can do for a queue in a fixed buffer is to have a start index and an end index - both of these can just keep incrementing until they hit the OutQueue size and wrap back to the 0. You only need to play something if the start and end indexes are at different values. Write your data to the end index and increment, read your data for playing from the start index and increment. You will still need to handle the case when you have too much data (e.g. the end index catches up with the start). I hope that makes sense - I too afraid to re-read it ![]() |
|
|
|
|
|
#15 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 249
Rep Power: 4
![]() |
Re: Streaming Audio over network
Thanks for the solution Dark, im looking into it now.
|
|
|
|
|
|
#16 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 249
Rep Power: 4
![]() |
Re: Streaming Audio over network
Ok so this is what your saying Dark:
I create two variables, lets say StartIndex and EndIndex, and every time I add a buffer to the queue I increment these values. So it might look something like this: c++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#17 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 816
Rep Power: 4
![]() |
Re: Streaming Audio over network
Not quite. It might be better to call the variables WriteIndex and ReadIndex. When you write into the buffer, increment WriteIndex. When you read from the buffer, increment ReadIndex. When ReadIndex and WriteIndex have the same value, there is nothing in the buffer to read.
You don't need the inner for loop as the outer while loop takes care of everything. Something like (untested): c++ Syntax (Toggle Plain Text)
The "% MAX_BUFFERS" is to wrap the index back to zero if it goes past the end of the queue buffer. |
|
|
|
|
|
#18 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 249
Rep Power: 4
![]() |
Re: Streaming Audio over network
Ok, thank you for the clarification.
|
|
|
|
|
|
#19 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 249
Rep Power: 4
![]() |
Re: Streaming Audio over network
I have done some re-coding using the suggestions but am still having problems. When I start the application and press the talk button, the program exits. Here is the code:
c++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#20 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 816
Rep Power: 4
![]() |
Re: Streaming Audio over network
You have two separate queues, input and output, so you will need two separate sets of ReadIndex and WriteIndex. It may even be worth making a queue class so you don't have to have the same code twice.
Also your PLayOutput and SendInput functions both use the variable a without setting a value into it. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Network Simulator design | renato | Software Design and Algorithms | 2 | Dec 11th, 2007 10:54 PM |
| An Audio and Video class for ruby | Master | Ruby | 3 | Mar 24th, 2006 5:49 AM |
| Streaming audio songs? | java_roshan | Coder's Corner Lounge | 1 | Oct 27th, 2005 1:35 PM |
| Code Request - Onboard Audio | Meecher | Other Programming Languages | 7 | Sep 20th, 2005 1:53 AM |
| Checking source codes of image, audio and video files | on_auc | C++ | 3 | Feb 21st, 2005 8:36 PM |