Mercurial > hg > forks > bilotrip-mj12
annotate liboggplayer-src/src/imp.hpp @ 27:e29773ac3ceb
Fix a #ifdef fence.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 05 Aug 2013 18:22:53 +0300 |
parents | 74b28a572438 |
children | 3eacedd172ab |
rev | line source |
---|---|
2 | 1 #include <oggplayer.h> |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
2 #ifdef VORBIS_SUPPORT |
2 | 3 #include "SDL_audiocvt.hpp" |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
4 #endif |
2 | 5 #include <fstream> |
6 #include <vector> | |
7 #include <theora/theora.h> | |
26
74b28a572438
Fence some more vorbis-related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
8 #ifdef VORBIS_SUPPORT |
2 | 9 #include <vorbis/codec.h> |
26
74b28a572438
Fence some more vorbis-related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
10 #endif |
2 | 11 #include <boost/thread.hpp> |
12 #include <boost/bind.hpp> | |
13 #include <boost/thread/mutex.hpp> | |
14 #include <boost/thread/locks.hpp> | |
15 #include <boost/thread/condition.hpp> | |
16 #include <boost/circular_buffer.hpp> | |
17 #include <boost/timer.hpp> | |
18 | |
19 struct OggPlayer::Imp { | |
20 | |
21 Imp() : | |
22 cirbuf(0),video_lock(video_mut, boost::defer_lock){ | |
23 failbit = false; | |
24 playing = false; | |
25 need_close = false; | |
26 time_factor = 1; | |
27 refs = 1; | |
28 } | |
29 | |
30 ~Imp() { | |
31 // open() tears down the partial setup on fail | |
32 if (!failbit) | |
33 close(); | |
34 } | |
35 int queue_page(ogg_page * page); | |
36 bool buffer_data(); | |
37 double get_time(); | |
38 void close(); | |
39 bool init_decoders(); | |
40 bool parse_headers(); | |
41 void open(std::string path, AudioFormat audio_format, int channels, | |
42 int rate, VideoFormat video_format); | |
43 bool decode_audio(); | |
44 bool decode_video(); | |
45 bool ready(); | |
46 void play(); | |
47 void play_loop(); | |
48 | |
49 bool failbit; | |
50 std::ifstream file_in; | |
51 | |
52 int theora_p; | |
53 int vorbis_p; | |
54 | |
55 ogg_sync_state o_sync; | |
56 | |
26
74b28a572438
Fence some more vorbis-related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
57 #ifdef VORBIS_SUPPORT |
2 | 58 vorbis_comment v_comment; |
27 | 59 vorbis_info v_info; |
60 #endif | |
61 | |
2 | 62 theora_info t_info; |
63 theora_comment t_comment; | |
64 | |
65 ogg_page o_page; | |
66 ogg_packet o_packet; | |
67 | |
68 ogg_stream_state o_tsstate; | |
69 ogg_stream_state o_vsstate; | |
70 | |
71 theora_state t_state; | |
26
74b28a572438
Fence some more vorbis-related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
72 |
74b28a572438
Fence some more vorbis-related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
73 #ifdef VORBIS_SUPPORT |
2 | 74 vorbis_dsp_state v_state; |
75 vorbis_block v_block; | |
26
74b28a572438
Fence some more vorbis-related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
76 #endif |
2 | 77 |
78 int pp_level_max; | |
79 int pp_level; | |
80 int pp_inc; | |
81 | |
82 char* audio_buffer; | |
83 boost::circular_buffer<char> cirbuf; | |
84 unsigned int audio_buffer_size; | |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
85 #ifdef VORBIS_SUPPORT |
2 | 86 SDL_AudioCVT cvt; |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
87 #endif |
2 | 88 |
89 bool playing; | |
90 | |
91 boost::thread play_thread; | |
92 boost::mutex audio_mut; | |
93 boost::mutex video_mut; | |
94 boost::condition_variable audio_ready_cond; | |
95 boost::condition_variable video_ready_cond; | |
96 | |
97 bool videobuf_ready; | |
98 double videobuf_time; | |
99 | |
100 bool audio_cache_ready; | |
101 | |
102 // This lock should only be used from the main thread | |
103 boost::unique_lock<boost::mutex> video_lock; | |
104 // These variables are used to identify the frames (not just count them, not a debug variable) | |
105 // see video_buffer_try_lock and video_read | |
106 int frame; | |
107 int last_frame_read; | |
108 | |
109 int audio_bytes_played; | |
110 struct AudioGranulePos { | |
111 int pos; | |
112 double set_time; | |
113 }; | |
114 std::deque<AudioGranulePos> audio_granule_poses; | |
115 double time_factor; | |
116 | |
117 struct PixelFormat{ | |
118 void set(int r,int g,int b,int bpp){ | |
119 r_offset = r; | |
120 g_offset = g; | |
121 b_offset = b; | |
122 this->bpp =bpp; | |
123 } | |
124 int r_offset; | |
125 int g_offset; | |
126 int b_offset; | |
127 // if bpp=4 we have an alpha channel at offset 4 | |
128 int bpp; | |
129 | |
130 } pixel_format; | |
131 bool need_close; | |
132 boost::timer timer; | |
133 int refs; | |
134 }; |