~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/output/outputStream.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  generic output class
 
3
  Copyright (C) 1999  Martin Vogt
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU Library General Public License as published by
 
7
  the Free Software Foundation.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
#include "outputStream.h"
 
15
#include "../util/mmx.h"
 
16
 
 
17
 
 
18
 
 
19
OutputStream::OutputStream() {
 
20
  // we call mm_support() here because it is the only position
 
21
  // where we gurantee that not threads are
 
22
  // running (the call is not thread safe)
 
23
  // afer the call we never execute the asm part again
 
24
  // and everything is fine
 
25
  mm_support();
 
26
  abs_thread_mutex_init(&stateChangeMut);
 
27
  abs_thread_cond_init(&stateChangeCond);
 
28
 
 
29
  audioState=0;
 
30
  audioInit();
 
31
  videoInit();
 
32
}
 
33
 
 
34
 
 
35
OutputStream::~OutputStream() {
 
36
  audioInit();
 
37
  videoInit();
 
38
  abs_thread_cond_destroy(&stateChangeCond);
 
39
  abs_thread_mutex_destroy(&stateChangeMut);
 
40
}
 
41
 
 
42
 
 
43
int OutputStream::audioInit() {
 
44
  sendSignal(_STREAM_MASK_IS_INIT,false,_STREAMTYPE_AUDIO);
 
45
  sendSignal(_STREAM_MASK_IS_EOF,false,_STREAMTYPE_AUDIO);
 
46
  sendSignal(_STREAM_MASK_IS_DATA,false,_STREAMTYPE_AUDIO);
 
47
  return true;
 
48
}
 
49
 
 
50
 
 
51
int OutputStream::audioSetup(int ,int ,
 
52
                             int ,int ,int ) {
 
53
  sendSignal(_STREAM_MASK_IS_INIT,true,_STREAMTYPE_AUDIO);
 
54
  return true;
 
55
}
 
56
 
 
57
 
 
58
int OutputStream::audioPlay(TimeStamp* ,
 
59
                            TimeStamp* ,char* , int len) {
 
60
  sendSignal(_STREAM_MASK_IS_DATA,true,_STREAMTYPE_AUDIO);
 
61
  return len;
 
62
}
 
63
 
 
64
void OutputStream::audioFlush() {
 
65
  sendSignal(_STREAM_MASK_IS_EOF,true,_STREAMTYPE_AUDIO);
 
66
}
 
67
 
 
68
 
 
69
void OutputStream::audioClose() {
 
70
  cerr << "direct virtual call OutputStream::audioClose"<<endl;
 
71
  exit(0);
 
72
}
 
73
 
 
74
void OutputStream::audioOpen() {
 
75
  cerr << "direct virtual call OutputStream::audioOpen"<<endl;
 
76
  exit(0);
 
77
}
 
78
 
 
79
 
 
80
 
 
81
void OutputStream::sendSignal(int signal,int value,int streamType) {
 
82
  abs_thread_mutex_lock(&stateChangeMut);
 
83
  int* modifyState=NULL;
 
84
  switch(streamType) {
 
85
  case _STREAMTYPE_AUDIO:
 
86
    modifyState=&audioState;
 
87
    break;
 
88
  case _STREAMTYPE_VIDEO:
 
89
    modifyState=&videoState;
 
90
    break;
 
91
  default:
 
92
    cout << "unknown streamType:"<<streamType
 
93
         <<" in OutputStream::sendSignal"<<endl;
 
94
    exit(0);
 
95
  }
 
96
  // should we set the bit?
 
97
  if (value==true) {
 
98
    // set it with "or"
 
99
    *modifyState|=signal;
 
100
  } else {
 
101
    // we should remove the bit
 
102
    // is it currently set?
 
103
    if (*modifyState & signal) {
 
104
      // remove it
 
105
      *modifyState-=signal;
 
106
    }
 
107
  }
 
108
 
 
109
 
 
110
  abs_thread_cond_signal(&stateChangeCond);
 
111
  abs_thread_mutex_unlock(&stateChangeMut);
 
112
 
 
113
}
 
114
 
 
115
 
 
116
int OutputStream::getPreferredDeliverSize() {
 
117
  cerr << "direct virtual call OutputStream::getPreferredDeliverSize()"<<endl;
 
118
  return 4096;
 
119
}
 
