summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/output/threadSafeOutputStream.cpp
blob: ec7ab510278c9e6944a6cb11716248fdaaf5a881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
  thread safe wrapper for output Stream
  Copyright (C) 2000  Martin Vogt

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Library General Public License as published by
  the Free Software Foundation.

  For more information look at the file COPYRIGHT in this package

 */


#include "threadSafeOutputStream.h"


ThreadSafeOutputStream::ThreadSafeOutputStream(OutputStream* output) {
  threadQueueAudio=new ThreadQueue();
  threadQueueVideo=new ThreadQueue();
  this->output=output;
}


ThreadSafeOutputStream::~ThreadSafeOutputStream() {
  delete threadQueueAudio;
  delete threadQueueVideo;
  delete output;
}

int ThreadSafeOutputStream::audioInit() {
  int back;
  threadQueueAudio->waitForExclusiveAccess();
  back=output->audioInit();
  threadQueueAudio->releaseExclusiveAccess();
  return back;
}


int ThreadSafeOutputStream::audioSetup(int freq,int stereo,
				       int sign,int big,int sampleSize) {
  int back;
  threadQueueAudio->waitForExclusiveAccess();
  back=output->audioSetup(freq,stereo,sign,big,sampleSize);
  threadQueueAudio->releaseExclusiveAccess();
  return back; 
}


int ThreadSafeOutputStream::audioPlay(TimeStamp* start,
				      TimeStamp* end,char* buf, int len) {
  int back;
  threadQueueAudio->waitForExclusiveAccess();
  back=output->audioPlay(start,end,buf,len);
  threadQueueAudio->releaseExclusiveAccess();
  return back;
}

void ThreadSafeOutputStream::audioFlush() {
  threadQueueAudio->waitForExclusiveAccess();
  output->audioFlush();
  threadQueueAudio->releaseExclusiveAccess(); 
}


void ThreadSafeOutputStream::audioClose() {
  threadQueueAudio->waitForExclusiveAccess();
  output->audioClose();
  threadQueueAudio->releaseExclusiveAccess();  
}

void ThreadSafeOutputStream::audioOpen() {
 threadQueueAudio->waitForExclusiveAccess();
 output->audioOpen();
 threadQueueAudio->releaseExclusiveAccess();    
}



int ThreadSafeOutputStream::getPreferredDeliverSize() {
  int back;
  threadQueueAudio->waitForExclusiveAccess();
  back=output->getPreferredDeliverSize();
  threadQueueAudio->releaseExclusiveAccess();
  return back;  
}

int ThreadSafeOutputStream::videoInit() {
  int back;
  threadQueueVideo->waitForExclusiveAccess();
  back=output->videoInit();
  threadQueueVideo->releaseExclusiveAccess();
  return back; 
}

int ThreadSafeOutputStream::openWindow(int w, int h,const char* title) {
  int back;
  threadQueueVideo->waitForExclusiveAccess();
  back=output->openWindow(w,h,title);
  threadQueueVideo->releaseExclusiveAccess();
  return back; 
}


void ThreadSafeOutputStream::closeWindow() {
  threadQueueVideo->waitForExclusiveAccess();
  output->closeWindow();
  threadQueueVideo->releaseExclusiveAccess();
}

void ThreadSafeOutputStream::flushWindow() {
  threadQueueVideo->waitForExclusiveAccess();
  output->flushWindow();
  threadQueueVideo->releaseExclusiveAccess(); 
} 


PictureArray* ThreadSafeOutputStream::lockPictureArray() {
  PictureArray* back;
  threadQueueVideo->waitForExclusiveAccess();
  back=output->lockPictureArray();
  threadQueueVideo->releaseExclusiveAccess();
  return back; 
}


void ThreadSafeOutputStream::unlockPictureArray(PictureArray* array) {
  threadQueueVideo->waitForExclusiveAccess();
  output->unlockPictureArray(array);
  threadQueueVideo->releaseExclusiveAccess();
}


int ThreadSafeOutputStream::getFrameusec() {
  int back;
  threadQueueVideo->waitForExclusiveAccess();
  back=output->getFrameusec();
  threadQueueVideo->releaseExclusiveAccess();
  return back;  
}

void ThreadSafeOutputStream::config(const char* key,
				    const char* value,void* user_data) {

  threadQueueVideo->waitForExclusiveAccess();
  threadQueueAudio->waitForExclusiveAccess();
  output->config(key,value,user_data);
  threadQueueVideo->releaseExclusiveAccess();
  threadQueueAudio->releaseExclusiveAccess();
  
}