src/audio/arts/SDL_artsaudio.c
changeset 2141 e1a70460c354
parent 2121 85ed90a755fa
child 2155 31269eb74914
equal deleted inserted replaced
2140:15b4a74cdac1 2141:e1a70460c354
    55 static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
    55 static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
    56                                          arts_parameter_t param);
    56                                          arts_parameter_t param);
    57 static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer,
    57 static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer,
    58                                     int count);
    58                                     int count);
    59 static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s);
    59 static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s);
    60 static int (*SDL_NAME(arts_suspended))(void);
    60 static int (*SDL_NAME(arts_suspended)) (void);
    61 static const char *(*SDL_NAME(arts_error_text)) (int errorcode);
    61 static const char *(*SDL_NAME(arts_error_text)) (int errorcode);
    62 
    62 
    63 #define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
    63 #define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
    64 static struct
    64 static struct
    65 {
    65 {
    66     const char *name;
    66     const char *name;
    67     void **func;
    67     void **func;
    68 } arts_functions[] = {
    68 } arts_functions[] = {
    69 SDL_ARTS_SYM(arts_init),
    69 /* *INDENT-OFF* */
    70         SDL_ARTS_SYM(arts_free),
    70     SDL_ARTS_SYM(arts_init),
    71         SDL_ARTS_SYM(arts_play_stream),
    71     SDL_ARTS_SYM(arts_free),
    72         SDL_ARTS_SYM(arts_stream_set),
    72     SDL_ARTS_SYM(arts_play_stream),
    73         SDL_ARTS_SYM(arts_stream_get),
    73     SDL_ARTS_SYM(arts_stream_set),
    74         SDL_ARTS_SYM(arts_write),
    74     SDL_ARTS_SYM(arts_stream_get),
    75         SDL_ARTS_SYM(arts_close_stream),
    75     SDL_ARTS_SYM(arts_write),
    76         SDL_ARTS_SYM(arts_suspended),
    76     SDL_ARTS_SYM(arts_close_stream),
    77         SDL_ARTS_SYM(arts_error_text),
    77     SDL_ARTS_SYM(arts_suspended),
       
    78     SDL_ARTS_SYM(arts_error_text),
       
    79 /* *INDENT-ON* */
    78 };
    80 };
       
    81 
    79 #undef SDL_ARTS_SYM
    82 #undef SDL_ARTS_SYM
    80 
    83 
    81 static void
    84 static void
    82 UnloadARTSLibrary()
    85 UnloadARTSLibrary()
    83 {
    86 {
   261         SDL_SetError("Unable to initialize ARTS: %s",
   264         SDL_SetError("Unable to initialize ARTS: %s",
   262                      SDL_NAME(arts_error_text) (rc));
   265                      SDL_NAME(arts_error_text) (rc));
   263         return 0;
   266         return 0;
   264     }
   267     }
   265 
   268 
   266     if ( ! SDL_NAME(arts_suspended)() ) {
   269     if (!SDL_NAME(arts_suspended) ()) {
   267         ARTS_CloseDevice(this);
   270         ARTS_CloseDevice(this);
   268         SDL_SetError("ARTS can not open audio device");
   271         SDL_SetError("ARTS can not open audio device");
   269         return 0;
   272         return 0;
   270     }
   273     }
   271 
   274 
   337             SDL_SetError("ARTS: arts_init failed (no audio server?)");
   340             SDL_SetError("ARTS: arts_init failed (no audio server?)");
   338             return 0;
   341             return 0;
   339         }
   342         }
   340 
   343 
   341         /* Play a stream so aRts doesn't crash */
   344         /* Play a stream so aRts doesn't crash */
   342         if ( SDL_NAME(arts_suspended)() ) {
   345         if (SDL_NAME(arts_suspended) ()) {
   343             arts_stream_t stream;
   346             arts_stream_t stream;
   344             stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
   347             stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
   345             SDL_NAME(arts_write) (stream, "", 0);
   348             SDL_NAME(arts_write) (stream, "", 0);
   346             SDL_NAME(arts_close_stream) (stream);
   349             SDL_NAME(arts_close_stream) (stream);
   347         }
   350         }