summaryrefslogtreecommitdiff
path: root/libao/src/src/ao_wmm.c
blob: 7cd05f1fe00f5436d1e91ac298dd77768baca10a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
/*
 *
 *  ao_wmm.c
 *
 *      Copyright (C) Benjamin Gerard - March 2007
 *
 *  This file is part of libao, a cross-platform library.  See
 *  README for a history of this source code.
 *
 *  libao is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  libao is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 ********************************************************************

 last mod: $Id: ao_wmm.c 17629 2010-11-18 12:04:46Z xiphmont $

 ********************************************************************/

//#define PREPARE_EACH
//#define _CRT_SECURE_NO_DEPRECATE

#include <windows.h>
#include <mmreg.h>
#include <mmsystem.h>
//#include <ks.h>
//#include <ksmedia.h>

#include <stdlib.h>
#include <string.h>

#include <stdarg.h>
#include <stdio.h>

//#ifndef KSDATAFORMAT_SUBTYPE_PCM
//#define KSDATAFORMAT_SUBTYPE_PCM (GUID) {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}}
//#endif

GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}};


#include "ao/ao.h"
/* #include "ao/plugin.h" */

#define GALLOC_WVHD_TYPE (GHND)
#define GALLOC_DATA_TYPE (GHND)

static const char * mmerror(MMRESULT mmrError)
{
  static char mmbuffer[1024];
  int len;
  sprintf(mmbuffer,"mm:%d ",(int)mmrError);
  len = (int)strlen(mmbuffer);
  waveOutGetErrorTextA(mmrError, mmbuffer+len, sizeof(mmbuffer)-len);
  mmbuffer[sizeof(mmbuffer)-1] = 0;
  return mmbuffer;
}

static char * ao_wmm_options[] = {"dev", "id", "matrix","verbose","quiet","debug"};
static ao_info ao_wmm_info =
  {
    /* type             */ AO_TYPE_LIVE,
    /* name             */ "WMM audio driver output ",
    /* short-name       */ "wmm",
    /* author           */ "Benjamin Gerard <benjihan@users.sourceforge.net>",
    /* comment          */ "Outputs audio to the Windows MultiMedia driver.",
    /* prefered format  */ AO_FMT_LITTLE,
    /* priority         */ 20,
    /* options          */ ao_wmm_options,
    /* # of options     */ sizeof(ao_wmm_options)/sizeof(*ao_wmm_options)
  };

typedef struct {
  WAVEHDR wh;          /* waveheader                        */
  char *  data;        /* sample data ptr                   */
  int     idx;         /* index of this header              */
  int     count;       /* current byte count                */
  int     length;      /* size of data                      */
  int     sent;        /* set when header is sent to device */
} myWH_t;

typedef struct ao_wmm_internal {
  UINT  id;             /* device id                       */
  HWAVEOUT hwo;         /* waveout handler                 */
  WAVEOUTCAPSA caps;     /* device caps                     */
  WAVEFORMATEXTENSIBLE wavefmt; /* sample format           */

  int opened;           /* device has been opened          */
  int prepared;         /* waveheaders have been prepared  */
  int blocks;           /* number of blocks (wave headers) */
  int splPerBlock;      /* sample per blocks.              */
  int msPerBlock;       /* millisecond per block (approx.) */

  void * bigbuffer;     /* Allocated buffer for waveheaders and sound data */
  myWH_t * wh;          /* Pointer to waveheaders in bigbuffer             */
  BYTE * spl;           /* Pointer to sound data in bigbuffer              */

  int sent_blocks;      /* Number of waveheader sent (not ack).        */
  int full_blocks;      /* Number of waveheader full (ready to send).  */
  int widx;             /* Index to the block being currently filled.  */
  int ridx;             /* Index to the block being sent.              */

} ao_wmm_internal;

int ao_wmm_test(void)
{
  return 1; /* This plugin works in default mode */
}

ao_info *ao_wmm_driver_info(void)
{
  return &ao_wmm_info;
}

