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:
parent
17a5db77c0
commit
cb3f273dd2
@ -76,7 +76,8 @@ public:
|
|||||||
status_t InitCheck() const;
|
status_t InitCheck() const;
|
||||||
|
|
||||||
// Get info about the underlying file format.
|
// 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.
|
// These functions are for read-only access to a media file.
|
||||||
|
@ -1,31 +1,23 @@
|
|||||||
/******************************************************************************
|
/*
|
||||||
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||||
File: PlaySound.h
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
Description: Interface for a simple beep sound.
|
|
||||||
|
|
||||||
Copyright 1995-97, Be Incorporated
|
|
||||||
|
|
||||||
******************************************************************************/
|
|
||||||
#ifndef _PLAY_SOUND_H
|
#ifndef _PLAY_SOUND_H
|
||||||
#define _PLAY_SOUND_H
|
#define _PLAY_SOUND_H
|
||||||
|
|
||||||
#ifndef _BE_BUILD_H
|
|
||||||
#include <BeBuild.h>
|
|
||||||
#endif
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
|
||||||
|
|
||||||
typedef sem_id sound_handle;
|
typedef sem_id sound_handle;
|
||||||
|
|
||||||
sound_handle play_sound(const entry_ref *soundRef,
|
|
||||||
bool mix,
|
sound_handle play_sound(const entry_ref* soundRef, bool mix, bool queue,
|
||||||
bool queue,
|
bool background);
|
||||||
bool background
|
|
||||||
);
|
|
||||||
|
|
||||||
status_t stop_sound(sound_handle handle);
|
status_t stop_sound(sound_handle handle);
|
||||||
|
|
||||||
status_t wait_for_sound(sound_handle handle);
|
status_t wait_for_sound(sound_handle handle);
|
||||||
|
|
||||||
#endif /* #ifndef _PLAY_SOUND_H*/
|
|
||||||
|
#endif // _PLAY_SOUND_H
|
||||||
|
@ -1,47 +1,55 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||||
/ File: RealtimeAlloc.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: Allocation from separate "pools" of memory. Those pools
|
#ifndef _REALTIME_ALLOC_H
|
||||||
/ 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)
|
|
||||||
#define _REALTIME_ALLOC_H
|
#define _REALTIME_ALLOC_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.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)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct rtm_pool rtm_pool;
|
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 the default pool is already created, it will return EALREADY. */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
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);
|
|
||||||
#endif
|
|
||||||
status_t rtm_delete_pool(rtm_pool * pool);
|
|
||||||
/* If NULL is passed for pool, the default pool is used (if created). */
|
|
||||||
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 */
|
status_t rtm_create_pool(rtm_pool** out_pool, size_t total_size,
|
||||||
rtm_pool * rtm_default_pool();
|
const char* name = NULL);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
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 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 it has not yet been initialized. */
|
||||||
|
rtm_pool* rtm_default_pool();
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SOUND_H
|
#ifndef _SOUND_H
|
||||||
#define _SOUND_H
|
#define _SOUND_H
|
||||||
|
|
||||||
|
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
|
|
||||||
class BFile;
|
class BFile;
|
||||||
@ -16,61 +16,63 @@ namespace BPrivate {
|
|||||||
class BTrackReader;
|
class BTrackReader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BSound {
|
class BSound {
|
||||||
public:
|
public:
|
||||||
BSound(void *data, size_t size,
|
BSound(void* data, size_t size,
|
||||||
const media_raw_audio_format &format,
|
const media_raw_audio_format& format,
|
||||||
bool freeWhenDone = false);
|
bool freeWhenDone = false);
|
||||||
BSound(const entry_ref *soundFile,
|
BSound(const entry_ref* soundFile,
|
||||||
bool loadIntoMemory = false);
|
bool loadIntoMemory = false);
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
BSound * AcquireRef();
|
BSound* AcquireRef();
|
||||||
bool ReleaseRef();
|
bool ReleaseRef();
|
||||||
int32 RefCount() const; // unreliable!
|
int32 RefCount() const; // unreliable!
|
||||||
|
|
||||||
virtual bigtime_t Duration() const;
|
virtual bigtime_t Duration() const;
|
||||||
virtual const media_raw_audio_format &Format() const;
|
virtual const media_raw_audio_format &Format() const;
|
||||||
virtual const void * Data() const; // returns NULL for files
|
virtual const void* Data() const; // returns NULL for files
|
||||||
virtual off_t Size() const;
|
virtual off_t Size() const;
|
||||||
|
|
||||||
virtual bool GetDataAt(off_t offset,
|
virtual bool GetDataAt(off_t offset,
|
||||||
void *intoBuffer, size_t bufferSize,
|
void* intoBuffer, size_t bufferSize,
|
||||||
size_t *outUsed);
|
size_t* outUsed);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BSound(const media_raw_audio_format &format);
|
BSound(const media_raw_audio_format& format);
|
||||||
virtual status_t Perform(int32 code, ...);
|
virtual status_t Perform(int32 code, ...);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class DummyFriend;
|
friend class DummyFriend;
|
||||||
virtual ~BSound();
|
virtual ~BSound();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual status_t BindTo(BSoundPlayer *player,
|
virtual status_t BindTo(BSoundPlayer* player,
|
||||||
const media_raw_audio_format &format);
|
const media_raw_audio_format& format);
|
||||||
virtual status_t UnbindFrom(BSoundPlayer *player);
|
virtual status_t UnbindFrom(BSoundPlayer* player);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _Reserved_Sound_0(void *); // BindTo
|
status_t _Reserved_Sound_0(void*); // BindTo
|
||||||
status_t _Reserved_Sound_1(void *); // UnbindFrom
|
status_t _Reserved_Sound_1(void*); // UnbindFrom
|
||||||
virtual status_t _Reserved_Sound_2(void *);
|
virtual status_t _Reserved_Sound_2(void*);
|
||||||
virtual status_t _Reserved_Sound_3(void *);
|
virtual status_t _Reserved_Sound_3(void*);
|
||||||
virtual status_t _Reserved_Sound_4(void *);
|
virtual status_t _Reserved_Sound_4(void*);
|
||||||
virtual status_t _Reserved_Sound_5(void *);
|
virtual status_t _Reserved_Sound_5(void*);
|
||||||
|
|
||||||
void * fData;
|
private:
|
||||||
size_t fDataSize;
|
void* fData;
|
||||||
BFile * fFile;
|
size_t fDataSize;
|
||||||
int32 fRefCount;
|
BFile* fFile;
|
||||||
status_t fStatus;
|
int32 fRefCount;
|
||||||
media_raw_audio_format fFormat;
|
status_t fStatus;
|
||||||
|
media_raw_audio_format fFormat;
|
||||||
|
|
||||||
bool fFreeWhenDone;
|
bool fFreeWhenDone;
|
||||||
bool fReserved[3];
|
bool fReserved[3];
|
||||||
|
|
||||||
BPrivate::BTrackReader *fTrackReader;
|
BPrivate::BTrackReader* fTrackReader;
|
||||||
uint32 fReserved2[18];
|
uint32 fReserved2[18];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SOUND_H
|
#endif // _SOUND_H
|
||||||
|
@ -1,103 +1,99 @@
|
|||||||
/******************************************************************************
|
/*
|
||||||
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||||
File: SoundFile.h
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
Description: Interface for a format-insensitive sound file object.
|
|
||||||
|
|
||||||
Copyright 1995-97, Be Incorporated
|
|
||||||
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SOUND_FILE_H
|
#ifndef _SOUND_FILE_H
|
||||||
#define _SOUND_FILE_H
|
#define _SOUND_FILE_H
|
||||||
|
|
||||||
#ifndef _BE_BUILD_H
|
|
||||||
#include <BeBuild.h>
|
|
||||||
#endif
|
|
||||||
#include <MediaDefs.h>
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
|
#include <MediaDefs.h>
|
||||||
|
|
||||||
enum /* sound_format*/
|
|
||||||
{ B_UNKNOWN_FILE,
|
|
||||||
B_AIFF_FILE,
|
|
||||||
B_WAVE_FILE,
|
|
||||||
B_UNIX_FILE };
|
|
||||||
|
|
||||||
class BSoundFile {
|
// file formats
|
||||||
|
enum {
|
||||||
public:
|
B_UNKNOWN_FILE,
|
||||||
BSoundFile();
|
B_AIFF_FILE,
|
||||||
BSoundFile(const entry_ref *ref,
|
B_WAVE_FILE,
|
||||||
uint32 open_mode);
|
B_UNIX_FILE
|
||||||
virtual ~BSoundFile();
|
|
||||||
|
|
||||||
status_t InitCheck() const;
|
|
||||||
|
|
||||||
status_t SetTo(const entry_ref *ref, uint32 open_mode);
|
|
||||||
|
|
||||||
int32 FileFormat() const;
|
|
||||||
int32 SamplingRate() const;
|
|
||||||
int32 CountChannels() const;
|
|
||||||
int32 SampleSize() const;
|
|
||||||
int32 ByteOrder() const;
|
|
||||||
int32 SampleFormat() const;
|
|
||||||
int32 FrameSize() const;
|
|
||||||
off_t CountFrames() const;
|
|
||||||
|
|
||||||
bool IsCompressed() const;
|
|
||||||
int32 CompressionType() const;
|
|
||||||
char *CompressionName() const;
|
|
||||||
|
|
||||||
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 SetCompressionType(int32 type);
|
|
||||||
virtual char *SetCompressionName(char *name);
|
|
||||||
virtual bool SetIsCompressed(bool tf);
|
|
||||||
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);
|
|
||||||
off_t FrameIndex() const;
|
|
||||||
off_t FramesRemaining() const;
|
|
||||||
|
|
||||||
BFile *fSoundFile;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
virtual void _ReservedSoundFile1();
|
|
||||||
virtual void _ReservedSoundFile2();
|
|
||||||
virtual void _ReservedSoundFile3();
|
|
||||||
|
|
||||||
int32 fFileFormat;
|
|
||||||
int32 fSamplingRate;
|
|
||||||
int32 fChannelCount;
|
|
||||||
int32 fSampleSize;
|
|
||||||
int32 fByteOrder;
|
|
||||||
int32 fSampleFormat;
|
|
||||||
|
|
||||||
off_t fByteOffset; /* offset to first sample */
|
|
||||||
|
|
||||||
off_t fFrameCount;
|
|
||||||
off_t fFrameIndex;
|
|
||||||
|
|
||||||
bool fIsCompressed;
|
|
||||||
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*/
|
class BSoundFile {
|
||||||
|
public:
|
||||||
|
BSoundFile();
|
||||||
|
BSoundFile(const entry_ref* ref,
|
||||||
|
uint32 openMode);
|
||||||
|
virtual ~BSoundFile();
|
||||||
|
|
||||||
|
status_t InitCheck() const;
|
||||||
|
|
||||||
|
status_t SetTo(const entry_ref* ref, uint32 openMode);
|
||||||
|
|
||||||
|
int32 FileFormat() const;
|
||||||
|
int32 SamplingRate() const;
|
||||||
|
int32 CountChannels() const;
|
||||||
|
int32 SampleSize() const;
|
||||||
|
int32 ByteOrder() const;
|
||||||
|
int32 SampleFormat() const;
|
||||||
|
int32 FrameSize() const;
|
||||||
|
off_t CountFrames() const;
|
||||||
|
|
||||||
|
bool IsCompressed() const;
|
||||||
|
int32 CompressionType() const;
|
||||||
|
char* CompressionName() const;
|
||||||
|
|
||||||
|
virtual int32 SetFileFormat(int32 format);
|
||||||
|
virtual int32 SetSamplingRate(int32 fps);
|
||||||
|
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 compressed);
|
||||||
|
virtual off_t SetDataLocation(off_t offset);
|
||||||
|
virtual off_t SetFrameCount(off_t count);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
BFile* fSoundFile;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
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;
|
||||||
|
int32 fSampleSize;
|
||||||
|
int32 fByteOrder;
|
||||||
|
int32 fSampleFormat;
|
||||||
|
|
||||||
|
off_t fByteOffset;
|
||||||
|
// offset to first sample
|
||||||
|
|
||||||
|
off_t fFrameCount;
|
||||||
|
off_t fFrameIndex;
|
||||||
|
|
||||||
|
bool fIsCompressed;
|
||||||
|
int32 fCompressionType;
|
||||||
|
char* fCompressionName;
|
||||||
|
status_t fCStatus;
|
||||||
|
BMediaFile* fMediaFile;
|
||||||
|
BMediaTrack* fMediaTrack;
|
||||||
|
|
||||||
|
uint32 _reserved[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _SOUND_FILE_H
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
/* SoundPlayer.h */
|
/*
|
||||||
/* Copyright 1998 Be Incorporated. All rights reserved. */
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
#if !defined(_SOUND_PLAYER_H)
|
*/
|
||||||
|
#ifndef _SOUND_PLAYER_H
|
||||||
#define _SOUND_PLAYER_H
|
#define _SOUND_PLAYER_H
|
||||||
|
|
||||||
|
|
||||||
#include <MediaDefs.h>
|
#include <exception>
|
||||||
|
|
||||||
#include <BufferProducer.h>
|
#include <BufferProducer.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <exception>
|
#include <MediaDefs.h>
|
||||||
|
|
||||||
|
|
||||||
class BContinuousParameter;
|
class BContinuousParameter;
|
||||||
@ -16,188 +18,214 @@ class BParameterWeb;
|
|||||||
class BSound;
|
class BSound;
|
||||||
class _SoundPlayNode;
|
class _SoundPlayNode;
|
||||||
|
|
||||||
|
|
||||||
class sound_error : public std::exception {
|
class sound_error : public std::exception {
|
||||||
const char * m_str_const;
|
const char* m_str_const;
|
||||||
public:
|
public:
|
||||||
sound_error(const char * str);
|
sound_error(const char* string);
|
||||||
const char * what() const throw ();
|
const char* what() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BSoundPlayer {
|
class BSoundPlayer {
|
||||||
friend class _SoundPlayNode;
|
friend class _SoundPlayNode;
|
||||||
public:
|
public:
|
||||||
enum sound_player_notification {
|
enum sound_player_notification {
|
||||||
B_STARTED = 1,
|
B_STARTED = 1,
|
||||||
B_STOPPED,
|
B_STOPPED,
|
||||||
B_SOUND_DONE
|
B_SOUND_DONE
|
||||||
};
|
};
|
||||||
|
|
||||||
BSoundPlayer(
|
BSoundPlayer(const char* name = NULL,
|
||||||
const char * name = NULL,
|
void (*PlayBuffer)(void*, void* buffer,
|
||||||
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
|
size_t size,
|
||||||
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
|
const media_raw_audio_format& format)
|
||||||
void * cookie = NULL);
|
= NULL,
|
||||||
BSoundPlayer(
|
void (*Notifier)(void*,
|
||||||
const media_raw_audio_format * format,
|
sound_player_notification what, ...)
|
||||||
const char * name = NULL,
|
= NULL,
|
||||||
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
|
void* cookie = NULL);
|
||||||
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
|
BSoundPlayer(
|
||||||
void * cookie = NULL);
|
const media_raw_audio_format* format,
|
||||||
BSoundPlayer(
|
const char* name = NULL,
|
||||||
const media_node & toNode,
|
void (*PlayBuffer)(void*, void* buffer,
|
||||||
const media_multi_audio_format * format = NULL,
|
size_t size,
|
||||||
const char * name = NULL,
|
const media_raw_audio_format& format)
|
||||||
const media_input * input = NULL,
|
= NULL,
|
||||||
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
|
void (*Notifier)(void*,
|
||||||
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
|
sound_player_notification what, ...)
|
||||||
void * cookie = NULL);
|
= NULL,
|
||||||
virtual ~BSoundPlayer();
|
void* cookie = NULL);
|
||||||
|
BSoundPlayer(
|
||||||
|
const media_node& toNode,
|
||||||
|
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* cookie = NULL);
|
||||||
|
virtual ~BSoundPlayer();
|
||||||
|
|
||||||
status_t InitCheck(); // new in R4.1
|
status_t InitCheck();
|
||||||
media_raw_audio_format Format() const; // new in R4.1
|
media_raw_audio_format Format() const;
|
||||||
|
|
||||||
status_t Start();
|
status_t Start();
|
||||||
void Stop(
|
void Stop(bool block = true, bool flush = true);
|
||||||
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,
|
||||||
BufferPlayerFunc BufferPlayer() const;
|
const media_raw_audio_format&);
|
||||||
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 * 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 * cookie = NULL);
|
|
||||||
|
|
||||||
typedef int32 play_id;
|
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,
|
||||||
|
...);
|
||||||
|
EventNotifierFunc EventNotifier() const;
|
||||||
|
void SetNotifier(void (*Notifier)(void*,
|
||||||
|
sound_player_notification what, ...));
|
||||||
|
void* Cookie() const;
|
||||||
|
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);
|
||||||
|
|
||||||
bigtime_t CurrentTime();
|
typedef int32 play_id;
|
||||||
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);
|
|
||||||
|
|
||||||
float Volume(); /* 0 - 1.0 */
|
bigtime_t CurrentTime();
|
||||||
void SetVolume( /* 0 - 1.0 */
|
bigtime_t PerformanceTime();
|
||||||
float new_volume);
|
status_t Preroll();
|
||||||
float VolumeDB( /* -xx - +xx (see GetVolumeInfo()) */
|
play_id StartPlaying(BSound* sound,
|
||||||
bool forcePoll = false); /* if false, cached value will be used if new enough */
|
bigtime_t atTime = 0);
|
||||||
void SetVolumeDB(
|
play_id StartPlaying(BSound* sound,
|
||||||
float volume_dB);
|
bigtime_t atTime,
|
||||||
status_t GetVolumeInfo(
|
float withVolume);
|
||||||
media_node * out_node,
|
status_t SetSoundVolume(play_id sound, float newVolume);
|
||||||
int32 * out_parameter_id,
|
bool IsPlaying(play_id id);
|
||||||
float * out_min_dB,
|
status_t StopPlaying(play_id id);
|
||||||
float * out_max_dB);
|
status_t WaitForSound(play_id id);
|
||||||
bigtime_t Latency();
|
|
||||||
|
|
||||||
virtual bool HasData();
|
// On [0..1]
|
||||||
void SetHasData( // this does more than just set a flag
|
float Volume();
|
||||||
bool has_data);
|
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(bool hasData);
|
||||||
|
|
||||||
|
// TODO: Needs Perform() method for FBC!
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void SetInitError( // new in R4.1
|
void SetInitError(status_t inError);
|
||||||
status_t in_error);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void _SoundPlayBufferFunc(void *cookie, void *buffer, size_t size,
|
static void _SoundPlayBufferFunc(void* cookie,
|
||||||
const media_raw_audio_format &format);
|
void* buffer, size_t size,
|
||||||
|
const media_raw_audio_format& format);
|
||||||
|
|
||||||
virtual status_t _Reserved_SoundPlayer_0(void *, ...);
|
// FBC padding
|
||||||
virtual status_t _Reserved_SoundPlayer_1(void *, ...);
|
virtual status_t _Reserved_SoundPlayer_0(void*, ...);
|
||||||
virtual status_t _Reserved_SoundPlayer_2(void *, ...);
|
virtual status_t _Reserved_SoundPlayer_1(void*, ...);
|
||||||
virtual status_t _Reserved_SoundPlayer_3(void *, ...);
|
virtual status_t _Reserved_SoundPlayer_2(void*, ...);
|
||||||
virtual status_t _Reserved_SoundPlayer_4(void *, ...);
|
virtual status_t _Reserved_SoundPlayer_3(void*, ...);
|
||||||
virtual status_t _Reserved_SoundPlayer_5(void *, ...);
|
virtual status_t _Reserved_SoundPlayer_4(void*, ...);
|
||||||
virtual status_t _Reserved_SoundPlayer_6(void *, ...);
|
virtual status_t _Reserved_SoundPlayer_5(void*, ...);
|
||||||
virtual status_t _Reserved_SoundPlayer_7(void *, ...);
|
virtual status_t _Reserved_SoundPlayer_6(void*, ...);
|
||||||
|
virtual status_t _Reserved_SoundPlayer_7(void*, ...);
|
||||||
_SoundPlayNode * fPlayerNode;
|
|
||||||
|
|
||||||
struct _playing_sound {
|
private:
|
||||||
_playing_sound *next;
|
_SoundPlayNode* fPlayerNode;
|
||||||
off_t current_offset;
|
|
||||||
BSound *sound;
|
|
||||||
play_id id;
|
|
||||||
int32 delta;
|
|
||||||
int32 rate;
|
|
||||||
sem_id wait_sem;
|
|
||||||
float volume;
|
|
||||||
};
|
|
||||||
_playing_sound *fPlayingSounds;
|
|
||||||
|
|
||||||
struct _waiting_sound {
|
struct _playing_sound {
|
||||||
_waiting_sound * next;
|
_playing_sound* next;
|
||||||
bigtime_t start_time;
|
off_t current_offset;
|
||||||
BSound * sound;
|
BSound* sound;
|
||||||
play_id id;
|
play_id id;
|
||||||
int32 rate;
|
int32 delta;
|
||||||
float volume;
|
int32 rate;
|
||||||
};
|
sem_id wait_sem;
|
||||||
_waiting_sound *fWaitingSounds;
|
float volume;
|
||||||
|
};
|
||||||
|
|
||||||
void (*fPlayBufferFunc)(void * cookie, void * buffer, size_t size, const media_raw_audio_format & format);
|
_playing_sound* fPlayingSounds;
|
||||||
void (*fNotifierFunc)(void * cookie, sound_player_notification what, ...);
|
|
||||||
BLocker fLocker;
|
|
||||||
float fVolumeDB;
|
|
||||||
media_input fMediaInput; // the system mixer
|
|
||||||
media_output fMediaOutput; // the player node
|
|
||||||
void * fCookie;
|
|
||||||
int32 fFlags;
|
|
||||||
|
|
||||||
status_t fInitStatus; // new in R4.1
|
struct _waiting_sound {
|
||||||
BContinuousParameter * fVolumeSlider;
|
_waiting_sound* next;
|
||||||
bigtime_t fLastVolumeUpdate;
|
bigtime_t start_time;
|
||||||
BParameterWeb *fParameterWeb;
|
BSound* sound;
|
||||||
uint32 _m_reserved[15];
|
play_id id;
|
||||||
|
int32 rate;
|
||||||
|
float volume;
|
||||||
|
};
|
||||||
|
|
||||||
void NotifySoundDone(
|
_waiting_sound* fWaitingSounds;
|
||||||
play_id sound,
|
|
||||||
bool got_to_play);
|
|
||||||
|
|
||||||
void get_volume_slider();
|
void (*fPlayBufferFunc)(void* cookie, void* buffer,
|
||||||
void Init(
|
size_t size, const media_raw_audio_format& format);
|
||||||
const media_node * node,
|
void (*fNotifierFunc)(void* cookie, sound_player_notification what,
|
||||||
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(
|
BLocker fLocker;
|
||||||
void * buffer,
|
float fVolumeDB;
|
||||||
size_t size,
|
media_input fMediaInput;
|
||||||
const media_raw_audio_format & format);
|
// Usually the system mixer
|
||||||
|
media_output fMediaOutput;
|
||||||
|
// The playback node
|
||||||
|
void* fCookie;
|
||||||
|
// Opaque handle passed to hooks
|
||||||
|
int32 fFlags;
|
||||||
|
|
||||||
|
status_t fInitStatus;
|
||||||
|
BContinuousParameter* fVolumeSlider;
|
||||||
|
bigtime_t fLastVolumeUpdate;
|
||||||
|
BParameterWeb* fParameterWeb;
|
||||||
|
|
||||||
|
uint32 _m_reserved[15];
|
||||||
|
|
||||||
|
private:
|
||||||
|
void NotifySoundDone(play_id sound, bool gotToPlay);
|
||||||
|
|
||||||
|
void get_volume_slider();
|
||||||
|
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, size_t size,
|
||||||
|
const media_raw_audio_format& format);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // _SOUND_PLAYER_H
|
||||||
#endif /* _SOUND_PLAYER_H */
|
|
||||||
|
Loading…
Reference in New Issue
Block a user