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
bddb6b42
Commit
bddb6b42
authored
Oct 17, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: allow changing replay gain mode on-the-fly
The new command "replay_gain_mode" allows the user to switch the replay gain mode on-the-fly. No more mpd.conf editing.
parent
7ec32704
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
1 deletion
+99
-1
NEWS
NEWS
+1
-0
protocol.xml
doc/protocol.xml
+35
-0
command.c
src/command.c
+27
-0
replay_gain.c
src/replay_gain.c
+20
-1
replay_gain.h
src/replay_gain.h
+16
-0
No files found.
NEWS
View file @
bddb6b42
...
...
@@ -8,6 +8,7 @@ ver 0.16 (20??/??/??)
- "previous" really plays the previous song
- "addid" with negative position is deprecated
- "load" supports remote playlists (m3u, pls, xspf, lastfm://)
- allow changing replay gain mode on-the-fly
* input:
- lastfm: obsolete plugin removed
* tags:
...
...
doc/protocol.xml
View file @
bddb6b42
...
...
@@ -487,6 +487,41 @@
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_replay_gain_mode"
>
<term>
<cmdsynopsis>
<command>
replay_gain_mode
</command>
<arg
choice=
"req"
><replaceable>
MODE
</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Sets the replay gain mode. One of
<parameter>
off
</parameter>
,
<parameter>
track
</parameter>
,
<parameter>
album
</parameter>
.
</para>
<para>
Changing the mode during playback may take several
seconds, because the new settings does not affect the
buffered data.
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_replay_gain_status"
>
<term>
<cmdsynopsis>
<command>
replay_gain_status
</command>
</cmdsynopsis>
</term>
<listitem>
<para>
Prints replay gain options. Currently, only the
variable
<varname>
replay_gain_mode
</varname>
is
returned.
</para>
</listitem>
</varlistentry>
</variablelist>
</section>
...
...
src/command.c
View file @
bddb6b42
...
...
@@ -44,6 +44,7 @@
#include "client.h"
#include "tag_print.h"
#include "path.h"
#include "replay_gain.h"
#include "idle.h"
#include "config.h"
...
...
@@ -1522,6 +1523,28 @@ handle_listplaylists(struct client *client,
}
static
enum
command_return
handle_replay_gain_mode
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
if
(
!
replay_gain_set_mode_string
(
argv
[
1
]))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Unrecognized replay gain mode"
);
return
COMMAND_RETURN_ERROR
;
}
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
handle_replay_gain_status
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
client_printf
(
client
,
"replay_gain_mode: %s
\n
"
,
replay_gain_get_mode_string
());
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
handle_idle
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
...
...
@@ -1765,6 +1788,10 @@ static const struct command commands[] = {
{
"random"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_random
},
{
"rename"
,
PERMISSION_CONTROL
,
2
,
2
,
handle_rename
},
{
"repeat"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_repeat
},
{
"replay_gain_mode"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_replay_gain_mode
},
{
"replay_gain_status"
,
PERMISSION_READ
,
0
,
0
,
handle_replay_gain_status
},
{
"rescan"
,
PERMISSION_ADMIN
,
0
,
1
,
handle_rescan
},
{
"rm"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_rm
},
{
"save"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_save
},
...
...
src/replay_gain.c
View file @
bddb6b42
...
...
@@ -42,7 +42,26 @@ enum replay_gain_mode replay_gain_mode = REPLAY_GAIN_OFF;
static
float
replay_gain_preamp
=
1
.
0
;
static
float
replay_gain_missing_preamp
=
1
.
0
;
static
bool
const
char
*
replay_gain_get_mode_string
(
void
)
{
switch
(
replay_gain_mode
)
{
case
REPLAY_GAIN_OFF
:
return
"off"
;
case
REPLAY_GAIN_TRACK
:
return
"track"
;
case
REPLAY_GAIN_ALBUM
:
return
"album"
;
}
/* unreachable */
assert
(
false
);
return
"off"
;
}
bool
replay_gain_set_mode_string
(
const
char
*
p
)
{
assert
(
p
!=
NULL
);
...
...
src/replay_gain.h
View file @
bddb6b42
...
...
@@ -23,6 +23,8 @@
#ifndef MPD_REPLAY_GAIN_H
#define MPD_REPLAY_GAIN_H
#include <stdbool.h>
enum
replay_gain_mode
{
REPLAY_GAIN_OFF
=
-
1
,
REPLAY_GAIN_ALBUM
,
...
...
@@ -52,6 +54,20 @@ void replay_gain_info_free(struct replay_gain_info *info);
void
replay_gain_global_init
(
void
);
/**
* Returns the current replay gain mode as a machine-readable string.
*/
const
char
*
replay_gain_get_mode_string
(
void
);
/**
* Sets the replay gain mode, parsed from a string.
*
* @return true on success, false if the string could not be parsed
*/
bool
replay_gain_set_mode_string
(
const
char
*
p
);
void
replay_gain_apply
(
struct
replay_gain_info
*
info
,
char
*
buffer
,
int
bufferSize
,
const
struct
audio_format
*
format
);
...
...
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