root/OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegAudioStream.cpp @ 9850

Revision 9850, 1.5 kB (checked in by robert, 5 years ago)

Improved the clean up ordering

RevLine 
[9847]1
2#include "FFmpegAudioStream.hpp"
3
4#include <OpenThreads/ScopedLock>
5#include <osg/Notify>
6
7#include "FFmpegDecoder.hpp"
8#include "MessageQueue.hpp"
9
10#include <memory>
11
12
13
14namespace osgFFmpeg {
15
16
17
18FFmpegAudioStream::FFmpegAudioStream(FFmpegDecoder* decoder):
19    m_decoder(decoder)
20{
21}
22
23
24
25FFmpegAudioStream::FFmpegAudioStream(const FFmpegAudioStream & audio, const osg::CopyOp & copyop) :
26    osg::AudioStream(audio, copyop)
27{
28}
29
30FFmpegAudioStream::~FFmpegAudioStream()
31{
[9850]32    // detact the audio sink first to avoid destrction order issues.
33    setAudioSink(0);
[9847]34}
35
36void FFmpegAudioStream::setAudioSink(osg::AudioSink* audio_sink)
37{
38    osg::notify(osg::NOTICE)<<"FFmpegAudioStream::setAudioSink( "<<audio_sink<<")"<<std::endl;
39    m_decoder->audio_decoder().setAudioSink(audio_sink);
40}
41
42
43void FFmpegAudioStream::consumeAudioBuffer(void * const buffer, const size_t size)
44{
45    m_decoder->audio_decoder().fillBuffer(buffer, size);
46}
47
48double FFmpegAudioStream::duration() const
49{
50    return m_decoder->duration();
51}
52
53
54bool FFmpegAudioStream::audioStream() const 
55{
56    return m_decoder->audio_decoder().validContext();
57}
58
59
60
61int FFmpegAudioStream::audioFrequency() const 
62{
63    return m_decoder->audio_decoder().frequency();
64}
65
66
67
68int FFmpegAudioStream::audioNbChannels() const 
69{
70    return m_decoder->audio_decoder().nbChannels();
71}
72
73
74
75osg::AudioStream::SampleFormat FFmpegAudioStream::audioSampleFormat() const 
76{
77    return m_decoder->audio_decoder().sampleFormat();
78}
79
80
81} // namespace osgFFmpeg
Note: See TracBrowser for help on using the browser.