120
 
 
121
int OutputStream::videoInit() {
 
122
  sendSignal(_STREAM_MASK_IS_INIT,false,_STREAMTYPE_VIDEO);
 
123
  sendSignal(_STREAM_MASK_IS_EOF,false,_STREAMTYPE_VIDEO);
 
124
  sendSignal(_STREAM_MASK_IS_DATA,false,_STREAMTYPE_VIDEO);
 
125
  return true;
 
126
}
 
127
 
 
128
int OutputStream::openWindow(int , int ,const char* ) {
 
129
  sendSignal(_STREAM_MASK_IS_INIT,true,_STREAMTYPE_VIDEO);
 
130
  return true;
 
131
}
 
132
 
 
133
 
 
134
void OutputStream::closeWindow() {
 
135
  cerr << "direct virtual call OutputStream::closeWindow"<<endl;
 
136
  exit(0);
 
137
}
 
138
 
 
139
void OutputStream::flushWindow() {
 
140
  sendSignal(_STREAM_MASK_IS_EOF,true,_STREAMTYPE_VIDEO);
 
141
 
142
 
 
143
 
 
144
PictureArray* OutputStream::lockPictureArray() {
 
145
  cerr << "direct virtual call OutputStream::lockPictureArray"<<endl;
 
146
  exit(0);
 
147
  return NULL;
 
148
}
 
149
 
 
150
 
 
151
void OutputStream::unlockPictureArray(PictureArray* ) {
 
152
  sendSignal(_STREAM_MASK_IS_DATA,true,_STREAMTYPE_VIDEO);
 
153
}
 
154
 
 
155
 
 
156
 
 
157
 
 
158
 
 
159
int OutputStream::getOutputInit() {
 
160
  cerr << "direct virtual call OutputStream::getOutputInit"<<endl;
 
161
  exit(0);
 
162
  return false;
 
163
}
 
164
 
 
165
 
 
166
void OutputStream::setOutputInit(int lInit) {
 
167
  cerr << "direct virtual call OutputStream::setOutputInit:"<<lInit<<endl;
 
168
  exit(0);
 
169
}
 
170
 
 
171
 
 
172
 
 
173
void OutputStream::writeInfo(PluginInfo* ) {
 
174
 
 
175
}
 
176
 
 
177
 
 
178
void OutputStream::config(const char* key,
 
179
                          const char* value,void* user_data) {
 
180
  cerr << "direct virtual call OutputStream::config"<<endl;
 
181
  printf("key:%s\n",key);
 
182
  printf("value:%s\n",value);
 
183
  printf("user_data:%p\n",user_data);
 
184
  exit(0);
 
185
}
 
186
 
 
187
int OutputStream::getFrameusec() {
 
188
  cerr << "direct virtual call OutputStream::getFrameusec"<<endl;
 
189
  return 0;
 
190
}
 
191
 
 
192
 
 
193
 
 
194
int OutputStream::waitStreamState(int method,int mask,int streamType) {
 
195
 
 
196
  int* waitState=NULL;
 
197
  switch(streamType) {
 
198
  case _STREAMTYPE_AUDIO:
 
199
    waitState=&audioState;
 
200
    break;
 
201
  case _STREAMTYPE_VIDEO:
 
202
    waitState=&videoState;
 
203
    break;
 
204
  default:
 
205
    cout << "unknown streamType:"<<streamType
 
206
         <<" in OutputStream::waitStreamState"<<endl;
 
207
    exit(0);
 
208
  }
 
209
 
 
210
  if (method == _OUTPUT_WAIT_METHOD_BLOCK) {
 
211
    abs_thread_mutex_lock(&stateChangeMut);
 
212
    while ((*waitState &= mask)==0) {
 
213
      cout << "waitStreamState:"<<waitState<<endl;
 
214
      cout << "mask:"<<mask<<endl;
 
215
      abs_thread_cond_wait(&stateChangeCond,&stateChangeMut);
 
216
    }
 
217
    abs_thread_mutex_unlock(&stateChangeMut);
 
218
    return true;
 
219
  }
 
220
    
 
221
  int back=false;
 
222
  if (method == _OUTPUT_WAIT_METHOD_POLL) {
 
223
    abs_thread_mutex_lock(&stateChangeMut);
 
224
    back=*waitState;
 
225
    abs_thread_mutex_unlock(&stateChangeMut);
 
226
    return back;
 
227
  }    
 
228
  cout << " OutputStream::waitStreamState method not implemented"<<endl;
 
229
  exit(0);
 
230
  return 0; 
 
231
}