1/******************************************************************************* 2/ 3/ File: SoundUtils.h 4/ 5/ Description: Utility functions for handling audio data. 6/ 7/ Copyright 1998-1999, Be Incorporated, All Rights Reserved 8/ 9*******************************************************************************/ 10 11#if ! defined( _SoundUtils_h ) 12#define _SoundUtils_h 13 14#include <MediaDefs.h> 15 16// Simple helper functions that come in handy when doing 17// buffer calculations. 18double us_to_s(bigtime_t usecs); 19bigtime_t s_to_us(double secs); 20 21int bytes_per_frame(const media_raw_audio_format & format); 22int frames_per_buffer(const media_raw_audio_format & format); 23bigtime_t buffer_duration(const media_raw_audio_format & format); 24bigtime_t frames_duration(const media_raw_audio_format & format, 25 int64 num_frames); 26int64 frames_for_duration(const media_raw_audio_format & format, 27 bigtime_t duration); 28int buffers_for_duration(const media_raw_audio_format & format, 29 bigtime_t duration); 30 31// This is a common hook function interface for 32// SoundConsumer and SoundProducer to use. 33typedef void (*SoundProcessFunc)(void * cookie, 34 bigtime_t timestamp, void * data, size_t datasize, 35 const media_raw_audio_format & format); 36typedef void (*SoundNotifyFunc)(void * cookie, 37 int32 code, ...); 38 39// These are special codes that we use in the Notify 40// function hook. 41enum { 42 B_WILL_START = 1, // performance_time 43 B_WILL_STOP, // performance_time immediate 44 B_WILL_SEEK, // performance_time media_time 45 B_WILL_TIMEWARP, // real_time performance_time 46 B_CONNECTED, // name (char*) 47 B_DISCONNECTED, // 48 B_FORMAT_CHANGED, // media_raw_audio_format* 49 B_NODE_DIES, // node will die! 50 B_HOOKS_CHANGED, // 51 B_OP_TIMED_OUT, // timeout that expired -- Consumer only 52 B_PRODUCER_DATA_STATUS, // status performance_time -- Consumer only 53 B_LATE_NOTICE // how_much performance_time -- Producer only 54}; 55 56#endif /* _SoundUtils_h */ 57