Changeset aef1799 in mainline


Ignore:
Timestamp:
2012-07-17T10:57:41Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1f7da3b
Parents:
cd8f19d
Message:

Integrate dplay into wavplay.

Files:
1 added
3 deleted
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • boot/arch/amd64/Makefile.inc

    rcd8f19d raef1799  
    6363RD_APPS_ESSENTIAL += \
    6464        $(USPACE_PATH)/app/edit/edit \
    65         $(USPACE_PATH)/app/dplay/dplay \
    66         $(USPACE_PATH)/app/drec/drec \
    6765        $(USPACE_PATH)/app/mixerctl/mixerctl \
    6866        $(USPACE_PATH)/app/wavplay/wavplay \
  • uspace/Makefile

    rcd8f19d raef1799  
    3838        app/bnchmark \
    3939        app/devctl \
    40         app/dplay \
    4140        app/drec \
    4241        app/edit \
  • uspace/app/wavplay/Makefile

    rcd8f19d raef1799  
    3131
    3232LIBS = \
    33         $(LIBHOUND_PREFIX)/libhound.a
     33        $(LIBHOUND_PREFIX)/libhound.a \
     34        $(LIBDRV_PREFIX)/libdrv.a
    3435
    3536EXTRA_CFLAGS = \
    36         -I$(LIBHOUND_PREFIX)/include -I$(LIBPCM_PREFIX)/include
     37        -I$(LIBDRV_PREFIX)/include \
     38        -I$(LIBHOUND_PREFIX)/include \
     39        -I$(LIBPCM_PREFIX)/include
    3740
    3841SOURCES = \
    39         wavplay.c \
     42        dplay.c \
     43        main.c \
    4044        wave.c
    4145
  • uspace/app/wavplay/dplay.c

    rcd8f19d raef1799  
    4949
    5050#include "wave.h"
     51#include "dplay.h"
    5152
    5253#define DEFAULT_DEVICE "/hw/pci0/00:01.0/sb16/pcm"
     
    153154}
    154155
    155 int main(int argc, char *argv[])
    156 {
    157         const char *device = DEFAULT_DEVICE;
    158         const char *file;
    159         switch (argc) {
    160         case 2:
    161                 file = argv[1];
    162                 break;
    163         case 3:
    164                 device = argv[1];
    165                 file = argv[2];
    166                 break;
    167         default:
    168                 printf("Usage: %s [device] file.\n", argv[0]);
    169                 return 1;
    170         }
    171 
     156int dplay(const char *device, const char *file)
     157{
     158        if (str_cmp(device, "default") == 0)
     159                device = DEFAULT_DEVICE;
    172160        audio_pcm_sess_t *session = audio_pcm_open(device);
    173161        if (!session) {
    174                 printf("Failed to connect to device.\n");
     162                printf("Failed to connect to device %s.\n", device);
    175163                return 1;
    176164        }
     165        printf("Playing on device: %s.\n", device);
    177166
    178167        const char* info = NULL;
  • uspace/app/wavplay/main.c

    rcd8f19d raef1799  
    4141#include <hound/client.h>
    4242#include <pcm/sample_format.h>
    43 
     43#include <getopt.h>
     44
     45#include "dplay.h"
    4446#include "wave.h"
    4547
     
    119121}
    120122
     123static const struct option opts[] = {
     124        {"device", required_argument, 0, 'd'},
     125        {"record", no_argument, 0, 'r'},
     126        {0, 0, 0, 0}
     127};
     128
     129
    121130int main(int argc, char *argv[])
    122131{
    123         if (argc != 2)
    124                 return 1;
    125         const char *file = argv[1];
     132        const char *device = "default";
     133        int idx = 0;
     134        bool direct = false, record = false;
     135        optind = 0;
     136        int ret = 0;
     137        while (ret != -1) {
     138                ret = getopt_long(argc, argv, "d:r", opts, &idx);
     139                switch (ret) {
     140                case 'd':
     141                        direct = true;
     142                        device = optarg;
     143                        break;
     144                case 'r':
     145                        record = true;
     146                        break;
     147                };
     148        }
     149
     150        if (optind == argc) {
     151                printf("Not enough arguments.\n");
     152                return 1;
     153        }
     154        const char *file = argv[optind];
     155
     156        printf("%s %s\n", record ? "Recording" : "Playing", file);
     157        if (record) {
     158                printf("Recording is not supported yet.\n");
     159                return 1;
     160        }
     161        if (direct)
     162                return dplay(device, file);
    126163
    127164        task_id_t tid = task_get_id();
     
    149186        pcm_sample_format_t format;
    150187        const char *error;
    151         const int ret = wav_parse_header(&header, NULL, NULL, &channels, &rate,
     188        ret = wav_parse_header(&header, NULL, NULL, &channels, &rate,
    152189            &format, &error);
    153190        if (ret != EOK) {
  • uspace/lib/pcm/src/format.c

    rcd8f19d raef1799  
    219219{
    220220        assert(f);
     221        assert(buffer);
    221222        if (channel >= f->channels)
    222223                return 0.0f;
     
    232233        /* This makes it positive */ \
    233234        sample -= (float)(type)low; \
    234         if (sample < 0.0f) { \
    235                 printf("SUB MIN failed\n"); \
    236         } \
    237235        /* This makes it <0,2> */ \
    238236        sample /= (((float)(type)high - (float)(type)low) / 2.0f); \
    239         if (sample > 2.0) { \
    240                 printf("DIV RANGE failed\n"); \
    241         } \
    242237        return sample - 1.0f; \
    243238} while (0)
Note: See TracChangeset for help on using the changeset viewer.