aboutsummaryrefslogtreecommitdiff
path: root/graphics/osg/files/patch-src_osgPlugins_ffmpeg_FFmpegDecoderAudio.hpp
blob: 5679e5baaad7c7d7353f7a87000967c72a537f8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--- src/osgPlugins/ffmpeg/FFmpegDecoderAudio.hpp.orig	2022-12-01 18:17:31 UTC
+++ src/osgPlugins/ffmpeg/FFmpegDecoderAudio.hpp
@@ -1,20 +1,19 @@
-
 #ifndef HEADER_GUARD_OSGFFMPEG_FFMPEG_DECODER_AUDIO_H
 #define HEADER_GUARD_OSGFFMPEG_FFMPEG_DECODER_AUDIO_H
 
-#include <OpenThreads/Thread>
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libswresample/swresample.h>
+}
 
+#include <OpenThreads/Thread>
 #include <osg/Timer>
-
+#include <osg/AudioStream>
 #include "FFmpegClocks.hpp"
 #include "FFmpegPacket.hpp"
 #include "FFmpegParameters.hpp"
-
-#include <osg/AudioStream>
-
 #include "BoundedMessageQueue.hpp"
 
-
 namespace osgFFmpeg {
 
 
@@ -24,12 +23,12 @@ class FFmpegDecoderAudio : public OpenThreads::Thread 
 public:
 
     typedef BoundedMessageQueue<FFmpegPacket> PacketQueue;
-    typedef void (* PublishFunc) (const FFmpegDecoderAudio & decoder, void * user_data);
+    typedef void (*PublishFunc)(const FFmpegDecoderAudio &decoder, void *user_data);
 
-    FFmpegDecoderAudio(PacketQueue & packets, FFmpegClocks & clocks);
+    FFmpegDecoderAudio(PacketQueue &packets, FFmpegClocks &clocks);
     ~FFmpegDecoderAudio();
 
-    void open(AVStream * stream, FFmpegParameters* parameters);
+    void open(AVStream *stream, FFmpegParameters *parameters);
     void pause(bool pause);
     void close(bool waitForThreadToExit);
 
@@ -39,7 +38,7 @@ class FFmpegDecoderAudio : public OpenThreads::Thread 
     virtual void run();
 
     void setAudioSink(osg::ref_ptr<osg::AudioSink> audio_sink);
-    void fillBuffer(void * buffer, size_t size);
+    void fillBuffer(void *buffer, size_t size);
 
     bool validContext() const;
     int frequency() const;
@@ -53,37 +52,37 @@ class FFmpegDecoderAudio : public OpenThreads::Thread 
 
     void decodeLoop();
     void adjustBufferEndPts(size_t buffer_size);
-    size_t decodeFrame(void * buffer, size_t size);
+    size_t decodeFrame(void *buffer, size_t size);
 
 
-    PacketQueue &                       m_packets;
-    FFmpegClocks &                      m_clocks;
-    AVStream *                          m_stream;
-    AVCodecContext *                    m_context;
-    FFmpegPacket                        m_packet;
-    const uint8_t *                     m_packet_data;
-    int                                 m_bytes_remaining;
+    PacketQueue &m_packets;
+    FFmpegClocks &m_clocks;
+    AVStream *m_stream;
+    AVCodecContext *m_context;
+    FFmpegPacket m_packet;
+    const uint8_t *m_packet_data;
+    int m_bytes_remaining;
 
-    Buffer                              m_audio_buffer;
-    size_t                              m_audio_buf_size;
-    size_t                              m_audio_buf_index;
+    Buffer m_audio_buffer;
+    size_t m_audio_buf_size;
+    size_t m_audio_buf_index;
 
-    int                                 m_in_sample_rate;
-    int                                 m_in_nb_channels;
-    AVSampleFormat                      m_in_sample_format;
-    int                                 m_out_sample_rate;
-    int                                 m_out_nb_channels;
-    AVSampleFormat                      m_out_sample_format;
+    int m_in_sample_rate;
+    int m_in_nb_channels;
+    AVSampleFormat m_in_sample_format;
+    int m_out_sample_rate;
+    int m_out_nb_channels;
+    AVSampleFormat m_out_sample_format;
 
-    SinkPtr                             m_audio_sink;
+    SinkPtr m_audio_sink;
 
-    osg::Timer                          m_pause_timer;
+    osg::Timer m_pause_timer;
 
-    bool                                m_end_of_stream;
-    bool                                m_paused;
-    volatile bool                       m_exit;
+    bool m_end_of_stream;
+    bool m_paused;
+    volatile bool m_exit;
 
-    SwrContext *                        m_swr_context;  // Sw resampling context
+    SwrContext *m_swr_context; // Sw resampling context
 };
 
 
@@ -92,7 +91,7 @@ inline bool FFmpegDecoderAudio::validContext() const
 
 inline bool FFmpegDecoderAudio::validContext() const
 {
-    return m_context != 0;
+    return m_context != nullptr;
 }
 
 
@@ -110,5 +109,5 @@ inline int FFmpegDecoderAudio::nbChannels() const
 } // namespace osgFFmpeg
 
 
-
 #endif // HEADER_GUARD_OSGFFMPEG_FFMPEG_DECODER_AUDIO_H
+