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
05693e2d
Commit
05693e2d
authored
Jul 19, 2009
by
David Woodhouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reverse_endian field to struct audio_format and handle conversion
parent
37754559
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
154 additions
and
6 deletions
+154
-6
Makefile.am
Makefile.am
+3
-1
audio_format.h
src/audio_format.h
+4
-1
convert_filter_plugin.c
src/filter/convert_filter_plugin.c
+1
-0
output_thread.c
src/output_thread.c
+6
-4
pcm_byteswap.c
src/pcm_byteswap.c
+71
-0
pcm_byteswap.h
src/pcm_byteswap.h
+50
-0
pcm_convert.c
src/pcm_convert.c
+19
-0
No files found.
Makefile.am
View file @
05693e2d
...
...
@@ -114,6 +114,7 @@ mpd_headers = \
src/pcm_convert.h
\
src/pcm_volume.h
\
src/pcm_mix.h
\
src/pcm_byteswap.h
\
src/pcm_channels.h
\
src/pcm_format.h
\
src/pcm_resample.h
\
...
...
@@ -218,6 +219,7 @@ src_mpd_SOURCES = \
src/pcm_convert.c
\
src/pcm_volume.c
\
src/pcm_mix.c
\
src/pcm_byteswap.c
\
src/pcm_channels.c
\
src/pcm_format.c
\
src/pcm_resample.c
\
...
...
@@ -708,7 +710,7 @@ test_run_filter_SOURCES = test/run_filter.c \
src/filter_plugin.c
\
src/filter_registry.c
\
src/conf.c src/buffer2array.c src/utils.c
\
src/pcm_volume.c src/pcm_convert.c
\
src/pcm_volume.c src/pcm_convert.c
src/pcm_byteswap.c
\
src/pcm_format.c src/pcm_channels.c src/pcm_dither.c
\
src/pcm_resample.c src/pcm_resample_fallback.c
\
src/audio_parser.c
\
...
...
src/audio_format.h
View file @
05693e2d
...
...
@@ -27,6 +27,7 @@ struct audio_format {
uint32_t
sample_rate
;
uint8_t
bits
;
uint8_t
channels
;
uint8_t
reverse_endian
;
};
static
inline
void
audio_format_clear
(
struct
audio_format
*
af
)
...
...
@@ -34,6 +35,7 @@ static inline void audio_format_clear(struct audio_format *af)
af
->
sample_rate
=
0
;
af
->
bits
=
0
;
af
->
channels
=
0
;
af
->
reverse_endian
=
0
;
}
static
inline
void
audio_format_init
(
struct
audio_format
*
af
,
...
...
@@ -97,7 +99,8 @@ static inline bool audio_format_equals(const struct audio_format *a,
{
return
a
->
sample_rate
==
b
->
sample_rate
&&
a
->
bits
==
b
->
bits
&&
a
->
channels
==
b
->
channels
;
a
->
channels
==
b
->
channels
&&
a
->
reverse_endian
==
b
->
reverse_endian
;
}
/**
...
...
src/filter/convert_filter_plugin.c
View file @
05693e2d
...
...
@@ -149,6 +149,7 @@ convert_filter_set(struct filter *_filter,
assert
(
audio_format_valid
(
&
filter
->
out_audio_format
));
assert
(
out_audio_format
!=
NULL
);
assert
(
audio_format_valid
(
out_audio_format
));
assert
(
filter
->
in_audio_format
.
reverse_endian
==
0
);
filter
->
out_audio_format
=
*
out_audio_format
;
}
src/output_thread.c
View file @
05693e2d
...
...
@@ -93,18 +93,20 @@ ao_open(struct audio_output *ao)
g_mutex_unlock
(
ao
->
mutex
);
g_debug
(
"opened plugin=%s name=
\"
%s
\"
"
"audio_format=%u:%u:%u"
,
"audio_format=%u:%u:%u
:%u
"
,
ao
->
plugin
->
name
,
ao
->
name
,
ao
->
out_audio_format
.
sample_rate
,
ao
->
out_audio_format
.
bits
,
ao
->
out_audio_format
.
channels
);
ao
->
out_audio_format
.
channels
,
ao
->
out_audio_format
.
reverse_endian
);
if
(
!
audio_format_equals
(
&
ao
->
in_audio_format
,
&
ao
->
out_audio_format
))
g_debug
(
"converting from %u:%u:%u"
,
g_debug
(
"converting from %u:%u:%u
:%u
"
,
ao
->
in_audio_format
.
sample_rate
,
ao
->
in_audio_format
.
bits
,
ao
->
in_audio_format
.
channels
);
ao
->
in_audio_format
.
channels
,
ao
->
in_audio_format
.
reverse_endian
);
}
static
void
...
...
src/pcm_byteswap.c
0 → 100644
View file @
05693e2d
/*
* Copyright (C) 2003-2009 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "pcm_byteswap.h"
#include "pcm_buffer.h"
#include <glib.h>
#include <assert.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "pcm"
static
inline
uint16_t
swab16
(
uint16_t
x
)
{
return
(
x
<<
8
)
|
(
x
>>
8
);
}
const
int16_t
*
pcm_byteswap_16
(
struct
pcm_buffer
*
buffer
,
const
int16_t
*
src
,
size_t
len
)
{
unsigned
i
;
int16_t
*
buf
=
pcm_buffer_get
(
buffer
,
len
);
if
(
!
buf
)
return
NULL
;
for
(
i
=
0
;
i
<
len
/
2
;
i
++
)
buf
[
i
]
=
swab16
(
src
[
i
]);
return
buf
;
}
static
inline
uint32_t
swab32
(
uint32_t
x
)
{
return
(
x
<<
24
)
|
((
x
&
0xff00
)
<<
8
)
|
((
x
&
0xff0000
)
>>
8
)
|
(
x
>>
24
);
}
const
int32_t
*
pcm_byteswap_32
(
struct
pcm_buffer
*
buffer
,
const
int32_t
*
src
,
size_t
len
)
{
unsigned
i
;
int32_t
*
buf
=
pcm_buffer_get
(
buffer
,
len
);
if
(
!
buf
)
return
NULL
;
for
(
i
=
0
;
i
<
len
/
4
;
i
++
)
buf
[
i
]
=
swab32
(
src
[
i
]);
return
buf
;
}
src/pcm_byteswap.h
0 → 100644
View file @
05693e2d
/*
* Copyright (C) 2003-2009 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_PCM_BYTESWAP_H
#define MPD_PCM_BYTESWAP_H
#include <stdint.h>
#include <stddef.h>
struct
pcm_buffer
;
/**
* Changes the endianness of 16 bit PCM data.
*
* @param buffer the destination pcm_buffer object
* @param src the source PCM buffer
* @param src_size the number of bytes in #src
* @return the destination buffer
*/
const
int16_t
*
pcm_byteswap_16
(
struct
pcm_buffer
*
buffer
,
const
int16_t
*
src
,
size_t
len
);
/**
* Changes the endianness of 32-bit (or 24-bit) PCM data.
*
* @param buffer the destination pcm_buffer object
* @param src the source PCM buffer
* @param src_size the number of bytes in #src
* @return the destination buffer
*/
const
int32_t
*
pcm_byteswap_32
(
struct
pcm_buffer
*
buffer
,
const
int32_t
*
src
,
size_t
len
);
#endif
src/pcm_convert.c
View file @
05693e2d
...
...
@@ -20,6 +20,7 @@
#include "pcm_convert.h"
#include "pcm_channels.h"
#include "pcm_format.h"
#include "pcm_byteswap.h"
#include "audio_format.h"
#include <assert.h>
...
...
@@ -83,6 +84,12 @@ pcm_convert_16(struct pcm_convert_state *state,
dest_format
->
sample_rate
,
&
len
);
if
(
dest_format
->
reverse_endian
)
{
buf
=
pcm_byteswap_16
(
&
state
->
format_buffer
,
buf
,
len
);
if
(
!
buf
)
g_error
(
"pcm_byteswap_16() failed"
);
}
*
dest_size_r
=
len
;
return
buf
;
}
...
...
@@ -120,6 +127,12 @@ pcm_convert_24(struct pcm_convert_state *state,
dest_format
->
sample_rate
,
&
len
);
if
(
dest_format
->
reverse_endian
)
{
buf
=
pcm_byteswap_32
(
&
state
->
format_buffer
,
buf
,
len
);
if
(
!
buf
)
g_error
(
"pcm_byteswap_32() failed"
);
}
*
dest_size_r
=
len
;
return
buf
;
}
...
...
@@ -157,6 +170,12 @@ pcm_convert_32(struct pcm_convert_state *state,
dest_format
->
sample_rate
,
&
len
);
if
(
dest_format
->
reverse_endian
)
{
buf
=
pcm_byteswap_32
(
&
state
->
format_buffer
,
buf
,
len
);
if
(
!
buf
)
g_error
(
"pcm_byteswap_32() failed"
);
}
*
dest_size_r
=
len
;
return
buf
;
}
...
...
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