Commit Graph

17 Commits

Author SHA1 Message Date
Max Kellermann
3bc4224bfd audio_format: added validation functions
In addition to audio_format_valid(), provide functions which validate
only one attribute of an audio_format.  These functions are reused by
audio_format_parse().
2009-02-11 18:00:48 +01:00
Max Kellermann
be9e60d55e audio_format: added audio_format_valid() 2008-11-21 20:27:05 +01:00
Max Kellermann
ea515494cb added prefix to header macros
"LOG_H" is a macro which is also used by ffmpeg/log.h.  This is
ffmpeg's fault, because short macros should be reserved for
applications, but since it's always a good idea to choose prefixed
macro names, even for applications, we are going to do that in MPD.
2008-10-31 09:19:53 +01:00
Max Kellermann
96155a3376 audio_format: added audio_format_frame_size()
A frame contains one sample per channel, thus it is sample_size *
channels.  This patch includes some cleanup for various locations
where the sample size for 24 bit audio was still 3 bytes (instead of
4).
2008-10-10 14:41:37 +02:00
Max Kellermann
de2cb3f375 audio_format: renamed sampleRate to sample_rate
The last bit of CamelCase in audio_format.h.  Additionally, rename a
bunch of local variables.
2008-10-10 14:40:54 +02:00
Max Kellermann
6101dc6c76 audio_format: unsigned integers
"bits" and "channels" cannot be negative.
2008-10-10 14:03:33 +02:00
Max Kellermann
b084bc28ed use the "bool" data type instead of "int"
"bool" should be used in C99 programs for boolean values.
2008-10-08 11:03:39 +02:00
Max Kellermann
a7651b9d30 assume stdint.h and stddef.h are available
Since we use a C99 compiler now, we can assert that the C99 standard
headers are available, no need for complicated compile time checks.
Kill mpd_types.h.
2008-09-29 15:53:53 +02:00
Max Kellermann
226d52b36f switch to C99 types, part II
Do full C99 integer type conversion in all modules which were not
touched by Eric's merged patch.
2008-09-29 15:49:29 +02:00
Max Kellermann
128d8c7c15 audio_format: added audio_format_sample_size()
The inline function audio_format_sample_size() calculates how many
bytes each sample consumes.  This function already takes into account
that 24 bit samples are 4 bytes long, not 3.
2008-09-23 23:59:54 +02:00
Max Kellermann
d92543698c audio_format: added audio_format_clear() and audio_format_defined()
audio_format_clear() sets an audio_format struct to an cleared
(undefined) state, which is both faster and smaller than memset(0).
audio_format_defined() checks if the audio_format struct actually has
a defined value (i.e. non-zero).  Both can be used to avoid pointers
to audio_format, replacing the "NULL" value with an "undefined"
audio_format.
2008-09-10 11:43:27 +02:00
Max Kellermann
be9212ba84 audio: moved cmpAudioFormat() to audio_format.h
Rename it to audio_format_equals() and return "true" if they are
equal.
2008-09-09 10:05:15 +02:00
Max Kellermann
dc7c6bd14d pack the struct audio_format
Due to clumsy layout, the audio_format struct took 12 bytes.  Move the
"channels" to the end, so it can be merged into the same 32 bit slot
as "bits", which reduces the struct size to 8 bytes.
2008-09-07 19:20:01 +02:00
Max Kellermann
f1dd9c209c audio_format: converted typedef AudioFormat to struct audio_format
Get rid of CamelCase, and don't use a typedef, so we can
forward-declare it, and unclutter the include dependencies.
2008-09-07 19:19:55 +02:00
Eric Wong
18fc10a926 audio_format: volatile removal
volatile provides absolutely no guarantee thread-safety in SMP
environments.  volatile was designed to access memory locations
in peripheral hardware directly; not for SMP.  If volatile is
needed to work properly on SMP, then it is only hiding subtle
bugs.

volatile only prevents the /compiler/ from making optimizations
when accessing variables.  CPUs do their own optimizations at
runtime so it cannot guarantee registers of CPUs are flushed
to memory cache-coherent access on different CPUs.

Furthermore, the thread-communication via condition variables
between threads sharing audio formats already results in memory
barriers.
2008-09-07 19:14:50 +02:00
Max Kellermann
2650b9eb31 added inline function audio_format_time_to_size()
Make the code more readable by hiding big formulas in an inline
function with a nice name.
2008-08-26 08:27:09 +02:00
Max Kellermann
1b845f94a0 moved struct AudioFormat to audio_format.h
We want to expose the AudioFormat structure to plugins; remove some
clutter by moving its declaration to a separate header file.
2008-08-26 08:27:06 +02:00