PageRenderTime 70ms CodeModel.GetById 9ms app.highlight 55ms RepoModel.GetById 1ms app.codeStats 1ms

/media/libsydneyaudio/src/sydney_audio_sunaudio.c

http://github.com/zpao/v8monkey
C | 756 lines | 503 code | 94 blank | 159 comment | 118 complexity | 9b7ddb4e5748599672a7a523832b951d MD5 | raw file
  1/* ***** BEGIN LICENSE BLOCK *****
  2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3 *
  4 * The contents of this file are subject to the Mozilla Public License Version
  5 * 1.1 (the "License"); you may not use this file except in compliance with
  6 * the License. You may obtain a copy of the License at
  7 * http://www.mozilla.org/MPL/
  8 *
  9 * Software distributed under the License is distributed on an "AS IS" basis,
 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 11 * for the specific language governing rights and limitations under the
 12 * License.
 13 *
 14 * The Initial Developer of the Original Code is
 15 * Copyright (C) 2008 Sun Microsystems, Inc.,
 16 *                Brian Lu <brian.lu@sun.com>
 17 *
 18 * Contributor(s):
 19 *                Ginn Chen <ginn.chen@sun.com>
 20 *
 21 * Alternatively, the contents of this file may be used under the terms of
 22 * either the GNU General Public License Version 2 or later (the "GPL"), or
 23 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 24 * in which case the provisions of the GPL or the LGPL are applicable instead
 25 * of those above. If you wish to allow use of your version of this file only
 26 * under the terms of either the GPL or the LGPL, and not to allow others to
 27 * use your version of this file under the terms of the MPL, indicate your
 28 * decision by deleting the provisions above and replace them with the notice
 29 * and other provisions required by the GPL or the LGPL. If you do not delete
 30 * the provisions above, a recipient may use your version of this file under
 31 * the terms of any one of the MPL, the GPL or the LGPL.
 32 *
 33 * ***** END LICENSE BLOCK ***** *
 34 */
 35#include <errno.h>
 36#include <fcntl.h>
 37#include <pthread.h>
 38#include <stdbool.h>
 39#include <stdio.h>
 40#include <stdlib.h>
 41#include <string.h>
 42#include <stropts.h>
 43#include <unistd.h>
 44#include <sys/audio.h>
 45#include <sys/stat.h>
 46#include <sys/mixer.h>
 47#include "sydney_audio.h"
 48
 49/* Sun Audio implementation based heavily on sydney_audio_mac.c */
 50
 51#define DEFAULT_AUDIO_DEVICE "/dev/audio"
 52#define DEFAULT_DSP_DEVICE   "/dev/dsp"
 53
 54/* Macros copied from audio_oss.h */
 55/*
 56 * CDDL HEADER START
 57 *
 58 * The contents of this file are subject to the terms of the
 59 * Common Development and Distribution License (the "License").
 60 * You may not use this file except in compliance with the License.
 61 *
 62 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 63 * or http://www.opensolaris.org/os/licensing.
 64 * See the License for the specific language governing permissions
 65 * and limitations under the License.
 66 *
 67 * When distributing Covered Code, include this CDDL HEADER in each
 68 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 69 * If applicable, add the following below this CDDL HEADER, with the
 70 * fields enclosed by brackets "[]" replaced with your own identifying
 71 * information: Portions Copyright [yyyy] [name of copyright owner]
 72 *
 73 * CDDL HEADER END
 74 */
 75/*
 76 * Copyright (C) 4Front Technologies 1996-2008.
 77 *
 78 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 79 * Use is subject to license terms.
 80 */
 81#define OSSIOCPARM_MASK 0x1fff          /* parameters must be < 8192 bytes */
 82#define OSSIOC_VOID     0x00000000      /* no parameters */
 83#define OSSIOC_OUT      0x20000000      /* copy out parameters */
 84#define OSSIOC_IN       0x40000000      /* copy in parameters */
 85#define OSSIOC_INOUT    (OSSIOC_IN|OSSIOC_OUT)
 86#define OSSIOC_SZ(t)    ((sizeof (t) & OSSIOCPARM_MASK) << 16)
 87#define __OSSIO(x, y)           ((int)(OSSIOC_VOID|(x<<8)|y))
 88#define __OSSIOR(x, y, t)       ((int)(OSSIOC_OUT|OSSIOC_SZ(t)|(x<<8)|y))
 89#define __OSSIOWR(x, y, t)      ((int)(OSSIOC_INOUT|OSSIOC_SZ(t)|(x<<8)|y))
 90#define SNDCTL_DSP_SPEED        __OSSIOWR('P', 2, int)
 91#define SNDCTL_DSP_CHANNELS     __OSSIOWR('P', 6, int)
 92#define SNDCTL_DSP_SETFMT       __OSSIOWR('P', 5, int)  /* Selects ONE fmt */
 93#define SNDCTL_DSP_GETPLAYVOL   __OSSIOR('P', 24, int)
 94#define SNDCTL_DSP_SETPLAYVOL   __OSSIOWR('P', 24, int)
 95#define SNDCTL_DSP_HALT_OUTPUT  __OSSIO('P', 34)
 96#define AFMT_S16_LE     0x00000010
 97#define AFMT_S16_BE     0x00000020
 98#ifdef SA_LITTLE_ENDIAN
 99#define AFMT_S16_NE    AFMT_S16_LE
