2012-12-25 00:42:48 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* John Scipione, jscipione@gmail.com
|
|
|
|
*
|
|
|
|
* Corresponds to:
|
|
|
|
* src/kits/game/FileGameSound.cpp hrev45076
|
|
|
|
* src/kits/game/FileGameSound.h hrev45076
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\file FileGameSound.h
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup game
|
|
|
|
\ingroup libbe
|
2012-12-25 03:31:08 +04:00
|
|
|
\brief Provides the BFileGameSound class.
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class BFileGameSound
|
|
|
|
\ingroup game
|
|
|
|
\ingroup libbe
|
2012-12-25 03:31:08 +04:00
|
|
|
\brief Playback audio from a sound file on disk.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-12 00:45:07 +04:00
|
|
|
\fn BFileGameSound::BFileGameSound(const entry_ref* file, bool looping,
|
|
|
|
BGameSoundDevice* device)
|
2012-12-25 00:42:48 +04:00
|
|
|
\brief Creates and initializes a BFileGameSound object from an
|
|
|
|
\c entry_ref allowing you to play the specified sound file.
|
|
|
|
|
|
|
|
If \a looping is \c true, the sound automatically replays from the
|
|
|
|
beginning once the end is reached. This is useful for playing
|
|
|
|
background music in a loop.
|
|
|
|
|
|
|
|
You can specify the sound devise to use by setting the \a device
|
|
|
|
parameter. Setting \a device to \c NULL uses the default sound device.
|
|
|
|
|
|
|
|
\param file The entry ref pointing to the sound file on disk.
|
|
|
|
\param looping Whether or not to repeat the sound in a loop.
|
|
|
|
\param device The sound device to use to play the sound, use \c NULL for
|
|
|
|
default.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-12 00:45:07 +04:00
|
|
|
\fn BFileGameSound::BFileGameSound(const char* file, bool looping,
|
|
|
|
BGameSoundDevice* device)
|
2012-12-25 00:42:48 +04:00
|
|
|
\brief Creates and initializes a BFileGameSound object from a file path
|
|
|
|
allowing you to play the specified sound file.
|
|
|
|
|
|
|
|
If \a looping is \c true, the sound automatically replays from the
|
|
|
|
beginning once the end is reached. This is useful for playing
|
|
|
|
background music in a loop.
|
|
|
|
|
|
|
|
You can specify the sound devise to use by setting the \a device
|
|
|
|
parameter. Setting \a device to \c NULL uses the default sound device.
|
|
|
|
|
|
|
|
\param file The path of the sound file on disk.
|
|
|
|
\param looping Whether or not to repeat the sound in a loop.
|
|
|
|
\param device The sound device to use to play the sound, use \c NULL for
|
2014-06-12 00:45:07 +04:00
|
|
|
default.
|
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-07-07 19:10:34 +03:00
|
|
|
/*!
|
|
|
|
\fn BFileGameSound::BFileGameSound(BDataIO* source, bool looping,
|
|
|
|
BGameSoundDevice* device)
|
|
|
|
\brief Creates and initializes a BFileGameSound object from a BDataIO
|
|
|
|
allowing you to play the specified sound data.
|
|
|
|
|
|
|
|
This allows using BFileGameSound with BFile as well as non-file based
|
|
|
|
storage (BMemoryIO, etc).
|
|
|
|
|
|
|
|
If \a looping is \c true, the sound automatically replays from the
|
|
|
|
beginning once the end is reached. This is useful for playing
|
|
|
|
background music in a loop.
|
|
|
|
|
|
|
|
You can specify the sound devise to use by setting the \a device
|
|
|
|
parameter. Setting \a device to \c NULL uses the default sound device.
|
|
|
|
|
|
|
|
\param source The place to get the data from.
|
|
|
|
\param looping Whether or not to repeat the sound in a loop.
|
|
|
|
\param device The sound device to use to play the sound, use \c NULL for
|
|
|
|
default.
|
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-12-25 00:42:48 +04:00
|
|
|
/*!
|
|
|
|
\fn BFileGameSound::~BFileGameSound()
|
|
|
|
\brief Destroys the BFileGameSound object.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BGameSound* BFileGameSound::Clone() const
|
|
|
|
\brief Not implemented, always returns \c NULL.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BFileGameSound::StartPlaying()
|
|
|
|
\brief Plays the sound file.
|
|
|
|
|
|
|
|
\returns A status code, \c B_OK on success or an error code on error.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BFileGameSound::StopPlaying()
|
|
|
|
\brief Stops playback of the sound file.
|
|
|
|
|
|
|
|
\returns A status code, \c B_OK on success or an error code on error.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BFileGameSound::Preload()
|
|
|
|
\brief Preload the sound file into memory so that playback won't be delayed.
|
|
|
|
|
|
|
|
\returns A status code, \c B_OK on success or an error code if we were
|
2014-06-12 00:45:07 +04:00
|
|
|
unable to communicate with the sound port.
|
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-12 00:45:07 +04:00
|
|
|
\fn void BFileGameSound::FillBuffer(void* inBuffer, size_t inByteCount)
|
2012-12-25 00:42:48 +04:00
|
|
|
\brief Fill a buffer with sound data.
|
|
|
|
|
|
|
|
\param inBuffer The buffer to fill.
|
|
|
|
\param inByteCount The number of bytes to fill buffer with.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BFileGameSound::SetPaused(bool isPaused, bigtime_t rampTime)
|
|
|
|
\brief Pauses playback if \a isPaused is \c true or resumes play if
|
2014-06-12 00:45:07 +04:00
|
|
|
\a isPaused is \c false.
|
2012-12-25 00:42:48 +04:00
|
|
|
|
|
|
|
\param isPaused \c true to pause playback, \c false to resume playback.
|
|
|
|
\param rampTime Determines how long the change in playback state should
|
2014-06-12 00:45:07 +04:00
|
|
|
take to complete in microseconds. Set to 0 for an instantaneous
|
|
|
|
change.
|
2012-12-25 00:42:48 +04:00
|
|
|
|
2012-12-25 01:05:51 +04:00
|
|
|
\returns A status code.
|
|
|
|
\retval B_OK The playback state was updated.
|
2012-12-25 00:42:48 +04:00
|
|
|
\retval EALREADY Already in the requested playback state.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 00:42:48 +04:00
|
|
|
*/
|
2012-12-25 01:05:51 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int32 BFileGameSound::IsPaused()
|
|
|
|
\brief Returns the current playback status.
|
|
|
|
|
|
|
|
\returns An integer indicating the current playback status.
|
|
|
|
\retval B_NOT_PAUSED Sound is playing.
|
|
|
|
\retval B_PAUSE_IN_PROGRESS The sound is transitioning to or from a paused state.
|
|
|
|
\retval B_PAUSED Sound is paused.
|
2014-06-12 00:45:07 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2012-12-25 01:05:51 +04:00
|
|
|
*/
|