|
|
I have to compute it myself on the paper without any program. but I cant do it,could you help me please?
|
|
|
|
|
Then you are probably wanting to compute Big O notation, and you can find a really great answer here:
http://stackoverflow.com/questions/3255/big-o-how-do-you-calculate-approximate-it[^]
Big O notation was developed to give a machine independent view of the performance of a piece of code. Since "performance" depends greatly upon what you run it on (your code would be slow on a 386 but fast on a i7-4ghz), there needs to be a way to calculate relative performance. That is what Big O was designed for and it is a very difficult concept to grasp.
|
|
|
|
|
in first program you use more variable
|
|
|
|
|
Hello gurus,
I have posted few questions here basically pussyfooting around the real issue and hoping to learn more about Windows events in the process. So this is almost a re-post. Sorry.
The real issue is with waveOutWrite and assertion of the header flags _ particularity the “loop” WHDR_DONE flag.
I can use event but have no idea how it actually works.
I just cannot believe that the only “option” is plain while / do time wasting loop.
I am looking for this flag to signal end of audio in a few seconds, so I feel doing while loop for such long time is really goofy.
while((pcm[i].whdr.dwFlags & 1) != 1)
{
TRACE("\nWaiting.. %i ",mSeconds );
;
}
I am open to any other solution.
Thanks for your help.
Cheers
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: I can use event but have no idea how it actually works.
...
I am open to any other solution. Any other solution such as?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I guess I was looking for "magic".
I will combine timer and the while loop and call it good.
|
|
|
|
|
Vaclav_Sal wrote: I guess I was looking for "magic". If you have a solution but have no idea how it works, that's pretty "magical" I'd say.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
mknod(pItem->handler,(S_IRWXU|S_IRWXG|S_IRWXO|S_IFCHR),MKDEV(pItem->nMajor,pItem->nMinor))
is failing with errno 2. Here handler is ~/seq. However I'm running the program with super user.
Any Help would be appreciated.
Thanks,
Sunil
|
|
|
|
|
|
This book will quickly show you (by full example) how to create fully functional WPF applications using C#, XAML, and Visual Studio 2010 or 2012, SQL Server 2012, LINQ, Entity Framework, and the DataGrid
|
|
|
|
|
I have a worker thread running and would like to notify the main thread about changes in the worker thread. Call it synchronization if you prefer that.
I understand “wait for event” does not load CPU (much or nil ) , per documentation.
<b>But if this is a worker thread of low priority would plain while / do loop load on CPU be also OK? </b>
Since I know approximately how often ( in seconds) the event occurs I could use timer also.
The notification is asynchronous, not real time critical.
Any comments on that?
Cheers
Vaclav
|
|
|
|
|
Even though the thread might be low priority, it will still cause 100% cpu usage. I would recommend strongly against it.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I think loop is the worst plan, it waste a lot of CPU cycle.
timer is OK
and sometime thread is a good solution
|
|
|
|
|
BTW, why do you want to wait on the worker thread? I simply don't understand this. Usually when a worker finishes with something you want to send an event to the "owner" of the worker thread immediately.
do-loop / "spinning" is almost always a bad advice. Spinning is usually acceptable only in the form of a spin lock in some special cases of locking where it can terribly outperform normal locks.
Thread priorities: Don't mess with thread priorities. Especially if your software is crossplatform. The best is to run everything on normal priority in most user space applications. In some cases setting the priority of some background data-loader threads to lower priority can help making the gui interaction smoother (usually if the machine is single-cpu and the IO terribly blocks on the background thread for some reason).
What does the main thread do? Is it prepared for the event? Your job would be pretty easy if the main thread would be a gui thread or some other kind of thread that processes jobs/tasks from a blocking message queue.
Timer??? Why do you need a timer and on which thread? Why don't you want to send the event from the worker thread immediately?
|
|
|
|
|
The main thread initialize worker thread whose job is to "send" timed audio to the main thread for processing (FFT). It is a test application, eventually it will be receiving real time data - audio - hence real time thread usage which will be time critical.
I just posted a similar question, maybe that will explain why I do this such convoluted way.
The key is how to monitor the WHDR_DONE flag which gets set AFTER the audio write is started / processed.
In other words - I am missing the "link" between waveOutWrite and WHDR_DONE.
<b>waveOUtWrite by itself does not wait for the WHDR_DONE flag to set. </b>
|
|
|
|
|
Well, I'm not familiar with that function call but it seems to me that the signaling of the completion of the data transfer is very primitive in this case and it seems that you will have to poll the flag. If its all about the right polling technique then... Depending on the architecture you may have to use at least an "acquire" memory barrier on the thread that polls the flag in order to notice the change in time. You start writing out a wave data chunk that is enough for the hardware for at least X milliseconds so your poll interval should probably be less than X/2 milliseconds to be successful but if the hardware has enough free buffer space then the transfer may complete in much shorter ("nearly zero"...) time then X milliseconds. If the precision of the OS scheduler is good enough then you can avoid busy-wait (do-loop) polling of the bit by sleeping for short periods between doing single-polls. If the OS scheduler isn't precise enough (for example because it can't put your thread to sleep state for shorter period then your Y poll period) then you have to do busy-waiting. Avoid busy waiting if possible, for example by writing out a large chunk that contains more than S*2 milliseconds of data if the period of the OS scheduler is S if possible. That way you can avoid busy waiting by polling this way: Sleep(S), check the flag, Sleep(S), check the flag,... This wont spin your poll thread. There are some situations when the only solution is spinning depending on the scenario but often it isn't.
|
|
|
|
|
Vaclav_Sal wrote: I have a worker thread running and would like to notify the main thread about changes in the worker thread. See the PostMessage() comments here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks.
It helps academically , I hope, but does not solve the stupid flag issue.
|
|
|
|
|
I'm in the mid of my project.
My task is to create an RTP server that can stream a file using ffmpeg in VC++. I got the ffmpeg.c but its complicate to understand for me. However I can:
Open the file using ffmpeg and can read it or can read the frames those are to be transmitted using VC++
But I'm not getting any way to stream it.
Please share your Experience and suggestions.
Thanks!
|
|
|
|
|
i've just doing a project like yours. i have refer to live555.com for my server and rtp directshow filter for my client
|
|
|
|
|
Thanks for giving time on this thread.
If you don't mind,will you please share some code snippet? so that I can understand better.
|
|
|
|
|
please help me to color the Subitem text of CListCtrl .
I m derived a Class from CListCtrl and write a code on its Custom draw but its not color the ListCtrl subitem text color
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF clrNewTextColor, clrNewBkColor;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
CString strTemp="";
if(pLVCD->iSubItem==8)
{
strTemp = GetItemText(nItem,pLVCD->iSubItem);
if(strTemp == "Y")
{
clrNewTextColor = RGB(0,0,255);
clrNewBkColor = RGB(255,255,255);
}
else
{
clrNewTextColor = RGB(0,0,0);
clrNewBkColor = RGB(255,255,255);
}
}
else
{
clrNewTextColor = RGB(0,0,0); clrNewBkColor = RGB(255,255,255); }
pLVCD->clrText = clrNewTextColor;
pLVCD->clrTextBk = clrNewBkColor;
*pResult = CDRF_DODEFAULT;
}
please help me correct me where I am wrong
|
|
|
|
|
Le@rner wrote: ...but its not color the ListCtrl subitem text color What color is it? What color do you want it to be?
What is the value of pLVCD->nmcd.dwDrawStage ? Of pLVCD->iSubItem ? Of strTemp ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
When changing colors, you must return CDRF_NEWFONT to notify the control that they has been changed (see last sentence at MSDN article Using Custom Draw[^]).
|
|
|
|