~ubuntu-branches/ubuntu/saucy/mpd/saucy

« back to all changes in this revision

Viewing changes to test/software_volume.c

  • Committer: Bazaar Package Importer
  • Author(s): Angel Abad
  • Date: 2011-02-02 12:26:30 UTC
  • mfrom: (1.5.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20110202122630-bdyx8w4k94doz4fs
Tags: 0.16.1-1ubuntu1
* Merge from debian unstable. Remaining changes:
  - debian/control:
    + Don't build-depend on libmikmod2-dev (Debian bug #510675).
    + Move avahi-daemon from Suggests field to Recommends field.
  - debian/mpd.init.d:
    + Read mpd user from mpd.conf.
  - debian/control, debian/rules:
    + Add libmp3lame-dev to the build dependencies and enable lame.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2003-2009 The Music Player Daemon Project
 
2
 * Copyright (C) 2003-2010 The Music Player Daemon Project
3
3
 * http://www.musicpd.org
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
23
23
 *
24
24
 */
25
25
 
 
26
#include "config.h"
26
27
#include "pcm_volume.h"
27
28
#include "audio_parser.h"
28
29
#include "audio_format.h"
 
30
#include "stdbin.h"
29
31
 
30
32
#include <glib.h>
31
33
 
35
37
int main(int argc, char **argv)
36
38
{
37
39
        GError *error = NULL;
38
 
        struct audio_format audio_format = {
39
 
                .sample_rate = 48000,
40
 
                .bits = 16,
41
 
                .channels = 2,
42
 
        };
 
40
        struct audio_format audio_format;
43
41
        bool ret;
44
42
        static char buffer[4096];
45
43
        ssize_t nbytes;
46
44
 
47
45
        if (argc > 2) {
48
 
                g_printerr("Usage: software_voluem [FORMAT] <IN >OUT\n");
 
46
                g_printerr("Usage: software_volume [FORMAT] <IN >OUT\n");
49
47
                return 1;
50
48
        }
51
49
 
52
50
        if (argc > 1) {
53
 
                ret = audio_format_parse(&audio_format, argv[1], &error);
 
51
                ret = audio_format_parse(&audio_format, argv[1],
 
52
                                         false, &error);
54
53
                if (!ret) {
55
54
                        g_printerr("Failed to parse audio format: %s\n",
56
55
                                   error->message);
57
56
                        return 1;
58
57
                }
59
 
        }
 
58
        } else
 
59
                audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2);
60
60
 
61
61
        while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
62
 
                pcm_volume(buffer, nbytes, &audio_format, PCM_VOLUME_1 / 2);
 
62
                if (!pcm_volume(buffer, nbytes, &audio_format,
 
63
                                PCM_VOLUME_1 / 2)) {
 
64
                        g_printerr("pcm_volume() has failed\n");
 
65
                        return 2;
 
66
                }
 
67
 
63
68
                write(1, buffer, nbytes);
64
69
        }
65
70
}