2
concret OutputClass for yaf text consol player
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 "yafOutputStream.h"
17
#define _AUDIO_DELAY_STAMPS 200
22
YafOutputStream::YafOutputStream(InputInterface* input) {
23
lInternalDevice=false;
28
directOutput=OutPlugin::createOutputStream(_OUTPUT_LOCAL,_OUTPUT_THREADSAFE);
35
perror("YafOutputStream pipe");
38
input->addFileDescriptor(fd[0]);
42
YafOutputStream::~YafOutputStream() {
47
int YafOutputStream::audioSetup(int frequency,int stereo,
48
int sign,int big,int bits) {
50
cout << "Command:0 Msg:streamInfo-Start"<<endl;
51
cout << "Command:0 Msg:streamInfo-Channels "<<stereo+1<<endl;
53
cout << "Command:0 Msg:streamInfo-SampleSize "<<bits<<endl;
54
cout << "Command:0 Msg:streamInfo-Speed "<<frequency<<endl;
55
cout << "Command:0 Msg:streamInfo-End"<<endl;
57
directOutput->audioSetup(frequency,stereo,sign,big,bits);
62
void YafOutputStream::audioOpen() {
63
if (lInternalDevice) {
64
directOutput->audioOpen();
68
void YafOutputStream::audioClose(void) {
69
if (lInternalDevice) {
70
// never close internal audio, because
71
// its not possible to open it again fast enough
72
//directOutput->audioClose();
74
directOutput->audioClose();
79
int YafOutputStream::audioPlay(TimeStamp* startStamp,
80
TimeStamp* endStamp,char *buffer, int size) {
83
if (lInternalDevice) {
84
directOutput->audioPlay(startStamp,endStamp,buffer,size);
90
// if we are doing video, we even have to sync
92
// Because yaf sends the audio data to another process
93
// but the video data _not_ the audio data is directly
94
// flushed here, but maybe stay on the other side
95
// in a very big buffer
96
// until the protocol has no better handle
97
// for this, we must make sure to
98
// dont get the buffer on the other
100
// we sleep some time until we write the next sample
105
directOutput->audioPlay(startStamp,endStamp,buffer,size);
108
ret=::send(sd,buffer,size,0);
118
cout << "fifo error in streamWriter";
119
perror("writeStream");
138
void YafOutputStream::audioFlush() {
139
// notify command line, that plugin state changed
140
input->write(fd[1],"update\n");
142
if (lInternalDevice) {
143
directOutput->audioFlush();
147
int YafOutputStream::getPreferredDeliverSize() {
148
return directOutput->getPreferredDeliverSize();
154
int YafOutputStream::openWindow(int width, int height,const char *title) {
155
return directOutput->openWindow(width,height,title);
159
void YafOutputStream::closeWindow() {
160
directOutput->closeWindow();
163
void YafOutputStream::flushWindow() {
164
directOutput->flushWindow();
167
PictureArray* YafOutputStream::lockPictureArray() {
168
return directOutput->lockPictureArray();
172
void YafOutputStream::unlockPictureArray(PictureArray* pictureArray) {
173
directOutput->unlockPictureArray(pictureArray);
177
int YafOutputStream::getFrameusec() {
178
return directOutput->getFrameusec();
183
int YafOutputStream::getOutputInit() {
184
return directOutput->getOutputInit();
188
void YafOutputStream::setOutputInit(int lInit) {
189
directOutput->setOutputInit(lInit);
195
void YafOutputStream::writeInfo(PluginInfo* pluginInfo) {
196
char* url=pluginInfo->getUrl();
197
const char* nameStart=strrchr(url,'/');
199
if (nameStart==NULL) {
203
if (strlen(nameStart) == 0) {
208
cout << "Command:0 Msg:musicinfo-Start"<<endl;
209
cout << "Command:0 Msg:song_filename "<<pluginInfo->getUrl()<<endl;
210
cout << "Command:0 Msg:song_name "<<nameStart<<endl;
211
cout << "Command:0 Msg:song_len "<<pluginInfo->getLength()<<endl;
212
cout << "Command:0 Msg:song_jumps 0"<<endl;
213
cout << "Command:0 Msg:musicinfo-End"<<endl;
221
void YafOutputStream::setBytesCounter(long value) {
228
int YafOutputStream::isOpenStream() {
233
void YafOutputStream::setStreamFile(const char* filename) {
237
this->filename=filename;
241
int YafOutputStream::openStream() {
243
cout << "stream already open! call ignored"<<endl;
246
sd=::socket(AF_UNIX,SOCK_STREAM,0);
248
perror("sd-Socket StreamWriter");exit(1);
252
sockad.sun_family=AF_UNIX;
254
while(i<strlen(filename)) {
255
sockad.sun_path[i]=filename[i];
258
sockad.sun_path[i]=0;
259
if (::connect(sd,(sockaddr*)&sockad,strlen(filename)+2)<0) {
260
perror("connect StreamWriter");exit(1);
269
int YafOutputStream::closeStream() {
276
cout << "stream already closed. call ignored!"<<endl;
282
void YafOutputStream::internalDevice(int lInternal){
283
lInternalDevice=lInternal;
288
long YafOutputStream::getBytesCounter() {
293
long YafOutputStream::getAllWriteCounter() {
299
void YafOutputStream::config(const char* key,const char* value,
302
directOutput->config(key,value,user_data);