root/OpenSceneGraph/trunk/include/osg/AudioStream @ 10925

Revision 10925, 2.6 kB (checked in by robert, 5 years ago)

Added virtual pause() method into osg::AudioSink? to support pausing of a movie thread and it's associated audio.

Updated osgmovie plugin to use the pause support.

RevLine 
[9827]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_AUDIOSTREAM
15#define OSG_AUDIOSTREAM 1
16
17#include <osg/Image>
[10764]18#include <stdlib.h>
[9827]19
20namespace osg {
21
[9847]22/** Pure virtual AudioSink bass class that is used to connect the audio system with AudioStreams. */
23class OSG_EXPORT AudioSink : public osg::Object
[9827]24{
25public:
26
[9847]27    AudioSink();
[9827]28
[10925]29    virtual const char * libraryName() const { return "osg"; }
30    virtual const char * className() const { return "AudioSinkInterface"; }
31
32    virtual void play() = 0;
33    virtual void pause()  = 0;
34    virtual void stop()  = 0;
35
[9827]36    virtual bool playing() const = 0;
37
38    virtual double getDelay() const { return _delay; }
39    virtual void setDelay(const double delay) { _delay = delay; }
40
41
42private:
43
[9847]44    virtual AudioSink * cloneType() const { return 0; }
45    virtual AudioSink * clone(const osg::CopyOp &) const { return 0; }
[9827]46
47    double  _delay;
48};
49
50/** Pure virtual AudioStream base class. Subclasses provide mechanism for reading/generating audio data*/
51class OSG_EXPORT AudioStream : public osg::Object
52{
53    public:
54        AudioStream();
55
56        /** Copy constructor using CopyOp to manage deep vs shallow copy. */
57        AudioStream(const AudioStream& audio,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
58
59        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const AudioStream*>(obj)!=0; }
60        virtual const char* libraryName() const { return "osg"; }
61        virtual const char* className() const { return "AudioStream"; }
62
[9847]63        virtual void setAudioSink(osg::AudioSink* audio_sink) = 0;
[9827]64       
65        virtual void consumeAudioBuffer(void * const buffer, const size_t size) = 0;
66       
67        virtual int audioFrequency() const = 0;
68        virtual int audioNbChannels() const = 0;
69
70        enum SampleFormat
71        {
72            SAMPLE_FORMAT_U8,
73            SAMPLE_FORMAT_S16,
74            SAMPLE_FORMAT_S24,
75            SAMPLE_FORMAT_S32,
76            SAMPLE_FORMAT_F32
77        };
78
79        virtual SampleFormat audioSampleFormat() const = 0;
80};
81
82} // namespace
83
84#endif
Note: See TracBrowser for help on using the browser.