3
Copyright (C) 1999 Martin Vogt
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.
9
For more information look at the file COPYRIGHT in this package
14
#include "outputStream.h"
15
#include "../util/mmx.h"
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
26
abs_thread_mutex_init(&stateChangeMut);
27
abs_thread_cond_init(&stateChangeCond);
35
OutputStream::~OutputStream() {
38
abs_thread_cond_destroy(&stateChangeCond);
39
abs_thread_mutex_destroy(&stateChangeMut);
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);
51
int OutputStream::audioSetup(int ,int ,
53
sendSignal(_STREAM_MASK_IS_INIT,true,_STREAMTYPE_AUDIO);
58
int OutputStream::audioPlay(TimeStamp* ,
59
TimeStamp* ,char* , int len) {
60
sendSignal(_STREAM_MASK_IS_DATA,true,_STREAMTYPE_AUDIO);
64
void OutputStream::audioFlush() {
65
sendSignal(_STREAM_MASK_IS_EOF,true,_STREAMTYPE_AUDIO);
69
void OutputStream::audioClose() {
70
cerr << "direct virtual call OutputStream::audioClose"<<endl;
74
void OutputStream::audioOpen() {
75
cerr << "direct virtual call OutputStream::audioOpen"<<endl;
81
void OutputStream::sendSignal(int signal,int value,int streamType) {
82
abs_thread_mutex_lock(&stateChangeMut);
83
int* modifyState=NULL;
85
case _STREAMTYPE_AUDIO:
86
modifyState=&audioState;
88
case _STREAMTYPE_VIDEO:
89
modifyState=&videoState;
92
cout << "unknown streamType:"<<streamType
93
<<" in OutputStream::sendSignal"<<endl;
96
// should we set the bit?
101
// we should remove the bit
102
// is it currently set?
103
if (*modifyState & signal) {
105
*modifyState-=signal;
110
abs_thread_cond_signal(&stateChangeCond);
111
abs_thread_mutex_unlock(&stateChangeMut);
116
int OutputStream::getPreferredDeliverSize() {
117
cerr << "direct virtual call OutputStream::getPreferredDeliverSize()"<<endl;
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);
128
int OutputStream::openWindow(int , int ,const char* ) {
129
sendSignal(_STREAM_MASK_IS_INIT,true,_STREAMTYPE_VIDEO);
134
void OutputStream::closeWindow() {
135
cerr << "direct virtual call OutputStream::closeWindow"<<endl;
139
void OutputStream::flushWindow() {
140
sendSignal(_STREAM_MASK_IS_EOF,true,_STREAMTYPE_VIDEO);
144
PictureArray* OutputStream::lockPictureArray() {
145
cerr << "direct virtual call OutputStream::lockPictureArray"<<endl;
151
void OutputStream::unlockPictureArray(PictureArray* ) {
152
sendSignal(_STREAM_MASK_IS_DATA,true,_STREAMTYPE_VIDEO);
159
int OutputStream::getOutputInit() {
160
cerr << "direct virtual call OutputStream::getOutputInit"<<endl;
166
void OutputStream::setOutputInit(int lInit) {
167
cerr << "direct virtual call OutputStream::setOutputInit:"<<lInit<<endl;
173
void OutputStream::writeInfo(PluginInfo* ) {
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);
187
int OutputStream::getFrameusec() {
188
cerr << "direct virtual call OutputStream::getFrameusec"<<endl;
194
int OutputStream::waitStreamState(int method,int mask,int streamType) {
198
case _STREAMTYPE_AUDIO:
199
waitState=&audioState;
201
case _STREAMTYPE_VIDEO:
202
waitState=&videoState;
205
cout << "unknown streamType:"<<streamType
206
<<" in OutputStream::waitStreamState"<<endl;
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);
217
abs_thread_mutex_unlock(&stateChangeMut);
222
if (method == _OUTPUT_WAIT_METHOD_POLL) {
223
abs_thread_mutex_lock(&stateChangeMut);
225
abs_thread_mutex_unlock(&stateChangeMut);
228
cout << " OutputStream::waitStreamState method not implemented"<<endl;