Rewrote more headers, style updates in some

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32785 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2009-08-28 14:39:55 +00:00
parent 17a5db77c0
commit cb3f273dd2
6 changed files with 371 additions and 344 deletions

View File

@ -76,7 +76,8 @@ public:
status_t InitCheck() const;
// Get info about the underlying file format.
status_t GetFileFormatInfo(media_file_format* mfi) const;
status_t GetFileFormatInfo(
media_file_format* mfi) const;
//
// These functions are for read-only access to a media file.

View File

@ -1,31 +1,23 @@
/******************************************************************************
File: PlaySound.h
Description: Interface for a simple beep sound.
Copyright 1995-97, Be Incorporated
******************************************************************************/
/*
* Copyright 2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _PLAY_SOUND_H
#define _PLAY_SOUND_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <OS.h>
#include <Entry.h>
typedef sem_id sound_handle;
sound_handle play_sound(const entry_ref *soundRef,
bool mix,
bool queue,
bool background
);
sound_handle play_sound(const entry_ref* soundRef, bool mix, bool queue,
bool background);
status_t stop_sound(sound_handle handle);
status_t wait_for_sound(sound_handle handle);
#endif /* #ifndef _PLAY_SOUND_H*/
#endif // _PLAY_SOUND_H

View File

@ -1,46 +1,54 @@
/*******************************************************************************
/
/ File: RealtimeAlloc.h
/
/ Description: Allocation from separate "pools" of memory. Those pools
/ will be locked in RAM if realtime allocators are turned
/ on in the BMediaRoster, so don't waste this memory unless
/ it's needed. Also, the shared pool is a scarce resource,
/ so it's better if you create your own pool for your own
/ needs and leave the shared pool for BMediaNode instances
/ and the needs of the Media Kit.
/
/ Copyright 1998-99, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_REALTIME_ALLOC_H)
/*
* Copyright 2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _REALTIME_ALLOC_H
#define _REALTIME_ALLOC_H
#include <SupportDefs.h>
/*! Allocation from separate "pools" of memory. Those pools will be locked
in RAM if realtime allocators are turned on in the BMediaRoster, so don't
waste this memory unless it's needed. Also, the shared pool is a scarce
resource, so it's better if you create your own pool for your own needs
and leave the shared pool for BMediaNode instances and the needs of the
Media Kit.
*/
#if defined(__cplusplus)
extern "C" {
#endif
typedef struct rtm_pool rtm_pool;
/* If out_pool is NULL, the default pool will be created if it isn't already. */
/* If out_pool is NULL, the default pool will be created if it isn't */
/* already. */
/* If the default pool is already created, it will return EALREADY. */
#if defined(__cplusplus)
status_t rtm_create_pool(rtm_pool ** out_pool, size_t total_size, const char * name=NULL);
status_t rtm_create_pool(rtm_pool** out_pool, size_t total_size,
const char* name = NULL);
#else
status_t rtm_create_pool(rtm_pool ** out_pool, size_t total_size, const char * name);
status_t rtm_create_pool(rtm_pool** out_pool, size_t total_size,
const char* name);
#endif
status_t rtm_delete_pool(rtm_pool* pool);
/* If NULL is passed for pool, the default pool is used (if created). */
/* If NULL is passed for 'pool', the default pool is used if it has been */
/* created already. */
void* rtm_alloc(rtm_pool* pool, size_t size);
status_t rtm_free(void* data);
status_t rtm_realloc(void** data, size_t new_size);
status_t rtm_size_for(void* data);
status_t rtm_phys_size_for(void* data);
/* Return the default pool, or NULL if not yet initialized */
/* Return the default pool, or NULL if it has not yet been initialized. */
rtm_pool* rtm_default_pool();
#if defined(__cplusplus)

View File

@ -1,11 +1,11 @@
/*
* Copyright 2009, Haiku Inc. All Rights Reserved.
* Copyright 2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SOUND_H
#define _SOUND_H
#include <MediaDefs.h>
class BFile;
@ -16,6 +16,7 @@ namespace BPrivate {
class BTrackReader;
};
class BSound {
public:
BSound(void* data, size_t size,
@ -59,6 +60,7 @@ virtual status_t _Reserved_Sound_3(void *);
virtual status_t _Reserved_Sound_4(void*);
virtual status_t _Reserved_Sound_5(void*);
private:
void* fData;
size_t fDataSize;
BFile* fFile;

View File

@ -1,41 +1,35 @@
/******************************************************************************
File: SoundFile.h
Description: Interface for a format-insensitive sound file object.
Copyright 1995-97, Be Incorporated
******************************************************************************/
/*
* Copyright 2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SOUND_FILE_H
#define _SOUND_FILE_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <MediaDefs.h>
#include <Entry.h>
#include <File.h>
#include <MediaDefs.h>
enum /* sound_format*/
{ B_UNKNOWN_FILE,
// file formats
enum {
B_UNKNOWN_FILE,
B_AIFF_FILE,
B_WAVE_FILE,
B_UNIX_FILE };
B_UNIX_FILE
};
class BSoundFile {
public:
BSoundFile();
BSoundFile(const entry_ref* ref,
uint32 open_mode);
uint32 openMode);
virtual ~BSoundFile();
status_t InitCheck() const;
status_t SetTo(const entry_ref *ref, uint32 open_mode);
status_t SetTo(const entry_ref* ref, uint32 openMode);
int32 FileFormat() const;
int32 SamplingRate() const;
@ -52,19 +46,19 @@ public:
virtual int32 SetFileFormat(int32 format);
virtual int32 SetSamplingRate(int32 fps);
virtual int32 SetChannelCount(int32 spf);
virtual int32 SetSampleSize(int32 bps);
virtual int32 SetByteOrder(int32 bord);
virtual int32 SetSampleFormat(int32 fmt);
virtual int32 SetChannelCount(int32 samplesPerFrame);
virtual int32 SetSampleSize(int32 bytesPerSample);
virtual int32 SetByteOrder(int32 byteOrder);
virtual int32 SetSampleFormat(int32 format);
virtual int32 SetCompressionType(int32 type);
virtual char* SetCompressionName(char* name);
virtual bool SetIsCompressed(bool tf);
virtual bool SetIsCompressed(bool compressed);
virtual off_t SetDataLocation(off_t offset);
virtual off_t SetFrameCount(off_t count);
size_t ReadFrames(char *buf, size_t count);
size_t WriteFrames(char *buf, size_t count);
virtual off_t SeekToFrame(off_t n);
size_t ReadFrames(char* buffer, size_t count);
size_t WriteFrames(char* buffer, size_t count);
virtual off_t SeekToFrame(off_t index);
off_t FrameIndex() const;
off_t FramesRemaining() const;
@ -76,6 +70,9 @@ virtual void _ReservedSoundFile1();
virtual void _ReservedSoundFile2();
virtual void _ReservedSoundFile3();
void _init_raw_stats();
status_t _ref_to_file(const entry_ref* ref);
int32 fFileFormat;
int32 fSamplingRate;
int32 fChannelCount;
@ -83,7 +80,8 @@ virtual void _ReservedSoundFile3();
int32 fByteOrder;
int32 fSampleFormat;
off_t fByteOffset; /* offset to first sample */
off_t fByteOffset;
// offset to first sample
off_t fFrameCount;
off_t fFrameIndex;
@ -92,12 +90,10 @@ virtual void _ReservedSoundFile3();
int32 fCompressionType;
char* fCompressionName;
status_t fCStatus;
void _init_raw_stats();
status_t _ref_to_file(const entry_ref *ref);
BMediaFile* fMediaFile;
BMediaTrack* fMediaTrack;
uint32 _reserved[2];
};
#endif /* #ifndef _SOUND_FILE_H*/
#endif // _SOUND_FILE_H

