---
name: "YSHMCloseSound"
section: "3"
platform: "linux"
package: "liby-dev"
version: "2.14.5-7"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/YSHMCloseSound"
---

# YSHMCloseSound(3)

shared sound buffer closing

## NAME

YSHMCloseSound - shared sound buffer closing

## SYNTAX

\#include \<Y2/Y.h\>\
 \#include \<Y2/Ylib.h\>

void YSHMCloseSound(\
\
         YConnection \**connection*,\
\
         void \**ptr*\
 )

## ARGUMENTS

- *connection*

  Specifies the connection to the Y server, obtained by a call to YOpenConnection.

- *ptr*

  Specifies the pointer to the sound buffer on the Y server that was obtained by a call to YSHMOpenSound.

## DESCRIPTION

The YSHMCloseSound closes a direct pointer to the sound buffer on the Y server. The pointer *ptr* must have been obtained by a prior call to YSHMOpenSound.

If you receive a YSHMSound event with the minor\_op\_code set to YSHMSoundClose then the pointer to the sound buffer obtained from YSHMOpenSound is no longer referenced by the Y server and is now useless. You need to reopen the buffer by calling YSHMCloseSound and then YSHMOpenSound to reobtain the direct pointer to the sound buffer on the Y server.

The process of the client and the server must both be running on the same physical machine.

## EXAMPLE

\#include \<stdio.h\>\
 \#include \<Y2/Y.h\>\
 \#include \<Y2/Ylib.h\>

int main(int argc, char \*argv\[\])\
 {\
\
         int length, id;\
\
         void \*buf;\
\
         YConnection \*con = YOpenConnection(\
\
                 "/usr/sbin/starty",\
\
                 "127.0.0.1:9433"\
\
         );\
\
         if(con == NULL)\
\
                 [return(1)](/return/1.md);

        /\* Obtain the pointer to the sound buffer. \*/\
\
         buf = YSHMOpenSound(con, &length, &id);\
\
         if(buf != NULL)\
\
         {\
\
                 /\* Do something with the buffer here. \*/

                /\* Close the pointer to the sound buffer. \*/\
\
                 YSHMCloseSound(con, buf);\
\
         }

        YCloseConnection(con, False);

        return(0);\
 }

## SEE ALSO

[YSHMOpenSound(3)](/YSHMOpenSound/3.md) [YEventYSHMSound(3)](/YEventYSHMSound/3.md)
