PlaybackNode.h

00001 /*
00002  * $Id: PlaybackNode.h 94 2003-05-13 10:54:17Z rene-cvs $
00003  * PortAudio Portable Real-Time Audio Library
00004  * Latest Version at: http://www.portaudio.com
00005  * BeOS Media Kit Implementation by Joshua Haberman
00006  *
00007  * Copyright (c) 2001 Joshua Haberman <joshua@haberman.com>
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining
00010  * a copy of this software and associated documentation files
00011  * (the "Software"), to deal in the Software without restriction,
00012  * including without limitation the rights to use, copy, modify, merge,
00013  * publish, distribute, sublicense, and/or sell copies of the Software,
00014  * and to permit persons to whom the Software is furnished to do so,
00015  * subject to the following conditions:
00016  *
00017  * The above copyright notice and this permission notice shall be
00018  * included in all copies or substantial portions of the Software.
00019  *
00020  * Any person wishing to distribute modifications to the Software is
00021  * requested to send the modifications to the original developer so that
00022  * they can be incorporated into the canonical version.
00023  *
00024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00027  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00028  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00029  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #include <be/media/MediaRoster.h>
00035 #include <be/media/MediaEventLooper.h>
00036 #include <be/media/BufferProducer.h>
00037 
00038 #include "portaudio.h"
00039 
00040 class PaPlaybackNode :
00041             public BBufferProducer,
00042             public BMediaEventLooper
00043 {
00044 
00045 public:
00046     PaPlaybackNode( uint32 channels, float frame_rate, uint32 frames_per_buffer,
00047                     PortAudioCallback *callback, void *user_data );
00048     ~PaPlaybackNode();
00049 
00050 
00051     /* Local methods ******************************************/
00052 
00053     BBuffer *FillNextBuffer(bigtime_t time);
00054     void SetSampleFormat(PaSampleFormat inFormat, PaSampleFormat outFormat);
00055     bool IsRunning();
00056     PaTimestamp GetStreamTime();
00057 
00058     /* BMediaNode methods *************************************/
00059 
00060     BMediaAddOn* AddOn( int32 * ) const;
00061     status_t HandleMessage( int32 message, const void *data, size_t size );
00062 
00063     /* BMediaEventLooper methods ******************************/
00064 
00065     void HandleEvent( const media_timed_event *event, bigtime_t lateness,
00066                       bool realTimeEvent );
00067     void NodeRegistered();
00068 
00069     /* BBufferProducer methods ********************************/
00070 
00071     status_t FormatSuggestionRequested( media_type type, int32 quality,
00072                                         media_format* format );
00073     status_t FormatProposal( const media_source& output, media_format* format );
00074     status_t FormatChangeRequested( const media_source& source,
00075                                     const media_destination& destination, media_format* io_format, int32* );
00076 
00077     status_t GetNextOutput( int32* cookie, media_output* out_output );
00078     status_t DisposeOutputCookie( int32 cookie );
00079 
00080     void LateNoticeReceived( const media_source& what, bigtime_t how_much,
00081                              bigtime_t performance_time );
00082     void EnableOutput( const media_source& what, bool enabled, int32* _deprecated_ );
00083 
00084     status_t PrepareToConnect( const media_source& what,
00085                                const media_destination& where, media_format* format,
00086                                media_source* out_source, char* out_name );
00087     void Connect(status_t error, const media_source& source,
00088                  const media_destination& destination, const media_format& format,
00089                  char* io_name);
00090     void Disconnect(const media_source& what, const media_destination& where);
00091 
00092     status_t SetBufferGroup(const media_source& for_source, BBufferGroup* newGroup);
00093 
00094     bool         mAborted;
00095 
00096 private:
00097     media_output mOutput;
00098     media_format mPreferredFormat;
00099     uint32       mOutputSampleWidth, mFramesPerBuffer;
00100     BBufferGroup *mBufferGroup;
00101     bigtime_t    mDownstreamLatency, mInternalLatency, mStartTime;
00102     uint64       mSamplesSent;
00103     PortAudioCallback *mCallback;
00104     void         *mUserData;
00105     bool         mRunning;
00106 
00107 };
00108 

Generated on Mon Jun 5 10:20:43 2006 for Intelligence.kdevelop by  doxygen 1.4.6