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
44f9e169
Commit
44f9e169
authored
Jul 30, 2006
by
Eric Wong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software volume can now be saved and read from the state file
git-svn-id:
https://svn.musicpd.org/mpd/trunk@4495
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
12aec573
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
state_file.c
src/state_file.c
+2
-0
volume.c
src/volume.c
+35
-0
volume.h
src/volume.h
+4
-0
No files found.
src/state_file.c
View file @
44f9e169
...
...
@@ -24,6 +24,7 @@
#include "audio.h"
#include "playlist.h"
#include "utils.h"
#include "volume.h"
#include <errno.h>
#include <stdlib.h>
...
...
@@ -35,6 +36,7 @@ static struct _sf_cb {
void
(
*
reader
)(
FILE
*
);
void
(
*
writer
)(
FILE
*
);
}
sf_callbacks
[]
=
{
{
read_sw_volume_state
,
save_sw_volume_state
},
{
readAudioDevicesState
,
saveAudioDevicesState
},
{
readPlaylistState
,
savePlaylistState
},
};
...
...
src/volume.c
View file @
44f9e169
...
...
@@ -21,6 +21,9 @@
#include "conf.h"
#include "log.h"
#include "player.h"
#include "state_file.h"
#include "gcc.h"
#include "utils.h"
#include <math.h>
#include <stdlib.h>
...
...
@@ -44,6 +47,7 @@
#define VOLUME_MIXER_OSS_DEFAULT "/dev/mixer"
#define VOLUME_MIXER_ALSA_DEFAULT "default"
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
#define SW_VOLUME_STATE "sw_volume: "
#ifdef HAVE_OSS
#define VOLUME_MIXER_TYPE_DEFAULT VOLUME_MIXER_TYPE_OSS
...
...
@@ -515,3 +519,34 @@ int changeVolumeLevel(int fd, int change, int rel)
break
;
}
}
void
read_sw_volume_state
(
FILE
*
fp
)
{
/* strlen(SW_VOLUME_STATE) + strlen('100') + '\0' */
#define bufsize 16
char
buf
[
bufsize
];
const
size_t
len
=
strlen
(
SW_VOLUME_STATE
);
char
*
end
=
NULL
;
long
int
sv
;
if
(
volume_mixerType
!=
VOLUME_MIXER_TYPE_SOFTWARE
)
return
;
while
(
myFgets
(
buf
,
bufsize
,
fp
))
{
if
(
strncmp
(
buf
,
SW_VOLUME_STATE
,
len
))
continue
;
sv
=
strtol
(
buf
+
len
,
&
end
,
10
);
if
(
mpd_likely
(
!*
end
))
changeSoftwareVolume
(
STDERR_FILENO
,
sv
,
0
);
else
ERROR
(
"Can't parse software volume: %s
\n
"
,
buf
);
return
;
}
#undef bufsize
}
void
save_sw_volume_state
(
FILE
*
fp
)
{
if
(
volume_mixerType
==
VOLUME_MIXER_TYPE_SOFTWARE
)
fprintf
(
fp
,
SW_VOLUME_STATE
"%d
\n
"
,
volume_softwareSet
);
}
src/volume.h
View file @
44f9e169
...
...
@@ -37,4 +37,8 @@ int getVolumeLevel();
int
changeVolumeLevel
(
int
fd
,
int
change
,
int
rel
);
void
read_sw_volume_state
(
FILE
*
fp
);
void
save_sw_volume_state
(
FILE
*
fp
);
#endif
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