int ao_wmm_set_option(ao_device *device,
                      const char *key, const char *value)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;
  int res = 0;

  if (!strcmp(key, "dev")) {
    if (!strcmp(value,"default")) {
      key = "id";
      value = "0";
    } else {
      WAVEOUTCAPSA caps;
      int i, max = waveOutGetNumDevs();

      adebug("searching for device %s among %d\n", value, max);
      for (i=0; i<max; ++i) {
        MMRESULT mmres = waveOutGetDevCapsA(i, &caps, sizeof(caps));
        if (mmres == MMSYSERR_NOERROR) {
          res = !strcmp(value, caps.szPname);
          adebug("checking id=%d, name='%s', ver=%d.%d  => [%s]\n",
                i,caps.szPname,caps.vDriverVersion>>8,caps.vDriverVersion&255,res?"YES":"no");
          if (res) {
            internal->id   = i;
            internal->caps = caps;
            break;
          }
        } else {
          aerror("waveOutGetDevCaps(%d) => %s",i,mmerror(mmres));
        }
      }
      goto finish;
    }
  }

  if (!strcmp(key,"id")) {
    MMRESULT mmres;
    WAVEOUTCAPSA caps;

    int id  = strtol(value,0,0);
    int max = waveOutGetNumDevs();

    if (id >= 0 &&  id <= max) {
      if (id-- == 0) {
        adebug("set default wavemapper\n");
        id = WAVE_MAPPER;
      }
      mmres = waveOutGetDevCapsA(id, &caps, sizeof(caps));

      if (mmres == MMSYSERR_NOERROR) {
        res = 1;
        adebug("checking id=%d, name='%s', ver=%d.%d  => [YES]\n",
              id,caps.szPname,caps.vDriverVersion>>8,caps.vDriverVersion&255);
        internal->id   = id;
        internal->caps = caps;
      } else {
        aerror("waveOutGetDevCaps(%d) => %s",id,mmerror(mmres));
      }
    }
  }

 finish:
  return res;
}


int ao_wmm_device_init(ao_device *device)
{
  ao_wmm_internal *internal;
  int res;

  internal = (ao_wmm_internal *) malloc(sizeof(ao_wmm_internal));
  device->internal = internal;
  if (internal != NULL) {
    memset(internal,0,sizeof(ao_wmm_internal));
    internal->id          = WAVE_MAPPER;
    internal->blocks      = 32;
    internal->splPerBlock = 512;
    /* set default device */
    ao_wmm_set_option(device,"id","0");
  }

  res = internal != NULL;

  device->output_matrix = _strdup("L,R,C,LFE,BL,BR,CL,CR,BC,SL,SR");
  device->output_matrix_order = AO_OUTPUT_MATRIX_COLLAPSIBLE;

  return res;
}

static int _ao_open_device(ao_device *device)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;
  int res;
  MMRESULT mmres;

  mmres =
    waveOutOpen(&internal->hwo,
		internal->id,
		&internal->wavefmt.Format,
		(DWORD_PTR)0/* waveOutProc */,
		(DWORD_PTR)device,
		CALLBACK_NULL/* |WAVE_FORMAT_DIRECT */|WAVE_ALLOWSYNC);

  if(mmres == MMSYSERR_NOERROR){
    adebug("waveOutOpen id=%d, channels=%d, bits=%d, rate %d => SUCCESS\n",
          internal->id,
          internal->wavefmt.Format.nChannels,
          (int)internal->wavefmt.Format.wBitsPerSample,
          (int)internal->wavefmt.Format.nSamplesPerSec);
  }else{
    aerror("waveOutOpen id=%d, channels=%d, bits=%d, rate %d => FAILED\n",
          internal->id,
          internal->wavefmt.Format.nChannels,
          (int)internal->wavefmt.Format.wBitsPerSample,
          (int)internal->wavefmt.Format.nSamplesPerSec);
  }

  if (mmres == MMSYSERR_NOERROR) {
    UINT id;
    if (MMSYSERR_NOERROR == waveOutGetID(internal->hwo,&id)) {
      internal->id = id;
    }
  }

  res = (mmres == MMSYSERR_NOERROR);
  return res;
}

