1/* 2 * Copyright 2012 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione, jscipione@gmail.com 7 * 8 * Corresponds to: 9 * src/kits/game/FileGameSound.cpp hrev45076 10 * src/kits/game/FileGameSound.h hrev45076 11 */ 12 13 14/*! 15 \file FileGameSound.h 16 \ingroup game 17 \ingroup libbe 18 \brief Provides the BFileGameSound class. 19*/ 20 21 22/*! 23 \class BFileGameSound 24 \ingroup game 25 \ingroup libbe 26 \brief Playback audio from a sound file on disk. 27 28 \since BeOS R5 29*/ 30 31 32/*! 33 \fn BFileGameSound::BFileGameSound(const entry_ref* file, bool looping, 34 BGameSoundDevice* device) 35 \brief Creates and initializes a BFileGameSound object from an 36 \c entry_ref allowing you to play the specified sound file. 37 38 If \a looping is \c true, the sound automatically replays from the 39 beginning once the end is reached. This is useful for playing 40 background music in a loop. 41 42 You can specify the sound device to use by setting the \a device 43 parameter. Setting \a device to \c NULL uses the default sound device. 44 45 \param file The entry ref pointing to the sound file on disk. 46 \param looping Whether or not to repeat the sound in a loop. 47 \param device The sound device to use to play the sound, use \c NULL for 48 default. 49 50 \since BeOS R5 51*/ 52 53 54/*! 55 \fn BFileGameSound::BFileGameSound(const char* file, bool looping, 56 BGameSoundDevice* device) 57 \brief Creates and initializes a BFileGameSound object from a file path 58 allowing you to play the specified sound file. 59 60 If \a looping is \c true, the sound automatically replays from the 61 beginning once the end is reached. This is useful for playing 62 background music in a loop. 63 64 You can specify the sound device to use by setting the \a device 65 parameter. Setting \a device to \c NULL uses the default sound device. 66 67 \param file The path of the sound file on disk. 68 \param looping Whether or not to repeat the sound in a loop. 69 \param device The sound device to use to play the sound, use \c NULL for 70 default. 71 72 \since BeOS R5 73*/ 74 75 76/*! 77 \fn BFileGameSound::BFileGameSound(BDataIO* source, bool looping, 78 BGameSoundDevice* device) 79 \brief Creates and initializes a BFileGameSound object from a BDataIO 80 allowing you to play the specified sound data. 81 82 This allows using BFileGameSound with BFile as well as non-file based 83 storage (BMemoryIO, etc). 84 85 If \a looping is \c true, the sound automatically replays from the 86 beginning once the end is reached. This is useful for playing 87 background music in a loop. 88 89 You can specify the sound device to use by setting the \a device 90 parameter. Setting \a device to \c NULL uses the default sound device. 91 92 \param source The place to get the data from. 93 \param looping Whether or not to repeat the sound in a loop. 94 \param device The sound device to use to play the sound, use \c NULL for 95 default. 96 97 \since Haiku R1 98*/ 99 100 101/*! 102 \fn BFileGameSound::~BFileGameSound() 103 \brief Destroys the BFileGameSound object. 104 105 \since BeOS R5 106*/ 107 108 109/*! 110 \fn BGameSound* BFileGameSound::Clone() const 111 \brief Not implemented, always returns \c NULL. 112 113 \since BeOS R5 114*/ 115 116 117/*! 118 \fn status_t BFileGameSound::StartPlaying() 119 \brief Plays the sound file. 120 121 \returns A status code, \c B_OK on success or an error code on error. 122 123 \since BeOS R5 124*/ 125 126 127/*! 128 \fn status_t BFileGameSound::StopPlaying() 129 \brief Stops playback of the sound file. 130 131 \returns A status code, \c B_OK on success or an error code on error. 132 133 \since BeOS R5 134*/ 135 136 137/*! 138 \fn status_t BFileGameSound::Preload() 139 \brief Preload the sound file into memory so that playback won't be delayed. 140 141 \returns A status code, \c B_OK on success or an error code if we were 142 unable to communicate with the sound port. 143 144 \since BeOS R5 145*/ 146 147 148/*! 149 \fn void BFileGameSound::FillBuffer(void* inBuffer, size_t inByteCount) 150 \brief Fill a buffer with sound data. 151 152 \param inBuffer The buffer to fill. 153 \param inByteCount The number of bytes to fill buffer with. 154 155 \since BeOS R5 156*/ 157 158 159/*! 160 \fn status_t BFileGameSound::SetPaused(bool isPaused, bigtime_t rampTime) 161 \brief Pauses playback if \a isPaused is \c true or resumes play if 162 \a isPaused is \c false. 163 164 \param isPaused \c true to pause playback, \c false to resume playback. 165 \param rampTime Determines how long the change in playback state should 166 take to complete in microseconds. Set to 0 for an instantaneous 167 change. 168 169 \returns A status code. 170 \retval B_OK The playback state was updated. 171 \retval EALREADY Already in the requested playback state. 172 173 \since BeOS R5 174*/ 175 176 177/*! 178 \fn int32 BFileGameSound::IsPaused() 179 \brief Returns the current playback status. 180 181 \returns An integer indicating the current playback status. 182 \retval B_NOT_PAUSED Sound is playing. 183 \retval B_PAUSE_IN_PROGRESS The sound is transitioning to or from a paused state. 184 \retval B_PAUSED Sound is paused. 185 186 \since BeOS R5 187*/ 188