DSPaudioIO Class Reference

audio output to linux pseudo-file /dev/dsp <short description=""> More...

#include <DSPaudioIO.hpp>

Inheritance diagram for DSPaudioIO:

AudioIO IO VThread List of all members.

Public Member Functions

 DSPaudioIO (AudioESInfo *es, ESSynchronizer *ess=NULL, bool enableHeadphones=false)
int initialize ()
FramegetFrame ()
 returns a frame if one complete frame is available, otherwise null is returned.
int writeFrame (Frame *frm, ESInfo *out_es=NULL)
 returns the number of packets sent.
bool open ()
 opens the IO connection.
bool close (bool immediate=false)
 closes the IO class.

Detailed Description

audio output to linux pseudo-file /dev/dsp <short description="">

Author:
Mithlesh Kumar
Version:
Id
DSPaudioIO.hpp,v 1.10 2006/01/20 15:37:18 mkropfbe Exp

Definition at line 78 of file DSPaudioIO.hpp.


Member Function Documentation

bool DSPaudioIO::close bool  immediate = false  )  [virtual]
 

closes the IO class.

Parameters:
immediate specifies, if (optional) buffered data should be read/sent to the client (==false), or immediately dumped (==true)

Implements IO.

Definition at line 167 of file DSPaudioIO.cpp.

References AudioIO::destroy(), and IO::setState().

00167 { 00168 00169 ::close(fd); 00170 00171 destroy(); 00172 setState(CLOSED); 00173 //::exit(0); 00174 return true; 00175 }

Frame * DSPaudioIO::getFrame  )  [virtual]
 

returns a frame if one complete frame is available, otherwise null is returned.

This function is typically blocking. Don't use a NULL return value to conclude STREAMEOF, always check with getState()!

Implements IO.

Definition at line 117 of file DSPaudioIO.cpp.

00117 { 00118 return NULL; 00119 }

bool DSPaudioIO::open  )  [virtual]
 

opens the IO connection.

State is set to OPENING. When the connection is ready for use, State is OPEN

Implements IO.

Definition at line 156 of file DSPaudioIO.cpp.

References ESSynchronizer::setPaused(), and IO::setState().

00156 { 00157 if (getESSync()) { 00158 dprintf_full("DSPaudioIO::open()PAUSING ESSynchronizer\n"); 00159 getESSync()->setPaused(true); 00160 requestUnpauseESS = true; // no locking, as the SDL thread is not running yet 00161 } 00162 setState(OPEN); 00163 return true; 00164 }

int DSPaudioIO::writeFrame Frame frm,
ESInfo out_es = NULL
[virtual]
 

returns the number of packets sent.

Returns 0 on error

Implements IO.

Definition at line 122 of file DSPaudioIO.cpp.

References GlobalTimer::adjustToTS(), Frame::getAU(), ESSynchronizer::getGlobalTimer(), and ESSynchronizer::setPaused().

00122 { 00123 dprintf_full("DSPaudioIO::writeFrame %i bytes, using %s audio device \n",frm->getAU()->size, AUDIO_DEVICE); 00124 if (firstFrame) { 00125 firstFrame = false; 00126 if(initialize() < 0) { 00127 dprintf_err("DSPaudioIO::writeFrame Error in initializing\n"); 00128 return 0; 00129 } 00130 } 00131 00132 audio_chunk = frm->getAU()->payload; 00133 audio_len = frm->getAU()->size; 00134 assert(audio_chunk != NULL); 00135 if(getState() != MUTED) { 00136 if (audio_buffer(fd, audio_chunk, audio_len ) < 0) { 00137 dprintf_err("DSPaudioIO:: Error in Playing audio chunk\n"); 00138 } 00139 } 00140 if (getESSync()) 00141 getESSync()->getGlobalTimer()->adjustToTS(frm->getAU()->cts, es->getMediaTimeScale()); 00142 if (requestUnpauseESS && getESSync()) { 00143 dprintf_full("DSPaudioIO: unpausing ESSychronizer\n"); 00144 requestUnpauseESS = false; 00145 getESSync()->setPaused(false); 00146 } 00147 00148 00149 //#ifdef _POSIX_PRIORITY_SCHEDULING 00150 // sched_yield(); //this is necessary to give parallel getFrames a chance 00151 //#endif 00152 return 1; //one frame written 00153 }


The documentation for this class was generated from the following files: