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
b7bfa24f
Commit
b7bfa24f
authored
Mar 02, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_volume: return bool
Don't abort MPD when a sample format is not supported by pcm_volume().
parent
0579b6ed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
13 deletions
+25
-13
pcm_volume.c
src/pcm_volume.c
+7
-8
pcm_volume.h
src/pcm_volume.h
+3
-1
player_thread.c
src/player_thread.c
+11
-2
read_tags.c
test/read_tags.c
+2
-1
run_decoder.c
test/run_decoder.c
+2
-1
No files found.
src/pcm_volume.c
View file @
b7bfa24f
...
...
@@ -112,36 +112,35 @@ pcm_volume_change_24(int32_t *buffer, unsigned num_samples, int volume)
}
}
void
bool
pcm_volume
(
void
*
buffer
,
int
length
,
const
struct
audio_format
*
format
,
int
volume
)
{
if
(
volume
==
PCM_VOLUME_1
)
return
;
return
true
;
if
(
volume
<=
0
)
{
memset
(
buffer
,
0
,
length
);
return
;
return
true
;
}
switch
(
format
->
bits
)
{
case
8
:
pcm_volume_change_8
((
int8_t
*
)
buffer
,
length
,
volume
);
break
;
return
true
;
case
16
:
pcm_volume_change_16
((
int16_t
*
)
buffer
,
length
/
2
,
volume
);
break
;
return
true
;
case
24
:
pcm_volume_change_24
((
int32_t
*
)
buffer
,
length
/
4
,
volume
);
break
;
return
true
;
default:
g_error
(
"%u bits not supported by pcm_volume!
\n
"
,
format
->
bits
);
return
false
;
}
}
src/pcm_volume.h
View file @
b7bfa24f
...
...
@@ -22,6 +22,7 @@
#include "pcm_prng.h"
#include <stdint.h>
#include <stdbool.h>
enum
{
/** this value means "100% volume" */
...
...
@@ -62,8 +63,9 @@ pcm_volume_dither(void)
* @param length the length of the PCM buffer
* @param format the audio format of the PCM buffer
* @param volume the volume between 0 and #PCM_VOLUME_1
* @return true on success, false if the audio format is not supported
*/
void
bool
pcm_volume
(
void
*
buffer
,
int
length
,
const
struct
audio_format
*
format
,
int
volume
);
...
...
src/player_thread.c
View file @
b7bfa24f
...
...
@@ -238,6 +238,8 @@ static bool
play_chunk
(
struct
song
*
song
,
struct
music_chunk
*
chunk
,
const
struct
audio_format
*
format
,
double
sizeToTime
)
{
bool
success
;
pc
.
elapsed_time
=
chunk
->
times
;
pc
.
bit_rate
=
chunk
->
bit_rate
;
...
...
@@ -266,8 +268,15 @@ play_chunk(struct song *song, struct music_chunk *chunk,
if
(
chunk
->
length
==
0
)
return
true
;
pcm_volume
(
chunk
->
data
,
chunk
->
length
,
format
,
pc
.
software_volume
);
success
=
pcm_volume
(
chunk
->
data
,
chunk
->
length
,
format
,
pc
.
software_volume
);
if
(
!
success
)
{
g_warning
(
"pcm_volume() failed on %u:%u:%u"
,
format
->
sample_rate
,
format
->
bits
,
format
->
channels
);
pc
.
errored_song
=
dc
.
current_song
;
pc
.
error
=
PLAYER_ERROR_AUDIO
;
return
false
;
}
if
(
!
audio_output_all_play
(
chunk
->
data
,
chunk
->
length
))
{
pc
.
errored_song
=
dc
.
current_song
;
...
...
test/read_tags.c
View file @
b7bfa24f
...
...
@@ -32,11 +32,12 @@
/**
* No-op dummy.
*/
void
bool
pcm_volume
(
G_GNUC_UNUSED
void
*
buffer
,
G_GNUC_UNUSED
int
length
,
G_GNUC_UNUSED
const
struct
audio_format
*
format
,
G_GNUC_UNUSED
int
volume
)
{
return
true
;
}
void
...
...
test/run_decoder.c
View file @
b7bfa24f
...
...
@@ -30,11 +30,12 @@
/**
* No-op dummy.
*/
void
bool
pcm_volume
(
G_GNUC_UNUSED
void
*
buffer
,
G_GNUC_UNUSED
int
length
,
G_GNUC_UNUSED
const
struct
audio_format
*
format
,
G_GNUC_UNUSED
int
volume
)
{
return
true
;
}
struct
decoder
{
...
...
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