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