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

« back to all changes in this revision

Viewing changes to mpeglib/lib/output/threadSafeOutputStream.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
  thread safe wrapper for output Stream
 
3
  Copyright (C) 2000  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 "threadSafeOutputStream.h"
 
15
 
 
16
 
 
17
ThreadSafeOutputStream::ThreadSafeOutputStream(OutputStream* output) {
 
18
  threadQueueAudio=new ThreadQueue();
 
19
  threadQueueVideo=new ThreadQueue();
 
20
  this->output=output;
 
21
}
 
22
 
 
23
 
 
24
ThreadSafeOutputStream::~ThreadSafeOutputStream() {
 
25
  delete threadQueueAudio;
 
26
  delete threadQueueVideo;
 
27
  delete output;
 
28
}
 
29
 
 
30
int ThreadSafeOutputStream::audioInit() {
 
31
  int back;
 
32
  threadQueueAudio->waitForExclusiveAccess();
 
33
  back=output->audioInit();
 
34
  threadQueueAudio->releaseExclusiveAccess();
 
35
  return back;
 
36
}
 
37
 
 
38
 
 
39
int ThreadSafeOutputStream::audioSetup(int freq,int stereo,
 
40
                                       int sign,int big,int sampleSize) {
 
41
  int back;
 
42
  threadQueueAudio->waitForExclusiveAccess();
 
43
  back=output->audioSetup(freq,stereo,sign,big,sampleSize);
 
44
  threadQueueAudio->releaseExclusiveAccess();
 
45
  return back; 
 
46
}
 
47
 
 
48
 
 
49
int ThreadSafeOutputStream::audioPlay(TimeStamp* start,
 
50
                                      TimeStamp* end,char* buf, int len) {
 
51
  int back;
 
52
  threadQueueAudio->waitForExclusiveAccess();
 
53
  back=output->audioPlay(start,end,buf,len);
 
54
  threadQueueAudio->releaseExclusiveAccess();
 
55
  return back;
 
56
}
 
57
 
 
58
void ThreadSafeOutputStream::audioFlush() {
 
59
  threadQueueAudio->waitForExclusiveAccess();
 
60
  output->audioFlush();
 
61
  threadQueueAudio->releaseExclusiveAccess(); 
 
62
}
 
63
 
 
64
 
 
65
void ThreadSafeOutputStream::audioClose() {
 
66
  threadQueueAudio->waitForExclusiveAccess();
 
67
  output->audioClose();
 
68
  threadQueueAudio->releaseExclusiveAccess();  
 
69
}
 
70
 
 
71
void ThreadSafeOutputStream::audioOpen() {
 
72
 threadQueueAudio->waitForExclusiveAccess();
 
73
 output->audioOpen();
 
74
 threadQueueAudio->releaseExclusiveAccess();    
 
75
}
 
76
 
 
77
 
 
78
 
 
79
int ThreadSafeOutputStream::getPreferredDeliverSize() {
 
80
  int back;
 
81
  threadQueueAudio->waitForExclusiveAccess();
 
82
  back=output->getPreferredDeliverSize();
 
83
  threadQueueAudio->releaseExclusiveAccess();
 
84
  return back;  
 
85
}
 
86
 
 
87
int ThreadSafeOutputStream::videoInit() {
 
88
  int back;
 
89
  threadQueueVideo->waitForExclusiveAccess();
 
90
  back=output->videoInit();
 
91
  threadQueueVideo->releaseExclusiveAccess();
 
92
  return back; 
 
93
}
 
94
 
 
95
int ThreadSafeOutputStream::openWindow(int w, int h,const char* title) {
 
96
  int back;
 
97
  threadQueueVideo->waitForExclusiveAccess();
 
98
  back=output->openWindow(w,h,title);
 
99
  threadQueueVideo->releaseExclusiveAccess();
 
100
  return back; 
 
101
}
 
102
 
 
103
 
 
104
void ThreadSafeOutputStream::closeWindow() {
 
105
  threadQueueVideo->waitForExclusiveAccess();
 
106
  output->closeWindow();
 
107
  threadQueueVideo->releaseExclusiveAccess();
 
108
}
 
109
 
 
110
void ThreadSafeOutputStream::flushWindow() {
 
111
  threadQueueVideo->waitForExclusiveAccess();
 
112
  output->flushWindow();
 
113
  threadQueueVideo->releaseExclusiveAccess(); 
 
114
 
115
 
 
116
 
 
117
PictureArray* ThreadSafeOutputStream::lockPictureArray() {
 
118
  PictureArray* back;
 
119
  threadQueueVideo->waitForExclusiveAccess();
 
120
  back=output->lockPictureArray();
 
121
  threadQueueVideo->releaseExclusiveAccess();
 
122
  return back; 
 
123
}
 
124
 
 
125
 
 
126
void ThreadSafeOutputStream::unlockPictureArray(PictureArray* array) {
 
127
  threadQueueVideo->waitForExclusiveAccess();
 
128
  output->unlockPictureArray(array);
 
129
  threadQueueVideo->releaseExclusiveAccess();
 
130
}
 
131
 
 
132
 
 
133
int ThreadSafeOutputStream::getFrameusec() {
 
134
  int back;
 
135
  threadQueueVideo->waitForExclusiveAccess();
 
136
  back=output->getFrameusec();
 
137
  threadQueueVideo->releaseExclusiveAccess();
 
138
  return back;  
 
139
}
 
140
 
 
141
void ThreadSafeOutputStream::config(const char* key,
 
142
                                    const char* value,void* user_data) {
 
143
 
 
144
  threadQueueVideo->waitForExclusiveAccess();
 
145
  threadQueueAudio->waitForExclusiveAccess();
 
146
  output->config(key,value,user_data);
 
147
  threadQueueVideo->releaseExclusiveAccess();
 
148
  threadQueueAudio->releaseExclusiveAccess();
 
149
  
 
150
}
 
151
 
 
152
 
 
153