1 /* 2 * Copyright 2003-2009 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Marcus Overhagen 7 */ 8 #ifndef _MIXER_UTILS_H 9 #define _MIXER_UTILS_H 10 11 12 #ifndef __SGI_STL_INTERNAL_ALGOBASE_H 13 template<class t> const t & max(const t &t1, const t &t2) { return (t1 > t2) ? t1 : t2; } 14 template<class t> const t & min(const t &t1, const t &t2) { return (t1 < t2) ? t1 : t2; } 15 #endif 16 template<class t> const t abs(const t t1) { return (t1 < 0) ? - t1 : t1; } 17 18 19 void fix_multiaudio_format(media_multi_audio_format *format); 20 21 int count_nonzero_bits(uint32 value); 22 23 uint32 GetChannelMask(int channel, uint32 all_channel_masks); 24 int GetChannelType(int channel, uint32 all_channel_masks); 25 26 bool HasKawamba(); 27 28 void ZeroFill(float *_dst, int32 _dst_sample_offset, int32 _sample_count); 29 30 bigtime_t buffer_duration(const media_multi_audio_format & format); 31 32 int bytes_per_sample(const media_multi_audio_format & format); 33 34 int bytes_per_frame(const media_multi_audio_format & format); 35 int frames_per_buffer(const media_multi_audio_format & format); 36 37 int64 frames_for_duration(double framerate, bigtime_t duration); 38 bigtime_t duration_for_frames(double framerate, int64 frames); 39 40 int ChannelMaskToChannelType(uint32 mask); 41 uint32 ChannelTypeToChannelMask(int type); 42 43 double us_to_s(bigtime_t usecs); 44 bigtime_t s_to_us(double secs); 45 46 class MixerInput; 47 class MixerOutput; 48 49 const char *StringForFormat(char *buf, MixerOutput *output); 50 const char *StringForFormat(char *buf, MixerInput *input); 51 const char *StringForChannelMask(char *buf, uint32 mask); 52 const char *StringForChannelType(char *buf, int type); 53 54 #endif // _MIXER_UTILS_H 55