Mercurial > libavcodec.hg
annotate os2thread.c @ 11280:fea25a6f874e libavcodec
3rd and hopefully last 100l fix.
author | michael |
---|---|
date | Wed, 24 Feb 2010 22:13:20 +0000 |
parents | d7ef6611a49e |
children | 7bfe7456e372 |
rev | line source |
---|---|
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
1 /* |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
2 * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
3 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3517
diff
changeset
|
4 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3517
diff
changeset
|
5 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3517
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3517
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
10 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3517
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
14 * Lesser General Public License for more details. |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
15 * |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3517
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
5215 | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
19 */ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
20 //#define DEBUG |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
21 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
22 // Ported by Vlad Stelmahovsky |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
23 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
24 #include "avcodec.h" |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
25 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
26 #define INCL_DOS |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
27 #define INCL_DOSERRORS |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
28 #define INCL_DOSDEVIOCTL |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
29 #include <os2.h> |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
30 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
31 typedef struct ThreadContext{ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
32 AVCodecContext *avctx; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
33 int thread; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
34 HEV work_sem; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
35 HEV done_sem; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
36 int (*func)(AVCodecContext *c, void *arg); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
37 void *arg; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
38 int ret; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
39 }ThreadContext; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
40 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
41 |
6496 | 42 void attribute_align_arg thread_func(void *v){ |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
43 ThreadContext *c= v; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
44 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
45 for(;;){ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
46 //printf("thread_func %X enter wait\n", (int)v); fflush(stdout); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
47 DosWaitEventSem(c->work_sem, SEM_INDEFINITE_WAIT); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
48 // WaitForSingleObject(c->work_sem, INFINITE); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
49 //printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
50 if(c->func) |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
51 c->ret= c->func(c->avctx, c->arg); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
52 else |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
53 return; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
54 //printf("thread_func %X signal complete\n", (int)v); fflush(stdout); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
55 DosPostEventSem(c->done_sem); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
56 // ReleaseSemaphore(c->done_sem, 1, 0); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
57 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
58 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
59 return; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
60 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
61 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
62 /** |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
63 * free what has been allocated by avcodec_thread_init(). |
5127 | 64 * must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
65 */ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
66 void avcodec_thread_free(AVCodecContext *s){ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
67 ThreadContext *c= s->thread_opaque; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
68 int i; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
69 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
70 for(i=0; i<s->thread_count; i++){ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
71 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
72 c[i].func= NULL; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
73 DosPostEventSem(c[i].work_sem); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
74 // ReleaseSemaphore(c[i].work_sem, 1, 0); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
75 DosWaitThread((PTID)&c[i].thread,DCWW_WAIT); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
76 // WaitForSingleObject(c[i].thread, INFINITE); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
77 if(c[i].work_sem) DosCloseEventSem(c[i].work_sem);//CloseHandle(c[i].work_sem); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
78 if(c[i].done_sem) DosCloseEventSem(c[i].done_sem);//CloseHandle(c[i].done_sem); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
79 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
80 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
81 av_freep(&s->thread_opaque); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
82 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
83 |
8129
a9734fe0811e
Making it easier to send arbitrary structures as work orders to MT workers
romansh
parents:
6496
diff
changeset
|
84 int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){ |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
85 ThreadContext *c= s->thread_opaque; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
86 int i; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
87 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
88 assert(s == c->avctx); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
89 assert(count <= s->thread_count); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
90 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
91 /* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
92 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
93 for(i=0; i<count; i++){ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
94 |
8129
a9734fe0811e
Making it easier to send arbitrary structures as work orders to MT workers
romansh
parents:
6496
diff
changeset
|
95 c[i].arg= (char*)arg + i*size; |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
96 c[i].func= func; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
97 c[i].ret= 12345; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
98 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
99 DosPostEventSem(c[i].work_sem); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
100 // ReleaseSemaphore(c[i].work_sem, 1, 0); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
101 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
102 for(i=0; i<count; i++){ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
103 DosWaitEventSem(c[i].done_sem,SEM_INDEFINITE_WAIT); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
104 // WaitForSingleObject(c[i].done_sem, INFINITE); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
105 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
106 c[i].func= NULL; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
107 if(ret) ret[i]= c[i].ret; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
108 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
109 return 0; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
110 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
111 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
112 int avcodec_thread_init(AVCodecContext *s, int thread_count){ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
113 int i; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
114 ThreadContext *c; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
115 uint32_t threadid; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
116 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
117 s->thread_count= thread_count; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
118 |
10954 | 119 if (thread_count <= 1) |
120 return 0; | |
121 | |
3081
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
122 assert(!s->thread_opaque); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
123 c= av_mallocz(sizeof(ThreadContext)*thread_count); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
124 s->thread_opaque= c; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
125 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
126 for(i=0; i<thread_count; i++){ |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
127 //printf("init semaphors %d\n", i); fflush(stdout); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
128 c[i].avctx= s; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
129 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
130 if (DosCreateEventSem(NULL,&c[i].work_sem,DC_SEM_SHARED,0)) |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
131 goto fail; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
132 if (DosCreateEventSem(NULL,&c[i].done_sem,DC_SEM_SHARED,0)) |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
133 goto fail; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
134 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
135 //printf("create thread %d\n", i); fflush(stdout); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
136 // c[i].thread = (HANDLE)_beginthreadex(NULL, 0, thread_func, &c[i], 0, &threadid ); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
137 c[i].thread = _beginthread(thread_func, NULL, 0x10000, &c[i]); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
138 if( c[i].thread <= 0 ) goto fail; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
139 } |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
140 //printf("init done\n"); fflush(stdout); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
141 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
142 s->execute= avcodec_thread_execute; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
143 |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
144 return 0; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
145 fail: |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
146 avcodec_thread_free(s); |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
147 return -1; |
4bf348f8e2b1
os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff
changeset
|
148 } |