repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / mediaplayer / supplier / MediaTrackAudioSupplier.h
blob9c484e98473529073031444fbc22f7ab8c242da7
1 /*
2 * Copyright 2000-2004 Ingo Weinhold <ingo_weinhold@gmx.de>
3 * Copyright 2006-2008 Stephan Aßmus <superstippi@gmx.de>
4 * All rights reserved. Distributed under the terms of the MIT License.
5 */
6 #ifndef MEDIA_TRACK_AUDIO_SUPPLIER_H
7 #define MEDIA_TRACK_AUDIO_SUPPLIER_H
10 #include <List.h>
12 #include "AudioTrackSupplier.h"
15 class BMediaTrack;
16 struct media_codec_info;
17 struct media_format;
20 class MediaTrackAudioSupplier : public AudioTrackSupplier {
21 public:
22 MediaTrackAudioSupplier(BMediaTrack* track,
23 int32 trackIndex);
24 virtual ~MediaTrackAudioSupplier();
26 virtual const media_format& Format() const;
27 virtual status_t GetEncodedFormat(media_format* format) const;
28 virtual status_t GetCodecInfo(media_codec_info* info) const;
29 virtual bigtime_t Duration() const;
31 // AudioReader interface
32 // (needed to reuse the class as AudioResampler input)
33 virtual bigtime_t InitialLatency() const;
34 virtual status_t Read(void* buffer, int64 pos, int64 frames);
36 virtual status_t InitCheck() const;
38 virtual int32 TrackIndex() const
39 { return fTrackIndex; }
41 private:
42 struct Buffer;
43 void _InitFromTrack();
45 int64 _FramesPerBuffer() const;
47 void _CopyFrames(void* source, int64 sourceOffset,
48 void* target, int64 targetOffset,
49 int64 position, int64 frames) const;
50 void _CopyFrames(Buffer* buffer, void* target,
51 int64 targetOffset, int64 position,
52 int64 frames) const;
54 void _AllocateBuffers();
55 void _FreeBuffers();
56 Buffer* _BufferAt(int32 index) const;
57 Buffer* _FindBufferAtFrame(int64 frame) const;
58 Buffer* _FindUnusedBuffer() const;
59 Buffer* _FindUsableBuffer() const;
60 Buffer* _FindUsableBufferFor(int64 position) const;
61 void _GetBuffersFor(BList& buffers, int64 position,
62 int64 frames) const;
63 void _TouchBuffer(Buffer* buffer);
65 status_t _ReadBuffer(Buffer* buffer, int64 position);
66 status_t _ReadBuffer(Buffer* buffer, int64 position,
67 bigtime_t time);
69 void _ReadCachedFrames(void*& buffer,
70 int64& position, int64& frames,
71 bigtime_t time);
73 status_t _ReadUncachedFrames(void* buffer,
74 int64 position, int64 frames,
75 bigtime_t time);
77 status_t _FindKeyFrameForward(int64& position);
78 status_t _FindKeyFrameBackward(int64& position);
79 // NOTE: unused
80 // status_t _SeekToKeyFrameForward(int64& position);
81 status_t _SeekToKeyFrameBackward(int64& position);
83 private:
84 BMediaTrack* fMediaTrack;
85 char* fBuffer;
86 int64 fBufferOffset;
87 int64 fBufferSize;
88 BList fBuffers;
89 bool fHasKeyFrames;
90 int64 fCountFrames;
91 bool fReportSeekError;
92 int32 fTrackIndex;
95 #endif // MEDIA_TRACK_AUDIO_SUPPLIER_H