2009-02-18 22:27:55 +01:00
|
|
|
/*
|
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-02-18 22:27:55 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program is a command line interface to MPD's software volume
|
|
|
|
* library (pcm_volume.c).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pcm_volume.h"
|
|
|
|
#include "audio_parser.h"
|
|
|
|
#include "audio_format.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
2009-07-19 17:24:43 +02:00
|
|
|
struct audio_format audio_format;
|
2009-02-18 22:27:55 +01:00
|
|
|
bool ret;
|
|
|
|
static char buffer[4096];
|
|
|
|
ssize_t nbytes;
|
|
|
|
|
|
|
|
if (argc > 2) {
|
|
|
|
g_printerr("Usage: software_voluem [FORMAT] <IN >OUT\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc > 1) {
|
2009-10-21 23:01:04 +02:00
|
|
|
ret = audio_format_parse(&audio_format, argv[1],
|
|
|
|
false, &error);
|
2009-02-18 22:27:55 +01:00
|
|
|
if (!ret) {
|
2009-02-25 16:44:05 +01:00
|
|
|
g_printerr("Failed to parse audio format: %s\n",
|
|
|
|
error->message);
|
2009-02-18 22:27:55 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2009-07-19 17:24:43 +02:00
|
|
|
audio_format_init(&audio_format, 48000, 16, 2);
|
2009-02-18 22:27:55 +01:00
|
|
|
|
|
|
|
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
|
|
|
|
pcm_volume(buffer, nbytes, &audio_format, PCM_VOLUME_1 / 2);
|
|
|
|
write(1, buffer, nbytes);
|
|
|
|
}
|
|
|
|
}
|