1.\" $NetBSD: audio.4,v 1.71 2010/09/19 10:34:33 mrg Exp $ 2.\" 3.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by John T. Kohl. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd September 29, 2009 31.Dt AUDIO 4 32.Os 33.Sh NAME 34.Nm audio 35.Nd device-independent audio driver layer 36.Sh SYNOPSIS 37.In sys/audioio.h 38.Sh DESCRIPTION 39The 40.Nm 41driver provides support for various audio peripherals. 42It provides a uniform programming interface layer above different 43underlying audio hardware drivers. 44The audio layer provides full-duplex operation if the 45underlying hardware configuration supports it. 46.Pp 47There are four device files available for audio operation: 48.Pa /dev/audio , 49.Pa /dev/sound , 50.Pa /dev/audioctl , 51and 52.Pa /dev/mixer . 53.Pp 54.Pa /dev/audio 55and 56.Pa /dev/sound 57are used for recording or playback of digital samples. 58.Pp 59.Pa /dev/mixer 60is used to manipulate volume, recording source, or other audio mixer 61functions. 62.Pp 63.Pa /dev/audioctl 64accepts the same 65.Xr ioctl 2 66operations as 67.Pa /dev/sound , 68but no other operations. 69.Pp 70In contrast to 71.Pa /dev/sound 72which has the exclusive open property 73.Pa /dev/audioctl 74can be opened at any time and can be used to manipulate the audio device 75while it is in use. 76.Sh SAMPLING DEVICES 77When 78.Pa /dev/audio 79is opened, it automatically directs the underlying driver to manipulate 80monaural 8-bit mu-law samples. 81In addition, if it is opened read-only 82(write-only) the device is set to half-duplex record (play) mode with 83recording (playing) unpaused and playing (recording) paused. 84When 85.Pa /dev/sound 86is opened, it maintains the previous audio sample mode and 87record/playback mode. 88In all other respects 89.Pa /dev/audio 90and 91.Pa /dev/sound 92are identical. 93.Pp 94Only one process may hold open a sampling device at a given time 95(although file descriptors may be shared between processes once the 96first open completes). 97.Pp 98On a half-duplex device, writes while recording is in progress will be 99immediately discarded. 100Similarly, reads while playback is in progress 101will be filled with silence but delayed to return at the current 102sampling rate. 103If both playback and recording are requested on a half-duplex 104device, playback mode takes precedence and recordings will get silence. 105.Pp 106On a full-duplex device, reads and writes may operate 107concurrently without interference. 108If a full-duplex capable audio device is opened for both reading and writing 109it will start in half-duplex play mode; full-duplex mode has to be set 110explicitly. 111.Pp 112On either type of device, if the playback mode is paused then silence is 113played instead of the provided samples, and if recording is paused then 114the process blocks in 115.Xr read 2 116until recording is unpaused. 117.Pp 118If a writing process does not call 119.Xr write 2 120frequently enough to provide samples at the pace the hardware 121consumes them silence is inserted. 122If the 123.Dv AUMODE_PLAY_ALL 124mode is not set the writing process must 125provide enough data via 126subsequent write calls to 127.Dq catch up 128in time to the current audio 129block before any more process-provided samples will be played. 130If a reading process does not call 131.Xr read 2 132frequently enough, it will simply miss samples. 133.Pp 134The audio device is normally accessed with 135.Xr read 2 136or 137.Xr write 2 138calls, but it can also be mapped into user memory with 139.Xr mmap 2 140(when supported by the device). 141Once the device has been mapped it can no longer be accessed 142by read or write; all access is by reading and writing to 143the mapped memory. 144The device appears as a block of memory 145of size 146.Va buffersize 147(as available via 148.Dv AUDIO_GETINFO 149or 150.Dv AUDIO_GETBUFINFO ) . 151The device driver will continuously move data from this buffer 152from/to the audio hardware, wrapping around at the end of the buffer. 153To find out where the hardware is currently accessing data in the buffer the 154.Dv AUDIO_GETIOFFS 155and 156.Dv AUDIO_GETOOFFS 157calls can be used. 158The playing and recording buffers are distinct and must be 159mapped separately if both are to be used. 160Only encodings that are not emulated (i.e. where 161.Dv AUDIO_ENCODINGFLAG_EMULATED 162is not set) work properly for a mapped device. 163.Pp 164The audio device, like most devices, can be used in 165.Va select , 166can be set in non-blocking mode and can be set (with a 167.Dv FIOASYNC 168ioctl) to send a 169.Dv SIGIO 170when I/O is possible. 171The mixer device can be set to generate a 172.Dv SIGIO 173whenever a mixer value is changed. 174.Pp 175The following 176.Xr ioctl 2 177commands are supported on the sample devices: 178.Pp 179.Bl -tag -width indent 180.It Dv AUDIO_FLUSH 181This command stops all playback and recording, clears all queued 182buffers, resets error counters, and restarts recording and playback as 183appropriate for the current sampling mode. 184.It Dv AUDIO_RERROR (int) 185This command fetches the count of dropped input samples into its integer 186argument. 187There is no information regarding when in the sample stream 188they were dropped. 189.It Dv AUDIO_WSEEK (u_long) 190This command fetches the count of samples that are queued ahead of the 191first sample in the most recent sample block written into its integer argument. 192.It Dv AUDIO_DRAIN 193This command suspends the calling process until all queued playback 194samples have been played by the hardware. 195.It Dv AUDIO_GETDEV (audio_device_t) 196This command fetches the current hardware device information into the 197audio_device_t argument. 198.Bd -literal 199typedef struct audio_device { 200 char name[MAX_AUDIO_DEV_LEN]; 201 char version[MAX_AUDIO_DEV_LEN]; 202 char config[MAX_AUDIO_DEV_LEN]; 203} audio_device_t; 204.Ed 205.It Dv AUDIO_GETFD (int) 206The command returns the current setting of the full duplex mode. 207.It Dv AUDIO_GETENC (audio_encoding_t) 208This command is used iteratively to fetch sample encoding names and 209format_ids into the input/output audio_encoding_t argument. 210.Bd -literal 211typedef struct audio_encoding { 212 int index; /* input: nth encoding */ 213 char name[MAX_AUDIO_DEV_LEN]; /* name of encoding */ 214 int encoding; /* value for encoding parameter */ 215 int precision; /* value for precision parameter */ 216 int flags; 217#define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */ 218} audio_encoding_t; 219.Ed 220.Pp 221To query 222all the supported encodings, start with an index field of 0 and 223continue with successive encodings (1, 2, ...) until the command returns 224an error. 225.It Dv AUDIO_SETFD (int) 226This command sets the device into full-duplex operation if its integer 227argument has a non-zero value, or into half-duplex operation if it 228contains a zero value. 229If the device does not support full-duplex 230operation, attempting to set full-duplex mode returns an error. 231.It Dv AUDIO_GETPROPS (int) 232This command gets a bit set of hardware properties. 233If the hardware 234has a certain property the corresponding bit is set, otherwise it is not. 235The properties can have the following values: 236.Pp 237.Bl -tag -width AUDIO_PROP_INDEPENDENT -compact 238.It Dv AUDIO_PROP_FULLDUPLEX 239the device admits full duplex operation. 240.It Dv AUDIO_PROP_MMAP 241the device can be used with 242.Xr mmap 2 . 243.It Dv AUDIO_PROP_INDEPENDENT 244the device can set the playing and recording encoding parameters 245independently. 246.It Dv AUDIO_PROP_PLAYBACK 247the device is capable of audio playback. 248.It Dv AUDIO_PROP_CAPTURE 249the device is capable of audio capture. 250.El 251.It Dv AUDIO_GETIOFFS (audio_offset_t) 252.It Dv AUDIO_GETOOFFS (audio_offset_t) 253This command fetches the current offset in the input(output) buffer where 254the audio hardware's DMA engine will be putting(getting) data. 255It mostly useful when the device 256buffer is available in user space via the 257.Xr mmap 2 258call. 259The information is returned in the audio_offset structure. 260.Bd -literal 261typedef struct audio_offset { 262 u_int samples; /* Total number of bytes transferred */ 263 u_int deltablks; /* Blocks transferred since last checked */ 264 u_int offset; /* Physical transfer offset in buffer */ 265} audio_offset_t; 266.Ed 267.It Dv AUDIO_GETINFO (audio_info_t) 268.It Dv AUDIO_GETBUFINFO (audio_info_t) 269.It Dv AUDIO_SETINFO (audio_info_t) 270Get or set audio information as encoded in the audio_info structure. 271.Bd -literal 272typedef struct audio_info { 273 struct audio_prinfo play; /* info for play (output) side */ 274 struct audio_prinfo record; /* info for record (input) side */ 275 u_int monitor_gain; /* input to output mix */ 276 /* BSD extensions */ 277 u_int blocksize; /* H/W read/write block size */ 278 u_int hiwat; /* output high water mark */ 279 u_int lowat; /* output low water mark */ 280 u_int _ispare1; 281 u_int mode; /* current device mode */ 282#define AUMODE_PLAY 0x01 283#define AUMODE_RECORD 0x02 284#define AUMODE_PLAY_ALL 0x04 /* do not do real-time correction */ 285} audio_info_t; 286.Ed 287.Pp 288When setting the current state with 289.Dv AUDIO_SETINFO , 290the audio_info structure should first be initialized with 291.Dv AUDIO_INITINFO Po \*[Am]info Pc 292and then the particular values to be changed should be set. 293This allows the audio driver to only set those things that you wish 294to change and eliminates the need to query the device with 295.Dv AUDIO_GETINFO 296or 297.Dv AUDIO_GETBUFINFO 298first. 299.Pp 300The 301.Va mode 302field should be set to 303.Dv AUMODE_PLAY , 304.Dv AUMODE_RECORD , 305.Dv AUMODE_PLAY_ALL , 306or a bitwise OR combination of the three. 307Only full-duplex audio devices support 308simultaneous record and playback. 309.Pp 310.Va hiwat 311and 312.Va lowat 313are used to control write behavior. 314Writes to the audio devices will queue up blocks until the high-water 315mark is reached, at which point any more write calls will block 316until the queue is drained to the low-water mark. 317.Va hiwat 318and 319.Va lowat 320set those high- and low-water marks (in audio blocks). 321The default for 322.Va hiwat 323is the maximum value and for 324.Va lowat 32575 % of 326.Va hiwat . 327.Pp 328.Va blocksize 329sets the current audio blocksize. 330The generic audio driver layer and the hardware driver have the 331opportunity to adjust this block size to get it within 332implementation-required limits. 333Upon return from an 334.Dv AUDIO_SETINFO 335call, the actual blocksize set is returned in this field. 336Normally the 337.Va blocksize 338is calculated to correspond to 50ms of sound and it is recalculated 339when the encoding parameter changes, but if the 340.Va blocksize 341is set explicitly this value becomes sticky, i.e., it remains 342even when the encoding is changed. 343The stickiness can be cleared by reopening the device or setting the 344.Va blocksize 345to 0. 346.Bd -literal 347struct audio_prinfo { 348 u_int sample_rate; /* sample rate in samples/s */ 349 u_int channels; /* number of channels, usually 1 or 2 */ 350 u_int precision; /* number of bits/sample */ 351 u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */ 352 u_int gain; /* volume level */ 353 u_int port; /* selected I/O port */ 354 u_long seek; /* BSD extension */ 355 u_int avail_ports; /* available I/O ports */ 356 u_int buffer_size; /* total size audio buffer */ 357 u_int _ispare[1]; 358 /* Current state of device: */ 359 u_int samples; /* number of samples */ 360 u_int eof; /* End Of File (zero-size writes) counter */ 361 u_char pause; /* non-zero if paused, zero to resume */ 362 u_char error; /* non-zero if underflow/overflow occurred */ 363 u_char waiting; /* non-zero if another process hangs in open */ 364 u_char balance; /* stereo channel balance */ 365 u_char cspare[2]; 366 u_char open; /* non-zero if currently open */ 367 u_char active; /* non-zero if I/O is currently active */ 368}; 369.Ed 370.Pp 371Note: many hardware audio drivers require identical playback and 372recording sample rates, sample encodings, and channel counts. 373The playing information is always set last and will prevail on such hardware. 374If the hardware can handle different settings the 375.Dv AUDIO_PROP_INDEPENDENT 376property is set. 377.Pp 378The encoding parameter can have the following values: 379.Pp 380.Bl -tag -width AUDIO_ENCODING_SLINEAR_BE -compact 381.It Dv AUDIO_ENCODING_ULAW 382mu-law encoding, 8 bits/sample 383.It Dv AUDIO_ENCODING_ALAW 384A-law encoding, 8 bits/sample 385.It Dv AUDIO_ENCODING_SLINEAR 386two's complement signed linear encoding with the platform byte order 387.It Dv AUDIO_ENCODING_ULINEAR 388unsigned linear encoding with the platform byte order 389.It Dv AUDIO_ENCODING_ADPCM 390ADPCM encoding, 8 bits/sample 391.It Dv AUDIO_ENCODING_SLINEAR_LE 392two's complement signed linear encoding with little endian byte order 393.It Dv AUDIO_ENCODING_SLINEAR_BE 394two's complement signed linear encoding with big endian byte order 395.It Dv AUDIO_ENCODING_ULINEAR_LE 396unsigned linear encoding with little endian byte order 397.It Dv AUDIO_ENCODING_ULINEAR_BE 398unsigned linear encoding with big endian byte order 399.El 400.Pp 401The 402.Va gain , 403.Va port 404and 405.Va balance 406settings provide simple shortcuts to the richer mixer 407interface described below and are not obtained by 408.Dv AUDIO_GETBUFINFO . 409The gain should be in the range 410.Bq Dv AUDIO_MIN_GAIN , Dv AUDIO_MAX_GAIN 411and the balance in the range 412.Bq Dv AUDIO_LEFT_BALANCE , Dv AUDIO_RIGHT_BALANCE 413with the normal setting at 414.Dv AUDIO_MID_BALANCE . 415.Pp 416The input port should be a combination of: 417.Pp 418.Bl -tag -width AUDIO_MICROPHONE -compact 419.It Dv AUDIO_MICROPHONE 420to select microphone input. 421.It Dv AUDIO_LINE_IN 422to select line input. 423.It Dv AUDIO_CD 424to select CD input. 425.El 426.Pp 427The output port should be a combination of: 428.Pp 429.Bl -tag -width AUDIO_HEADPHONE -compact 430.It Dv AUDIO_SPEAKER 431to select speaker output. 432.It Dv AUDIO_HEADPHONE 433to select headphone output. 434.It Dv AUDIO_LINE_OUT 435to select line output. 436.El 437.Pp 438The available ports can be found in 439.Va avail_ports 440.Dv ( AUDIO_GETBUFINFO 441only). 442.Pp 443.Va buffer_size 444is the total size of the audio buffer. 445The buffer size divided by the 446.Va blocksize 447gives the maximum value for 448.Va hiwat . 449Currently the 450.Va buffer_size 451can only be read and not set. 452.Pp 453The 454.Va seek 455and 456.Va samples 457fields are only used by 458.Dv AUDIO_GETINFO 459and 460.Dv AUDIO_GETBUFINFO . 461.Va seek 462represents the count of 463samples pending; 464.Va samples 465represents the total number of bytes recorded or played, less those 466that were dropped due to inadequate consumption/production rates. 467.Pp 468.Va pause 469returns the current pause/unpause state for recording or playback. 470For 471.Dv AUDIO_SETINFO , 472if the pause value is specified it will either pause 473or unpause the particular direction. 474.El 475.Sh MIXER DEVICE 476The mixer device, 477.Pa /dev/mixer , 478may be manipulated with 479.Xr ioctl 2 480but does not support 481.Xr read 2 482or 483.Xr write 2 . 484It supports the following 485.Xr ioctl 2 486commands: 487.Bl -tag -width indent 488.It Dv AUDIO_GETDEV (audio_device_t) 489This command is the same as described above for the sampling devices. 490.It Dv AUDIO_MIXER_READ (mixer_ctrl_t) 491.It Dv AUDIO_MIXER_WRITE (mixer_ctrl_t) 492These commands read the current mixer state or set new mixer state for 493the specified device 494.Va dev . 495.Va type 496identifies which type of value is supplied in the 497.Va mixer_ctrl_t 498argument. 499.Bd -literal 500#define AUDIO_MIXER_CLASS 0 501#define AUDIO_MIXER_ENUM 1 502#define AUDIO_MIXER_SET 2 503#define AUDIO_MIXER_VALUE 3 504typedef struct mixer_ctrl { 505 int dev; /* input: nth device */ 506 int type; 507 union { 508 int ord; /* enum */ 509 int mask; /* set */ 510 mixer_level_t value; /* value */ 511 } un; 512} mixer_ctrl_t; 513 514#define AUDIO_MIN_GAIN 0 515#define AUDIO_MAX_GAIN 255 516typedef struct mixer_level { 517 int num_channels; 518 u_char level[8]; /* [num_channels] */ 519} mixer_level_t; 520#define AUDIO_MIXER_LEVEL_MONO 0 521#define AUDIO_MIXER_LEVEL_LEFT 0 522#define AUDIO_MIXER_LEVEL_RIGHT 1 523.Ed 524.Pp 525For a mixer value, the 526.Va value 527field specifies both the number of channels and the values for each 528channel. 529If the channel count does not match the current channel count, the 530attempt to change the setting may fail (depending on the hardware 531device driver implementation). 532For an enumeration value, the 533.Va ord 534field should be set to one of the possible values as returned by a prior 535.Dv AUDIO_MIXER_DEVINFO 536command. 537The type 538.Dv AUDIO_MIXER_CLASS 539is only used for classifying particular mixer device 540types and is not used for 541.Dv AUDIO_MIXER_READ 542or 543.Dv AUDIO_MIXER_WRITE . 544.It Dv AUDIO_MIXER_DEVINFO (mixer_devinfo_t) 545This command is used iteratively to fetch audio mixer device information 546into the input/output mixer_devinfo_t argument. 547To query all the supported devices, start with an index field of 5480 and continue with successive devices (1, 2, ...) until the 549command returns an error. 550.Bd -literal 551typedef struct mixer_devinfo { 552 int index; /* input: nth mixer device */ 553 audio_mixer_name_t label; 554 int type; 555 int mixer_class; 556 int next, prev; 557#define AUDIO_MIXER_LAST -1 558 union { 559 struct audio_mixer_enum { 560 int num_mem; 561 struct { 562 audio_mixer_name_t label; 563 int ord; 564 } member[32]; 565 } e; 566 struct audio_mixer_set { 567 int num_mem; 568 struct { 569 audio_mixer_name_t label; 570 int mask; 571 } member[32]; 572 } s; 573 struct audio_mixer_value { 574 audio_mixer_name_t units; 575 int num_channels; 576 int delta; 577 } v; 578 } un; 579} mixer_devinfo_t; 580.Ed 581.Pp 582The 583.Va label 584field identifies the name of this particular mixer control. 585The 586.Va index 587field may be used as the 588.Va dev 589field in 590.Dv AUDIO_MIXER_READ 591and 592.Dv AUDIO_MIXER_WRITE 593commands. 594The 595.Va type 596field identifies the type of this mixer control. 597Enumeration types are typically used for on/off style controls (e.g. a 598mute control) or for input/output device selection (e.g. select 599recording input source from CD, line in, or microphone). 600Set types are similar to enumeration types but any combination 601of the mask bits can be used. 602.Pp 603The 604.Va mixer_class 605field identifies what class of control this is. 606The 607.Pq arbitrary 608value set by the hardware driver may be determined by examining the 609.Va mixer_class 610field of the class itself, 611a mixer of type 612.Dv AUDIO_MIXER_CLASS . 613For example, a mixer controlling the input gain on the line in circuit 614would have a 615.Va mixer_class 616that matches an input class device with the name 617.Dq inputs 618.Dv ( AudioCinputs ) , 619and would have a 620.Va label 621of 622.Dq line 623.Dv ( AudioNline ) . 624Mixer controls which control audio circuitry for a particular audio 625source (e.g. line-in, CD in, DAC output) are collected under the input class, 626while those which control all audio sources (e.g. master volume, 627equalization controls) are under the output class. 628Hardware devices capable of recording typically also have a record class, 629for controls that only affect recording, 630and also a monitor class. 631.Pp 632The 633.Va next 634and 635.Va prev 636may be used by the hardware device driver to provide hints for the next 637and previous devices in a related set (for example, the line in level 638control would have the line in mute as its 639.Dq next 640value). 641If there is no relevant next or previous value, 642.Dv AUDIO_MIXER_LAST 643is specified. 644.Pp 645For 646.Dv AUDIO_MIXER_ENUM 647mixer control types, 648the enumeration values and their corresponding names are filled in. 649For example, a mute control would return appropriate values paired with 650.Dv AudioNon 651and 652.Dv AudioNoff . 653For 654.Dv AUDIO_MIXER_VALUE 655and 656.Dv AUDIO_MIXER_SET 657mixer control types, the channel count is 658returned; the units name specifies what the level controls (typical 659values are 660.Dv AudioNvolume , 661.Dv AudioNtreble , 662.Dv AudioNbass ) . 663.\" For AUDIO_MIXER_SET mixer control types, what is what? 664.El 665.Pp 666By convention, all the mixer devices can be distinguished from other 667mixer controls because they use a name from one of the 668.Dv AudioC* 669string values. 670.Sh FILES 671.Bl -tag -width /dev/audioctl -compact 672.It Pa /dev/audio 673.It Pa /dev/audioctl 674.It Pa /dev/sound 675.It Pa /dev/mixer 676.El 677.Sh SEE ALSO 678.Xr audioctl 1 , 679.Xr mixerctl 1 , 680.Xr ioctl 2 , 681.Xr ossaudio 3 , 682.Xr midi 4 , 683.Xr radio 4 684.Ss ISA bus 685.Xr aria 4 , 686.Xr ess 4 , 687.Xr gus 4 , 688.Xr guspnp 4 , 689.Xr pas 4 , 690.Xr sb 4 , 691.Xr wss 4 , 692.Xr ym 4 693.Ss PCI bus 694.Xr auacer 4 , 695.Xr auich 4 , 696.Xr auixp 4 , 697.Xr autri 4 , 698.Xr auvia 4 , 699.Xr azalia 4 , 700.Xr clcs 4 , 701.Xr clct 4 , 702.Xr cmpci 4 , 703.Xr eap 4 , 704.Xr emuxki 4 , 705.Xr esa 4 , 706.Xr esm 4 , 707.Xr eso 4 , 708.Xr fms 4 , 709.Xr neo 4 , 710.Xr sv 4 , 711.Xr yds 4 712.Ss TURBOchannel 713.Xr bba 4 714.Ss USB 715.Xr uaudio 4 716.Sh BUGS 717If the device is used in 718.Xr mmap 2 719it is currently always mapped for writing (playing) due to 720VM system weirdness. 721