2 * Copyright 2008 Stephan Aßmus, <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
5 #ifndef SUPPORT_FUNCTIONS_H
6 #define SUPPORT_FUNCTIONS_H
11 bytes_per_frame(const media_format
& format
)
13 int32 channelCount
= format
.u
.raw_audio
.channel_count
;
14 size_t sampleSize
= format
.u
.raw_audio
.format
15 & media_raw_audio_format::B_AUDIO_SIZE_MASK
;
16 return sampleSize
* channelCount
;
20 static inline bigtime_t
21 time_for_buffer(size_t size
, const media_format
& format
)
23 int32 frameSize
= bytes_per_frame(format
);
24 float frameRate
= format
.u
.raw_audio
.frame_rate
;
26 return (bigtime_t
)((double)size
* 1000000 / frameSize
/ frameRate
);
30 #endif // SUPPORT_FUNCTIONS_H