components/desktop/thunderbird/patches/firefox-19-cubeb.patch
changeset 6431 e4667e7df088
equal deleted inserted replaced
6430:74bc7531ae5a 6431:e4667e7df088
       
     1 For SunAudio audio playback. We need to investigate whether we care about
       
     2 this or whether we are just going to support PulseAudio.
       
     3 
       
     4 diff --git a/media/libcubeb/src/cubeb.c b/media/libcubeb/src/cubeb.c
       
     5 --- a/media/libcubeb/src/cubeb.c
       
     6 +++ b/media/libcubeb/src/cubeb.c
       
     7 @@ -56,6 +56,9 @@
       
     8  #if defined(USE_AUDIOTRACK)
       
     9  int audiotrack_init(cubeb ** context, char const * context_name);
       
    10  #endif
       
    11 +#if defined(USE_SUN)
       
    12 +int sunaudio_init(cubeb ** context, char const * context_name);
       
    13 +#endif
       
    14  
       
    15  int
       
    16  validate_stream_params(cubeb_stream_params stream_params)
       
    17 @@ -122,6 +125,9 @@
       
    18  #if defined(USE_AUDIOTRACK)
       
    19      audiotrack_init,
       
    20  #endif
       
    21 +#if defined(USE_SUN)
       
    22 +    sunaudio_init,
       
    23 +#endif
       
    24    };
       
    25    int i;
       
    26  
       
    27 diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build
       
    28 --- a/media/libcubeb/src/moz.build
       
    29 +++ b/media/libcubeb/src/moz.build
       
    30 @@ -31,6 +31,12 @@
       
    31      ]
       
    32      DEFINES['USE_SNDIO'] = True
       
    33  
       
    34 +if CONFIG['OS_ARCH'] == 'SunOS':
       
    35 +    SOURCES += [
       
    36 +        'cubeb_sun.c',
       
    37 +    ]
       
    38 +    DEFINES['USE_SUN'] = True
       
    39 +
       
    40  if CONFIG['OS_TARGET'] == 'Darwin':
       
    41      SOURCES += [
       
    42          'cubeb_audiounit.c',
       
    43 diff --git a/media/libcubeb/src/cubeb_sun.c b/media/libcubeb/src/cubeb_sun.c
       
    44 new file mode 100644
       
    45 --- /dev/null
       
    46 +++ b/media/libcubeb/src/cubeb_sun.c
       
    47 @@ -0,0 +1,500 @@
       
    48 +/*
       
    49 + * Copyright (c) 2013 Ginn Chen <[email protected]>
       
    50 + *
       
    51 + * This program is made available under an ISC-style license.  See the
       
    52 + * accompanying file LICENSE for details.
       
    53 + */
       
    54 +#include <poll.h>
       
    55 +#include <pthread.h>
       
    56 +#include <stdlib.h>
       
    57 +#include <stdio.h>
       
    58 +#include <errno.h>
       
    59 +#include <fcntl.h>
       
    60 +#include <sys/audio.h>
       
    61 +#include <sys/stat.h>
       
    62 +#include <unistd.h>
       
    63 +#include <sys/stropts.h>
       
    64 +#include "cubeb/cubeb.h"
       
    65 +#include "cubeb-internal.h"
       
    66 +
       
    67 +/* Macros copied from audio_oss.h */
       
    68 +/*
       
    69 + * CDDL HEADER START
       
    70 + *
       
    71 + * The contents of this file are subject to the terms of the
       
    72 + * Common Development and Distribution License (the "License").
       
    73 + * You may not use this file except in compliance with the License.
       
    74 + *
       
    75 + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
    76 + * or http://www.opensolaris.org/os/licensing.
       
    77 + * See the License for the specific language governing permissions
       
    78 + * and limitations under the License.
       
    79 + *
       
    80 + * When distributing Covered Code, include this CDDL HEADER in each
       
    81 + * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    82 + * If applicable, add the following below this CDDL HEADER, with the
       
    83 + * fields enclosed by brackets "[]" replaced with your own identifying
       
    84 + * information: Portions Copyright [yyyy] [name of copyright owner]
       
    85 + *
       
    86 + * CDDL HEADER END
       
    87 + */
       
    88 +/*
       
    89 + * Copyright (C) 4Front Technologies 1996-2008.
       
    90 + *
       
    91 + * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
       
    92 + * Use is subject to license terms.
       
    93 + */
       
    94 +#define OSSIOCPARM_MASK 0x1fff          /* parameters must be < 8192 bytes */
       
    95 +#define OSSIOC_VOID     0x00000000      /* no parameters */
       
    96 +#define OSSIOC_OUT      0x20000000      /* copy out parameters */
       
    97 +#define OSSIOC_IN       0x40000000      /* copy in parameters */
       
    98 +#define OSSIOC_INOUT    (OSSIOC_IN|OSSIOC_OUT)
       
    99 +#define OSSIOC_SZ(t)    ((sizeof (t) & OSSIOCPARM_MASK) << 16)
       
   100 +#define __OSSIO(x, y)           ((int)(OSSIOC_VOID|(x<<8)|y))
       
   101 +#define __OSSIOR(x, y, t)       ((int)(OSSIOC_OUT|OSSIOC_SZ(t)|(x<<8)|y))
       
   102 +#define __OSSIOWR(x, y, t)      ((int)(OSSIOC_INOUT|OSSIOC_SZ(t)|(x<<8)|y))
       
   103 +#define SNDCTL_DSP_SPEED        __OSSIOWR('P', 2, int)
       
   104 +#define SNDCTL_DSP_CHANNELS     __OSSIOWR('P', 6, int)
       
   105 +#define SNDCTL_DSP_SETFMT       __OSSIOWR('P', 5, int)  /* Selects ONE fmt */
       
   106 +#define SNDCTL_DSP_GETODELAY    __OSSIOR('P', 23, int)
       
   107 +#define SNDCTL_DSP_HALT_OUTPUT  __OSSIO('P', 34)
       
   108 +#define AFMT_S16_LE     0x00000010
       
   109 +#define AFMT_S16_BE     0x00000020
       
   110 +
       
   111 +#if defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
       
   112 +#define AFMT_S16_NE    AFMT_S16_BE
       
   113 +#else
       
   114 +#define AFMT_S16_NE    AFMT_S16_LE
       
   115 +#endif
       
   116 +
       
   117 +#define DEFAULT_AUDIO_DEVICE "/dev/audio"
       
   118 +#define DEFAULT_DSP_DEVICE   "/dev/dsp"
       
   119 +
       
   120 +#define BUF_SIZE_MS 10
       
   121 +
       
   122 +#if defined(CUBEB_SUNAUDIO_DEBUG)
       
   123 +#define DPR(...) fprintf(stderr, __VA_ARGS__);
       
   124 +#else
       
   125 +#define DPR(...) do {} while(0)
       
   126 +#endif
       
   127 +
       
   128 +static struct cubeb_ops const sunaudio_ops;
       
   129 +
       
   130 +struct cubeb {
       
   131 +  struct cubeb_ops const * ops;
       
   132 +};
       
   133 +
       
   134 +struct cubeb_stream {
       
   135 +  cubeb * context;
       
   136 +  pthread_t th;			  /* to run real-time audio i/o */
       
   137 +  pthread_mutex_t mutex;	  /* protects fd and frm_played */
       
   138 +  int fd;			  /* link us to sunaudio */
       
   139 +  int active;			  /* cubec_start() called */
       
   140 +  int conv;			  /* need float->s16 conversion */
       
   141 +  int using_oss;
       
   142 +  unsigned char *buf;		  /* data is prepared here */
       
   143 +  unsigned int rate;
       
   144 +  unsigned int n_channles;
       
   145 +  unsigned int bytes_per_ch;
       
   146 +  unsigned int n_frm;
       
   147 +  unsigned int buffer_size;
       
   148 +  int64_t frm_played;
       
   149 +  cubeb_data_callback data_cb;    /* cb to preapare data */
       
   150 +  cubeb_state_callback state_cb;  /* cb to notify about state changes */
       
   151 +  void *arg;			  /* user arg to {data,state}_cb */
       
   152 +};
       
   153 +
       
   154 +static void
       
   155 +float_to_s16(void *ptr, long nsamp)
       
   156 +{
       
   157 +  int16_t *dst = ptr;
       
   158 +  float *src = ptr;
       
   159 +
       
   160 +  while (nsamp-- > 0)
       
   161 +    *(dst++) = *(src++) * 32767;
       
   162 +}
       
   163 +
       
   164 +static void *
       
   165 +sunaudio_mainloop(void *arg)
       
   166 +{
       
   167 +  struct cubeb_stream *s = arg;
       
   168 +  int state;
       
   169 +
       
   170 +  DPR("sunaudio_mainloop()\n");
       
   171 +
       
   172 +  s->state_cb(s, s->arg, CUBEB_STATE_STARTED);
       
   173 +
       
   174 +  pthread_mutex_lock(&s->mutex);
       
   175 +  DPR("sunaudio_mainloop(), started\n");
       
   176 +
       
   177 +  for (;;) {
       
   178 +    if (!s->active) {
       
   179 +      DPR("sunaudio_mainloop() stopped\n");
       
   180 +      state = CUBEB_STATE_STOPPED;
       
   181 +      break;
       
   182 +    }
       
   183 +
       
   184 +    if (!s->using_oss) {
       
   185 +      audio_info_t info;
       
   186 +      ioctl(s->fd, AUDIO_GETINFO, &info);
       
   187 +      if (s->frm_played > info.play.samples + 3 * s->n_frm) {
       
   188 +        pthread_mutex_unlock(&s->mutex);
       
   189 +        struct timespec ts = {0, 10000}; // 10 ms
       
   190 +        nanosleep(&ts, NULL);
       
   191 +        pthread_mutex_lock(&s->mutex);
       
   192 +        continue;
       
   193 +      }
       
   194 +    }
       
   195 +
       
   196 +    pthread_mutex_unlock(&s->mutex);
       
   197 +    unsigned int got = s->data_cb(s, s->arg, s->buf, s->n_frm);
       
   198 +    DPR("sunaudio_mainloop() ask %d got %d\n", s->n_frm, got);
       
   199 +    pthread_mutex_lock(&s->mutex);
       
   200 +
       
   201 +    if (got < 0) {
       
   202 +      DPR("sunaudio_mainloop() cb err\n");
       
   203 +      state = CUBEB_STATE_ERROR;
       
   204 +      break;
       
   205 +    }
       
   206 +
       
   207 +    if (s->conv) {
       
   208 +      float_to_s16(s->buf, got * s->n_channles);
       
   209 +    }
       
   210 +
       
   211 +    unsigned int avail = got * 2 * s->n_channles; // coverted to s16
       
   212 +    unsigned int pos = 0;
       
   213 +
       
   214 +    while (avail > 0 && s->active) {
       
   215 +      int written = write(s->fd, s->buf + pos, avail);
       
   216 +      if (written == -1) {
       
   217 +        if (errno != EINTR && errno != EWOULDBLOCK) {
       
   218 +          DPR("sunaudio_mainloop() write err\n");
       
   219 +          state = CUBEB_STATE_ERROR;
       
   220 +          break;
       
   221 +        }
       
   222 +        pthread_mutex_unlock(&s->mutex);
       
   223 +        struct timespec ts = {0, 10000}; // 10 ms
       
   224 +        nanosleep(&ts, NULL);
       
   225 +        pthread_mutex_lock(&s->mutex);
       
   226 +      } else {
       
   227 +        pos += written;
       
   228 +        DPR("sunaudio_mainloop() write %d pos %d\n", written, pos);
       
   229 +        s->frm_played += written / 2 / s->n_channles;
       
   230 +        avail -= written;
       
   231 +      }
       
   232 +    }
       
   233 +
       
   234 +    if ((got  < s->n_frm)) {
       
   235 +      DPR("sunaudio_mainloop() drained\n");
       
   236 +      state = CUBEB_STATE_DRAINED;
       
   237 +      break;
       
   238 +    }
       
   239 +  }
       
   240 +
       
   241 +  pthread_mutex_unlock(&s->mutex);
       
   242 +  s->state_cb(s, s->arg, state);
       
   243 +
       
   244 +  return NULL;
       
   245 +}
       
   246 +
       
   247 +/*static*/ int
       
   248 +sunaudio_init(cubeb **context, char const *context_name)
       
   249 +{
       
   250 +  DPR("sunaudio_init(%s)\n", context_name);
       
   251 +  *context = malloc(sizeof(*context));
       
   252 +  (*context)->ops = &sunaudio_ops;
       
   253 +  (void)context_name;
       
   254 +  return CUBEB_OK;
       
   255 +}
       
   256 +
       
   257 +static char const *
       
   258 +sunaudio_get_backend_id(cubeb *context)
       
   259 +{
       
   260 +  return "sunaudio";
       
   261 +}
       
   262 +
       
   263 +static void
       
   264 +sunaudio_destroy(cubeb *context)
       
   265 +{
       
   266 +  DPR("sunaudio_destroy()\n");
       
   267 +  free(context);
       
   268 +}
       
   269 +
       
   270 +static int
       
   271 +sunaudio_stream_init(cubeb *context,
       
   272 +                  cubeb_stream **stream,
       
   273 +                  char const *stream_name,
       
   274 +                  cubeb_stream_params stream_params, unsigned int latency,
       
   275 +                  cubeb_data_callback data_callback,
       
   276 +                  cubeb_state_callback state_callback,
       
   277 +                  void *user_ptr)
       
   278 +{
       
   279 +  struct cubeb_stream *s;
       
   280 +  DPR("sunaudio_stream_init(%s)\n", stream_name);
       
   281 +  size_t size;
       
   282 +
       
   283 +  s = malloc(sizeof(struct cubeb_stream));
       
   284 +  if (s == NULL)
       
   285 +    return CUBEB_ERROR;
       
   286 +  s->context = context;
       
   287 +
       
   288 +  // If UTAUDIODEV is set, use it with Sun Audio interface
       
   289 +  char * sa_device_name = getenv("UTAUDIODEV");
       
   290 +  char * dsp_device_name = NULL;
       
   291 +  if (!sa_device_name) {
       
   292 +    dsp_device_name = getenv("AUDIODSP");
       
   293 +    if (!dsp_device_name) {
       
   294 +      dsp_device_name = DEFAULT_DSP_DEVICE;
       
   295 +    }
       
   296 +    sa_device_name = getenv("AUDIODEV");
       
   297 +    if (!sa_device_name) {
       
   298 +      sa_device_name = DEFAULT_AUDIO_DEVICE;
       
   299 +    }
       
   300 +  }
       
   301 +
       
   302 +  s->using_oss = 0;
       
   303 +  // Try to use OSS if available
       
   304 +  if (dsp_device_name) {
       
   305 +    s->fd = open(dsp_device_name, O_WRONLY | O_NONBLOCK);
       
   306 +    if (s->fd >= 0) {
       
   307 +      s->using_oss = 1;
       
   308 +    }
       
   309 +  }
       
   310 +
       
   311 +  // Try Sun Audio
       
   312 +  if (!s->using_oss) {
       
   313 +    s->fd = open(sa_device_name, O_WRONLY | O_NONBLOCK);
       
   314 +  }
       
   315 +
       
   316 +  if (s->fd < 0) {
       
   317 +    free(s);
       
   318 +    DPR("sunaudio_stream_init(), open() failed\n");
       
   319 +    return CUBEB_ERROR;
       
   320 +  }
       
   321 +
       
   322 +  if (s->using_oss) {
       
   323 +    if (ioctl(s->fd, SNDCTL_DSP_SPEED, &stream_params.rate) < 0) {
       
   324 +      DPR("ioctl SNDCTL_DSP_SPEED failed.\n");
       
   325 +      close(s->fd);
       
   326 +      free(s);
       
   327 +      return CUBEB_ERROR_INVALID_FORMAT;
       
   328 +    }
       
   329 +
       
   330 +    if (ioctl(s->fd, SNDCTL_DSP_CHANNELS, &stream_params.channels) < 0) {
       
   331 +      DPR("ioctl SNDCTL_DSP_CHANNELS failed.\n");
       
   332 +      close(s->fd);
       
   333 +      free(s);
       
   334 +      return CUBEB_ERROR_INVALID_FORMAT;
       
   335 +    }
       
   336 +
       
   337 +    int format = AFMT_S16_NE;
       
   338 +    if (ioctl(s->fd, SNDCTL_DSP_SETFMT, &format) < 0) {
       
   339 +      DPR("ioctl SNDCTL_DSP_SETFMT failed.\n");
       
   340 +      close(s->fd);
       
   341 +      free(s);
       
   342 +      return CUBEB_ERROR_INVALID_FORMAT;
       
   343 +    }
       
   344 +  } else {
       
   345 +    audio_info_t audio_info;
       
   346 +    AUDIO_INITINFO(&audio_info)
       
   347 +    audio_info.play.sample_rate = stream_params.rate;
       
   348 +    audio_info.play.channels = stream_params.channels;
       
   349 +    audio_info.play.encoding = AUDIO_ENCODING_LINEAR;
       
   350 +    audio_info.play.precision = 16;
       
   351 +    if (ioctl(s->fd, AUDIO_SETINFO, &audio_info) == -1) {
       
   352 +      DPR("ioctl AUDIO_SETINFO failed.\n");
       
   353 +      close(s->fd);
       
   354 +      free(s);
       
   355 +      return CUBEB_ERROR_INVALID_FORMAT;
       
   356 +    }
       
   357 +  }
       
   358 +
       
   359 +  s->conv = 0;
       
   360 +  switch (stream_params.format) {
       
   361 +    case CUBEB_SAMPLE_S16NE:
       
   362 +      s->bytes_per_ch = 2;
       
   363 +      break;
       
   364 +    case CUBEB_SAMPLE_FLOAT32NE:
       
   365 +      s->bytes_per_ch = 4;
       
   366 +      s->conv = 1;
       
   367 +      break;
       
   368 +    default:
       
   369 +      DPR("sunaudio_stream_init() unsupported format\n");
       
   370 +      close(s->fd);
       
   371 +      free(s);
       
   372 +      return CUBEB_ERROR_INVALID_FORMAT;
       
   373 +  }
       
   374 +
       
   375 +  s->active = 0;
       
   376 +  s->rate = stream_params.rate;
       
   377 +  s->n_channles = stream_params.channels;
       
   378 +  s->data_cb = data_callback;
       
   379 +  s->state_cb = state_callback;
       
   380 +  s->arg = user_ptr;
       
   381 +  if (pthread_mutex_init(&s->mutex, NULL) != 0) {
       
   382 +    free(s);
       
   383 +    return CUBEB_ERROR;
       
   384 +  }
       
   385 +  s->frm_played = 0;
       
   386 +  s->n_frm = s->rate * BUF_SIZE_MS / 1000;
       
   387 +  s->buffer_size = s->bytes_per_ch * s->n_channles * s->n_frm;
       
   388 +  s->buf = malloc(s->buffer_size);
       
   389 +  if (s->buf == NULL) {
       
   390 +    close(s->fd);
       
   391 +    free(s);
       
   392 +    return CUBEB_ERROR;
       
   393 +  }
       
   394 +
       
   395 +  *stream = s;
       
   396 +  DPR("sunaudio_stream_init() end, ok\n");
       
   397 +  return CUBEB_OK;
       
   398 +}
       
   399 +
       
   400 +static void
       
   401 +sunaudio_stream_destroy(cubeb_stream *s)
       
   402 +{
       
   403 +  DPR("sunaudio_stream_destroy()\n");
       
   404 +  if (s->fd > 0) {
       
   405 +    // Flush buffer
       
   406 +    if (s->using_oss) {
       
   407 +      ioctl(s->fd, SNDCTL_DSP_HALT_OUTPUT);
       
   408 +    } else {
       
   409 +      ioctl(s->fd, I_FLUSH);
       
   410 +    }
       
   411 +    close(s->fd);
       
   412 +  }
       
   413 +  free(s->buf);
       
   414 +  free(s);
       
   415 +}
       
   416 +
       
   417 +static int
       
   418 +sunaudio_stream_start(cubeb_stream *s)
       
   419 +{
       
   420 +  int err;
       
   421 +
       
   422 +  DPR("sunaudio_stream_start()\n");
       
   423 +  s->active = 1;
       
   424 +  err = pthread_create(&s->th, NULL, sunaudio_mainloop, s);
       
   425 +  if (err) {
       
   426 +    s->active = 0;
       
   427 +    return CUBEB_ERROR;
       
   428 +  }
       
   429 +  return CUBEB_OK;
       
   430 +}
       
   431 +
       
   432 +static int
       
   433 +sunaudio_stream_stop(cubeb_stream *s)
       
   434 +{
       
   435 +  void *dummy;
       
   436 +
       
   437 +  DPR("sunaudio_stream_stop()\n");
       
   438 +  if (s->active) {
       
   439 +    s->active = 0;
       
   440 +    pthread_join(s->th, &dummy);
       
   441 +  }
       
   442 +  return CUBEB_OK;
       
   443 +}
       
   444 +
       
   445 +static int
       
   446 +sunaudio_stream_get_position(cubeb_stream *s, uint64_t *p)
       
   447 +{
       
   448 +  int rv = CUBEB_OK;
       
   449 +  pthread_mutex_lock(&s->mutex);
       
   450 +  if (s->active && s->fd > 0) {
       
   451 +    if (s->using_oss) {
       
   452 +      int delay;
       
   453 +      ioctl(s->fd, SNDCTL_DSP_GETODELAY, &delay);
       
   454 +      int64_t t = s->frm_played - delay / s->n_channles / 2;
       
   455 +      if (t < 0) {
       
   456 +        *p = 0;
       
   457 +      } else {
       
   458 +        *p = t;
       
   459 +      }
       
   460 +    } else {
       
   461 +      audio_info_t info;
       
   462 +      ioctl(s->fd, AUDIO_GETINFO, &info);
       
   463 +      *p = info.play.samples;
       
   464 +    }
       
   465 +    DPR("sunaudio_stream_get_position() %lld\n", *p);
       
   466 +  } else {
       
   467 +    rv = CUBEB_ERROR;
       
   468 +  }
       
   469 +  pthread_mutex_unlock(&s->mutex);
       
   470 +  return rv;
       
   471 +}
       
   472 +
       
   473 +static int
       
   474 +sunaudio_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
       
   475 +{
       
   476 +  if (!ctx || !max_channels)
       
   477 +    return CUBEB_ERROR;
       
   478 +
       
   479 +  *max_channels = 2;
       
   480 +
       
   481 +  return CUBEB_OK;
       
   482 +}
       
   483 +
       
   484 +static int
       
   485 +sunaudio_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
       
   486 +{
       
   487 +  if (!ctx || !rate)
       
   488 +    return CUBEB_ERROR;
       
   489 +
       
   490 +  // XXX Not yet implemented.
       
   491 +  *rate = 44100;
       
   492 +
       
   493 +  return CUBEB_OK;
       
   494 +}
       
   495 +
       
   496 +static int
       
   497 +sunaudio_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * latency_ms)
       
   498 +{
       
   499 +  if (!ctx || !latency_ms)
       
   500 +    return CUBEB_ERROR;
       
   501 +
       
   502 +  // XXX Not yet implemented.
       
   503 +  *latency_ms = 20;
       
   504 +
       
   505 +  return CUBEB_OK;
       
   506 +}
       
   507 +
       
   508 +static int
       
   509 +sunaudio_stream_get_latency(cubeb_stream * s, uint32_t * latency)
       
   510 +{
       
   511 +  if (!s || !latency)
       
   512 +    return CUBEB_ERROR;
       
   513 +
       
   514 +  int rv = CUBEB_OK;
       
   515 +  pthread_mutex_lock(&s->mutex);
       
   516 +  if (s->active && s->fd > 0) {
       
   517 +    if (s->using_oss) {
       
   518 +      int delay;
       
   519 +      ioctl(s->fd, SNDCTL_DSP_GETODELAY, &delay);
       
   520 +      *latency = delay / s->n_channles / 2 / s->rate;
       
   521 +    } else {
       
   522 +      audio_info_t info;
       
   523 +      ioctl(s->fd, AUDIO_GETINFO, &info);
       
   524 +      *latency = (s->frm_played - info.play.samples) / s->rate;
       
   525 +    }
       
   526 +    DPR("sunaudio_stream_get_position() %lld\n", *p);
       
   527 +  } else {
       
   528 +    rv = CUBEB_ERROR;
       
   529 +  }
       
   530 +  pthread_mutex_unlock(&s->mutex);
       
   531 +  return rv;
       
   532 +}
       
   533 +
       
   534 +static struct cubeb_ops const sunaudio_ops = {
       
   535 +  .init = sunaudio_init,
       
   536 +  .get_backend_id = sunaudio_get_backend_id,
       
   537 +  .destroy = sunaudio_destroy,
       
   538 +  .get_preferred_sample_rate = sunaudio_get_preferred_sample_rate,
       
   539 +  .stream_init = sunaudio_stream_init,
       
   540 +  .stream_destroy = sunaudio_stream_destroy,
       
   541 +  .stream_start = sunaudio_stream_start,
       
   542 +  .stream_stop = sunaudio_stream_stop,
       
   543 +  .stream_get_position = sunaudio_stream_get_position,
       
   544 +  .get_max_channel_count = sunaudio_get_max_channel_count,
       
   545 +  .get_min_latency = sunaudio_get_min_latency,
       
   546 +  .stream_get_latency = sunaudio_stream_get_latency
       
   547 +};