Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
f1dd9c20
Commit
f1dd9c20
authored
Sep 07, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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.
parent
bd81fd8b
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
98 additions
and
83 deletions
+98
-83
audio.c
src/audio.c
+13
-12
audio.h
src/audio.h
+8
-8
audioOutput.c
src/audioOutput.c
+4
-4
audioOutput.h
src/audioOutput.h
+4
-4
audioOutput_alsa.c
src/audioOutputs/audioOutput_alsa.c
+1
-1
audioOutput_jack.c
src/audioOutputs/audioOutput_jack.c
+2
-2
audioOutput_oss.c
src/audioOutputs/audioOutput_oss.c
+1
-1
audioOutput_pulse.c
src/audioOutputs/audioOutput_pulse.c
+1
-1
audioOutput_shout.c
src/audioOutputs/audioOutput_shout.c
+1
-1
audio_format.h
src/audio_format.h
+4
-4
crossfade.c
src/crossfade.c
+2
-2
crossfade.h
src/crossfade.h
+4
-3
decoder_api.c
src/decoder_api.c
+1
-1
decoder_api.h
src/decoder_api.h
+2
-1
decoder_control.h
src/decoder_control.h
+1
-1
_flac_common.h
src/inputPlugins/_flac_common.h
+1
-1
aac_plugin.c
src/inputPlugins/aac_plugin.c
+2
-2
audiofile_plugin.c
src/inputPlugins/audiofile_plugin.c
+1
-1
mod_plugin.c
src/inputPlugins/mod_plugin.c
+1
-1
mp3_plugin.c
src/inputPlugins/mp3_plugin.c
+2
-2
mp4_plugin.c
src/inputPlugins/mp4_plugin.c
+1
-1
mpc_plugin.c
src/inputPlugins/mpc_plugin.c
+1
-1
oggvorbis_plugin.c
src/inputPlugins/oggvorbis_plugin.c
+1
-1
wavpack_plugin.c
src/inputPlugins/wavpack_plugin.c
+1
-1
normalize.c
src/normalize.c
+3
-1
normalize.h
src/normalize.h
+3
-2
outputBuffer.h
src/outputBuffer.h
+1
-1
pcm_utils.c
src/pcm_utils.c
+10
-7
pcm_utils.h
src/pcm_utils.h
+9
-7
player_thread.c
src/player_thread.c
+1
-1
replayGain.c
src/replayGain.c
+3
-1
replayGain.h
src/replayGain.h
+3
-3
timer.c
src/timer.c
+2
-1
timer.h
src/timer.h
+3
-2
No files found.
src/audio.c
View file @
f1dd9c20
...
...
@@ -17,6 +17,7 @@
*/
#include "audio.h"
#include "audio_format.h"
#include "audioOutput.h"
#include "log.h"
#include "path.h"
...
...
@@ -27,9 +28,9 @@
#define AUDIO_DEVICE_STATE_LEN (sizeof(AUDIO_DEVICE_STATE)-1)
#define AUDIO_BUFFER_SIZE 2*MPD_PATH_MAX
static
AudioF
ormat
audio_format
;
static
struct
audio_f
ormat
audio_format
;
static
AudioF
ormat
*
audio_configFormat
;
static
struct
audio_f
ormat
*
audio_configFormat
;
static
AudioOutput
*
audioOutputArray
;
static
unsigned
int
audioOutputArraySize
;
...
...
@@ -63,15 +64,15 @@ static unsigned int audio_output_count(void)
return
nr
;
}
void
copyAudioFormat
(
AudioFormat
*
dest
,
const
AudioFormat
*
src
)
void
copyAudioFormat
(
struct
audio_format
*
dest
,
const
struct
audio_format
*
src
)
{
if
(
!
src
)
return
;
memcpy
(
dest
,
src
,
sizeof
(
AudioForma
t
));
memcpy
(
dest
,
src
,
sizeof
(
*
des
t
));
}
int
cmpAudioFormat
(
const
AudioFormat
*
f1
,
const
AudioFormat
*
f2
)
int
cmpAudioFormat
(
const
struct
audio_format
*
f1
,
const
struct
audio_format
*
f2
)
{
if
(
f1
&&
f2
&&
(
f1
->
sampleRate
==
f2
->
sampleRate
)
&&
(
f1
->
bits
==
f2
->
bits
)
&&
(
f1
->
channels
==
f2
->
channels
))
...
...
@@ -141,8 +142,8 @@ void initAudioDriver(void)
}
}
void
getOutputAudioFormat
(
const
AudioFormat
*
inAudioFormat
,
AudioFormat
*
outAudioFormat
)
void
getOutputAudioFormat
(
const
struct
audio_format
*
inAudioFormat
,
struct
audio_format
*
outAudioFormat
)
{
if
(
audio_configFormat
)
{
copyAudioFormat
(
outAudioFormat
,
audio_configFormat
);
...
...
@@ -157,7 +158,7 @@ void initAudioConfig(void)
if
(
NULL
==
param
||
NULL
==
param
->
value
)
return
;
audio_configFormat
=
xmalloc
(
sizeof
(
Audio
Format
));
audio_configFormat
=
xmalloc
(
sizeof
(
*
audio_config
Format
));
if
(
0
!=
parseAudioConfig
(
audio_configFormat
,
param
->
value
))
{
FATAL
(
"error parsing
\"
%s
\"
at line %i
\n
"
,
...
...
@@ -165,11 +166,11 @@ void initAudioConfig(void)
}
}
int
parseAudioConfig
(
AudioFormat
*
audioFormat
,
char
*
conf
)
int
parseAudioConfig
(
struct
audio_format
*
audioFormat
,
char
*
conf
)
{
char
*
test
;
memset
(
audioFormat
,
0
,
sizeof
(
A
udioFormat
));
memset
(
audioFormat
,
0
,
sizeof
(
*
a
udioFormat
));
audioFormat
->
sampleRate
=
strtol
(
conf
,
&
test
,
10
);
...
...
@@ -251,7 +252,7 @@ void finishAudioDriver(void)
audioOutputArraySize
=
0
;
}
int
isCurrentAudioFormat
(
const
AudioFormat
*
audioFormat
)
int
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
)
{
if
(
!
audioFormat
)
return
1
;
...
...
@@ -320,7 +321,7 @@ static int flushAudioBuffer(void)
return
ret
;
}
int
openAudioDevice
(
const
AudioFormat
*
audioFormat
)
int
openAudioDevice
(
const
struct
audio_format
*
audioFormat
)
{
int
ret
=
-
1
;
unsigned
int
i
;
...
...
src/audio.h
View file @
f1dd9c20
...
...
@@ -20,21 +20,21 @@
#define AUDIO_H
#include "os_compat.h"
#include "audio_format.h"
#define AUDIO_AO_DRIVER_DEFAULT "default"
struct
audio_format
;
struct
tag
;
struct
client
;
void
copyAudioFormat
(
AudioFormat
*
dest
,
const
AudioFormat
*
src
);
void
copyAudioFormat
(
struct
audio_format
*
dest
,
const
struct
audio_format
*
src
);
int
cmpAudioFormat
(
const
AudioFormat
*
dest
,
const
AudioFormat
*
src
);
int
cmpAudioFormat
(
const
struct
audio_format
*
dest
,
const
struct
audio_format
*
src
);
void
getOutputAudioFormat
(
const
AudioFormat
*
inFormat
,
AudioFormat
*
outFormat
);
void
getOutputAudioFormat
(
const
struct
audio_format
*
inFormat
,
struct
audio_format
*
outFormat
);
int
parseAudioConfig
(
AudioFormat
*
audioFormat
,
char
*
conf
);
int
parseAudioConfig
(
struct
audio_format
*
audioFormat
,
char
*
conf
);
/* make sure initPlayerData is called before this function!! */
void
initAudioConfig
(
void
);
...
...
@@ -45,7 +45,7 @@ void initAudioDriver(void);
void
finishAudioDriver
(
void
);
int
openAudioDevice
(
const
AudioFormat
*
audioFormat
);
int
openAudioDevice
(
const
struct
audio_format
*
audioFormat
);
int
playAudio
(
const
char
*
playChunk
,
size_t
size
);
...
...
@@ -55,7 +55,7 @@ void closeAudioDevice(void);
int
isAudioDeviceOpen
(
void
);
int
isCurrentAudioFormat
(
const
AudioFormat
*
audioFormat
);
int
isCurrentAudioFormat
(
const
struct
audio_format
*
audioFormat
);
void
sendMetadataToAudioDevice
(
const
struct
tag
*
tag
);
...
...
src/audioOutput.c
View file @
f1dd9c20
...
...
@@ -130,9 +130,9 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param)
ao
->
convBuffer
=
NULL
;
ao
->
convBufferLen
=
0
;
memset
(
&
ao
->
inAudioFormat
,
0
,
sizeof
(
AudioFormat
));
memset
(
&
ao
->
outAudioFormat
,
0
,
sizeof
(
AudioFormat
));
memset
(
&
ao
->
reqAudioFormat
,
0
,
sizeof
(
AudioFormat
));
memset
(
&
ao
->
inAudioFormat
,
0
,
sizeof
(
ao
->
in
AudioFormat
));
memset
(
&
ao
->
outAudioFormat
,
0
,
sizeof
(
ao
->
out
AudioFormat
));
memset
(
&
ao
->
reqAudioFormat
,
0
,
sizeof
(
ao
->
req
AudioFormat
));
memset
(
&
ao
->
convState
,
0
,
sizeof
(
ConvState
));
if
(
format
)
{
...
...
@@ -152,7 +152,7 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param)
}
int
openAudioOutput
(
AudioOutput
*
audioOutput
,
const
AudioFormat
*
audioFormat
)
const
struct
audio_format
*
audioFormat
)
{
int
ret
=
0
;
...
...
src/audioOutput.h
View file @
f1dd9c20
...
...
@@ -65,9 +65,9 @@ struct _AudioOutput {
AudioOutputSendMetadataFunc
sendMetdataFunc
;
int
convertAudioFormat
;
AudioF
ormat
inAudioFormat
;
AudioF
ormat
outAudioFormat
;
AudioF
ormat
reqAudioFormat
;
struct
audio_f
ormat
inAudioFormat
;
struct
audio_f
ormat
outAudioFormat
;
struct
audio_f
ormat
reqAudioFormat
;
ConvState
convState
;
char
*
convBuffer
;
size_t
convBufferLen
;
...
...
@@ -97,7 +97,7 @@ void unloadAudioOutputPlugin(AudioOutputPlugin * audioOutputPlugin);
int
initAudioOutput
(
AudioOutput
*
,
ConfigParam
*
param
);
int
openAudioOutput
(
AudioOutput
*
audioOutput
,
const
AudioFormat
*
audioFormat
);
const
struct
audio_format
*
audioFormat
);
int
playAudioOutput
(
AudioOutput
*
audioOutput
,
const
char
*
playChunk
,
size_t
size
);
void
dropBufferedAudioOutput
(
AudioOutput
*
audioOutput
);
...
...
src/audioOutputs/audioOutput_alsa.c
View file @
f1dd9c20
...
...
@@ -123,7 +123,7 @@ static int alsa_testDefault(void)
static
int
alsa_openDevice
(
AudioOutput
*
audioOutput
)
{
AlsaData
*
ad
=
audioOutput
->
data
;
AudioF
ormat
*
audioFormat
=
&
audioOutput
->
outAudioFormat
;
struct
audio_f
ormat
*
audioFormat
=
&
audioOutput
->
outAudioFormat
;
snd_pcm_format_t
bitformat
;
snd_pcm_hw_params_t
*
hwparams
;
snd_pcm_sw_params_t
*
swparams
;
...
...
src/audioOutputs/audioOutput_jack.c
View file @
f1dd9c20
...
...
@@ -118,7 +118,7 @@ static void jack_finishDriver(AudioOutput *audioOutput)
static
int
srate
(
mpd_unused
jack_nframes_t
rate
,
void
*
data
)
{
JackData
*
jd
=
(
JackData
*
)
((
AudioOutput
*
)
data
)
->
data
;
AudioF
ormat
*
audioFormat
=
&
(((
AudioOutput
*
)
data
)
->
outAudioFormat
);
struct
audio_f
ormat
*
audioFormat
=
&
(((
AudioOutput
*
)
data
)
->
outAudioFormat
);
audioFormat
->
sampleRate
=
(
int
)
jack_get_sample_rate
(
jd
->
client
);
...
...
@@ -183,7 +183,7 @@ static void shutdown_callback(void *arg)
static
void
set_audioformat
(
AudioOutput
*
audioOutput
)
{
JackData
*
jd
=
audioOutput
->
data
;
AudioF
ormat
*
audioFormat
=
&
audioOutput
->
outAudioFormat
;
struct
audio_f
ormat
*
audioFormat
=
&
audioOutput
->
outAudioFormat
;
audioFormat
->
sampleRate
=
(
int
)
jack_get_sample_rate
(
jd
->
client
);
DEBUG
(
"samplerate = %d
\n
"
,
audioFormat
->
sampleRate
);
...
...
src/audioOutputs/audioOutput_oss.c
View file @
f1dd9c20
...
...
@@ -484,7 +484,7 @@ static int oss_openDevice(AudioOutput * audioOutput)
{
int
ret
;
OssData
*
od
=
audioOutput
->
data
;
AudioF
ormat
*
audioFormat
=
&
audioOutput
->
outAudioFormat
;
struct
audio_f
ormat
*
audioFormat
=
&
audioOutput
->
outAudioFormat
;
od
->
channels
=
(
mpd_sint8
)
audioFormat
->
channels
;
od
->
sampleRate
=
audioFormat
->
sampleRate
;
...
...
src/audioOutputs/audioOutput_pulse.c
View file @
f1dd9c20
...
...
@@ -112,7 +112,7 @@ static int pulse_testDefault(void)
static
int
pulse_openDevice
(
AudioOutput
*
audioOutput
)
{
PulseData
*
pd
;
AudioF
ormat
*
audioFormat
;
struct
audio_f
ormat
*
audioFormat
;
pa_sample_spec
ss
;
time_t
t
;
int
error
;
...
...
src/audioOutputs/audioOutput_shout.c
View file @
f1dd9c20
...
...
@@ -66,7 +66,7 @@ typedef struct _ShoutData {
Timer
*
timer
;
/* just a pointer to audioOutput->outAudioFormat */
AudioF
ormat
*
audioFormat
;
struct
audio_f
ormat
*
audioFormat
;
}
ShoutData
;
static
ShoutData
*
newShoutData
(
void
)
...
...
src/audio_format.h
View file @
f1dd9c20
...
...
@@ -21,18 +21,18 @@
#include "mpd_types.h"
typedef
struct
_AudioF
ormat
{
struct
audio_f
ormat
{
mpd_sint8
channels
;
mpd_uint32
sampleRate
;
mpd_sint8
bits
;
}
AudioFormat
;
};
static
inline
double
audio_format_time_to_size
(
const
AudioFormat
*
af
)
static
inline
double
audio_format_time_to_size
(
const
struct
audio_format
*
af
)
{
return
af
->
sampleRate
*
af
->
bits
*
af
->
channels
/
8
.
0
;
}
static
inline
double
audioFormatSizeToTime
(
const
AudioFormat
*
af
)
static
inline
double
audioFormatSizeToTime
(
const
struct
audio_format
*
af
)
{
return
8
.
0
/
af
->
bits
/
af
->
channels
/
af
->
sampleRate
;
}
...
...
src/crossfade.c
View file @
f1dd9c20
...
...
@@ -22,7 +22,7 @@
#include "pcm_utils.h"
unsigned
cross_fade_calc
(
float
duration
,
float
total_time
,
const
AudioFormat
*
af
,
const
struct
audio_format
*
af
,
unsigned
max_chunks
)
{
unsigned
int
chunks
;
...
...
@@ -46,7 +46,7 @@ unsigned cross_fade_calc(float duration, float total_time,
}
void
cross_fade_apply
(
ob_chunk
*
a
,
const
ob_chunk
*
b
,
const
AudioFormat
*
format
,
const
struct
audio_format
*
format
,
unsigned
int
current_chunk
,
unsigned
int
num_chunks
)
{
assert
(
current_chunk
<=
num_chunks
);
...
...
src/crossfade.h
View file @
f1dd9c20
...
...
@@ -20,15 +20,16 @@
#ifndef CROSSFADE_H
#define CROSSFADE_H
#include "audio_format.h"
#include "outputBuffer.h"
struct
audio_format
;
unsigned
cross_fade_calc
(
float
duration
,
float
total_time
,
const
AudioFormat
*
af
,
const
struct
audio_format
*
af
,
unsigned
max_chunks
);
void
cross_fade_apply
(
ob_chunk
*
a
,
const
ob_chunk
*
b
,
const
AudioFormat
*
format
,
const
struct
audio_format
*
format
,
unsigned
int
current_chunk
,
unsigned
int
num_chunks
);
#endif
src/decoder_api.c
View file @
f1dd9c20
...
...
@@ -39,7 +39,7 @@ void decoder_plugin_unregister(struct decoder_plugin *plugin)
}
void
decoder_initialized
(
struct
decoder
*
decoder
,
const
AudioFormat
*
audio_format
,
const
struct
audio_format
*
audio_format
,
float
total_time
)
{
assert
(
dc
.
state
==
DECODE_STATE_START
);
...
...
src/decoder_api.h
View file @
f1dd9c20
...
...
@@ -30,6 +30,7 @@
#include "replayGain.h"
#include "tag.h"
#include "tag_id3.h"
#include "audio_format.h"
#include "playerData.h"
...
...
@@ -112,7 +113,7 @@ struct decoder;
* that it has read the song's meta data.
*/
void
decoder_initialized
(
struct
decoder
*
decoder
,
const
AudioFormat
*
audio_format
,
const
struct
audio_format
*
audio_format
,
float
total_time
);
const
char
*
decoder_get_url
(
struct
decoder
*
decoder
,
char
*
buffer
);
...
...
src/decoder_control.h
View file @
f1dd9c20
...
...
@@ -48,7 +48,7 @@ struct decoder_control {
volatile
mpd_sint8
seekError
;
volatile
mpd_sint8
seekable
;
volatile
double
seekWhere
;
AudioF
ormat
audioFormat
;
struct
audio_f
ormat
audioFormat
;
Song
*
current_song
;
Song
*
volatile
next_song
;
volatile
float
totalTime
;
...
...
src/inputPlugins/_flac_common.h
View file @
f1dd9c20
...
...
@@ -143,7 +143,7 @@ typedef struct {
size_t
chunk_length
;
float
time
;
unsigned
int
bitRate
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
float
total_time
;
FLAC__uint64
position
;
struct
decoder
*
decoder
;
...
...
src/inputPlugins/aac_plugin.c
View file @
f1dd9c20
...
...
@@ -310,7 +310,7 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
faacDecFrameInfo
frameInfo
;
faacDecConfigurationPtr
config
;
long
bread
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
uint32_t
sampleRate
;
unsigned
char
channels
;
unsigned
int
sampleCount
;
...
...
@@ -444,7 +444,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
faacDecFrameInfo
frameInfo
;
faacDecConfigurationPtr
config
;
long
bread
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
uint32_t
sampleRate
;
unsigned
char
channels
;
unsigned
int
sampleCount
;
...
...
src/inputPlugins/audiofile_plugin.c
View file @
f1dd9c20
...
...
@@ -48,7 +48,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
int
fs
,
frame_count
;
AFfilehandle
af_fp
;
int
bits
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
float
total_time
;
mpd_uint16
bitRate
;
struct
stat
st
;
...
...
src/inputPlugins/mod_plugin.c
View file @
f1dd9c20
...
...
@@ -171,7 +171,7 @@ static void mod_close(mod_Data * data)
static
int
mod_decode
(
struct
decoder
*
decoder
,
char
*
path
)
{
mod_Data
*
data
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
float
total_time
=
0
.
0
;
int
ret
;
float
secPerByte
;
...
...
src/inputPlugins/mp3_plugin.c
View file @
f1dd9c20
...
...
@@ -1021,7 +1021,7 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
}
static
void
initAudioFormatFromMp3DecodeData
(
mp3DecodeData
*
data
,
AudioF
ormat
*
af
)
struct
audio_f
ormat
*
af
)
{
af
->
bits
=
16
;
af
->
sampleRate
=
(
data
->
frame
).
header
.
samplerate
;
...
...
@@ -1033,7 +1033,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
mp3DecodeData
data
;
struct
tag
*
tag
=
NULL
;
ReplayGainInfo
*
replayGainInfo
=
NULL
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
if
(
openMp3FromInputStream
(
inStream
,
&
data
,
decoder
,
&
tag
,
&
replayGainInfo
)
<
0
)
{
...
...
src/inputPlugins/mp4_plugin.c
View file @
f1dd9c20
...
...
@@ -88,7 +88,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
faacDecHandle
decoder
;
faacDecFrameInfo
frameInfo
;
faacDecConfigurationPtr
config
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
unsigned
char
*
mp4Buffer
;
unsigned
int
mp4BufferSize
;
uint32_t
sampleRate
;
...
...
src/inputPlugins/mpc_plugin.c
View file @
f1dd9c20
...
...
@@ -102,7 +102,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_decoder
decoder
;
mpc_reader
reader
;
mpc_streaminfo
info
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
MpcCallbackData
data
;
...
...
src/inputPlugins/oggvorbis_plugin.c
View file @
f1dd9c20
...
...
@@ -210,7 +210,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
OggVorbis_File
vf
;
ov_callbacks
callbacks
;
OggCallbackData
data
;
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
int
current_section
;
int
prev_section
=
-
1
;
long
ret
;
...
...
src/inputPlugins/wavpack_plugin.c
View file @
f1dd9c20
...
...
@@ -131,7 +131,7 @@ static void wavpack_decode(struct decoder * decoder,
WavpackContext
*
wpc
,
int
canseek
,
ReplayGainInfo
*
replayGainInfo
)
{
AudioF
ormat
audio_format
;
struct
audio_f
ormat
audio_format
;
void
(
*
format_samples
)(
int
Bps
,
void
*
buffer
,
uint32_t
samcnt
);
char
chunk
[
CHUNK_SIZE
];
float
file_time
;
...
...
src/normalize.c
View file @
f1dd9c20
...
...
@@ -19,6 +19,7 @@
#include "normalize.h"
#include "compress.h"
#include "conf.h"
#include "audio_format.h"
#define DEFAULT_VOLUME_NORMALIZATION 0
...
...
@@ -39,7 +40,8 @@ void finishNormalization(void)
if
(
normalizationEnabled
)
CompressFree
();
}
void
normalizeData
(
char
*
buffer
,
int
bufferSize
,
const
AudioFormat
*
format
)
void
normalizeData
(
char
*
buffer
,
int
bufferSize
,
const
struct
audio_format
*
format
)
{
if
((
format
->
bits
!=
16
)
||
(
format
->
channels
!=
2
))
return
;
...
...
src/normalize.h
View file @
f1dd9c20
...
...
@@ -19,7 +19,7 @@
#ifndef NORMALIZE_H
#define NORMALIZE_H
#include "audio_format.h"
struct
audio_format
;
extern
int
normalizationEnabled
;
...
...
@@ -27,6 +27,7 @@ void initNormalization(void);
void
finishNormalization
(
void
);
void
normalizeData
(
char
*
buffer
,
int
bufferSize
,
const
AudioFormat
*
format
);
void
normalizeData
(
char
*
buffer
,
int
bufferSize
,
const
struct
audio_format
*
format
);
#endif
/* !NORMALIZE_H */
src/outputBuffer.h
View file @
f1dd9c20
...
...
@@ -51,7 +51,7 @@ struct output_buffer {
the buffer becomes non-empty */
int
lazy
;
AudioF
ormat
audioFormat
;
struct
audio_f
ormat
audioFormat
;
Notify
*
notify
;
};
...
...
src/pcm_utils.c
View file @
f1dd9c20
...
...
@@ -22,9 +22,11 @@
#include "log.h"
#include "utils.h"
#include "conf.h"
#include "audio_format.h"
#include "os_compat.h"
void
pcm_volumeChange
(
char
*
buffer
,
int
bufferSize
,
const
AudioFormat
*
format
,
void
pcm_volumeChange
(
char
*
buffer
,
int
bufferSize
,
const
struct
audio_format
*
format
,
int
volume
)
{
mpd_sint32
temp32
;
...
...
@@ -76,7 +78,7 @@ void pcm_volumeChange(char *buffer, int bufferSize, const AudioFormat * format,
static
void
pcm_add
(
char
*
buffer1
,
const
char
*
buffer2
,
size_t
bufferSize1
,
size_t
bufferSize2
,
int
vol1
,
int
vol2
,
const
AudioFormat
*
format
)
const
struct
audio_format
*
format
)
{
mpd_sint32
temp32
;
mpd_sint8
*
buffer8_1
=
(
mpd_sint8
*
)
buffer1
;
...
...
@@ -130,7 +132,8 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1,
}
void
pcm_mix
(
char
*
buffer1
,
const
char
*
buffer2
,
size_t
bufferSize1
,
size_t
bufferSize2
,
const
AudioFormat
*
format
,
float
portion1
)
size_t
bufferSize2
,
const
struct
audio_format
*
format
,
float
portion1
)
{
int
vol1
;
float
s
=
sin
(
M_PI_2
*
portion1
);
...
...
@@ -392,9 +395,9 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer,
}
/* outFormat bits must be 16 and channels must be 1 or 2! */
size_t
pcm_convertAudioFormat
(
const
AudioFormat
*
inFormat
,
size_t
pcm_convertAudioFormat
(
const
struct
audio_format
*
inFormat
,
const
char
*
inBuffer
,
size_t
inSize
,
const
AudioFormat
*
outFormat
,
const
struct
audio_format
*
outFormat
,
char
*
outBuffer
,
ConvState
*
convState
)
{
const
char
*
buf
;
...
...
@@ -430,8 +433,8 @@ size_t pcm_convertAudioFormat(const AudioFormat * inFormat,
return
len
;
}
size_t
pcm_sizeOfConvBuffer
(
const
AudioFormat
*
inFormat
,
size_t
inSize
,
const
AudioFormat
*
outFormat
)
size_t
pcm_sizeOfConvBuffer
(
const
struct
audio_format
*
inFormat
,
size_t
inSize
,
const
struct
audio_format
*
outFormat
)
{
const
double
ratio
=
(
double
)
outFormat
->
sampleRate
/
(
double
)
inFormat
->
sampleRate
;
...
...
src/pcm_utils.h
View file @
f1dd9c20
...
...
@@ -21,13 +21,15 @@
#include "../config.h"
#include "
audio_format
.h"
#include "
mpd_types
.h"
#include "os_compat.h"
#ifdef HAVE_LIBSAMPLERATE
#include <samplerate.h>
#endif
struct
audio_format
;
typedef
struct
_ConvState
{
#ifdef HAVE_LIBSAMPLERATE
SRC_STATE
*
state
;
...
...
@@ -42,17 +44,17 @@ typedef struct _ConvState {
int
error
;
}
ConvState
;
void
pcm_volumeChange
(
char
*
buffer
,
int
bufferSize
,
const
AudioFormat
*
format
,
void
pcm_volumeChange
(
char
*
buffer
,
int
bufferSize
,
const
struct
audio_format
*
format
,
int
volume
);
void
pcm_mix
(
char
*
buffer1
,
const
char
*
buffer2
,
size_t
bufferSize1
,
size_t
bufferSize2
,
const
AudioFormat
*
format
,
float
portion1
);
size_t
bufferSize2
,
const
struct
audio_format
*
format
,
float
portion1
);
size_t
pcm_convertAudioFormat
(
const
AudioFormat
*
inFormat
,
size_t
pcm_convertAudioFormat
(
const
struct
audio_format
*
inFormat
,
const
char
*
inBuffer
,
size_t
inSize
,
const
AudioFormat
*
outFormat
,
const
struct
audio_format
*
outFormat
,
char
*
outBuffer
,
ConvState
*
convState
);
size_t
pcm_sizeOfConvBuffer
(
const
AudioFormat
*
inFormat
,
size_t
inSize
,
const
AudioFormat
*
outFormat
);
size_t
pcm_sizeOfConvBuffer
(
const
struct
audio_format
*
inFormat
,
size_t
inSize
,
const
struct
audio_format
*
outFormat
);
#endif
src/player_thread.c
View file @
f1dd9c20
...
...
@@ -158,7 +158,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r,
}
static
int
playChunk
(
ob_chunk
*
chunk
,
const
AudioFormat
*
format
,
double
sizeToTime
)
const
struct
audio_format
*
format
,
double
sizeToTime
)
{
pc
.
elapsedTime
=
chunk
->
times
;
pc
.
bitRate
=
chunk
->
bitRate
;
...
...
src/replayGain.c
View file @
f1dd9c20
...
...
@@ -22,6 +22,8 @@
#include "log.h"
#include "conf.h"
#include "audio_format.h"
#include "mpd_types.h"
#include "os_compat.h"
/* Added 4/14/2004 by AliasMrJones */
...
...
@@ -104,7 +106,7 @@ void freeReplayGainInfo(ReplayGainInfo * info)
}
void
doReplayGain
(
ReplayGainInfo
*
info
,
char
*
buffer
,
int
bufferSize
,
const
AudioFormat
*
format
)
const
struct
audio_format
*
format
)
{
mpd_sint16
*
buffer16
;
mpd_sint8
*
buffer8
;
...
...
src/replayGain.h
View file @
f1dd9c20
...
...
@@ -20,12 +20,12 @@
#ifndef REPLAYGAIN_H
#define REPLAYGAIN_H
#include "audio_format.h"
#define REPLAYGAIN_OFF 0
#define REPLAYGAIN_TRACK 1
#define REPLAYGAIN_ALBUM 2
struct
audio_format
;
extern
int
replayGainState
;
typedef
struct
_ReplayGainInfo
{
...
...
@@ -45,6 +45,6 @@ void freeReplayGainInfo(ReplayGainInfo * info);
void
initReplayGainState
(
void
);
void
doReplayGain
(
ReplayGainInfo
*
info
,
char
*
buffer
,
int
bufferSize
,
const
AudioFormat
*
format
);
const
struct
audio_format
*
format
);
#endif
src/timer.c
View file @
f1dd9c20
...
...
@@ -18,6 +18,7 @@
#include "timer.h"
#include "utils.h"
#include "audio_format.h"
#include "os_compat.h"
static
uint64_t
now
(
void
)
...
...
@@ -29,7 +30,7 @@ static uint64_t now(void)
return
((
uint64_t
)
tv
.
tv_sec
*
1000000
)
+
tv
.
tv_usec
;
}
Timer
*
timer_new
(
AudioF
ormat
*
af
)
Timer
*
timer_new
(
struct
audio_f
ormat
*
af
)
{
Timer
*
timer
;
...
...
src/timer.h
View file @
f1dd9c20
...
...
@@ -19,16 +19,17 @@
#ifndef MPD_TIMER_H
#define MPD_TIMER_H
#include "audio_format.h"
#include "os_compat.h"
struct
audio_format
;
typedef
struct
_Timer
{
uint64_t
time
;
int
started
;
int
rate
;
}
Timer
;
Timer
*
timer_new
(
AudioF
ormat
*
af
);
Timer
*
timer_new
(
struct
audio_f
ormat
*
af
);
void
timer_free
(
Timer
*
timer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment