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
de2cb3f3
Commit
de2cb3f3
authored
Oct 10, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
audio_format: renamed sampleRate to sample_rate
The last bit of CamelCase in audio_format.h. Additionally, rename a bunch of local variables.
parent
6101dc6c
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
94 additions
and
95 deletions
+94
-95
audio.c
src/audio.c
+5
-5
audioOutput_alsa.c
src/audioOutputs/audioOutput_alsa.c
+8
-8
audioOutput_ao.c
src/audioOutputs/audioOutput_ao.c
+1
-1
audioOutput_jack.c
src/audioOutputs/audioOutput_jack.c
+4
-4
audioOutput_mvp.c
src/audioOutputs/audioOutput_mvp.c
+4
-4
audioOutput_oss.c
src/audioOutputs/audioOutput_oss.c
+2
-2
audioOutput_osx.c
src/audioOutputs/audioOutput_osx.c
+2
-2
audioOutput_pulse.c
src/audioOutputs/audioOutput_pulse.c
+2
-2
audioOutput_shout.c
src/audioOutputs/audioOutput_shout.c
+1
-1
audioOutput_shout_mp3.c
src/audioOutputs/audioOutput_shout_mp3.c
+1
-1
audioOutput_shout_ogg.c
src/audioOutputs/audioOutput_shout_ogg.c
+2
-2
audio_format.h
src/audio_format.h
+5
-5
crossfade.c
src/crossfade.c
+1
-1
_flac_common.c
src/inputPlugins/_flac_common.c
+1
-1
aac_plugin.c
src/inputPlugins/aac_plugin.c
+21
-21
audiofile_plugin.c
src/inputPlugins/audiofile_plugin.c
+4
-4
flac_plugin.c
src/inputPlugins/flac_plugin.c
+2
-2
mod_plugin.c
src/inputPlugins/mod_plugin.c
+2
-2
mp3_plugin.c
src/inputPlugins/mp3_plugin.c
+1
-1
mp4_plugin.c
src/inputPlugins/mp4_plugin.c
+4
-4
mpc_plugin.c
src/inputPlugins/mpc_plugin.c
+6
-6
oggflac_plugin.c
src/inputPlugins/oggflac_plugin.c
+2
-2
oggvorbis_plugin.c
src/inputPlugins/oggvorbis_plugin.c
+2
-2
wavpack_plugin.c
src/inputPlugins/wavpack_plugin.c
+4
-5
pcm_utils.c
src/pcm_utils.c
+5
-5
player_thread.c
src/player_thread.c
+1
-1
timer.c
src/timer.c
+1
-1
No files found.
src/audio.c
View file @
de2cb3f3
...
...
@@ -137,16 +137,16 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
memset
(
audioFormat
,
0
,
sizeof
(
*
audioFormat
));
audioFormat
->
sample
R
ate
=
strtol
(
conf
,
&
test
,
10
);
audioFormat
->
sample
_r
ate
=
strtol
(
conf
,
&
test
,
10
);
if
(
*
test
!=
':'
)
{
ERROR
(
"error parsing audio output format: %s
\n
"
,
conf
);
return
-
1
;
}
if
(
audioFormat
->
sample
R
ate
<=
0
)
{
ERROR
(
"sample rate %
i
is not >= 0
\n
"
,
(
int
)
audioFormat
->
sampleR
ate
);
if
(
audioFormat
->
sample
_r
ate
<=
0
)
{
ERROR
(
"sample rate %
u
is not >= 0
\n
"
,
audioFormat
->
sample_r
ate
);
return
-
1
;
}
...
...
@@ -315,7 +315,7 @@ static int flushAudioBuffer(void)
static
size_t
audio_buffer_size
(
const
struct
audio_format
*
af
)
{
return
(
af
->
bits
>>
3
)
*
af
->
channels
*
(
af
->
sample
R
ate
>>
5
);
return
(
af
->
bits
>>
3
)
*
af
->
channels
*
(
af
->
sample
_r
ate
>>
5
);
}
static
void
audio_buffer_resize
(
size_t
size
)
...
...
src/audioOutputs/audioOutput_alsa.c
View file @
de2cb3f3
...
...
@@ -142,7 +142,7 @@ static int alsa_openDevice(void *data, struct audio_format *audioFormat)
snd_pcm_format_t
bitformat
;
snd_pcm_hw_params_t
*
hwparams
;
snd_pcm_sw_params_t
*
swparams
;
unsigned
int
sample
Rate
=
audioFormat
->
sampleR
ate
;
unsigned
int
sample
_rate
=
audioFormat
->
sample_r
ate
;
unsigned
int
channels
=
audioFormat
->
channels
;
snd_pcm_uframes_t
alsa_buffer_size
;
snd_pcm_uframes_t
alsa_period_size
;
...
...
@@ -217,13 +217,13 @@ configure_hw:
audioFormat
->
channels
=
(
int8_t
)
channels
;
err
=
snd_pcm_hw_params_set_rate_near
(
ad
->
pcmHandle
,
hwparams
,
&
sample
R
ate
,
NULL
);
if
(
err
<
0
||
sample
R
ate
==
0
)
{
ERROR
(
"ALSA device
\"
%s
\"
does not support %
i
Hz audio
\n
"
,
ad
->
device
,
(
int
)
audioFormat
->
sampleR
ate
);
&
sample
_r
ate
,
NULL
);
if
(
err
<
0
||
sample
_r
ate
==
0
)
{
ERROR
(
"ALSA device
\"
%s
\"
does not support %
u
Hz audio
\n
"
,
ad
->
device
,
audioFormat
->
sample_r
ate
);
goto
fail
;
}
audioFormat
->
sample
Rate
=
sampleR
ate
;
audioFormat
->
sample
_rate
=
sample_r
ate
;
buffer_time
=
ad
->
buffer_time
;
cmd
=
"snd_pcm_hw_params_set_buffer_time_near"
;
...
...
@@ -291,8 +291,8 @@ configure_hw:
ad
->
sampleSize
=
audio_format_sample_size
(
audioFormat
)
*
audioFormat
->
channels
;
DEBUG
(
"ALSA device
\"
%s
\"
will be playing %i bit, %u channel audio at "
"%
i
Hz
\n
"
,
ad
->
device
,
audioFormat
->
bits
,
channels
,
sample
R
ate
);
"%
u
Hz
\n
"
,
ad
->
device
,
audioFormat
->
bits
,
channels
,
sample
_r
ate
);
return
0
;
...
...
src/audioOutputs/audioOutput_ao.c
View file @
de2cb3f3
...
...
@@ -182,7 +182,7 @@ static int audioOutputAo_openDevice(void *data,
}
format
.
bits
=
audio_format
->
bits
;
format
.
rate
=
audio_format
->
sample
R
ate
;
format
.
rate
=
audio_format
->
sample
_r
ate
;
format
.
byte_format
=
AO_FMT_NATIVE
;
format
.
channels
=
audio_format
->
channels
;
...
...
src/audioOutputs/audioOutput_jack.c
View file @
de2cb3f3
...
...
@@ -126,7 +126,7 @@ static int srate(mpd_unused jack_nframes_t rate, void *data)
JackData
*
jd
=
(
JackData
*
)
data
;
struct
audio_format
*
audioFormat
=
jd
->
audio_format
;
audioFormat
->
sampleR
ate
=
(
int
)
jack_get_sample_rate
(
jd
->
client
);
audioFormat
->
sample_r
ate
=
(
int
)
jack_get_sample_rate
(
jd
->
client
);
return
0
;
}
...
...
@@ -188,13 +188,13 @@ static void shutdown_callback(void *arg)
static
void
set_audioformat
(
JackData
*
jd
,
struct
audio_format
*
audioFormat
)
{
audioFormat
->
sample
Rate
=
(
int
)
jack_get_sample_rate
(
jd
->
client
);
DEBUG
(
"samplerate = %
d
\n
"
,
audioFormat
->
sampleR
ate
);
audioFormat
->
sample
_rate
=
jack_get_sample_rate
(
jd
->
client
);
DEBUG
(
"samplerate = %
u
\n
"
,
audioFormat
->
sample_r
ate
);
audioFormat
->
channels
=
2
;
audioFormat
->
bits
=
16
;
jd
->
bps
=
audioFormat
->
channels
*
sizeof
(
jack_default_audio_sample_t
)
*
audioFormat
->
sample
R
ate
;
*
audioFormat
->
sample
_r
ate
;
}
static
void
error_callback
(
const
char
*
msg
)
...
...
src/audioOutputs/audioOutput_mvp.c
View file @
de2cb3f3
...
...
@@ -202,11 +202,11 @@ static int mvp_openDevice(struct audio_output *audioOutput,
return
-
1
;
}
#ifdef WORDS_BIGENDIAN
mvp_setPcmParams
(
md
,
audioFormat
->
sample
Rate
,
audioFormat
->
channels
,
0
,
audioFormat
->
bits
);
mvp_setPcmParams
(
md
,
audioFormat
->
sample
_rate
,
audioFormat
->
channels
,
0
,
audioFormat
->
bits
);
#else
mvp_setPcmParams
(
md
,
audioFormat
->
sample
Rate
,
audioFormat
->
channels
,
1
,
audioFormat
->
bits
);
mvp_setPcmParams
(
md
,
audioFormat
->
sample
_rate
,
audioFormat
->
channels
,
1
,
audioFormat
->
bits
);
#endif
return
0
;
}
...
...
src/audioOutputs/audioOutput_oss.c
View file @
de2cb3f3
...
...
@@ -487,14 +487,14 @@ static int oss_openDevice(void *data,
OssData
*
od
=
data
;
od
->
channels
=
(
int8_t
)
audioFormat
->
channels
;
od
->
sampleRate
=
audioFormat
->
sample
R
ate
;
od
->
sampleRate
=
audioFormat
->
sample
_r
ate
;
od
->
bits
=
(
int8_t
)
audioFormat
->
bits
;
if
((
ret
=
oss_open
(
od
))
<
0
)
return
ret
;
audioFormat
->
channels
=
od
->
channels
;
audioFormat
->
sample
R
ate
=
od
->
sampleRate
;
audioFormat
->
sample
_r
ate
=
od
->
sampleRate
;
audioFormat
->
bits
=
od
->
bits
;
DEBUG
(
"oss device
\"
%s
\"
will be playing %i bit %i channel audio at "
...
...
src/audioOutputs/audioOutput_osx.c
View file @
de2cb3f3
...
...
@@ -259,7 +259,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
return
-
1
;
}
streamDesc
.
mSampleRate
=
audioFormat
->
sample
R
ate
;
streamDesc
.
mSampleRate
=
audioFormat
->
sample
_r
ate
;
streamDesc
.
mFormatID
=
kAudioFormatLinearPCM
;
streamDesc
.
mFormatFlags
=
kLinearPCMFormatFlagIsSignedInteger
;
#ifdef WORDS_BIGENDIAN
...
...
@@ -283,7 +283,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
}
/* create a buffer of 1s */
od
->
bufferSize
=
(
audioFormat
->
sample
R
ate
)
*
od
->
bufferSize
=
(
audioFormat
->
sample
_r
ate
)
*
(
audioFormat
->
bits
>>
3
)
*
(
audioFormat
->
channels
);
od
->
buffer
=
xrealloc
(
od
->
buffer
,
od
->
bufferSize
);
...
...
src/audioOutputs/audioOutput_pulse.c
View file @
de2cb3f3
...
...
@@ -138,7 +138,7 @@ static int pulse_openDevice(void *data,
}
ss
.
format
=
PA_SAMPLE_S16NE
;
ss
.
rate
=
audioFormat
->
sample
R
ate
;
ss
.
rate
=
audioFormat
->
sample
_r
ate
;
ss
.
channels
=
audioFormat
->
channels
;
pd
->
s
=
pa_simple_new
(
pd
->
server
,
MPD_PULSE_NAME
,
PA_STREAM_PLAYBACK
,
...
...
@@ -159,7 +159,7 @@ static int pulse_openDevice(void *data,
"channel audio at %i Hz
\n
"
,
audio_output_get_name
(
pd
->
ao
),
audioFormat
->
bits
,
audioFormat
->
channels
,
audioFormat
->
sample
R
ate
);
audioFormat
->
channels
,
audioFormat
->
sample
_r
ate
);
return
0
;
}
...
...
src/audioOutputs/audioOutput_shout.c
View file @
de2cb3f3
...
...
@@ -255,7 +255,7 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
snprintf
(
temp
,
sizeof
(
temp
),
"%u"
,
sd
->
audio_format
.
channels
);
shout_set_audio_info
(
sd
->
shout_conn
,
SHOUT_AI_CHANNELS
,
temp
);
snprintf
(
temp
,
sizeof
(
temp
),
"%
d"
,
sd
->
audio_format
.
sampleR
ate
);
snprintf
(
temp
,
sizeof
(
temp
),
"%
u"
,
sd
->
audio_format
.
sample_r
ate
);
shout_set_audio_info
(
sd
->
shout_conn
,
SHOUT_AI_SAMPLERATE
,
temp
);
...
...
src/audioOutputs/audioOutput_shout_mp3.c
View file @
de2cb3f3
...
...
@@ -93,7 +93,7 @@ static int shout_mp3_encoder_init_encoder(struct shout_data *sd)
}
if
(
0
!=
lame_set_in_samplerate
(
ld
->
gfp
,
sd
->
audio_format
.
sample
R
ate
))
{
sd
->
audio_format
.
sample
_r
ate
))
{
ERROR
(
"error setting lame sample rate
\n
"
);
return
-
1
;
}
...
...
src/audioOutputs/audioOutput_shout_ogg.c
View file @
de2cb3f3
...
...
@@ -187,7 +187,7 @@ static int reinit_encoder(struct shout_data *sd)
if
(
sd
->
quality
>=
-
1
.
0
)
{
if
(
0
!=
vorbis_encode_init_vbr
(
&
od
->
vi
,
sd
->
audio_format
.
channels
,
sd
->
audio_format
.
sample
R
ate
,
sd
->
audio_format
.
sample
_r
ate
,
sd
->
quality
*
0
.
1
))
{
ERROR
(
"error initializing vorbis vbr
\n
"
);
vorbis_info_clear
(
&
od
->
vi
);
...
...
@@ -196,7 +196,7 @@ static int reinit_encoder(struct shout_data *sd)
}
else
{
if
(
0
!=
vorbis_encode_init
(
&
od
->
vi
,
sd
->
audio_format
.
channels
,
sd
->
audio_format
.
sample
R
ate
,
-
1
.
0
,
sd
->
audio_format
.
sample
_r
ate
,
-
1
.
0
,
sd
->
bitrate
*
1000
,
-
1
.
0
))
{
ERROR
(
"error initializing vorbis encoder
\n
"
);
vorbis_info_clear
(
&
od
->
vi
);
...
...
src/audio_format.h
View file @
de2cb3f3
...
...
@@ -23,27 +23,27 @@
#include <stdbool.h>
struct
audio_format
{
uint32_t
sample
R
ate
;
uint32_t
sample
_r
ate
;
uint8_t
bits
;
uint8_t
channels
;
};
static
inline
void
audio_format_clear
(
struct
audio_format
*
af
)
{
af
->
sample
R
ate
=
0
;
af
->
sample
_r
ate
=
0
;
af
->
bits
=
0
;
af
->
channels
=
0
;
}
static
inline
bool
audio_format_defined
(
const
struct
audio_format
*
af
)
{
return
af
->
sample
R
ate
!=
0
;
return
af
->
sample
_r
ate
!=
0
;
}
static
inline
bool
audio_format_equals
(
const
struct
audio_format
*
a
,
const
struct
audio_format
*
b
)
{
return
a
->
sample
Rate
==
b
->
sampleR
ate
&&
return
a
->
sample
_rate
==
b
->
sample_r
ate
&&
a
->
bits
==
b
->
bits
&&
a
->
channels
==
b
->
channels
;
}
...
...
@@ -63,7 +63,7 @@ static inline unsigned audio_format_sample_size(const struct audio_format *af)
static
inline
double
audio_format_time_to_size
(
const
struct
audio_format
*
af
)
{
return
af
->
sample
R
ate
*
af
->
channels
*
audio_format_sample_size
(
af
);
return
af
->
sample
_r
ate
*
af
->
channels
*
audio_format_sample_size
(
af
);
}
static
inline
double
audioFormatSizeToTime
(
const
struct
audio_format
*
af
)
...
...
src/crossfade.c
View file @
de2cb3f3
...
...
@@ -37,7 +37,7 @@ unsigned cross_fade_calc(float duration, float total_time,
assert
(
duration
>
0
);
assert
(
af
->
bits
>
0
);
assert
(
af
->
channels
>
0
);
assert
(
af
->
sample
R
ate
>
0
);
assert
(
af
->
sample
_r
ate
>
0
);
chunks
=
audio_format_time_to_size
(
af
)
/
CHUNK_SIZE
;
chunks
=
(
chunks
*
duration
+
0
.
5
);
...
...
src/inputPlugins/_flac_common.c
View file @
de2cb3f3
...
...
@@ -162,7 +162,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
switch
(
block
->
type
)
{
case
FLAC__METADATA_TYPE_STREAMINFO
:
data
->
audio_format
.
bits
=
(
int8_t
)
si
->
bits_per_sample
;
data
->
audio_format
.
sample
R
ate
=
si
->
sample_rate
;
data
->
audio_format
.
sample
_r
ate
=
si
->
sample_rate
;
data
->
audio_format
.
channels
=
(
int8_t
)
si
->
channels
;
data
->
total_time
=
((
float
)
si
->
total_samples
)
/
(
si
->
sample_rate
);
break
;
...
...
src/inputPlugins/aac_plugin.c
View file @
de2cb3f3
...
...
@@ -148,7 +148,7 @@ static size_t adts_find_frame(AacBuffer * b)
static
void
adtsParse
(
AacBuffer
*
b
,
float
*
length
)
{
unsigned
int
frames
,
frameLength
;
int
sample
R
ate
=
0
;
int
sample
_r
ate
=
0
;
float
framesPerSec
;
/* Read all frames to ensure correct time and bitrate */
...
...
@@ -158,7 +158,7 @@ static void adtsParse(AacBuffer * b, float *length)
frameLength
=
adts_find_frame
(
b
);
if
(
frameLength
>
0
)
{
if
(
frames
==
0
)
{
sample
R
ate
=
adtsSampleRates
[(
b
->
sample
_r
ate
=
adtsSampleRates
[(
b
->
buffer
[
2
]
&
0x3c
)
>>
2
];
}
...
...
@@ -171,7 +171,7 @@ static void adtsParse(AacBuffer * b, float *length)
break
;
}
framesPerSec
=
(
float
)
sample
R
ate
/
1024
.
0
;
framesPerSec
=
(
float
)
sample
_r
ate
/
1024
.
0
;
if
(
framesPerSec
!=
0
)
*
length
=
(
float
)
frames
/
framesPerSec
;
}
...
...
@@ -253,7 +253,7 @@ static float getAacFloatTotalTime(char *file)
float
length
;
faacDecHandle
decoder
;
faacDecConfigurationPtr
config
;
uint32_t
sample
R
ate
;
uint32_t
sample
_r
ate
;
unsigned
char
channels
;
InputStream
inStream
;
long
bread
;
...
...
@@ -274,11 +274,11 @@ static float getAacFloatTotalTime(char *file)
fillAacBuffer
(
&
b
);
#ifdef HAVE_FAAD_BUFLEN_FUNCS
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
b
.
bytesIntoBuffer
,
&
sample
R
ate
,
&
channels
);
&
sample
_r
ate
,
&
channels
);
#else
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
&
sample
R
ate
,
&
channels
);
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
&
sample
_r
ate
,
&
channels
);
#endif
if
(
bread
>=
0
&&
sample
R
ate
>
0
&&
channels
>
0
)
if
(
bread
>=
0
&&
sample
_r
ate
>
0
&&
channels
>
0
)
length
=
0
;
faacDecClose
(
decoder
);
...
...
@@ -312,7 +312,7 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
faacDecConfigurationPtr
config
;
long
bread
;
struct
audio_format
audio_format
;
uint32_t
sample
R
ate
;
uint32_t
sample
_r
ate
;
unsigned
char
channels
;
unsigned
int
sampleCount
;
char
*
sampleBuffer
;
...
...
@@ -346,9 +346,9 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
#ifdef HAVE_FAAD_BUFLEN_FUNCS
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
b
.
bytesIntoBuffer
,
&
sample
R
ate
,
&
channels
);
&
sample
_r
ate
,
&
channels
);
#else
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
&
sample
R
ate
,
&
channels
);
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
&
sample
_r
ate
,
&
channels
);
#endif
if
(
bread
<
0
)
{
ERROR
(
"Error not a AAC stream.
\n
"
);
...
...
@@ -386,12 +386,12 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
break
;
}
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
sample
R
ate
=
frameInfo
.
samplerate
;
sample
_r
ate
=
frameInfo
.
samplerate
;
#endif
if
(
!
initialized
)
{
audio_format
.
channels
=
frameInfo
.
channels
;
audio_format
.
sample
Rate
=
sampleR
ate
;
audio_format
.
sample
_rate
=
sample_r
ate
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
totalTime
);
initialized
=
1
;
}
...
...
@@ -402,11 +402,11 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
if
(
sampleCount
>
0
)
{
bitRate
=
frameInfo
.
bytesconsumed
*
8
.
0
*
frameInfo
.
channels
*
sample
R
ate
/
frameInfo
.
channels
*
sample
_r
ate
/
frameInfo
.
samples
/
1000
+
0
.
5
;
file_time
+=
(
float
)(
frameInfo
.
samples
)
/
frameInfo
.
channels
/
sample
R
ate
;
sample
_r
ate
;
}
sampleBufferLen
=
sampleCount
*
2
;
...
...
@@ -446,7 +446,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
faacDecConfigurationPtr
config
;
long
bread
;
struct
audio_format
audio_format
;
uint32_t
sample
R
ate
;
uint32_t
sample
_r
ate
;
unsigned
char
channels
;
unsigned
int
sampleCount
;
char
*
sampleBuffer
;
...
...
@@ -484,9 +484,9 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
#ifdef HAVE_FAAD_BUFLEN_FUNCS
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
b
.
bytesIntoBuffer
,
&
sample
R
ate
,
&
channels
);
&
sample
_r
ate
,
&
channels
);
#else
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
&
sample
R
ate
,
&
channels
);
bread
=
faacDecInit
(
decoder
,
b
.
buffer
,
&
sample
_r
ate
,
&
channels
);
#endif
if
(
bread
<
0
)
{
ERROR
(
"Error not a AAC stream.
\n
"
);
...
...
@@ -522,12 +522,12 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
break
;
}
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
sample
R
ate
=
frameInfo
.
samplerate
;
sample
_r
ate
=
frameInfo
.
samplerate
;
#endif
if
(
!
initialized
)
{
audio_format
.
channels
=
frameInfo
.
channels
;
audio_format
.
sample
Rate
=
sampleR
ate
;
audio_format
.
sample
_rate
=
sample_r
ate
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
totalTime
);
initialized
=
1
;
...
...
@@ -539,11 +539,11 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if
(
sampleCount
>
0
)
{
bitRate
=
frameInfo
.
bytesconsumed
*
8
.
0
*
frameInfo
.
channels
*
sample
R
ate
/
frameInfo
.
channels
*
sample
_r
ate
/
frameInfo
.
samples
/
1000
+
0
.
5
;
file_time
+=
(
float
)(
frameInfo
.
samples
)
/
frameInfo
.
channels
/
sample
R
ate
;
sample
_r
ate
;
}
sampleBufferLen
=
sampleCount
*
2
;
...
...
src/inputPlugins/audiofile_plugin.c
View file @
de2cb3f3
...
...
@@ -71,14 +71,14 @@ static int audiofile_decode(struct decoder * decoder, char *path)
AF_SAMPFMT_TWOSCOMP
,
16
);
afGetVirtualSampleFormat
(
af_fp
,
AF_DEFAULT_TRACK
,
&
fs
,
&
bits
);
audio_format
.
bits
=
(
uint8_t
)
bits
;
audio_format
.
sample
R
ate
=
audio_format
.
sample
_r
ate
=
(
unsigned
int
)
afGetRate
(
af_fp
,
AF_DEFAULT_TRACK
);
audio_format
.
channels
=
(
uint8_t
)
afGetVirtualChannels
(
af_fp
,
AF_DEFAULT_TRACK
);
frame_count
=
afGetFrameCount
(
af_fp
,
AF_DEFAULT_TRACK
);
total_time
=
((
float
)
frame_count
/
(
float
)
audio_format
.
sample
R
ate
);
total_time
=
((
float
)
frame_count
/
(
float
)
audio_format
.
sample
_r
ate
);
bitRate
=
(
uint16_t
)(
st
.
st_size
*
8
.
0
/
total_time
/
1000
.
0
+
0
.
5
);
...
...
@@ -97,7 +97,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
if
(
decoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
decoder_clear
(
decoder
);
current
=
decoder_seek_where
(
decoder
)
*
audio_format
.
sample
R
ate
;
audio_format
.
sample
_r
ate
;
afSeekFrame
(
af_fp
,
AF_DEFAULT_TRACK
,
current
);
decoder_command_finished
(
decoder
);
}
...
...
@@ -110,7 +110,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
current
+=
ret
;
decoder_data
(
decoder
,
NULL
,
1
,
chunk
,
ret
*
fs
,
(
float
)
current
/
(
float
)
audio_format
.
sample
R
ate
,
(
float
)
current
/
(
float
)
audio_format
.
sample
_r
ate
,
bitRate
,
NULL
);
}
while
(
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
);
...
...
src/inputPlugins/flac_plugin.c
View file @
de2cb3f3
...
...
@@ -350,11 +350,11 @@ static int flac_decode_internal(struct decoder * decoder,
break
;
if
(
decoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
FLAC__uint64
sampleToSeek
=
decoder_seek_where
(
decoder
)
*
data
.
audio_format
.
sample
R
ate
+
0
.
5
;
data
.
audio_format
.
sample
_r
ate
+
0
.
5
;
if
(
flac_seek_absolute
(
flacDec
,
sampleToSeek
))
{
decoder_clear
(
decoder
);
data
.
time
=
((
float
)
sampleToSeek
)
/
data
.
audio_format
.
sample
R
ate
;
data
.
audio_format
.
sample
_r
ate
;
data
.
position
=
0
;
decoder_command_finished
(
decoder
);
}
else
...
...
src/inputPlugins/mod_plugin.c
View file @
de2cb3f3
...
...
@@ -186,12 +186,12 @@ static int mod_decode(struct decoder * decoder, char *path)
}
audio_format
.
bits
=
16
;
audio_format
.
sample
R
ate
=
44100
;
audio_format
.
sample
_r
ate
=
44100
;
audio_format
.
channels
=
2
;
secPerByte
=
1
.
0
/
((
audio_format
.
bits
*
audio_format
.
channels
/
8
.
0
)
*
(
float
)
audio_format
.
sample
R
ate
);
(
float
)
audio_format
.
sample
_r
ate
);
decoder_initialized
(
decoder
,
&
audio_format
,
0
);
...
...
src/inputPlugins/mp3_plugin.c
View file @
de2cb3f3
...
...
@@ -1030,7 +1030,7 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data,
struct
audio_format
*
af
)
{
af
->
bits
=
16
;
af
->
sample
R
ate
=
(
data
->
frame
).
header
.
samplerate
;
af
->
sample
_r
ate
=
(
data
->
frame
).
header
.
samplerate
;
af
->
channels
=
MAD_NCHANNELS
(
&
(
data
->
frame
).
header
);
}
...
...
src/inputPlugins/mp4_plugin.c
View file @
de2cb3f3
...
...
@@ -92,7 +92,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
struct
audio_format
audio_format
;
unsigned
char
*
mp4Buffer
;
unsigned
int
mp4BufferSize
;
uint32_t
sample
R
ate
;
uint32_t
sample
_r
ate
;
unsigned
char
channels
;
long
sampleId
;
long
numSamples
;
...
...
@@ -149,7 +149,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
mp4ff_get_decoder_config
(
mp4fh
,
track
,
&
mp4Buffer
,
&
mp4BufferSize
);
if
(
faacDecInit2
(
decoder
,
mp4Buffer
,
mp4BufferSize
,
&
sample
R
ate
,
&
channels
)
<
0
)
{
(
decoder
,
mp4Buffer
,
mp4BufferSize
,
&
sample
_r
ate
,
&
channels
)
<
0
)
{
ERROR
(
"Error not a AAC stream.
\n
"
);
faacDecClose
(
decoder
);
mp4ff_close
(
mp4fh
);
...
...
@@ -157,7 +157,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
return
-
1
;
}
audio_format
.
sample
Rate
=
sampleR
ate
;
audio_format
.
sample
_rate
=
sample_r
ate
;
audio_format
.
channels
=
channels
;
file_time
=
mp4ff_get_track_duration_use_offsets
(
mp4fh
,
track
);
scale
=
mp4ff_time_scale
(
mp4fh
,
track
);
...
...
@@ -255,7 +255,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
scale
=
frameInfo
.
samplerate
;
#endif
audio_format
.
sample
R
ate
=
scale
;
audio_format
.
sample
_r
ate
=
scale
;
audio_format
.
channels
=
frameInfo
.
channels
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
total_time
);
...
...
src/inputPlugins/mpc_plugin.c
View file @
de2cb3f3
...
...
@@ -154,7 +154,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
audio_format
.
bits
=
16
;
audio_format
.
channels
=
info
.
channels
;
audio_format
.
sample
R
ate
=
info
.
sample_freq
;
audio_format
.
sample
_r
ate
=
info
.
sample_freq
;
replayGainInfo
=
newReplayGainInfo
();
replayGainInfo
->
albumGain
=
info
.
gain_album
*
0
.
01
;
...
...
@@ -168,7 +168,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
while
(
!
eof
)
{
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
samplePos
=
decoder_seek_where
(
mpd_decoder
)
*
audio_format
.
sample
R
ate
;
audio_format
.
sample
_r
ate
;
if
(
mpc_decoder_seek_sample
(
&
decoder
,
samplePos
))
{
decoder_clear
(
mpd_decoder
);
s16
=
(
int16_t
*
)
chunk
;
...
...
@@ -201,10 +201,10 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
if
(
chunkpos
>=
MPC_CHUNK_SIZE
)
{
total_time
=
((
float
)
samplePos
)
/
audio_format
.
sample
R
ate
;
audio_format
.
sample
_r
ate
;
bitRate
=
vbrUpdateBits
*
audio_format
.
sample
R
ate
/
1152
/
1000
;
audio_format
.
sample
_r
ate
/
1152
/
1000
;
decoder_data
(
mpd_decoder
,
inStream
,
inStream
->
seekable
,
...
...
@@ -224,10 +224,10 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
if
(
decoder_get_command
(
mpd_decoder
)
!=
DECODE_COMMAND_STOP
&&
chunkpos
>
0
)
{
total_time
=
((
float
)
samplePos
)
/
audio_format
.
sample
R
ate
;
total_time
=
((
float
)
samplePos
)
/
audio_format
.
sample
_r
ate
;
bitRate
=
vbrUpdateBits
*
audio_format
.
sample
R
ate
/
1152
/
1000
;
vbrUpdateBits
*
audio_format
.
sample
_r
ate
/
1152
/
1000
;
decoder_data
(
mpd_decoder
,
NULL
,
inStream
->
seekable
,
chunk
,
chunkpos
,
total_time
,
bitRate
,
...
...
src/inputPlugins/oggflac_plugin.c
View file @
de2cb3f3
...
...
@@ -316,12 +316,12 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
}
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
FLAC__uint64
sampleToSeek
=
decoder_seek_where
(
mpd_decoder
)
*
data
.
audio_format
.
sample
R
ate
+
0
.
5
;
data
.
audio_format
.
sample
_r
ate
+
0
.
5
;
if
(
OggFLAC__seekable_stream_decoder_seek_absolute
(
decoder
,
sampleToSeek
))
{
decoder_clear
(
mpd_decoder
);
data
.
time
=
((
float
)
sampleToSeek
)
/
data
.
audio_format
.
sample
R
ate
;
data
.
audio_format
.
sample
_r
ate
;
data
.
position
=
0
;
decoder_command_finished
(
mpd_decoder
);
}
else
...
...
src/inputPlugins/oggvorbis_plugin.c
View file @
de2cb3f3
...
...
@@ -278,7 +278,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
/*printf("new song!\n"); */
vorbis_info
*
vi
=
ov_info
(
&
vf
,
-
1
);
audio_format
.
channels
=
vi
->
channels
;
audio_format
.
sample
R
ate
=
vi
->
rate
;
audio_format
.
sample
_r
ate
=
vi
->
rate
;
if
(
!
initialized
)
{
float
total_time
=
ov_time_total
(
&
vf
,
-
1
);
if
(
total_time
<
0
)
...
...
@@ -311,7 +311,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
decoder_data
(
decoder
,
inStream
,
inStream
->
seekable
,
chunk
,
chunkpos
,
ov_pcm_tell
(
&
vf
)
/
audio_format
.
sample
R
ate
,
ov_pcm_tell
(
&
vf
)
/
audio_format
.
sample
_r
ate
,
bitRate
,
replayGainInfo
);
chunkpos
=
0
;
if
(
decoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
)
...
...
src/inputPlugins/wavpack_plugin.c
View file @
de2cb3f3
...
...
@@ -140,7 +140,7 @@ static void wavpack_decode(struct decoder * decoder,
int
position
,
outsamplesize
;
int
Bps
;
audio_format
.
sample
R
ate
=
WavpackGetSampleRate
(
wpc
);
audio_format
.
sample
_r
ate
=
WavpackGetSampleRate
(
wpc
);
audio_format
.
channels
=
WavpackGetReducedChannels
(
wpc
);
audio_format
.
bits
=
WavpackGetBitsPerSample
(
wpc
);
...
...
@@ -168,7 +168,7 @@ static void wavpack_decode(struct decoder * decoder,
samplesreq
=
sizeof
(
chunk
)
/
(
4
*
audio_format
.
channels
);
decoder_initialized
(
decoder
,
&
audio_format
,
(
float
)
allsamples
/
audio_format
.
sample
R
ate
);
(
float
)
allsamples
/
audio_format
.
sample
_r
ate
);
position
=
0
;
...
...
@@ -180,7 +180,7 @@ static void wavpack_decode(struct decoder * decoder,
decoder_clear
(
decoder
);
where
=
decoder_seek_where
(
decoder
)
*
audio_format
.
sampleR
ate
;
audio_format
.
sample_r
ate
;
if
(
WavpackSeekSample
(
wpc
,
where
))
{
position
=
where
;
decoder_command_finished
(
decoder
);
...
...
@@ -200,8 +200,7 @@ static void wavpack_decode(struct decoder * decoder,
int
bitrate
=
(
int
)(
WavpackGetInstantBitrate
(
wpc
)
/
1000
+
0
.
5
);
position
+=
samplesgot
;
file_time
=
(
float
)
position
/
audio_format
.
sampleRate
;
file_time
=
(
float
)
position
/
audio_format
.
sample_rate
;
format_samples
(
Bps
,
chunk
,
samplesgot
*
audio_format
.
channels
);
...
...
src/pcm_utils.c
View file @
de2cb3f3
...
...
@@ -503,13 +503,13 @@ size_t pcm_convertAudioFormat(const struct audio_format *inFormat,
exit
(
EXIT_FAILURE
);
}
if
(
inFormat
->
sample
Rate
==
outFormat
->
sampleR
ate
)
{
if
(
inFormat
->
sample
_rate
==
outFormat
->
sample_r
ate
)
{
assert
(
outSize
>=
len
);
memcpy
(
outBuffer
,
buf
,
len
);
}
else
{
len
=
pcm_convertSampleRate
(
outFormat
->
channels
,
inFormat
->
sample
R
ate
,
buf
,
len
,
outFormat
->
sample
R
ate
,
outBuffer
,
inFormat
->
sample
_r
ate
,
buf
,
len
,
outFormat
->
sample
_r
ate
,
outBuffer
,
outSize
,
convState
);
if
(
len
==
0
)
exit
(
EXIT_FAILURE
);
...
...
@@ -521,8 +521,8 @@ size_t pcm_convertAudioFormat(const struct audio_format *inFormat,
size_t
pcm_sizeOfConvBuffer
(
const
struct
audio_format
*
inFormat
,
size_t
inSize
,
const
struct
audio_format
*
outFormat
)
{
const
double
ratio
=
(
double
)
outFormat
->
sample
R
ate
/
(
double
)
inFormat
->
sample
R
ate
;
const
double
ratio
=
(
double
)
outFormat
->
sample
_r
ate
/
(
double
)
inFormat
->
sample
_r
ate
;
const
int
shift
=
2
*
outFormat
->
channels
;
size_t
outSize
=
inSize
;
...
...
src/player_thread.c
View file @
de2cb3f3
...
...
@@ -253,7 +253,7 @@ static void do_play(void)
closeAudioDevice
();
}
pc
.
totalTime
=
dc
.
totalTime
;
pc
.
sampleRate
=
dc
.
audioFormat
.
sample
R
ate
;
pc
.
sampleRate
=
dc
.
audioFormat
.
sample
_r
ate
;
pc
.
bits
=
dc
.
audioFormat
.
bits
;
pc
.
channels
=
dc
.
audioFormat
.
channels
;
sizeToTime
=
audioFormatSizeToTime
(
&
ob
.
audioFormat
);
...
...
src/timer.c
View file @
de2cb3f3
...
...
@@ -40,7 +40,7 @@ Timer *timer_new(const struct audio_format *af)
timer
=
xmalloc
(
sizeof
(
Timer
));
timer
->
time
=
0
;
timer
->
started
=
0
;
timer
->
rate
=
af
->
sample
R
ate
*
(
af
->
bits
/
CHAR_BIT
)
*
af
->
channels
;
timer
->
rate
=
af
->
sample
_r
ate
*
(
af
->
bits
/
CHAR_BIT
)
*
af
->
channels
;
return
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