|
|
Hi, if somebody could just give a look at this code :
Iknow it's not C++, it's only C....
I don't know what I do wrong....
Thanks a lot
Starn
[code]
/* This little piece of code initiate 2 queue
**First queue is filled of empty buffers
**second queue is filled with the full buffers
**PROBLEM : I can only fill the 2 first buffers in the FOR loop
** queueX.h contains the TAILQ macros. (see after the main function...)
*/
//I know, I don't need all these includes... (it's for other functions...)
#include <stdio.h>
#include <unistd.h>
#include <atomic.h>
#include <malloc.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_types.h>
#include <netinet/in.h>
#include <sys/syspage.h>
#include <sys/neutrino.h>
#include <syslog.h>
#include <sys/dispatch.h>
#include <sys/io-net.h>
#include <string.h>
#include <stdbool.h>
#include<sys/queueX.h>
#define NB_BY 192 // 192 bytes = 1536 bits = 2x 48 échantillons de 16 bits car 1 ms = 2 x 48 ech à 48000Hz
int msg_thread_send;
TAILQ_HEAD(buffers,entry) head;
struct buffers *headp;
struct entry{
char data[NB_BY];
TAILQ_ENTRY(entry) entries;
} *n1, *n2, *n3,*n4,*n5, *np,*sendp,*ready_sendp;
TAILQ_HEAD(send,entry) head_send;
struct send *head_sendp;
int main()
{
FILE *file1;
int i, file_size;
if ((file1 = fopen ("/home/s_16_44.wav", "r")) == 0)
printf ("can not open file\n ");
fseek(file1, 0, SEEK_END);
file_size=ftell(file1);
fseek(file1, 48, SEEK_SET);
TAILQ_INIT (&head);
TAILQ_INIT (&head_send);
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
TAILQ_INSERT_HEAD(&head, n1, entries);
n2 = malloc(sizeof(struct entry)); /* Insert at the tail. */
TAILQ_INSERT_AFTER(&head, n1,n2, entries);
//TAILQ_INSERT_TAIL(&head, n1, entries);
n3 = malloc(sizeof(struct entry)); /* Insert at the tail. */
TAILQ_INSERT_AFTER(&head, n2,n3, entries);
//TAILQ_INSERT_TAIL(&head, n4, entries);
n4 = malloc(sizeof(struct entry)); /* Insert at the tail. */
TAILQ_INSERT_AFTER(&head,n3, n4, entries);
//TAILQ_INSERT_TAIL(&head, n4, entries);
n5 = malloc(sizeof(struct entry)); /* Insert at the tail. */
TAILQ_INSERT_TAIL(&head, n5, entries);
for (np = head.tqh_first; np != NULL; np = np->entries.tqe_next)
{
fread(np->data,NB_BY,1,file1);
if(np=head.tqh_first)
{
TAILQ_INSERT_HEAD(&head_send, np, entries);
printf("insert_head\n");
}
else
TAILQ_INSERT_TAIL(&head_send, np, entries);
printf("insert_queue\n");
}
np=head.tqh_first;
//ready_sendp=head_send.tqh_first;
// ICI, démarrer le thread_send
while(1)
{
if(msg_thread_send) //tant que le thread_send n'a pas mis ce bit à , il n'y a pas de buffer de libre
{
fread(np->data,NB_BY,1,file1);
// if(j>4)
//{
TAILQ_INSERT_TAIL(&head_send, np, entries);
//voir si il ne faut pas retirer le premier élément de la queue_send (memory leacks) ca devrait être arrangé avec TAILQ_REMOVE
np = np->entries.tqe_next;
msg_thread_send=0;
}
if( np == NULL) //si on est au bout de la queue, on revient au début...
np=head.tqh_first;
}
// printf("data : %c\n",n1->data);
fclose(file1);
return(0);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* Tail queue declarations.
*/
#define TAILQ_HEAD(name, type) \
struct name { \
struct type *tqh_first; /* first element */ \
struct type **tqh_last; /* addr of last next element */ \
}
#define TAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first }
#define TAILQ_ENTRY(type) \
struct { \
struct type *tqe_next; /* next element */ \
struct type **tqe_prev; /* address of previous next element */ \
}
/*
* Tail queue functions.
*/
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
#define TAILQ_FIRST(head) ((head)->tqh_first)
#define TAILQ_FOREACH(var, head, field) \
for ((var) = TAILQ_FIRST((head)); \
(var); \
(var) = TAILQ_NEXT((var), field))
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for ((var) = TAILQ_LAST((head), headname); \
(var); \
(var) = TAILQ_PREV((var), headname, field))
#define TAILQ_INIT(head) do { \
TAILQ_FIRST((head)) = NULL; \
(head)->tqh_last = &TAILQ_FIRST((head)); \
} while (0)
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
TAILQ_NEXT((elm), field)->field.tqe_prev = \
&TAILQ_NEXT((elm), field); \
else \
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
TAILQ_NEXT((listelm), field) = (elm); \
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
} while (0)
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
TAILQ_NEXT((elm), field) = (listelm); \
*(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
} while (0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
TAILQ_FIRST((head))->field.tqe_prev = \
&TAILQ_NEXT((elm), field); \
else \
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
TAILQ_FIRST((head)) = (elm); \
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
} while (0)
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
TAILQ_NEXT((elm), field) = NULL; \
(elm)->field.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
} while (0)
#define TAILQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last))
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
#define TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
#define TAILQ_REMOVE(head, elm, field) do { \
if ((TAILQ_NEXT((elm), field)) != NULL) \
TAILQ_NEXT((elm), field)->field.tqe_prev = \
(elm)->field.tqe_prev; \
else \
(head)->tqh_last = (elm)->field.tqe_prev; \
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
} while (0)
[/code]
|
|
|
|
|
Hi,
I have a COM Interface where I want to define a method which returns a class pointer but it's giving MIDL2025/MIDL2026 error. If any one has any idea plz help me.
Uttam
Regards;
Uttam Kumar
|
|
|
|
|
What does your IDL code look like that you are trying to compile?
One other thing, if you return a C++ class pointer then you will not be able to use your COM object in any other language than C++, are you sure that is what you want to do?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi Kilowatt,
Thanks for ur knid and quick response. Yes Kilowatt I'm using C++ client only and want to see the structure of IDL file. In fact I'm trying to do something similar to
[id(2), helpstring("method GetSeExceptionPtr")] HRESULT GetSeExceptionPtr([out,retval]CSeException *pSe); // Where CSeException is a C++ class in my IDL file but it's giving error code MIDL/2025/2026.
Plz help me and if possible plz send me a block of code too.
Thanks for giving time once again.
Regards;
Uttam Kumar
Regards;
Uttam Kumar
Senior Development Engineer
Omitec Information Services Ltd.
Mobile : +44 (0)77 5494 2930
Direct line : +44 (0)24 7660 8508
Direct Fax : +44 (0)24 7660 8501
e-mail : uttam.kumar@omitec.com
Website : www.omitec.com
|
|
|
|
|
does your class need to have methods? If not, you could make up a IDL structure. If you need methods, make up an interface. I don't think this is a good idea to pass C++ classes betweeen interfaces, even if the client and the server are both in C++.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
This should be simple.....you would think
I have a listbox with LBS_SORT, and adding item to it with LBS_ADDSTRING.
But the items are *not* sorted!?
Someone got a clue to why this is happening?
The LBS_SORT is set in the dlg editor.
I have verified with spy++ that it is set.
The listbox is NOT ownerdraw.
(and i dont get any WM_COMPAREITEM calls, which i shouldn't get either)
/Magnus
|
|
|
|
|
Hi there,
I'm writing a gdi game ...
I used WM_MOUSEDOWN - WM_MOUSEUP - WM_MOUSEMOVE events for darging and droping ...
I have still problem for solving flickering image
The problem is it, when i drag-drop my bitmap in the dialog, image has flickering problem !!!
I drew the image in OnPaint()
I redraw that by InvalidateRect function ...
Could u help me please !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
There are many solutions to flickering. Likely, your biggest problem is that your WM_ERASEBKGRND is drawing a white rectangle everytime you invalidate, and before you repaint your image. Override WM_ERASEBKGRND and do something more intelligent.
Another option are Memory DC's, which you can draw into and then blit into your physical DC all at once. There are several samples of both here at CP.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Thanks aloooooooot for ur reply
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hello again
I have just one other problem about OnEraseBkgnd event !
Right now, i solved my pervious problem that was about Flickering image in the dialog by returning FALSE in that message !!!
Now, i want to know how could i refresh the image in each movement ?!!!
Because, i can't use Invalidate() or InvalidateRect() functions ...
Could u help me in it, please
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I agree with Erik, the problem is more than likely going to be WM_ERASEBKGRND which you must override and probably just return false. However, I think a better solution completely would be to use the DirectX SDK if your writing your own game. Its much faster than GDI because you can access your graphics hardware to deal with all the drawing, and can eliminate flickering by updating the monitor when the vertical blank occurs (if you wanted to). The drawback is its more complicated to implement than GDI (you need to know about backbuffers, surfaces and flipping), oh, and the version 8 SDK is about 180Mb, if your on a 56k modem you could go days without using the telephone line .
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Hello
Thanks for ur reply and ur advice about OnEraseBackground message ...
and about DirectX, right now i have an article about it in my homepage ...
But unfortunly i have to write 20 game projects in only TWO months
So, i have to write FAST code
Anyway, thanks !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hello again
I have just one other problem about OnEraseBkgnd event !
Right now, i solved my pervious problem that was about Flickering image in the dialog by returning FALSE in that message !!!
Now, i want to know how could i refresh the image in each movement ?!!!
Because, i can't use Invalidate() or InvalidateRect() functions ...
Could u help me in it, please
(Please reply FAST, ASAP)
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
When you say "refresh the image in each movement" what exactly do you mean? are you trying to create an animation? If you are trying to do something like this with GDI, its probably your best bet to create a memory DC and draw/update that DC to your liking before blitting the final result on to the screen DC (no flickering). This should have the effect of movement (so long as you do it right of course). I'd imagine there would need to be some kind of timer to keep track of when the image is needing refreshment but I'm not sure on that kind of stuff (I've never made a game using GDI). If I've waffled on about the wrong thing feel free to reply. Oh, cheers for your article on DirectX, I'm reading it as we speak, very interesting.
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
ok, let me talking about my game ...
It's a Card game like Solitaire in windows os.
User can drag & drop cards in the game ...
So, i must redraw the image in each movement, ok ?
I mean i have to refresh image in MOUSE MOVE event ...
How ?
How can i do it ?
PS: Thx, i'll write about DirectDraw and D3D
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Right, ok, I have an idea, but since I've never done this it will remain an idea till it gets proven one way or the other. I know there is an event OnMouseMove(UINT flags, CPoint pos) that processes the WM_MOUSEMOVE message and is triggered when you move the mouse - obviously. You can test if the left mouse button is being held down by checking the flags for MK_LBUTTON. The event will give you the (x,y) coordinates of the mouse in a CPoint structure to which you can draw the card (whether these (x,y) coordinates represent the top left, middle, bottom right of the card is up to you - I know you know all this so far, but its just for the benefit of others who may want to do it). Now heres the good part, you need to create a memory DC to work with. Without this you WILL get flickering from a screen that is getting regularly drawn to. Something like this MAY work (I'm very rusty on this ):
CDC dcMem;
dcMem.CreateCompatibleDC(GetDC());
OK so you have a background DC (similar to the DirectDraw backbuffer), select your background bitmap into ANOTHER DC (not screen) and blit to the memDC(start afresh) with SRCCOPY flag. Then select your card bitmap into the extra DC and blit it again with but this time to the (x,y) coordinate of the memory DC. Finally blit the memory DC to the screen and you should find it keeps redrawing the card image as you move the mouse (providing your custom tests are met). I'm not sure how fast or smooth this solution is likely to be, but I'd like to know (if it works or not at all too).
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
How do you call Windiff from with in a program and specify the two files that you want compared.
In the help of WinDiff it tells about
Invoking Windiff from the command line
To compare two files
Windiff path_to_first_file path_to_second_file
How do i implement this?
Thanks
Scott
|
|
|
|
|
Use CreateProcess() and absolute paths to Windiff executable and files to compare.
|
|
|
|
|
Works great, thanks
The only problem is, that it doesn't like the paths passes in the command line if they have spaces. Is there a way to convert them to a DOS style with a tilda or something else?
Scott
|
|
|
|
|
It used to work for me as well, with no problem. Check documentaion again (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_9dpv.asp) and possibly try to use lpApplicationName only to specify path and parameters.
|
|
|
|
|
It does open up Windiff correctly but the problem is that why i send in the files to compare "C:\My Documents\test.h C:\My Documents\test2.h" it tells me that it can not open the file "C:\My"
It works if the directories don't have spaces in them.
Scott
|
|
|
|
|
I am sorry, I understood you wrong. You can convert path with spaces into its short version with this function:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/filesio_0cyt.asp
|
|
|
|
|
thanks, that's what i needed
Scott
|
|
|
|
|
I think it's better to just quote ("") the two paths than to re-introduce the horrible 8.3 limits again.
|
|
|
|
|