1 /* BSound.h */ 2 /* Copyright 1998 Be Incorporated. All rights reserved. */ 3 4 #if !defined(_SOUND_H) 5 #define _SOUND_H 6 7 #include <MediaDefs.h> 8 9 class BSoundFile; 10 11 namespace BPrivate { 12 class BTrackReader; 13 } 14 15 class BSound { 16 public: 17 BSound( 18 void * data, 19 size_t size, 20 const media_raw_audio_format & format, 21 bool free_when_done = false); 22 BSound( 23 const entry_ref * sound_file, 24 bool load_into_memory = false); 25 26 status_t InitCheck(); 27 BSound * AcquireRef(); 28 bool ReleaseRef(); 29 int32 RefCount() const; // unreliable! 30 31 virtual bigtime_t Duration() const; 32 virtual const media_raw_audio_format & Format() const; 33 virtual const void * Data() const; /* returns NULL for files */ 34 virtual off_t Size() const; 35 36 virtual bool GetDataAt( 37 off_t offset, 38 void * into_buffer, 39 size_t buffer_size, 40 size_t * out_used); 41 42 protected: 43 44 BSound( 45 const media_raw_audio_format & format); 46 47 virtual status_t Perform( 48 int32 code, 49 ...); 50 51 private: 52 53 BSound(const BSound &); // unimplemented 54 BSound & operator=(const BSound &); // unimplemented 55 56 friend class BSoundPlayer; 57 friend class _HostApp; 58 59 void Reset(); 60 61 virtual ~BSound(); 62 63 void free_data(); 64 static status_t load_entry(void * arg); 65 void loader_thread(); 66 bool check_stop(); 67 68 public: 69 70 virtual status_t BindTo( 71 BSoundPlayer * player, 72 const media_raw_audio_format & format); 73 virtual status_t UnbindFrom( 74 BSoundPlayer * player); 75 76 private: 77 status_t _Reserved_Sound_0(void *); // BindTo 78 status_t _Reserved_Sound_1(void *); // UnbindFrom 79 virtual status_t _Reserved_Sound_2(void *); 80 virtual status_t _Reserved_Sound_3(void *); 81 virtual status_t _Reserved_Sound_4(void *); 82 virtual status_t _Reserved_Sound_5(void *); 83 84 void * _m_data; 85 BMediaFile * _m_file; 86 int32 _m_ref_count; 87 status_t _m_error; 88 size_t _m_size; 89 media_raw_audio_format _m_format; 90 bool _m_free_when_done; 91 bool _m_checkStopped; 92 bool _m_reserved[2]; 93 area_id _m_area; 94 sem_id _m_avail_sem; 95 sem_id _m_free_sem; 96 thread_id _m_loader_thread; 97 size_t _m_read_pos; 98 sem_id _m_check_token; 99 int32 _m_prev_sem_count; 100 101 BSoundPlayer * _m_bound_player; 102 int32 _m_bind_flags; 103 104 BPrivate::BTrackReader * _m_trackReader; 105 char m_tname[32]; 106 uint32 _reserved_[1]; 107 108 }; 109 110 111 #endif /* _SOUND_H */ 112