static int _ao_close_device(ao_device *device)
{
  ao_wmm_internal * internal = (ao_wmm_internal *) device->internal;
  int res;
  MMRESULT mmres;

  mmres = waveOutClose(internal->hwo);
  if(mmres == MMSYSERR_NOERROR) {
    adebug("waveOutClose(%d)\n => %s\n", internal->id, mmerror(mmres));
  }else{
    aerror("waveOutClose(%d)\n => %s\n", internal->id, mmerror(mmres));
  }
  res = (mmres == MMSYSERR_NOERROR);

  return res;
}

static int _ao_alloc_wave_headers(ao_device *device)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;
  int bytesPerBlock = internal->wavefmt.Format.nBlockAlign * internal->splPerBlock;
  /*   int bytes = internal->blocks * (sizeof(WAVEHDR) + bytesPerBlock); */
  int bytes = internal->blocks * (sizeof(*internal->wh) + bytesPerBlock);
  int res;
  MMRESULT mmres;

  adebug("_ao_alloc_wave_headers blocks=%d, bytes/blocks=%d, total=%d\n",
         internal->blocks,bytesPerBlock,bytes);

  internal->bigbuffer = malloc(bytes);
  if (internal->bigbuffer != NULL) {
    int i;
    BYTE * b;

    memset(internal->bigbuffer,0,bytes);
    internal->wh = internal->bigbuffer;
    internal->spl = (LPBYTE) (internal->wh+internal->blocks);
    for (i=0, b=internal->spl; i<internal->blocks; ++i, b+=bytesPerBlock) {
      internal->wh[i].data = (char*)b;
      internal->wh[i].wh.lpData = internal->wh[i].data;
      internal->wh[i].length = bytesPerBlock;
      internal->wh[i].wh.dwBufferLength = internal->wh[i].length;
      internal->wh[i].wh.dwUser = (DWORD_PTR)device;
      mmres = waveOutPrepareHeader(internal->hwo,
				   &internal->wh[i].wh,sizeof(WAVEHDR));
      if (MMSYSERR_NOERROR != mmres) {
        aerror("waveOutPrepareHeader(%d) => %s\n",i, mmerror(mmres));
        break;
      }
    }
    if (i<internal->blocks) {
      while (--i >= 0) {
        waveOutUnprepareHeader(internal->hwo,
			       &internal->wh[i].wh,sizeof(WAVEHDR));
      }
      free(internal->bigbuffer);
      internal->wh        = 0;
      internal->spl       = 0;
      internal->bigbuffer = 0;
    } else {
      /* all ok ! */
    }
  } else {
    adebug("malloc() => FAILED\n");
  }

  res = (internal->bigbuffer != NULL);
  if(!res){
    aerror("_ao_alloc_wave_headers() => FAILED\n");
  }else{
    adebug("_ao_alloc_wave_headers() => success\n");
  }
  return res;
}

static int _ao_get_free_block(ao_device * device);
static int _ao_wait_wave_headers(ao_device *device, int wait_all)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;
  int res = 1;

  adebug("wait for %d blocks (%swait all)\n",
         internal->sent_blocks,wait_all?"":"not ");

  while (internal->sent_blocks > 0) {
    int n;
    _ao_get_free_block(device);
    n = internal->sent_blocks;
    if (n > 0) {
      unsigned int ms = (internal->msPerBlock>>1)+1;
      if (wait_all) ms *= n;
      adebug("sleep for %ums wait on %d blocks\n",ms, internal->sent_blocks);
      Sleep(ms);
    }
  }

  res &= !internal->sent_blocks;
  if(!res){
    aerror("_ao_wait_wave_headers => FAILED\n");
  }else{
    adebug("_ao_wait_wave_headers => success\n");
  }
  return res;
}

static int _ao_free_wave_headers(ao_device *device)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;
  MMRESULT mmres;
  int res = 1;

  if (internal->wh) {
    int i;

    /* Reset so we dont need to wait ... Just a satefy net
     * since _ao_wait_wave_headers() has been called once before.
     */
    mmres = waveOutReset(internal->hwo);
    adebug("waveOutReset(%d) => %s\n", internal->id, mmerror(mmres));
    /* Wait again to be sure reseted waveheaders has been released. */
    _ao_wait_wave_headers(device,0);

    for (i=internal->blocks; --i>=0; ) {
      mmres = waveOutUnprepareHeader(internal->hwo,
				     &internal->wh[i].wh,sizeof(WAVEHDR));
      if (mmres != MMSYSERR_NOERROR)
        aerror("waveOutUnprepareHeader(%d) => %s\n", i, mmerror(mmres));

      res &= mmres == MMSYSERR_NOERROR;
    }
    internal->wh  = 0;
    internal->spl = 0;
  }

  if(!res){
    aerror("_ao_alloc_wave_headers() => FAILED\n");
  }else{
    adebug("_ao_alloc_wave_headers() => success\n");
  }
  return res;
}


