src/audio/nds/SDL_ndsaudio.c
author Sam Lantinga
Sat, 06 Oct 2012 11:23:47 -0700
changeset 6565 1f3c0df426dc
parent 6138 4c64952a58fb
child 6885 700f1b25f77f
permissions -rw-r--r--
When using Xinerama, XVidMode always works on screen 0. Otherwise use the real X11 screen.
slouken@2735
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@2735
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2735
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2735
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2735
    20
*/
slouken@2735
    21
#include "SDL_config.h"
slouken@2735
    22
slouken@6044
    23
#if SDL_AUDIO_DRIVER_NDS
slouken@6044
    24
slouken@2735
    25
/* Output audio to NDS */
slouken@2735
    26
slouken@2735
    27
#include <nds.h>
slouken@2735
    28
slouken@2735
    29
#include "SDL_audio.h"
slouken@2735
    30
#include "../SDL_audio_c.h"
slouken@2735
    31
#include "SDL_ndsaudio.h"
slouken@2735
    32
slouken@2735
    33
static int
slouken@2735
    34
NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture)
slouken@2735
    35
{
slouken@2735
    36
    SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
slouken@2735
    37
    int valid_datatype = 0;
slouken@2735
    38
slouken@2735
    39
    this->hidden = SDL_malloc(sizeof(*(this->hidden)));
slouken@2735
    40
    if (!this->hidden) {
slouken@2735
    41
        SDL_OutOfMemory();
slouken@2735
    42
        return 0;
slouken@2735
    43
    }
slouken@2735
    44
    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
slouken@2735
    45
slouken@2735
    46
    while ((!valid_datatype) && (test_format)) {
slouken@2735
    47
        this->spec.format = test_format;
slouken@2735
    48
        switch (test_format) {
slouken@2735
    49
        case AUDIO_S8:
slouken@2735
    50
            /*case AUDIO_S16LSB: */
slouken@2735
    51
            valid_datatype = 1;
slouken@2735
    52
            break;
slouken@2735
    53
        default:
slouken@2735
    54
            test_format = SDL_NextAudioFormat();
slouken@2735
    55
            break;
slouken@2735
    56
        }
slouken@2735
    57
    }
slouken@2735
    58
slouken@5270
    59
#if 0
slouken@2735
    60
    /* set the generic sound parameters */
slouken@2735
    61
    setGenericSound(22050,      /* sample rate */
slouken@2735
    62
                    127,        /* volume */
slouken@2735
    63
                    64,         /* panning/balance */
slouken@2735
    64
                    0);         /* sound format */
slouken@5270
    65
#endif
slouken@2735
    66
slouken@2735
    67
    return 1;
slouken@2735
    68
}
slouken@2735
    69
slouken@2735
    70
static void
slouken@2735
    71
NDSAUD_PlayDevice(_THIS)
slouken@2735
    72
{
slouken@5270
    73
#if 0
slouken@5270
    74
    playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
slouken@2735
    75
slouken@2735
    76
//    sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
slouken@2735
    77
//    sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
slouken@2735
    78
//    sound->rate = 22050; /* sample rate = 22050Hz */
slouken@2735
    79
//    sound->vol = 127;    /* volume [0..127] for [min..max] */
slouken@2735
    80
//    sound->pan = 64;     /* balance [0..127] for [left..right] */
slouken@2735
    81
//    sound->format = 0;   /* 0 for 16-bit, 1 for 8-bit */
slouken@2735
    82
//    playSound(sound);
slouken@2735
    83
#endif
slouken@2735
    84
}
slouken@2735
    85
slouken@2735
    86
slouken@2735
    87
static Uint8 *
slouken@2735
    88
NDSAUD_GetDeviceBuf(_THIS)
slouken@2735
    89
{
slouken@2735
    90
    return this->hidden->mixbuf;        /* is this right? */
slouken@2735
    91
}
slouken@2735
    92
slouken@2735
    93
static void
slouken@2735
    94
NDSAUD_WaitDevice(_THIS)
slouken@2735
    95
{
slouken@2735
    96
    /* stub */
slouken@2735
    97
}
slouken@2735
    98
slouken@2735
    99
static void
slouken@2735
   100
NDSAUD_CloseDevice(_THIS)
slouken@2735
   101
{
slouken@2735
   102
    /* stub */
slouken@2735
   103
}
slouken@2735
   104
slouken@2735
   105
static int
slouken@2735
   106
NDSAUD_Init(SDL_AudioDriverImpl * impl)
slouken@2735
   107
{
slouken@2735
   108
    /* Set the function pointers */
slouken@2735
   109
    impl->OpenDevice = NDSAUD_OpenDevice;
slouken@2735
   110
    impl->PlayDevice = NDSAUD_PlayDevice;
slouken@2735
   111
    impl->WaitDevice = NDSAUD_WaitDevice;
slouken@2735
   112
    impl->GetDeviceBuf = NDSAUD_GetDeviceBuf;
slouken@2735
   113
    impl->CloseDevice = NDSAUD_CloseDevice;
slouken@2735
   114
slouken@2735
   115
    /* and the capabilities */
slouken@2735
   116
    impl->HasCaptureSupport = 1;
slouken@2735
   117
    impl->OnlyHasDefaultOutputDevice = 1;
slouken@2735
   118
    impl->OnlyHasDefaultInputDevice = 1;
slouken@2735
   119
icculus@3699
   120
    return 1;   /* this audio target is available. */
slouken@2735
   121
}
slouken@2735
   122
slouken@2735
   123
AudioBootStrap NDSAUD_bootstrap = {
slouken@2735
   124
    "nds", "SDL NDS audio driver", NDSAUD_Init, 0       /*1? */
slouken@2735
   125
};
slouken@2735
   126
slouken@6044
   127
#endif /* SDL_AUDIO_DRIVER_NDS */
slouken@6044
   128
slouken@2735
   129
/* vi: set ts=4 sw=4 expandtab: */