100#else
101#define AFMT_S16_NE    AFMT_S16_BE
102#endif
103
104typedef struct sa_buf sa_buf;
105struct sa_buf {
106  unsigned int      size;
107  unsigned int      start;
108  unsigned int      end;
109  sa_buf          * next;
110  unsigned char     data[];
111};
112
113struct sa_stream {
114  bool              using_oss;
115  int               output_fd;
116  pthread_t         thread_id;
117  pthread_mutex_t   mutex;
118  bool              playing;
119  int64_t           bytes_played;
120
121  /* audio format info */
122  unsigned int      rate;
123  unsigned int      n_channels;
124  unsigned int      bytes_per_ch;
125
126  /* buffer list */
127  sa_buf          * bl_head;
128  sa_buf          * bl_tail;
129  int               n_bufs;
130};
131
132/* Use a default buffer size with enough room for one second of audio,
133 * assuming stereo data at 44.1kHz with 32 bits per channel, and impose
134 * a generous limit on the number of buffers.
135 */
136#define BUF_SIZE    (2 * 44100 * 4)
137#define BUF_LIMIT   5
138
139#if BUF_LIMIT < 2
140#error BUF_LIMIT must be at least 2!
141#endif
142
143static void *audio_callback(void *s);
144static sa_buf *new_buffer(void);
145static int shutdown_device(sa_stream_t *s);
146
147/*
148 * -----------------------------------------------------------------------------
149 * Startup and shutdown functions
150 * -----------------------------------------------------------------------------
151 */
152
153int
154sa_stream_create_pcm(
155  sa_stream_t      ** _s,
156  const char        * client_name,
157  sa_mode_t           mode,
158  sa_pcm_format_t     format,
159  unsigned  int       rate,
160  unsigned  int       n_channels
161) {
162  /*
163   * Make sure we return a NULL stream pointer on failure.
164   */
165  if (_s == NULL) {
166    return SA_ERROR_INVALID;
167  }
168  *_s = NULL;
169
170  if (mode != SA_MODE_WRONLY) {
171    return SA_ERROR_NOT_SUPPORTED;
172  }
173  if (format != SA_PCM_FORMAT_S16_NE) {
174    return SA_ERROR_NOT_SUPPORTED;
175  }
176
177  /*
178   * Allocate the instance and required resources.
179   */
180  sa_stream_t *s;
181  if ((s = malloc(sizeof(sa_stream_t))) == NULL) {
182    return SA_ERROR_OOM;
183  }
184  if ((s->bl_head = new_buffer()) == NULL) {
185    free(s);
186    return SA_ERROR_SYSTEM;
187  }
188  if (pthread_mutex_init(&s->mutex, NULL) != 0) {
189    free(s->bl_head);
190    free(s);
191    return SA_ERROR_SYSTEM;
192  }
193
194  s->output_fd          = -1;
195  s->playing            = false;
196  s->bytes_played       = 0;
197  s->rate               = rate;
198  s->n_channels         = n_channels;
199  s->bytes_per_ch       = 2;
200  s->bl_tail            = s->bl_head;
201  s->n_bufs             = 1;
202
203  *_s = s;
204  return SA_SUCCESS;
205}
206
207int
208sa_stream_open(sa_stream_t *s) {
209  if (s == NULL) {
210    return SA_ERROR_NO_INIT;
211  }
212  if (s->output_fd != -1) {
213    return SA_ERROR_INVALID;
214  }
215
216  /*
217   * Open the default audio output unit.
218   */
219
220  /* If UTAUDIODEV is set, use it with Sun Audio interface */
221  char * sa_device_name = getenv("UTAUDIODEV");
222  char * dsp_device_name = NULL;
223  if (!sa_device_name) {
224    dsp_device_name = getenv("AUDIODSP");
225    if (!dsp_device_name) {
226      dsp_device_name = DEFAULT_DSP_DEVICE;
227    }
228    sa_device_name = getenv("AUDIODEV");
229    if (!sa_device_name) {
230      sa_device_name = DEFAULT_AUDIO_DEVICE;
231    }
232  }
233
234  int fd = -1;
235  s->using_oss = false;
236  /* Try to use OSS if available */
237  if (dsp_device_name) {
238    fd = open(dsp_device_name, O_WRONLY | O_NONBLOCK);
239    if (fd >= 0) {
240      s->using_oss = true;
241    }
242  }
243
244  /* Try Sun Audio */
245  if (!s->using_oss) {
246    fd = open(sa_device_name, O_WRONLY | O_NONBLOCK);
247  }
248
249  if (fd < 0)
250  {
251    printf("Open %s failed:%s.\n", sa_device_name, strerror(errno));
252    return SA_ERROR_NO_DEVICE;
253  }
254
255  if (s->using_oss) {
256    /* set the playback rate */
257    if (ioctl(fd, SNDCTL_DSP_SPEED, &(s->rate)) < 0) {
258      close(fd);
259      return SA_ERROR_NOT_SUPPORTED;
260    }
261
262    /* set the channel numbers */
263    if (ioctl(fd, SNDCTL_DSP_CHANNELS, &(s->n_channels)) < 0) {
264      close(fd);
265      return SA_ERROR_NOT_SUPPORTED;
266    }
267
268    int format = AFMT_S16_NE;
269    if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0)  {
270      close(fd);
271      return SA_ERROR_NOT_SUPPORTED;
272    }
273
274    s->output_fd = fd;
275    return SA_SUCCESS;
276  }
277
278  audio_info_t audio_info;
279  AUDIO_INITINFO(&audio_info)
280  audio_info.play.sample_rate = s->rate;
281  audio_info.play.channels    = s->n_channels;
282  audio_info.play.precision   = s->bytes_per_ch * 8;
283
284  /* Signed Linear PCM encoding */
285  audio_info.play.encoding = AUDIO_ENCODING_LINEAR;
286
287  if (ioctl(fd, AUDIO_SETINFO, &audio_info) == -1) {
288    printf("ioctl AUDIO_SETINFO failed.\n");
289    close(fd);
290    return SA_ERROR_NOT_SUPPORTED;
291  }
292
293  s->output_fd = fd;
294  return SA_SUCCESS;
295}
296
297int
298sa_stream_destroy(sa_stream_t *s) {
299  if (s == NULL) {
300    return SA_SUCCESS;
301  }
302
303  /*
304   * Join the thread.
305   */
306  bool thread_created = false;
307  pthread_mutex_lock(&s->mutex);
308  if (s->playing) {
309    thread_created = true;
310    s->playing = false;
311  }
312  pthread_mutex_unlock(&s->mutex);
313  if (thread_created) {
314    pthread_join(s->thread_id, NULL);
315  }
316
317  int result = SA_SUCCESS;
318
319
320  /*
321   * Shutdown the audio output device.
322   */
323  result = shutdown_device(s);
324
325  /*
326   * Release resouces.
327   */
328  if (pthread_mutex_destroy(&s->mutex) != 0) {
329    result = SA_ERROR_SYSTEM;
330  }
331  while (s->bl_head != NULL) {
332    sa_buf * next = s->bl_head->next;
333    free(s->bl_head);
334    s->bl_head = next;
335  }
336  free(s);
337
338  return result;
339}
340
341/*
342 * -----------------------------------------------------------------------------
343 * Data read and write functions
344 * -----------------------------------------------------------------------------
345 */
346
347int
348sa_stream_write(sa_stream_t *s, const void *data, size_t nbytes) {
349  if (s == NULL || s->output_fd == -1) {
350    return SA_ERROR_NO_INIT;
351  }
352  if (nbytes == 0) {
353    return SA_SUCCESS;
354  }
355
356  pthread_mutex_lock(&s->mutex);
357
358  /*
359   * Append the new data to the end of our buffer list.
360   */
361  int result = SA_SUCCESS;
362  while (1) {
363    unsigned int avail = s->bl_tail->size - s->bl_tail->end;
364
365    if (nbytes <= avail) {
366      /*
367       * The new data will fit into the current tail buffer, so
368       * just copy it in and we're done.
369       */
370      memcpy(s->bl_tail->data + s->bl_tail->end, data, nbytes);
371      s->bl_tail->end += nbytes;
372      break;
373
374    } else {
375      /*
376       * Copy what we can into the tail and allocate a new buffer
377       * for the rest.
378       */
379      memcpy(s->bl_tail->data + s->bl_tail->end, data, avail);
380      s->bl_tail->end += avail;
381      data = ((unsigned char *)data) + avail;
382      nbytes -= avail;
383
384      /*
385       * If we still have data left to copy but we've hit the limit of
386       * allowable buffer allocations, we need to spin for a bit to allow
387       * the audio callback function to slurp some more data up.
388       */
389      if (nbytes > 0 && s->n_bufs == BUF_LIMIT) {
390#ifdef TIMING_TRACE
391        printf("#");  /* too much audio data */
392#endif
393        if (!s->playing) {
394          /*
395           * We haven't even started playing yet! That means the
396           * BUF_SIZE/BUF_LIMIT values are too low... Not much we can
397           * do here; spinning won't help because the audio callback
398           * hasn't been enabled yet. Oh well, error time.
399           */
400          printf("Too much audio data received before audio device enabled!\n");
401          result = SA_ERROR_SYSTEM;
402          break;
403        }
404        while (s->n_bufs == BUF_LIMIT) {
405          pthread_mutex_unlock(&s->mutex);
406          struct timespec ts = {0, 1000000};
407          nanosleep(&ts, NULL);
408          pthread_mutex_lock(&s->mutex);
409        }
410      }
411
412      /*
413       * Allocate a new tail buffer, and go 'round again to fill it up.
414       */
415      if ((s->bl_tail->next = new_buffer()) == NULL) {
416        result = SA_ERROR_OOM;
417        break;
418      }
419      s->n_bufs++;
420      s->bl_tail = s->bl_tail->next;
421
422    } /* if (nbytes <= avail), else */
423
424  } /* while (1) */
425
426  /*
427   * Once we have our first block of audio data, enable the audio callback
428   * function.
429   */
430  if (!s->playing) {
431    s->playing = true;
432    if (pthread_create(&s->thread_id, NULL, audio_callback, s) != 0) {
433      result = SA_ERROR_SYSTEM;
434    }
435  }
436
437  pthread_mutex_unlock(&s->mutex);
438
439  return result;
440}
441
442static void *
443audio_callback(void *data) {
444  sa_stream_t *s = data;
445
446  pthread_mutex_lock(&s->mutex);
447  while (s->playing) {
448    /*
449     * Consume data from the start of the buffer list.
450     */
451    while (s->output_fd != -1) {
452      unsigned int avail = s->bl_head->end - s->bl_head->start;
453      if (avail > 0) {
454        int written = write(s->output_fd, s->bl_head->data + s->bl_head->start, avail);
455        if (written == -1) {
456          break; /* Try again later. */
457        }
458        s->bl_head->start += written;
459        s->bytes_played += written;
460        if (written < avail) {
461          break;
462        }
463      }
464
465      sa_buf  * next = s->bl_head->next;
466      if (next == NULL) {
467#ifdef TIMING_TRACE
468        printf("!");  /* not enough audio data */
469#endif
470        break;
471      }
472      free(s->bl_head);
473      s->bl_head = next;
474      s->n_bufs--;
475    } /* while (s->output_fd != -1) */
476    pthread_mutex_unlock(&s->mutex);
477    struct timespec ts = {0, 1000000};
478    nanosleep(&ts, NULL);
479    pthread_mutex_lock(&s->mutex);
480  } /* s->playing */
481  pthread_mutex_unlock(&s->mutex);
482  return NULL;
483}
484
485/*
486 * -----------------------------------------------------------------------------
487 * General query and support functions
488 * -----------------------------------------------------------------------------
489 */
490
491int
492sa_stream_get_write_size(sa_stream_t *s, size_t *size) {
493  if (s == NULL || s->output_fd == -1) {
494    return SA_ERROR_NO_INIT;
495  }
496
497  pthread_mutex_lock(&s->mutex);
498
499  /*
500   * The sum of the free space in the tail buffer plus the size of any new
501   * buffers represents the write space available before blocking.
502   */
503
504  unsigned int avail = s->bl_tail->size - s->bl_tail->end;
505  avail += (BUF_LIMIT - s->n_bufs) * BUF_SIZE;
506  *size = avail;
507
508  pthread_mutex_unlock(&s->mutex);
509  return SA_SUCCESS;
510}
511
512/* ---------------------------------------------------------------------------
513 * General query and support functions
514 * -----------------------------------------------------------------------------
515 */
516
517int
518sa_stream_get_position(sa_stream_t *s, sa_position_t position, int64_t *pos) {
519  if (s == NULL || s->output_fd == -1) {
520    return SA_ERROR_NO_INIT;
521  }
522  if (position != SA_POSITION_WRITE_SOFTWARE) {
523    return SA_ERROR_NOT_SUPPORTED;
524  }
525
526  pthread_mutex_lock(&s->mutex);
527  *pos = s->bytes_played;
528  pthread_mutex_unlock(&s->mutex);
529  return SA_SUCCESS;
530}
531
532int
533sa_stream_drain(sa_stream_t *s) {
534  if (s == NULL || s->output_fd == -1) {
535    return SA_ERROR_NO_INIT;
536  }
537
538  while (1) {
539    pthread_mutex_lock(&s->mutex);
540    sa_buf  * b;
541    size_t    used = 0;
542    for (b = s->bl_head; b != NULL; b = b->next) {
543      used += b->end - b->start;
544    }
545    pthread_mutex_unlock(&s->mutex);
546
547    if (used == 0) {
548      break;
549    }
550
551    struct timespec ts = {0, 1000000};
552    nanosleep(&ts, NULL);
553  }
554  return SA_SUCCESS;
555}
556
557int
558sa_stream_pause(sa_stream_t *s) {
559  if (s == NULL || s->output_fd == -1) {
560    return SA_ERROR_NO_INIT;
561  }
562
563  pthread_mutex_lock(&s->mutex);
564  int result = shutdown_device(s);
565  if (result == SA_SUCCESS) {
566    s->output_fd = -1;
567  }
568  pthread_mutex_unlock(&s->mutex);
569
570  return result;
571}
572
573
574int
575sa_stream_resume(sa_stream_t *s) {
576  if (s == NULL) {
577    return SA_ERROR_NO_INIT;
578  }
579
580  pthread_mutex_lock(&s->mutex);
581  int result = sa_stream_open(s);
582  pthread_mutex_unlock(&s->mutex);
583
584  return result;
585}
586
587static sa_buf *
588new_buffer(void) {
589  sa_buf  * b = malloc(sizeof(sa_buf) + BUF_SIZE);
590  if (b != NULL) {
591    b->size  = BUF_SIZE;
592    b->start = 0;
593    b->end   = 0;
594    b->next  = NULL;
595  }
596  return b;
597}
598
599static int
600shutdown_device(sa_stream_t *s) {
601  if (s->output_fd != -1)
602  {
603    /* Flush buffer. */
604    if (s->using_oss) {
605      ioctl(s->output_fd, SNDCTL_DSP_HALT_OUTPUT);
606    } else {
607      ioctl(s->output_fd, I_FLUSH);
608    }
609
610    if (close(s->output_fd) < 0)
611    {
612      return SA_ERROR_SYSTEM;
613    }
614  }
615  return SA_SUCCESS;
616}
617
618/*
619 * -----------------------------------------------------------------------------
620 * Extension functions
621 * -----------------------------------------------------------------------------
622 */
623
624int
625sa_stream_set_volume_abs(sa_stream_t *s, float vol) {
626  if (s == NULL || s->output_fd == -1) {
627    return SA_ERROR_NO_INIT;
628  }
629
630  if (s->using_oss) {
631    int mvol = ((int)(100 * vol)) | ((int)(100 * vol) << 8);
632    if (ioctl(s->output_fd, SNDCTL_DSP_SETPLAYVOL, &mvol) < 0) {
633      return SA_ERROR_SYSTEM;
634    }
635    return SA_SUCCESS;
636  }
637
638  unsigned int newVolume = (AUDIO_MAX_GAIN - AUDIO_MIN_GAIN) * vol + AUDIO_MIN_GAIN;
639
640  /* Check if the new volume is valid or not */
641  if ( newVolume < AUDIO_MIN_GAIN || newVolume > AUDIO_MAX_GAIN )
642    return SA_ERROR_INVALID;
643
644  pthread_mutex_lock(&s->mutex);
645  audio_info_t audio_info;
646  AUDIO_INITINFO(&audio_info);
647  audio_info.play.gain = newVolume;
648  int err = ioctl(s->output_fd, AUDIO_SETINFO, &audio_info);
649  pthread_mutex_unlock(&s->mutex);
650
651  if (err == -1)
652  {
653    perror("sa_stream_set_volume_abs failed\n");
654    return SA_ERROR_SYSTEM;
655  }
656
657  return SA_SUCCESS;
658}
659
660int
661sa_stream_get_volume_abs(sa_stream_t *s, float *vol) {
662  if (s == NULL || s->output_fd == -1) {
663    return SA_ERROR_NO_INIT;
664  }
665
666  if (s->using_oss) {
667    int mvol;
668    if (ioctl(s->output_fd, SNDCTL_DSP_GETPLAYVOL, &mvol) < 0){
669      return SA_ERROR_SYSTEM;
670    }
671    *vol = ((mvol & 0xFF) + (mvol >> 8)) / 200.0f;
672    return SA_SUCCESS;
673  }
674
675  pthread_mutex_lock(&s->mutex);
676  audio_info_t audio_info;
677  AUDIO_INITINFO(&audio_info);
678  int err = ioctl(s->output_fd, AUDIO_GETINFO, &audio_info);
679  pthread_mutex_unlock(&s->mutex);
680
681  if (err == -1)
682  {
683    perror("sa_stream_get_volume_abs failed\n");
684    return SA_ERROR_SYSTEM;
685  }
686
687  *vol =  (float)((audio_info.play.gain - AUDIO_MIN_GAIN))/(AUDIO_MAX_GAIN - AUDIO_MIN_GAIN);
688
689  return SA_SUCCESS;
690}
691
692/*
693 * -----------------------------------------------------------------------------
694 * Unsupported functions
695 * -----------------------------------------------------------------------------
696 */
697#define UNSUPPORTED(func)   func { return SA_ERROR_NOT_SUPPORTED; }
698
699UNSUPPORTED(int sa_stream_create_opaque(sa_stream_t **s, const char *client_name, sa_mode_t mode, const char *codec))
700UNSUPPORTED(int sa_stream_set_write_lower_watermark(sa_stream_t *s, size_t size))
701UNSUPPORTED(int sa_stream_set_read_lower_watermark(sa_stream_t *s, size_t size))
702UNSUPPORTED(int sa_stream_set_write_upper_watermark(sa_stream_t *s, size_t size))
703UNSUPPORTED(int sa_stream_set_read_upper_watermark(sa_stream_t *s, size_t size))
704UNSUPPORTED(int sa_stream_set_channel_map(sa_stream_t *s, const sa_channel_t map[], unsigned int n))
705UNSUPPORTED(int sa_stream_set_xrun_mode(sa_stream_t *s, sa_xrun_mode_t mode))
706UNSUPPORTED(int sa_stream_set_non_interleaved(sa_stream_t *s, int enable))
707UNSUPPORTED(int sa_stream_set_dynamic_rate(sa_stream_t *s, int enable))
708UNSUPPORTED(int sa_stream_set_driver(sa_stream_t *s, const char *driver))
709UNSUPPORTED(int sa_stream_start_thread(sa_stream_t *s, sa_event_callback_t callback))
710UNSUPPORTED(int sa_stream_stop_thread(sa_stream_t *s))
711UNSUPPORTED(int sa_stream_change_device(sa_stream_t *s, const char *device_name))
712UNSUPPORTED(int sa_stream_change_read_volume(sa_stream_t *s, const int32_t vol[], unsigned int n))
713UNSUPPORTED(int sa_stream_change_write_volume(sa_stream_t *s, const int32_t vol[], unsigned int n))
714UNSUPPORTED(int sa_stream_change_rate(sa_stream_t *s, unsigned int rate))
715UNSUPPORTED(int sa_stream_change_meta_data(sa_stream_t *s, const char *name, const void *data, size_t size))
716UNSUPPORTED(int sa_stream_change_user_data(sa_stream_t *s, const void *value))
717UNSUPPORTED(int sa_stream_set_adjust_rate(sa_stream_t *s, sa_adjust_t direction))
718UNSUPPORTED(int sa_stream_set_adjust_nchannels(sa_stream_t *s, sa_adjust_t direction))
719UNSUPPORTED(int sa_stream_set_adjust_pcm_format(sa_stream_t *s, sa_adjust_t direction))
720UNSUPPORTED(int sa_stream_set_adjust_watermarks(sa_stream_t *s, sa_adjust_t direction))
721UNSUPPORTED(int sa_stream_get_mode(sa_stream_t *s, sa_mode_t *access_mode))
722UNSUPPORTED(int sa_stream_get_codec(sa_stream_t *s, char *codec, size_t *size))
723UNSUPPORTED(int sa_stream_get_pcm_format(sa_stream_t *s, sa_pcm_format_t *format))
724UNSUPPORTED(int sa_stream_get_rate(sa_stream_t *s, unsigned int *rate))
725UNSUPPORTED(int sa_stream_get_nchannels(sa_stream_t *s, int *nchannels))
726UNSUPPORTED(int sa_stream_get_user_data(sa_stream_t *s, void **value))
727UNSUPPORTED(int sa_stream_get_write_lower_watermark(sa_stream_t *s, size_t *size))
728UNSUPPORTED(int sa_stream_get_read_lower_watermark(sa_stream_t *s, size_t *size))
729UNSUPPORTED(int sa_stream_get_write_upper_watermark(sa_stream_t *s, size_t *size))
730UNSUPPORTED(int sa_stream_get_read_upper_watermark(sa_stream_t *s, size_t *size))
731UNSUPPORTED(int sa_stream_get_channel_map(sa_stream_t *s, sa_channel_t map[], unsigned int *n))
732UNSUPPORTED(int sa_stream_get_xrun_mode(sa_stream_t *s, sa_xrun_mode_t *mode))
733UNSUPPORTED(int sa_stream_get_non_interleaved(sa_stream_t *s, int *enabled))
734UNSUPPORTED(int sa_stream_get_dynamic_rate(sa_stream_t *s, int *enabled))
735UNSUPPORTED(int sa_stream_get_driver(sa_stream_t *s, char *driver_name, size_t *size))
736UNSUPPORTED(int sa_stream_get_device(sa_stream_t *s, char *device_name, size_t *size))
737UNSUPPORTED(int sa_stream_get_read_volume(sa_stream_t *s, int32_t vol[], unsigned int *n))
738UNSUPPORTED(int sa_stream_get_write_volume(sa_stream_t *s, int32_t vol[], unsigned int *n))
739UNSUPPORTED(int sa_stream_get_meta_data(sa_stream_t *s, const char *name, void*data, size_t *size))
740UNSUPPORTED(int sa_stream_get_adjust_rate(sa_stream_t *s, sa_adjust_t *direction))
741UNSUPPORTED(int sa_stream_get_adjust_nchannels(sa_stream_t *s, sa_adjust_t *direction))
742UNSUPPORTED(int sa_stream_get_adjust_pcm_format(sa_stream_t *s, sa_adjust_t *direction))
743UNSUPPORTED(int sa_stream_get_adjust_watermarks(sa_stream_t *s, sa_adjust_t *direction))
744UNSUPPORTED(int sa_stream_get_state(sa_stream_t *s, sa_state_t *state))
745UNSUPPORTED(int sa_stream_get_event_error(sa_stream_t *s, sa_error_t *error))
746UNSUPPORTED(int sa_stream_get_event_notify(sa_stream_t *s, sa_notify_t *notify))
747UNSUPPORTED(int sa_stream_read(sa_stream_t *s, void *data, size_t nbytes))
748UNSUPPORTED(int sa_stream_read_ni(sa_stream_t *s, unsigned int channel, void *data, size_t nbytes))
749UNSUPPORTED(int sa_stream_write_ni(sa_stream_t *s, unsigned int channel, const void *data, size_t nbytes))
750UNSUPPORTED(int sa_stream_pwrite(sa_stream_t *s, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence))
751UNSUPPORTED(int sa_stream_pwrite_ni(sa_stream_t *s, unsigned int channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence))
752UNSUPPORTED(int sa_stream_get_read_size(sa_stream_t *s, size_t *size))
753UNSUPPORTED(int sa_stream_get_min_write(sa_stream_t *s, size_t *size))
754
755const char *sa_strerror(int code) { return NULL; }
756