/*
 * open the audio device for writing to
 */
int ao_wmm_open(ao_device * device, ao_sample_format * format)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;
  int res = 0;
  WAVEFORMATEXTENSIBLE wavefmt;

  adebug("open() channels=%d, bits=%d, rate=%d, format %d(%s)\n",
         device->output_channels,format->bits,format->rate,format->byte_format,
         format->byte_format==AO_FMT_LITTLE
         ?"little"
         :(format->byte_format==AO_FMT_NATIVE
           ?"native"
           :(format->byte_format==AO_FMT_BIG?"big":"unknown")));

  if(internal->opened) {
    aerror("open() => already opened\n");
    goto error_no_close;
  }

  /* Force LITTLE as specified by WIN32 API */
  format->byte_format = AO_FMT_LITTLE;
  device->driver_byte_format = AO_FMT_LITTLE;

  /* $$$ WMM 8 bit samples are unsigned... Not sure for ao ... */
  /* Yes, ao 8 bit PCM is unsigned -- Monty */

  /* Make sample format */
  memset(&wavefmt,0,sizeof(wavefmt));
  wavefmt.Format.wFormatTag          = WAVE_FORMAT_EXTENSIBLE;
  wavefmt.Format.nChannels           = device->output_channels;
  wavefmt.Format.wBitsPerSample      = (((format->bits+7)>>3)<<3);
  wavefmt.Format.nSamplesPerSec      = format->rate;
  wavefmt.Format.nBlockAlign         = (wavefmt.Format.wBitsPerSample>>3)*wavefmt.Format.nChannels;
  wavefmt.Format.nAvgBytesPerSec     = wavefmt.Format.nSamplesPerSec*wavefmt.Format.nBlockAlign;
  wavefmt.Format.cbSize              = 22;
  wavefmt.Samples.wValidBitsPerSample = format->bits;
  wavefmt.SubFormat           = KSDATAFORMAT_SUBTYPE_PCM;
  wavefmt.dwChannelMask       = device->output_mask;

  internal->wavefmt       = wavefmt;

  /* $$$ later this should be optionnal parms */
  internal->blocks      = 64;
  internal->splPerBlock = 512;
  internal->msPerBlock  =
    (internal->splPerBlock * 1000 + format->rate - 1) / format->rate;

  /* Open device */
  if(!_ao_open_device(device))
    goto error;
  internal->opened = 1;

  /* Allocate buffers */
  if (!_ao_alloc_wave_headers(device))
    goto error;
  internal->prepared = 1;

  res = 1;
 error:
  if (!res) {
    if (internal->prepared) {
      _ao_free_wave_headers(device);
      internal->prepared = 0;
    }
    if (internal->opened) {
      _ao_close_device(device);
      internal->opened = 0;
    }
  }

 error_no_close:
  if(res){
    adebug("open() => success\n");
  }else{
    aerror("open() => FAILED\n");
  }
  return res;
}



/* Send a block to audio hardware */
static int _ao_send_block(ao_device *device, const int idx)
{
  ao_wmm_internal * internal = (ao_wmm_internal *) device->internal;
  MMRESULT mmres;

  /* Satanity checks */
  if (internal->wh[idx].sent) {
    adebug("block %d marked SENT\n",idx);
    return 0;
  }
  if (!!(internal->wh[idx].wh.dwFlags & WHDR_DONE)) {
    adebug("block %d marked DONE\n",idx);
    return 0;
  }

  /* count <= 0, just pretend it's been sent */
  if (internal->wh[idx].count <= 0) {
    internal->wh[idx].sent = 2; /* set with 2 so we can track these special cases */
    internal->wh[idx].wh.dwFlags |= WHDR_DONE;
    ++internal->sent_blocks;
    return 1;
  }

  internal->wh[idx].wh.dwBufferLength = internal->wh[idx].count;
  internal->wh[idx].count = 0;
  mmres = waveOutWrite(internal->hwo,
		       &internal->wh[idx].wh, sizeof(WAVEHDR));
  internal->wh[idx].sent = (mmres == MMSYSERR_NOERROR);
  /*&& !(internal->wh[idx].wh.dwFlags & WHDR_DONE);*/
  internal->sent_blocks += internal->wh[idx].sent;
  if (mmres != MMSYSERR_NOERROR) {
    adebug("waveOutWrite(%d) => %s\n",idx,mmerror(mmres));
  }
  return mmres == MMSYSERR_NOERROR;
}

