# DSP_PlayShutterSound

## Syntax

    BOOL DSP_PlayShutterSound(const void *src, u32 len);

## Arguments

src

Wave format shutter sound data.
You can only specify the 32730-Hz and 47610-Hz data below the `$TwlSDK/data/shutter_sound` and `$TwlSDK/data/videorec_sound` directories. The sampling rate must match the I2S operating frequency obtained with the `SNDEX_GetI2SFrequency` function.
The specified buffer has the same restrictions as a 16-bit DMA transfer. See Note below for more details.

len | Byte size of the wave data.

## Return Values

Returns `FALSE` if the specified shutter sound does not match the I2S operating frequency or if invalid data has been specified.

## Description

Plays the shutter sound from the DSP.
Playing the sound specified by this function has priority over all other sound output. Internally it is exclusively controlled as follows.

- Before playback, the `SNDEX_GetI2SFrequency` function is called to confirm that the sample rate of the shutter sound matches the I2S operating frequency, and then playback is set so that only DSP sound plays from the speaker. After playback, the original setting is restored.
- The `DSP_PlaySound` function is ignored if it is called during play.
- During the playback process, if a `SNDEX` function runs, it returns `SNDEX_RESULT_EXCLUSIVE` and does nothing until playback ends. (There are some exceptions, however.)

This function can be used if any of the DSP components have been loaded.

This function performs preprocessing using the SNDEX library.
Thus, depending on how the program is written, the preprocessing may in some cases fail because of exclusive control of the SNDEX library.
If preprocessing fails, this function retries until it succeeds.
The `OS_Sleep` function is called from inside the retry process.
To always play the shutter sound without performing this internal retry process, you need to use the method below to eliminate the possibility of preprocess failure.

- Use the `OS_LockMutex` function to run this function exclusively so that there is no overlap with processes of other SNDEX functions.

## Notes

- The specified buffers must all satisfy the same conditions as 16-bit DMA transfers.
  - Addresses must be 16-bit aligned.
  - The buffer content must be cached in advance.
- While the shutter sound is being played, an IIR filter that has been set by `SNDEX_SetIirFilter[Async]` is disabled.
- Use the `DSP_IsShutterSoundPlaying` function to determine whether playback of the shutter sound has completed.

## See Also

`DSP_IsShutterSoundPlaying`
`DSP_LoadG711`

## Revision History

2009/09/02 Deleted a note stating that this cannot be used together with other component features.
2009/07/16 Added an explanation about using this together with other component features.
2009/01/07 Changed descriptions to say that internal function processing retries until the shutter sound is played successfully.
2008/11/26 Deleted the stereo and monaural specifications.
2008/11/14 Added a description of the kinds of shutter sounds that can be specified.
2008/11/07 Mentioned that SNDEX functions cannot be used during shutter sound playback, and added information for correctly playing the shutter sound.
2008/10/23 Added a description about the function to use to wait for shutter sound playback to end.
2008/09/26 Mentioned that IIR filters are disabled during shutter sound playback.
2008/09/25 Mentioned that sound output is controlled exclusively.
2008/07/09 Changed the size accepted as an argument from half-words to bytes.
2008/06/24 Initial version.

CONFIDENTIAL