xref: /haiku/src/add-ons/media/media-add-ons/mixer/MixerUtils.h (revision 16d5c24e533eb14b7b8a99ee9f3ec9ba66335b1e)
1 #ifndef _MIXER_UTILS_H
2 #define _MIXER_UTILS_H
3 
4 #ifndef __SGI_STL_INTERNAL_ALGOBASE_H
5 template<class t> const t & max(const t &t1, const t &t2) { return (t1 > t2) ?  t1 : t2; }
6 template<class t> const t & min(const t &t1, const t &t2) { return (t1 < t2) ?  t1 : t2; }
7 #endif
8 template<class t> const t abs(const t t1) { return (t1 < 0) ?  - t1 : t1; }
9 
10 void fix_multiaudio_format(media_multi_audio_format *format);
11 
12 int count_nonzero_bits(uint32 value);
13 
14 uint32 GetChannelMask(int channel, uint32 all_channel_masks);
15 int GetChannelType(int channel, uint32 all_channel_masks);
16 
17 bool HasKawamba();
18 
19 void ZeroFill(float *_dst, int32 _dst_sample_offset, int32 _sample_count);
20 
21 bigtime_t buffer_duration(const media_multi_audio_format & format);
22 
23 int bytes_per_sample(const media_multi_audio_format & format);
24 
25 int bytes_per_frame(const media_multi_audio_format & format);
26 int frames_per_buffer(const media_multi_audio_format & format);
27 
28 int64 frames_for_duration(double framerate, bigtime_t duration);
29 bigtime_t duration_for_frames(double framerate, int64 frames);
30 
31 int ChannelMaskToChannelType(uint32 mask);
32 uint32 ChannelTypeToChannelMask(int type);
33 
34 double us_to_s(bigtime_t usecs);
35 bigtime_t s_to_us(double secs);
36 
37 class MixerInput;
38 class MixerOutput;
39 
40 const char *StringForFormat(char *buf, MixerOutput *output);
41 const char *StringForFormat(char *buf, MixerInput *input);
42 const char *StringForChannelMask(char *buf, uint32 mask);
43 const char *StringForChannelType(char *buf, int type);
44 
45 #endif //_MIXER_UTILS_H
46