/* Get idx of next free block. */
static int _ao_get_free_block(ao_device * device)
{
  ao_wmm_internal * internal = (ao_wmm_internal *) device->internal;
  const int idx = internal->widx;
  int ridx = internal->ridx;

  while (internal->wh[ridx].sent && !!(internal->wh[ridx].wh.dwFlags & WHDR_DONE)) {
    /* block successfully sent to hardware, release it */
    /*debug("_ao_get_free_block: release block %d\n",ridx);*/
    internal->wh[ridx].sent = 0;
    internal->wh[ridx].wh.dwFlags &= ~WHDR_DONE;

    --internal->full_blocks;
    if (internal->full_blocks<0) {
      adebug("internal error with full block counter\n");
      internal->full_blocks = 0;
    }

    --internal->sent_blocks;
    if (internal->sent_blocks<0) {
      adebug("internal error with sent block counter\n");
      internal->sent_blocks = 0;
    }
    if (++ridx >= internal->blocks) ridx = 0;
  }
  internal->ridx = ridx;

  return internal->wh[idx].sent
    ? -1
    : idx;
}

/*
 * play the sample to the already opened file descriptor
 */
int ao_wmm_play(ao_device *device,
                const char *output_samples, uint_32 num_bytes)
{
  int ret = 1;
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;

  while(ret && num_bytes > 0) {
    int n;
    const int idx = _ao_get_free_block(device);

    if (idx == -1) {
      Sleep(internal->msPerBlock);
      continue;
    }

    /* Get free bytes in the block */
    n = internal->wh[idx].wh.dwBufferLength
      - internal->wh[idx].count;

    /* Get amount to copy */
    if (n > (int)num_bytes) {
      n = num_bytes;
    }

    /* Do copy */
    CopyMemory((char*)internal->wh[idx].wh.lpData
	       + internal->wh[idx].count,
	       output_samples, n);

    /* Updates pointers and counters */
    output_samples += n;
    num_bytes -= n;
    internal->wh[idx].count += n;

    /* Is this block full ? */
    if (internal->wh[idx].count
	== internal->wh[idx].wh.dwBufferLength) {
      ++internal->full_blocks;
      if (++internal->widx == internal->blocks) {
	internal->widx = 0;
      }
      ret = _ao_send_block(device,idx);
    }
  }

  adebug("ao_wmm_play => %d rem => [%s]\n",num_bytes,ret?"success":"error");
  return ret;

}

int ao_wmm_close(ao_device *device)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;
  int ret = 0;

  if (internal->opened && internal->prepared) {
    _ao_wait_wave_headers(device, 1);
  }

  if (internal->prepared) {
    ret = _ao_free_wave_headers(device);
    internal->prepared = 0;
  }

  if (internal->opened) {
    ret = _ao_close_device(device);
    internal->opened = 0;
  }

  return ret;
}

void ao_wmm_device_clear(ao_device *device)
{
  ao_wmm_internal *internal = (ao_wmm_internal *) device->internal;

  if (internal->bigbuffer) {
    free(internal->bigbuffer); internal->bigbuffer = NULL;
  }
  free(internal);
  device->internal=NULL;
}

ao_functions ao_wmm = {
  ao_wmm_test,
  ao_wmm_driver_info,
  ao_wmm_device_init,
  ao_wmm_set_option,
  ao_wmm_open,
  ao_wmm_play,
  ao_wmm_close,
  ao_wmm_device_clear
};