View File

@ -1,14 +1,16 @@
/* SoundPlayer.h */
/* Copyright 1998 Be Incorporated. All rights reserved. */
#if !defined(_SOUND_PLAYER_H)
/*
* Copyright 2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SOUND_PLAYER_H
#define _SOUND_PLAYER_H
#include <MediaDefs.h>
#include <exception>
#include <BufferProducer.h>
#include <Locker.h>
#include <exception>
#include <MediaDefs.h>
class BContinuousParameter;
@ -16,13 +18,15 @@ class BParameterWeb;
class BSound;
class _SoundPlayNode;
class sound_error : public std::exception {
const char* m_str_const;
public:
sound_error(const char * str);
sound_error(const char* string);
const char* what() const throw();
};
class BSoundPlayer {
friend class _SoundPlayNode;
public:
@ -32,49 +36,69 @@ public:
B_SOUND_DONE
};
BSoundPlayer(
const char * name = NULL,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
BSoundPlayer(const char* name = NULL,
void (*PlayBuffer)(void*, void* buffer,
size_t size,
const media_raw_audio_format& format)
= NULL,
void (*Notifier)(void*,
sound_player_notification what, ...)
= NULL,
void* cookie = NULL);
BSoundPlayer(
const media_raw_audio_format* format,
const char* name = NULL,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
void (*PlayBuffer)(void*, void* buffer,
size_t size,
const media_raw_audio_format& format)
= NULL,
void (*Notifier)(void*,
sound_player_notification what, ...)
= NULL,
void* cookie = NULL);
BSoundPlayer(
const media_node& toNode,
const media_multi_audio_format * format = NULL,
const media_multi_audio_format* format
= NULL,
const char* name = NULL,
const media_input* input = NULL,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
void (*PlayBuffer)(void*, void* buffer,
size_t size,
const media_raw_audio_format& format)
= NULL,
void (*Notifier)(void*,
sound_player_notification what, ...)
= NULL,
void* cookie = NULL);
virtual ~BSoundPlayer();
status_t InitCheck(); // new in R4.1
media_raw_audio_format Format() const; // new in R4.1
status_t InitCheck();
media_raw_audio_format Format() const;
status_t Start();
void Stop(
bool block = true,
bool flush = true);
void Stop(bool block = true, bool flush = true);
typedef void (*BufferPlayerFunc)(void*, void*, size_t,
const media_raw_audio_format&);
typedef void (*BufferPlayerFunc)(void *, void *, size_t, const media_raw_audio_format &);
BufferPlayerFunc BufferPlayer() const;
void SetBufferPlayer(
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format));
typedef void (*EventNotifierFunc)(void *, sound_player_notification what, ...);
void SetBufferPlayer(void (*PlayBuffer)(void*,
void* buffer, size_t size,
const media_raw_audio_format& format));
typedef void (*EventNotifierFunc)(void*, sound_player_notification what,
...);
EventNotifierFunc EventNotifier() const;
void SetNotifier(
void (*Notifier)(void *, sound_player_notification what, ...));
void SetNotifier(void (*Notifier)(void*,
sound_player_notification what, ...));
void* Cookie() const;
void SetCookie(
void * cookie);
void SetCallbacks( // atomic change
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
void SetCookie(void* cookie);
void SetCallbacks(void (*PlayBuffer)(void*,
void* buffer, size_t size,
const media_raw_audio_format& format)
= NULL,
void (*Notifier)(void*,
sound_player_notification what, ...)
= NULL,
void* cookie = NULL);
typedef int32 play_id;
@ -82,50 +106,45 @@ virtual ~BSoundPlayer();
bigtime_t CurrentTime();
bigtime_t PerformanceTime();
status_t Preroll();
play_id StartPlaying(
BSound * sound,
bigtime_t at_time = 0);
play_id StartPlaying(
BSound * sound,
bigtime_t at_time,
float with_volume);
status_t SetSoundVolume(
play_id sound, // update only non-NULL values
float new_volume);
bool IsPlaying(
play_id id);
status_t StopPlaying(
play_id id);
status_t WaitForSound(
play_id id);
play_id StartPlaying(BSound* sound,
bigtime_t atTime = 0);
play_id StartPlaying(BSound* sound,
bigtime_t atTime,
float withVolume);
status_t SetSoundVolume(play_id sound, float newVolume);
bool IsPlaying(play_id id);
status_t StopPlaying(play_id id);
status_t WaitForSound(play_id id);
float Volume(); /* 0 - 1.0 */
void SetVolume( /* 0 - 1.0 */
float new_volume);
float VolumeDB( /* -xx - +xx (see GetVolumeInfo()) */
bool forcePoll = false); /* if false, cached value will be used if new enough */
void SetVolumeDB(
float volume_dB);
status_t GetVolumeInfo(
media_node * out_node,
int32 * out_parameter_id,
float * out_min_dB,
float * out_max_dB);
// On [0..1]
float Volume();
void SetVolume(float volume);
// -xx - +xx (see GetVolumeInfo())
// If 'forcePoll' is false, a cached value will be used if new
// enough.
float VolumeDB(bool forcePoll = false);
void SetVolumeDB(float dB);
status_t GetVolumeInfo(media_node* _node,
int32* _parameterID, float* _minDB,
float* _maxDB);
bigtime_t Latency();
virtual bool HasData();
void SetHasData( // this does more than just set a flag
bool has_data);
void SetHasData(bool hasData);
// TODO: Needs Perform() method for FBC!
protected:
void SetInitError( // new in R4.1
status_t in_error);
void SetInitError(status_t inError);
private:
static void _SoundPlayBufferFunc(void *cookie, void *buffer, size_t size,
static void _SoundPlayBufferFunc(void* cookie,
void* buffer, size_t size,
const media_raw_audio_format& format);
// FBC padding
virtual status_t _Reserved_SoundPlayer_0(void*, ...);
virtual status_t _Reserved_SoundPlayer_1(void*, ...);
virtual status_t _Reserved_SoundPlayer_2(void*, ...);
@ -135,6 +154,7 @@ virtual status_t _Reserved_SoundPlayer_5(void *, ...);
virtual status_t _Reserved_SoundPlayer_6(void*, ...);
virtual status_t _Reserved_SoundPlayer_7(void*, ...);
private:
_SoundPlayNode* fPlayerNode;
struct _playing_sound {
@ -147,6 +167,7 @@ virtual status_t _Reserved_SoundPlayer_7(void *, ...);
sem_id wait_sem;
float volume;
};
_playing_sound* fPlayingSounds;
struct _waiting_sound {
@ -157,47 +178,54 @@ virtual status_t _Reserved_SoundPlayer_7(void *, ...);
int32 rate;
float volume;
};
_waiting_sound* fWaitingSounds;
void (*fPlayBufferFunc)(void * cookie, void * buffer, size_t size, const media_raw_audio_format & format);
void (*fNotifierFunc)(void * cookie, sound_player_notification what, ...);
void (*fPlayBufferFunc)(void* cookie, void* buffer,
size_t size, const media_raw_audio_format& format);
void (*fNotifierFunc)(void* cookie, sound_player_notification what,
...);
BLocker fLocker;
float fVolumeDB;
media_input fMediaInput; // the system mixer
media_output fMediaOutput; // the player node
media_input fMediaInput;
// Usually the system mixer
media_output fMediaOutput;
// The playback node
void* fCookie;
// Opaque handle passed to hooks
int32 fFlags;
status_t fInitStatus; // new in R4.1
status_t fInitStatus;
BContinuousParameter* fVolumeSlider;
bigtime_t fLastVolumeUpdate;
BParameterWeb* fParameterWeb;
uint32 _m_reserved[15];
void NotifySoundDone(
play_id sound,
bool got_to_play);
private:
void NotifySoundDone(play_id sound, bool gotToPlay);
void get_volume_slider();
void Init(
const media_node * node,
void Init(const media_node* node,
const media_multi_audio_format* format,
const char* name,
const media_input* input,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format),
void (*Notifier)(void *, sound_player_notification what, ...),
void * cookie);
// for B_STARTED and B_STOPPED, the argument is BSoundPlayer* (this)
// for B_SOUND_DONE, the arguments are play_id and true/false for whether it got to play data at all
virtual void Notify(
sound_player_notification what,
...);
// get data into the buffer to play -- this version will use the queued BSound system
virtual void PlayBuffer(
void * buffer,
void (*PlayBuffer)(void*, void* buffer,
size_t size,
const media_raw_audio_format& format),
void (*Notifier)(void*,
sound_player_notification what, ...),
void* cookie);
// For B_STARTED and B_STOPPED, the argument is BSoundPlayer* (this).
// For B_SOUND_DONE, the arguments are play_id and true/false for
// whether it got to play data at all.
virtual void Notify(sound_player_notification what,
...);
// Get data into the buffer to play -- this version will use the
// queued BSound system.
virtual void PlayBuffer(void* buffer, size_t size,
const media_raw_audio_format& format);
};
#endif /* _SOUND_PLAYER_H */
#endif // _SOUND_PLAYER_H