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
13template<class t> const t & max(const t &t1, const t &t2) { return (t1 > t2) ?  t1 : t2; }
14template<class t> const t & min(const t &t1, const t &t2) { return (t1 < t2) ?  t1 : t2; }
15#endif
16template<class t> const t abs(const t t1) { return (t1 < 0) ?  - t1 : t1; }
17
18
19void fix_multiaudio_format(media_multi_audio_format *format);
20
21int count_nonzero_bits(uint32 value);
22
23uint32 GetChannelMask(int channel, uint32 all_channel_masks);
24int GetChannelType(int channel, uint32 all_channel_masks);
25
26bool HasKawamba();
27
28void ZeroFill(float *_dst, int32 _dst_sample_offset, int32 _sample_count);
29
30bigtime_t buffer_duration(const media_multi_audio_format & format);
31
32int bytes_per_sample(const media_multi_audio_format & format);
33
34int bytes_per_frame(const media_multi_audio_format & format);
35int frames_per_buffer(const media_multi_audio_format & format);
36
37int64 frames_for_duration(double framerate, bigtime_t duration);
38bigtime_t duration_for_frames(double framerate, int64 frames);
39
40int ChannelMaskToChannelType(uint32 mask);
41uint32 ChannelTypeToChannelMask(int type);
42
43double us_to_s(bigtime_t usecs);
44bigtime_t s_to_us(double secs);
45
46class MixerInput;
47class MixerOutput;
48
49const char *StringForFormat(char *buf, MixerOutput *output);
50const char *StringForFormat(char *buf, MixerInput *input);
51const char *StringForChannelMask(char *buf, uint32 mask);
52const char *StringForChannelType(char *buf, int type);
53
54#endif // _MIXER_UTILS_H
55