Electronic device and method for controlling buffer

According to certain embodiments, an electronic device comprises a communication circuit, a memory including a buffer configured to store audio data received from an external electronic device via the communication circuit, an audio output circuit, and a processor electrically connected to the communication circuit, the memory, and the audio output circuit.

CROSS-REFERENCE TO RELATED APPLICATION(S)

This application is based on and claims priority under 35 U.S.C. § 119 to Korean Patent Application No. 10-2020-0015956, filed on Feb. 10, 2020, in the Korean Intellectual Property Office, the disclosure of which is incorporated by reference herein in its entirety.

BACKGROUND

Field

Certain embodiments relate to an electronic device and method for controlling a buffer of a wireless communication device.

Description of Related Art

Users may access a variety of media while carrying electronic devices. These electronic devices may be connected to external devices by using wireless network technologies that provide extended functions.

SUMMARY

According to certain embodiments, an electronic device comprises a communication circuit, a memory including a buffer configured to store audio data received from an external electronic device via the communication circuit, an audio output circuit, and a processor electrically connected to the25communication circuit, the memory, and the audio output circuit, wherein the processor is configured to: control the communication circuit to connect to the external electronic device with a first communication scheme; process pulse code modulation (PCM) samples obtained by decoding audio data output from the buffer with a first number of PCM samples, and control the audio output circuit to output the PCM samples which are processed, with the first number of PCM samples; in response to receiving a request for adjusting a size of the buffer from the external electronic device, change a processing number of PCM samples from the first number of PCM samples to a second number of PCM samples; in response to the change in the processing number of PCM samples to the second number of PCM samples, process PCM samples obtained by decoding the audio data output from the buffer, with the second number of PCM samples while the size of the buffer is adjusted, and control the audio output circuit to output the PCM samples which are processed with the second number of PCM samples; and when the size of the buffer being adjusted reaches a designated buffer size, process PCM samples obtained by decoding the audio data output from the buffer, with the first number of PCM samples, and control the audio output circuit to output the PCM samples which are processed with the first number of PCM samples.

According to certain embodiments, an electronic device, comprises a communication circuit; a memory; an audio processing circuit; and a processor electrically connected to the communication circuit, the memory, and the audio processing circuit, wherein the processor is configured to: control the communication circuit to connect to an external electronic device using a first communication scheme; control the audio processing circuit to process pulse code modulation (PCM) samples for an audio source with the first number of the PCM samples; control the communication circuit to transmit, to the external electronic device, audio data which is generated by encoding PCM samples which are processed with the first number of PCM samples; in response to identifying occurrence of an event for controlling a buffer of the external electronic device, control the audio processing circuit to process the PCM samples for the audio source with a second number of PCM samples; control the communication circuit to transmit, to the external electronic device, audio data which is generated by encoding PCM samples which are processed with the second number of PCM samples; and when identifying that a size of the buffer of the external electronic device being adjusted reaches a designated buffer size, control the communication circuit to transmit, to the external electronic device, audio data which is generated by encoding PCM samples which are processed with the first number of PCM samples.

According to certain embodiments, a method for controlling a buffer in an electronic device comprises: connecting to an external electronic device using a first communication scheme; storing audio data received from the external electronic device in a buffer; processing pulse code modulation (PCM) samples with a first number of the PCM samples, and outputting the PCM samples which are processed with the first number, the PCM samples are obtained by decoding audio data output from the buffer; in response to receiving a request for adjusting a size of the buffer from the external electronic device, changing a processing number of PCM samples from the first number of PCM samples to a second number of PCM samples; in response to the change in the processing number of PCM samples to the second number of PCM samples, processing PCM samples which are obtained by decoding audio data outputted from the buffer with the second number of PCM samples while the size of the buffer is adjusted, and outputting the PCM samples which are processed with the second number of PCM samples; and when the size of the buffer being adjusted reaches a designated buffer size, processing PCM samples which are obtained by decoding audio data outputted from the buffer with the first number of PCM samples, and outputting the PCM samples which are processed with the first number of PCM samples.

DETAILED DESCRIPTION

Electronic devices may use a Bluetooth network technology as one of a variety of wireless network interfaces. The Bluetooth network technology may include a Bluetooth legacy (or classic) network technology or a Bluetooth low energy (BLE) network, and may include a topology of various connection forms such as a piconet and a scatternet. External wireless communication devices may be wirelessly connected to electronic devices using such Bluetooth technology. Audio data for contents that are played (or reproduced) in the electronic devices may be transmitted to the external wireless communication devices. The audio data may be processed in the external wireless communication devices and be outputted to users.

In a case that audio data is processed in an electronic device which is based on a Bluetooth technology, a buffer size of the electronic device is fixed. Accordingly, if the buffer size of the electronic device is large, latency is high, so delay may occur when audio data for contents such as a live event is processed.

If the size of the buffer of the electronic device is small, the latency is small, but sound interruption may occur frequently when users listen to contents such as music. Even if the size of the buffer is changed to an appropriate size depending on a used scenario, a mute state may temporarily occur while the size of the buffer is reset.

An electronic device and method for controlling a buffer of a wireless communication device as described in this document may alleviate the foregoing problem.

Hereinafter, an electronic device according to certain embodiments will be described with reference to the accompanying drawings.

The electronic device101may use a Bluetooth network technology as one of a variety of wireless network interfaces to wirelessly connect to external electronic devices, such as external electronic device102. The electronic device100may transmit audio data to the external electronic device102.

When audio data is processed in electronic device101based on Bluetooth technology, a buffer size of the electronic device in the memory130can be fixed. Accordingly, if the buffer size of the electronic device is large, latency is high, so delay may occur when audio data for contents such as a live event is processed. If the size of the buffer of the electronic device is small, the latency is small, but sound interruption may occur frequently when users listen to contents such as music. When the size of the buffer is changed to an appropriate size depending, a mute state may be avoided while the size of the buffer is reset.FIG.2is a diagram illustrating an example of a structure of an electronic device and an external electronic device according to an embodiment.

Referring toFIGS.1and2, an external electronic device102according to an embodiment may communicate with an electronic device101with a first communication scheme (e.g., a Bluetooth communication). For example, the external electronic device102may be an accessory device such as an earphone or an ear bud. For example, the electronic device101and the external electronic device102may be configured as an audio source device and an audio sink device, respectively.

For example, the external electronic device102may be configured to include a primary device102aand a secondary device that are physically separated from each other, but communicate with each other. The primary device102aand the secondary device102bmay communicate with each other by using the first communication scheme. As another example, the external electronic device102may be configured as a single device without being divided into the primary device102aand the secondary device102b. For example, the primary device102amay be a right ear bud and the secondary device102bmay be a left ear bud.

The primary device102aof the external electronic device102may include a memory201a, a communication circuit203a, a processor205a, a sensor circuit207a, an audio output circuit209a(e.g., speaker), and a battery211a. The secondary device102bof the external electronic device102may include a memory201b, a communication circuit203b, a processor205b, a sensor circuit207b, an audio output circuit209b(e.g., speaker), and a battery211b. The primary device102aand the secondary device102bof the external electronic device102may store address information of each other, and may be connected to each other by using the stored address information.

The primary device102aand the secondary device102bmay be configured as a device which performs a master role and a device which performs a slave role, respectively. The primary device102amay perform the master role according to a communication between the primary device102aand the secondary devices102b. The primary device102amay transmit a data packet received from the electronic device101to the secondary device102b. The secondary device102bmay perform the slave role according to the communication, and may receive the data packet from the primary device102a. In an example, the secondary device102bmay receive a data packet from the electronic device101and then transmit the data packet to the primary device102a. The packet data may include audio data and/or related information for processing the audio data. The primary device102amay be synchronized with the secondary device102bto process the audio data. In certain embodiments, the audio data can include presentation time stamps indicating the time that the audio data should be converted to sound. For another example, according to a subject connected to the electronic device101, the primary device102amay be configured as a device which performs the slave role, and the secondary device102bmay be configured as a primary device which performs the master role.

When the external electronic device102is configured as a single device without being divided into the primary device102aand the secondary device102b, the external electronic device102may include the same components as the memory201a, the communication circuit203a, the processor205a, the sensor circuit207a, the audio output circuit209a, and the battery211aincluded in the primary device102a.

The external electronic device102may connect the primary device102ato the electronic device101via, for example, the first communication scheme, and the primary device102amay transmit, to the secondary device102b, audio data and related information for processing the audio data which are received by the electronic device101. The secondary device102bmay process the same operation as the primary device102aas the secondary device102breceives, from the primary device102a, the received audio data and related information for processing the audio data.

If the primary device102areceives a request for adjusting a buffer size from the electronic device101, the primary device102amay transmit related information to the secondary device102bso that the primary device102ais synchronized with a buffer of the secondary device102band adjust the buffer size. For another example, the external electronic device102may communicate with the electronic device101by using the first communication scheme via the secondary device102b, and the secondary device102bmay transmit, to the primary device102a, audio data and related information for processing the audio data which are received by the electronic device101.

For still another example, the external electronic device102may communicate with the electronic device101via both the primary device102aand the secondary device102b. For example, the primary device102amay communicate with the electronic device101via the first communication scheme. The secondary device102bmay receive or monitor audio data and related information for processing the audio data which are transmitted and received between the primary device102aand the electronic device101based on information about the first communication scheme which is received from the primary device102a.

For example, the received information about the first communication scheme may include address information or clock information of the electronic device101. The secondary device102bmay receive the same data packet as a data packet received by the primary device102avia monitoring. A monitoring operation may be referred to as shadowing, listening, or snooping. The secondary device102bmay receive the information about the first communication scheme via various schemes other than a scheme of receiving the information about the first communication scheme from the primary device102a. For example, the secondary device102bmay receive, from an external server (not shown), the information about the first communication scheme stored in the external server (not shown). For another example, the secondary device102bmay receive, via the external server, the information about the first communication scheme transferred (or shared) from the primary device102a.

The memories201aand201bof the external electronic device102may store at least one of audio contents which are stored by a user and a user profile, device information, device information of the external electronic device, and counterpart earphone information. The memories201aand201bmay be configured to include a buffer (not shown) which temporarily stores audio data received from the electronic device101.

In certain embodiments, the electronic device101can receive audio data. The audio data can include a transport stream in accordance with the Motion Picture Experts Group (MPEG) standard. The transport stream can include fixed packets of packetized elementary stream. The packetized elementary stream can include audio data compressed using Inverse Modification Discreet Cosine Transformation (IMDCT). The primary102aand secondary devices102bcan decode the audio data resulting in a time based analog signal. The analog signal can be digitized using Pulse Code Modulation samples at different numbers of samples per second. That is, one second of the analog signal can be represented by different numbers of a PCM samples, based on the digitization rate.

The communication circuits203aand203bof the external electronic device102may communicate with an external electronic device (e.g., the electronic device101) via a short-range wireless communication (e.g., Bluetooth (BT) or Wi-Fi), and may be configured to include an antenna for the short-range wireless communication.

The processors205aand205bof the external electronic device102may control the communication circuits203aand203bto connect to the electronic device101with the first communication scheme (e.g., Bluetooth (BT)), The processors205aand205bcan decode audio data received via buffers of the memories201aand201b, thereby resulting in PCM samples. The PCM modulation samples can digitize the audio content using a particular rate having a particular number of samples per second. The processors205a,205bcan cause audio output circuits209aand209bto output sound from the processed PCM samples.

The processors205aand205bmay change a processing number of PCM samples from the first number of PCM samples to a second number of PCM samples in response to receiving a request for adjusting a size of the buffer from the electronic device101. The processors205aand205bcan process the PCM samples which are obtained by decoding the audio data received via the buffer with the second number of PCM samples while the size of the buffer is adjusted, and control the audio output circuits209aand209bto output PCM samples that digitize the sound signals at the second number of PCM samples.

When the size of the buffer being adjusted reaches a designated buffer size, the processors205aand205bmay process PCM samples which are obtained by decoding audio data received via the buffer of the designated buffer size with the first number of PCM samples, and control the audio output circuits209aand209bto output PCM samples which are processed with the first number of PCM samples.

The sensor modules207aand207bof the external electronic device102may be configured to include at least one of a motion sensor (e.g., an acceleration sensor, and a gyro sensor), a proximity sensor, or a biometric sensor (e.g., including an optical sensor and an electrode). The sensor modules207aand207bmay include various other sensors as well.

The audio output circuits209aand209bof the external electronic device102may be configured to output PCM samples of audio data processed by the processors205aand205bvia a speaker so that the user may hear the audio data received from the external electronic device101.

The batteries211aand211bof the external electronic device102may supply power to at least one component of the external electronic device102. According to an embodiment, the batteries211aand211bmay include, for example, a non-rechargeable primary battery, a rechargeable secondary battery, or a fuel battery.

FIG.3is a diagram illustrating an example of a structure of an electronic device and an external electronic device according to an embodiment.

The external electronic device102receives audio data from the electronic device101. The audio data can include audio data compressed in accordance with the MPEG standard. The audio data is received in a buffer301. The decoder decodes the audio data and provides the decoded audio data to a PCM sample module311. The PCM sampling module311digitizes the decoded audio signal at a particular sampling rate. The correction module313corrects PCM samples so that the pitch is maintained.

A structure of an external electronic device102to be described with reference toFIG.3will be described based on a primary device (e.g., a primary device102ainFIG.2), and a secondary device of the external electronic device102(e.g., a secondary device102binFIG.2) may be configured to include the same components as the primary device, and may perform the same operations as the primary device. For another example, even if the external electronic device102is configured as a single device without being divided into the primary device and the secondary device, the external electronic device102may be configured to include the same components as the primary device and may perform the same operations as the primary device.

Referring toFIG.3, the external electronic device102(e.g., the primary device102aor the secondary device102binFIG.2) according to an embodiment may be configured to include a buffer301, a decoder303, and a pulse code modulation (PCM) processing module305. The PCM processing module305may be configured to include a PCM sample control module311and a correction module313. The PCM processing module305may be configured as a separate component which is included in a processor205ainFIG.2or controlled by the processor205a.

According to an embodiment, the external electronic device102may control to temporarily store audio data which is received from the electronic device101via a communication circuit (e.g., a communication circuit203ainFIG.2) in a buffer301of a memory (e.g., a memory201ainFIG.2). The external electronic device102may decode the audio data stored in the buffer301by using the decoder303, and process PCM samples of decoded audio data outputted from the decoder303via the PCM processing module305. Upon receiving audio data while a buffer size of the buffer301is set to a first buffer size, the external electronic device102may process PCM samples of audio data which is received from the buffer301of the first buffer size and then decoded with a first number of PCM samples via the PCM processing module305, and control an audio output circuit (e.g., an audio output circuit209ainFIG.2) to output PCM samples which are processed with the first number of PCM samples.

According to an embodiment, when receiving a request for adjusting the size of the buffer301from the electronic device101, the external electronic device102may perform operations for adjusting the size of the buffer301based on information related to a buffer size received from the electronic device101. For example, the external electronic device102may receive the information related to the buffer size from the electronic device101and identify a designated buffer size based on the received information related to the buffer size. The information related to the buffer size may include at least one of information about the designated buffer size, information about a type of an application run on the external electronic device102, or information about communication quality. For example, the external electronic device102may directly detect communication quality of a communication between the electronic device101and the external electronic device102, and may identify the designated buffer size based on information related to the directly detected communication quality.

According to an embodiment, the external electronic device102may change a processing number of PCM samples from a first number of PCM samples to a second number of PCM samples in response to the request for adjusting the size of the buffer301from the electronic device101. The second number of PCM samples may be a number which is increased than the first number of PCM samples so as to increase the size of the buffer301, or a number which is decreased than the first number of PCM samples so as to decrease the size of the buffer301. In an embodiment, when the primary device102aof the external electronic device102receives the request for adjusting the size of the buffer301from the electronic device101, the primary device102aof the external electronic device102may transmit, to the secondary device102b, the information about the designated buffer size and information about the second number of PCM samples which is changed for the primary device102ato be synchronized with a buffer of the secondary device102bof the external electronic device102and adjust the size of the buffer301, and the information about the designated buffer size to the secondary device102b. In response to the change in the processing number of PCM samples to the second number of PCM samples, the external electronic device102may change a processing number of PCM samples for processing PCM samples which are obtained by decoding audio data received from the buffer301while the size of the buffer is adjusted to the second number of PCM samples, process the obtained PCM samples with the changed second number of PCM samples via the PCM processing module305, and control the audio output circuit (e.g., the audio output circuit209ainFIG.2) to output processed PCM samples.

According to an embodiment, when the size of the buffer301being adjusted reaches the designated buffer size, the external electronic device102may change the processing number of PCM samples from the second number of PCM samples back to the first number of PCM samples, process PCM samples which are obtained by decoding audio data received via the buffer301with the first number of PCM samples, and control the audio output circuit (e.g., the audio output circuit209ainFIG.2) to output PCM samples which are processed with the first number of PCM samples. The size of the buffer301may be gradually or stepwise adjusted (e.g., increased or decreased) from a previous buffer size (e.g., a first buffer size) until the size of the buffer301reaches the designated buffer size (e.g., a second buffer size) corresponding to a fact that the PCM samples are processed with the second number of PCM samples). For example, the request for adjusting the size of the buffer301may be received via a request message of a message format message (or a packet) according to the first communication scheme. The request message may include, for example, control information indicating a decrease or increase to a buffer size which is designated according to contents (or an application) executed in the electronic device101. The request message may include, for example, information (e.g., a type of the contents (or the application)) related to the contents (or the application) executed in the electronic device101. The request message may include, for example, information about a buffer size which is directly designated by the user via a menu displayed on a display of the electronic device101.

According to an embodiment, the external electronic device102may correct the PCM samples which are processed with the second number of PCM samples so that a pitch is maintained.

According to an embodiment, the primary device (PE)(e.g., the primary device102ainFIG.2) of the external electronic device102may synchronize a buffer of the primary device with a buffer of the secondary device (SE)(e.g., the secondary device102binFIG.2) while the size of the buffer301is adjusted. For example, upon receiving a buffer size adjustment request from the electronic device101, the primary device may transmit information related to buffer size adjustment to the secondary device. As the secondary device transmits a response to the request to the primary device, the primary device and the secondary device may adjust the size of the buffer301so that the size of the buffer301is changed to a designated buffer size while processing PCM samples with the changed processing number of PCM samples (e.g., the second number of PCM samples). When the size of the buffer301being adjusted reaches the designated buffer size and the change is completed, the primary device and the secondary device may exchange state information with each other and process PCM samples with the first number of PCM samples at the same time. For example, when the buffer size change is completed, the primary device and the secondary device may identify that the change in the buffer size is completed without exchanging buffer size change completion information and process PCM samples with the first number of PCM samples.

According to an embodiment, the external electronic device102may process, differently for each of types of applications, operations for adjusting a processing number of PCM samples which are processed via the PCM sample processing module305and adjusting the buffer size. For example, a change in the buffer size in a case of playing a game may be performed faster than a change in the buffer size in a case of playing music. Accordingly, for the game, the external electronic device102may adjust a number of PCM samples from the first number of PCM samples to the second number of PCM samples (a number which is decreased from the first number of PCM samples), and adjust the buffer size to a second buffer size (e.g., 100 ms). As described above, in an embodiment, major components of the external electronic device102have been described with reference to the external electronic device102inFIGS.2and3. However, in certain embodiments, not all of the components shown inFIGS.2and3are essential components, and the external electronic device102(e.g., the primary device102aor the secondary device102b) may be implemented by more components or fewer components than the components shown inFIGS.2and3. In addition, a location of each of the major components of the external electronic device102described above with reference toFIGS.2and3may be changed according to certain embodiments.

FIG.4is a diagram illustrating an example of a structure of an electronic device and an external electronic device according to another embodiment.

Referring toFIGS.1and4, an electronic device101according to another embodiment may be configured to include a PCM processing module401which processes PCM samples of an audio signal (an audio source) and an encoder403which encodes processed PCM samples as components for controlling a buffer421(e.g., a buffer301inFIG.3) of an external electronic device102. The PCM processing module401and the encoder403may be configured as a separate component which is included in a processor (e.g., a processor120inFIG.1) of the electronic device101or which is controlled by the processor. In certain embodiments, the encoder can comprises a hardware accelerator or a Application Specific Integrated Circuit (ASIC). The PCM processing module401may be configured to include a PCM sample control module411for changing a processing number of PCM samples for an audio signal (an audio source) based on information related to a size of a buffer421(e.g., a buffer301inFIG.3) of the external electronic device102, and a correction module413for correcting processed PCM samples so that a pitch value of the PCM samples which are processed by the PCM sample control module411is maintained.

The processor of the electronic device101may pre-designate and store the information about the size of the buffer421of the external electronic device102, or receive the information about the size of the buffer421of the external electronic device102from the external electronic device102. Generally speaking, a buffer with less memory can hold audio data representing less time, or can hold audio data where the PCM samples are sampled at a lower sampling rate. In certain embodiments, to avoid buffer overflow, the sampling rate is reduced when the buffer size is reduced. Accordingly, the processor of the electronic device101may identify whether the size of the buffer421is changed based on the information related to the size of the buffer421of the external electronic device102.

According to another embodiment, the processor of the electronic device101may process the PCM samples of the audio signal with a first number of PCM samples via the PCM processing module401, encode the PCM samples of the audio signal via the encoder403, and transmit, to the external electronic device102, audio data for encoded PCM samples to control the external electronic device102to output the audio data. Here, the first number of PCM samples may be a number which is initially set or identified corresponding to buffer size information set in contents (or an application) including the audio signal.

According to another embodiment, the processor of the electronic device101may identify whether the size of the buffer421of the external electronic device102is changed and a changed size of the buffer421based on the information related to the size of the buffer421of the external electronic device102. The processor of the electronic device101may control to change the processing number of PCM samples for the audio signal via the PCM processing module401based on the changed size of the buffer421which is identified based on the information related to the size of the buffer421, and to process PCM samples which are processed with the changed processing number of PCM samples (e.g., a second number of PCM samples). The processor of the electronic device101may control to encode the PCM samples which are processed with the changed processing number of PCM samples (e.g., the second number of PCM samples) via the encoder403, and transmit audio data for the encoded PCM samples to the external electronic device102via a communication circuit (e.g., a communication module190inFIG.1).

According to another embodiment, the processor of the electronic device101may control to correct the processed PCM samples which are processed with the changed processing number of PCM samples (e.g., a second number of PCM samples) via the correction module413so that a pitch value is maintained.

According to another embodiment, the external electronic device102may temporarily store audio data received from the electronic device101in the buffer421(e.g., the buffer301inFIG.3), decode the audio data outputted from the buffer421according to the size of the buffer421via a decoder423(e.g., a decoder303inFIG.3), and output PCM samples of decoded audio data via an audio output circuit (e.g., audio output circuits209aand209binFIG.2).

The electronic device101according to an embodiment and another embodiment may obtain information related to signal strength or communication quality of a communication between the electronic device101and the external electronic devices102when the external electronic device102is connected to the electronic device101. The electronic device101may transmit, to the external electronic device102, information related to the signal strength or the communication quality as information related to a buffer size, and the external electronic device102may identify a designated buffer size which corresponds to the signal strength or the communication quality based on the received information related to the buffer size.

According to an embodiment, the electronic device101may identify the communication quality based on a retransmission rate for a packet transmitted to the external electronic device102, effective channel map information, or RSSI information. For example, if the communication quality is poor, the external electronic device102may not normally receive a packet transmitted by the electronic device101, and thus the external electronic device102may transmit a NACK or may not transmit a response packet. The electronic device101may retransmit the same packet until the external electronic device102normally receives the packet (e.g., until the external electronic device102transmits an ACK). For another example, if a distance between the electronic device101and the external electronic device102increases, received RSSI may be low. The electronic device101may identify that the communication quality is poor if the received RSSI is less than or equal to a designated threshold value. According to an embodiment, if the communication quality is poor, the electronic device101may request to increase the buffer size of the external electronic device102, thereby decreasing occurrence of sound interruption or noise. According to an embodiment, if the communication quality is good, the electronic device102may request to decrease the buffer size of the external electronic device102, thereby outputting audio without latency in a state in which sound quality is not degraded.

The external electronic device102according to one embodiment and another embodiment may directly identify the signal strength or the communication quality of the communication between the electronic device101and the external electronic device102. In this case, the external electronic device102may adjust the size of the buffer to increase or decrease the size of the buffer to the designated buffer size based on information related to a buffer size according to the signal strength or communication quality which is directly identified by the external electronic device102without receiving the information related to the buffer size from the electronic device101.

An electronic device (e.g., an external electronic device102inFIGS.1to3) according to an embodiment may include a communication circuit (e.g., a communication circuit203aor203binFIG.2), a memory (e.g., a memory201aor201binFIG.2) including a buffer (e.g., a buffer301inFIG.3) configured to store audio data received from an external electronic device via the communication circuit, an audio output circuit (e.g., an audio output circuit209aor209binFIG.2), and a processor (e.g., a processor205aor205binFIG.2) electrically connected to the communication circuit, the memory, and the audio output circuit, and the processor may be configured to: control the communication circuit to connect to the external electronic device with a first communication scheme, process pulse code modulation (PCM) samples which are obtained by decoding audio data outputted from the buffer with a first number of PCM samples, and control the audio output circuit to output the PCM samples which are processed with the first number of PCM samples, in response to receiving a request for adjusting a size of the buffer from the external electronic device, change a processing number of the PCM samples from the first number of PCM samples to a second number of PCM samples, in response to the change in the processing number of the PCM samples to the second number of PCM samples, process PCM samples which are obtained by decoding audio data outputted from the buffer with the second number of PCM samples while the size of the buffer is adjusted, and control the audio output circuit to output the PCM samples which are processed with the second number of PCM samples, and when the size of the buffer being adjusted reaches a designated buffer size, process PCM samples which are obtained by decoding audio data outputted from the buffer with the first number of PCM samples, and control the audio output circuit to output the PCM samples which are processed with the first number of PCM samples.

According to an embodiment, the processor (e.g., the processor205aor205binFIG.2) may be further configured to correct the PCM samples which are processed with the second number of PCM samples so that a pitch is maintained.

According to an embodiment, the processor (e.g., the processor205aor205binFIG.2) may be configured to control the communication circuit to transmit information related to a state of the buffer to the external electronic device. The information related to the size of the buffer may include at least one of information about the designated buffer size, information about a type of an application run on the external electronic device, or information about communication quality.

According to an embodiment, the processor (e.g., the processor205aor205binFIG.2) may be configured to control the communication circuit to transmit information related to a state of the buffer to the external electronic device.

According to an embodiment, the first communication scheme may be a Bluetooth communication.

According to an embodiment, the processor (e.g., the processor205aor205binFIG.2) may be further configured to connect to a secondary device via the first communication scheme when the electronic device performs a role of a primary device, transmit the audio data which is received from the external electronic device to the secondary device, and in response to receiving the request for adjusting the size of the buffer, control the communication circuit to transmit information about the changed second number of PCM samples and information about the designated buffer size to the secondary device, and the buffer may be synchronized with a buffer of the secondary device.

An electronic device (e.g., a first electronic device101inFIGS.1and2) according to another embodiment may include a communication circuit (e.g., a communication module190inFIG.1), a memory (e.g., a memory130inFIG.1), an audio processing circuit (a sound output device155inFIG.1), and a processor (e.g., a processor120inFIG.1) electrically connected to the communication circuit, the memory, and the audio processing circuit, and the processor may be configured to: control the communication circuit to connect to an external electronic device with a first communication scheme, control the audio processing circuit to process pulse code modulation (PCM) samples for an audio source with a first number of PCM samples, control the communication circuit to transmit, to the external electronic device, audio data which is generated by encoding PCM samples which are processed with the first number of PCM samples, in response to identifying occurrence of an event for controlling a buffer of the external electronic device, control the audio processing circuit to process the PCM samples for the audio signal with a second number of PCM samples, control the communication circuit to transmit, to the external electronic device, audio data which is generated by encoding PCM samples which are processed with the second number of PCM samples, and when identifying that a size of the buffer of the external electronic device being adjusted reaches a designated buffer size, control the communication circuit to transmit, to the external electronic device, audio data which is generated by encoding PCM samples which are processed with the first number of PCM samples.

According to another embodiment, the processor (e.g., the processor120inFIG.1) may be further configured to correct the PCM samples which are processed with the second number of PCM samples so that a pitch is maintained.

According to another embodiment, the processor (e.g., the processor120inFIG.1) may be further configured to obtain information related to the size of the buffer, and identify the designated buffer size based on the information related to the size of the buffer.

According to another embodiment, the processor (e.g., the processor120inFIG.1) may be configured to identify that the event occurs when contents which generate the audio source are changed.

According to another embodiment, the processor (e.g., the processor120inFIG.1) may be configured to identify that the event occurs when communication quality of the first communication scheme changes.

According to another embodiment, the electronic device may further comprise a display (e.g., a display160inFIG.1), and the processor (e.g., the processor120inFIG.1) may be configured to identify that the event occurs when information related to at least one buffer size which is displayed on the display is selected by a user.

According to another embodiment, the first communication scheme may be a Bluetooth communication.

The operation procedure in the electronic device (e.g., the external electronic device102inFIGS.1to3) as described above will be described in detail with reference to the accompanying drawings.

FIG.5is a diagram illustrating an example of an operation procedure for controlling a buffer in an external electronic device according to an embodiment.

Referring toFIG.5, in operation501, an external electronic device (e.g., an external electronic device102inFIGS.1to3) according to an embodiment may be connected to an electronic device (e.g., an electronic device101inFIGS.1and2) via a first communication scheme (e.g., a Bluetooth communication).

In operation503, the external electronic device may store, in a buffer (e.g., a buffer301inFIG.3), audio data which is received from the electronic device (e.g., the electronic device101inFIGS.1and2) via a communication circuit (e.g., a communication circuit203aor203binFIG.2), and decode the audio data outputted from the buffer. The external electronic device may receive audio data for contents (or an application) executed in the electronic device, and temporarily store the received audio data in the buffer. When the audio data temporarily stored in the buffer whose buffer size is set to a first buffer size (e.g., 100 ms) is outputted from the buffer, the external electronic device may decode the audio data by using a decoder (a decoder303inFIG.3).

In operation505, the external electronic device may process PCM samples of decoded audio data with a set first number of PCM samples by using a PCM processing module (e.g., a PCM processing module305inFIG.3). The external electronic device may output PCM samples (e.g., first PCM samples) which are processed with the first number of PCM samples via an audio output circuit (e.g., audio output circuits209aand209binFIG.2).

In operation507, the external electronic device may identify whether a request (e.g., a request message) for adjusting a buffer size from a first electronic device is received while outputting the PCM samples (e.g., the first PCM samples) which are processed with the first number of PCM samples. If the request (e.g., the request message) for adjusting the buffer size is received, the external electronic device may perform operation509. If the request (e.g., the request message) for adjusting the buffer size is not received, the external electronic device may decode audio data which is continuously outputted from the buffer whose buffer size is set to the first buffer size (e.g., 100 ms) and process PCM samples of decoded audio data with the first number of PCM samples by performing operation503again.

In operation509, in response to receiving the request (e.g., the request message) for adjusting the buffer size from the first electronic device, the external electronic device may identify a designated buffer size based on information related to a buffer size included in the request message, and change the processing number of PCM samples from the first number of PCM samples to a second number of PCM samples. For example, the external electronic device may identify a second buffer size (e.g., 300 ms) which is the designated buffer size, and change the processing number of PCM samples to the second number of PCM samples based on the identified second buffer size.

In operation511, while the buffer size is adjusted by the second buffer size (e.g., 300 ms), the external electronic device may process PCM samples (e.g., second PCM samples) which are obtained by decoding audio data received via the buffer with the second number of PCM samples, and output PCM samples (e.g., second PCM samples) which are processed with the second number of PCM samples via an audio output circuit (e.g., audio output circuits209aand209binFIG.2).

In operation513, the external electronic device may identify whether the buffer size being adjusted reaches the second buffer size (e.g., 300 ms) which is the designated buffer size. If the buffer size being adjusted reaches the second buffer size (e.g., 300 ms), the external electronic device may perform operation515. If the buffer size being adjusted does not reach the second buffer size (e.g., 300 ms), the external electronic device may continuously process the PCM samples of the decoded audio data with the second number of PCM samples by performing operations511to513.

In operation515, the external electronic device may process PCM samples which are obtained by decoding audio data outputted from the buffer whose buffer size is changed to the second buffer size (e.g., 300 ms) with the first number of PCM samples, and output PCM samples (e.g., first PCM samples) which are processed with the first number of PCM samples via the audio output circuit (e.g., the audio output circuits209aand209binFIG.2).

According to another embodiment, when receiving the buffer size adjustment request as in operation507, the external electronic device may perform an operation of gradually or stepwise adjusting the size of the buffer (e.g., the buffer301inFIG.3) until the size of the buffer (e.g., the buffer301inFIG.3) reaches a designated buffer size without performing operations509and513, and process, as in operation515, the PCM samples of the decoded audio data with the first number of PCM samples to output PCM samples which are processed with the first number of PCM samples.

According to still another embodiment, when receiving the buffer size adjustment request as in operation507, the external electronic device may perform an operation of gradually or stepwise adjusting the size of the buffer (e.g., the buffer301inFIG.3) until the size of the buffer (e.g., the buffer301inFIG.3) reaches the designated buffer size without performing operations509and513, and process, as in operation515, the PCM samples of the decoded audio data with a first speed which is a play speed for the decoded audio data to output PCM samples which are processed with the first speed.

FIG.6A-6Care diagrams illustrating an example of an operation procedure for controlling a buffer in an external electronic device according to an embodiment.

According to an embodiment, as shown inFIG.6A, when receiving audio data from an electronic device (e.g., an electronic device101inFIGS.1and2), an external electronic device (e.g., an external electronic device102inFIGS.1to3) may temporarily store the received audio data in a buffer301(e.g., a buffer301inFIG.3) whose buffer size is set to a first buffer size (t1size (e.g., 100 ms)). The external electronic device may decode the audio data outputted from the buffer301via a decoder303(e.g., a decoder303inFIG.3), and process PCM samples (e.g., first PCM samples) of decoded audio data with a first number of PCM samples to output PCM samples which are processed with the first number of PCM samples.

According to an embodiment, as shown inFIG.6B, in response to receiving a request for increasing the size of the buffer301from the electronic device (the electronic device101inFIG.1), the external electronic device may adjust the size of the buffer301by increasing the size of the buffer301so that the size of the buffer301is a designated buffer size (t3size (e.g., 300 ms)). While the size of the buffer301is increased by the designated buffer size (e.g., t3size), the external electronic device may decode the audio data outputted from the buffer301via the decoder303, and process PCM samples (e.g., second PCM samples) of decoded audio data with a changed second number of PCM samples (e.g., a number increased from the first number of PCM samples) to output PCM samples which are processed with the second number of PCM samples via a PCM processing module305(e.g., a PCM processing module305inFIG.3). The PCM processing module305may be configured to include a PCM sample control module311(e.g., a PCM sample control module311inFIG.3) and a correction module313(e.g., a correction module313inFIG.3). The PCM sample control module311may change a processing number for processing PCM samples of audio data which is decoded in the decoder303from the first number of PCM samples to the second number of PCM samples based on the designated buffer size, and process PCM samples (e.g., second PCM samples) with the changed second number of PCM samples. The correction module313may correct PCM samples which are processed with the second number of PCM samples so that a pitch is maintained, and output corrected PCM samples (e.g., second PCM samples) to an audio output circuit (e.g., an audio output circuit209aor209binFIG.2).

According to an embodiment, as shown inFIG.6C, when the size of the buffer301is increased and reaches a second buffer size (e.g., t3size) which is the designated buffer size, the external electronic device may decode the audio data outputted from the buffer301via the decoder303, and process PCM samples (e.g., first PCM samples) of the decoded audio data with the first number of PCM samples to output processed PCM samples which are processed with the first number of PCM samples. As the PCM samples (e.g., the second PCM samples) are processed with the second number of PCM samples, the buffer size may be increased gradually or stepwise until the buffer size reaches the second buffer size.

FIG.7A-7Care diagrams illustrating an example of an operation procedure for controlling a buffer in an external electronic device according to an embodiment.

According to an embodiment, as shown inFIG.7A, when receiving audio data from a first electronic device (e.g., a first electronic device101inFIGS.1and2) which exists outside, an external electronic device (e.g., an external electronic device102inFIGS.1to3) may temporarily store the received audio data in a buffer301(e.g., a buffer301inFIG.3) whose buffer size is set to a first buffer size (t3size (e.g., 300 ms)). The external electronic device may decode the audio data outputted from the buffer301via a decoder303(e.g., a decoder303inFIG.3), and process PCM samples (e.g., first PCM samples) of decoded audio data with a first number of PCM samples to output PCM samples which are processed with the first number of PCM samples.

According to an embodiment, as shown inFIG.7B, in response to receiving a request for decreasing the size of the buffer301to a designated buffer size (t1size (e.g., 100 ms)) from the first electronic device, the external electronic device may adjust the size of the buffer301by decreasing the size of the buffer301so that the size of the buffer301is the designated buffer size (t1size (e.g., 100 ms)). While the size of the buffer301is decreased to the designated buffer size (e.g., t1size), the external electronic device may decode the audio data outputted from the buffer301via the decoder303, and process PCM samples (e.g., second PCM samples) of decoded audio data with a changed second number of PCM samples (e.g., a number decreased from the first number of PCM samples) to output PCM samples which are processed with the second number of PCM samples via a PCM processing module305(e.g., a PCM processing module305inFIG.3). The PCM processing module305may be configured to include a PCM sample control module311(e.g., a PCM sample control module311inFIG.3) and a correction module313(e.g., a correction module313inFIG.3). The PCM sample control module311may change a processing number of PCM samples of audio data which is decoded in the decoder303from the first number of PCM samples to the second number of PCM samples based on the designated buffer size, and process PCM samples (e.g., second PCM samples) with the changed second number of PCM samples. The correction module313may correct PCM samples which are processed with the second number of PCM samples so that a pitch is maintained, and output corrected PCM samples (e.g., second PCM samples) to an audio output circuit (e.g., an audio output circuit209aor209binFIG.2).

According to an embodiment, as shown inFIG.7C, when the size of the buffer301is gradually decreased and reaches the designated buffer size (e.g., t1size), the external electronic device may decode the audio data outputted from the buffer301via the decoder303, and process PCM samples (e.g., first PCM samples) of the decoded audio data with the first number of PCM samples to output processed PCM samples which are processed with the first number of PCM samples. As the PCM samples (e.g., the second PCM samples) are processed with the second number of PCM samples, the buffer size may be decreased gradually or stepwise until the buffer size reaches the second buffer size.

FIG.8is a diagram illustrating an example of an operation procedure for controlling a buffer in an electronic device and an external electronic device according to an embodiment.FIG.9is a diagram illustrating an example of an operation procedure for controlling a buffer in an electronic device and an external electronic device according to an embodiment.

Referring toFIG.8, in operation801, according to an embodiment, an electronic device101(e.g., an electronic device101inFIGS.1and2) may be connected to an external electronic device102(e.g., an external electronic device102inFIGS.1to3) via a first communication scheme (e.g., a Bluetooth communication). For example, the electronic device101may be connected to a primary device (e.g., the secondary device102ainFIG.2) of the external electronic device102to perform a communication with the primary device of the external electronic device102, and the primary device may perform a communication connection with a secondary device (e.g., the secondary device102binFIG.2) of the external electronic device102. The primary device may establish a communication link by transferring information for a communication connection (e.g., information related to a link) to the secondary device and receiving a response. For another example, the external electronic device102may be connected to the secondary device or to all of the primary device and the secondary device.

In operation803, the electronic device101(e.g., the electronic device101inFIGS.1and2) may run a first application (or first contents). For example, as shown inFIG.9, the first application may be an application901which provides music.

In operation805, the electronic device101may transmit audio data for the run first application to the external electronic device102via the first communication scheme (e.g., the Bluetooth communication). Buffer size information which is set in the external electronic device102corresponding to the first application may be a first buffer size (e.g., 300 ms). For example, the secondary device of the external electronic device102may receive audio data by monitoring a communication between the electronic device101and the primary device. For another example, the audio data may be transmitted to the primary device102aof the external electronic device102. The primary device102amay transmit the received audio data to the secondary device102bof the external electronic device102(e.g., the secondary device102binFIG.2) via an established communication link. The primary device may transfer all audio data or some data (e.g., some data which is not transferred) to the secondary device. The primary device may transfer the received audio data according to a request of the secondary device, or may transfer the received audio data after inquiring whether the secondary device receives the received audio data. For another example, the electronic device101may transmit audio data to the secondary device or all of the primary device and the secondary device. In operation807, the external electronic device102may receive audio data (e.g., first audio data) from the electronic device101, temporarily stores the received audio data (e.g., the first audio data) in a buffer (e.g., in a buffer301inFIG.3), and decode the first audio data outputted via the buffer. For example, a buffer size of the buffer may be set to a first buffer size (e.g., 300 ms) before receiving a buffer size adjustment request. For example, when the primary device receives audio data from the electronic device101, the primary device may transfer the audio data to the secondary device. A buffer size of the primary device may be synchronized with a buffer size of the secondary device each other. When the buffer size is adjusted, in order to synchronize with the secondary device, the primary device may perform an operation of exchanging information for synchronization of a buffer size with the secondary device before a start of adjustment of the buffer size, setting a current buffer size to the same buffer size as the secondary device, and starting the adjustment of the buffer size simultaneously with the secondary device and terminating the adjustment of the buffer size simultaneously with the secondary device.

According to an embodiment, based on the audio data received from the electronic device101in operation805, the external electronic device102may obtain at least one of information about a type of a first application run on the electronic device101, information about a designated buffer size, or information related to communication quality as information related to a buffer size. The information related to the buffer size may be obtained periodically or when the audio data is received. For example, the external electronic device102may identify that a currently set buffer size (e.g., a first buffer size) does not need to be changed based on the obtained information related to the buffer size. In operation809, the external electronic device102may process PCM samples of decoded audio data with a set first number of PCM samples. The external electronic device102may output PCM samples (e.g., first PCM samples) processed with the first number of PCM samples via an audio output circuit (e.g., audio output circuits209aand209binFIG.2). In an embodiment, as the primary device of the external electronics102transfers the received audio data (e.g., the first audio data) to the secondary device, the primary device and the secondary device may perform operation809in the same manner.

In operation811, the electronic device101may run a second application while running the first application. For example, as shown inFIG.9, the second application may be an application903which provides a game in which audio needs to be immediately outputted without latency. Buffer size information which is set corresponding to the second application may be a second buffer size (e.g., 100 ms). In operation811, a case that the second application is run while the first application is run has been described as an example, but as another example, the electronic device101does not perform operation811, and may set information related to adjustment of a buffer size based on immediacy if the immediacy is required while the electronic device101operates based on, for example, stability, while running the first application. For example, the electronic device101may display a setting screen which is displayed on a display (e.g., a display device160inFIG.1) in order for a user to set information related to adjustment of a buffer size without running an additional application (e.g., the second application).

In operation813, the electronic device101may transmit a request message for adjusting the buffer size of the external electronic device102. For example, the electronic device101may transmit the request message according to running of the second application which is set to the second buffer size (e.g., 100 ms). For another example, if immediacy is required while the electronic device101operates based on, for example, stability, while running the first application, the electronic device101does not perform operation811, and may transmit the request message including information related to adjustment of the buffer size which is set by the user in operation813. The request message for adjusting the buffer size is configured in a designated packet format, and may include control information indicating buffer size adjustment and the information related to the buffer size. The information related to the buffer size may include at least one of information about a buffer size which is designated based on the second application, information about a type of the second application, and communication quality. For example, upon receiving the request message for adjusting the buffer size, the primary device of the external electronic device102may inform the secondary device of the request for adjusting the buffer size, and exchange information with the secondary device for synchronization of the buffer size.

In operation815, as the external electronic device102receives the request message for adjusting the buffer size, the external electronic device102may identify the designated buffer size based on the information related to the buffer size included in the received request message. The external electronic device102may change a processing number of the PCM samples from the first number of PCM samples to the second number of PCM samples based on the designated buffer size. For example, the designated buffer size may be the second buffer size (e.g., 100 ms) which is set corresponding to the second application. The external electronic device102may transmit a packet including information related to a buffer state according to the change in the buffer size to the electronic device101at a time point at which the change in the buffer size starts as the request message is received. For example, when operation815is performed by the primary device of the external electronic device102, the primary device may identify the designated buffer size for adjusting the buffer size based on the information related to the buffer size which is received according to the request for adjusting the buffer size, and change the processing number of the PCM samples from the first number of PCM samples to the second number of PCM samples. The primary device may change to the second number of PCM samples based on the designated buffer size. The primary device102amay transmit, to the secondary device, information about the changed second number of PCM samples and information about the designated buffer size for requesting to adjust the buffer size. The secondary device may synchronize a buffer size of the secondary device with a buffer size of the primary device based on the information about the changed second number of PCM samples and the information about the designated buffer size, and decode audio data outputted from a buffer whose buffer size is adjusted and process decoded PCM samples in the same manner as the primary device.

In operation817, the electronic device101may transmit audio data (e.g., second audio data) included in the second application to the external electronic device102. For example, when the primary device of the external electronic device102receives the second audio data from the electronic device101, the primary device may transfer the received second audio data to the secondary device.

In operation819, the external electronic device102may receive the audio data, temporarily store the audio data in a buffer, and decode the audio data (e.g., the second audio data) outputted from the buffer so that a size of the buffer is changed to the second buffer size (e.g., 100 ms) which is the designated buffer size.

In operation821, the external electronic device102may process PCM samples of the decoded audio data (e.g., the second audio data) with the changed second number of PCM samples and output PCM samples which are processed with the second number of PCM samples. For example, as the primary device of the external electronics102transfers the received audio data (e.g., the second audio data) to the secondary device, the primary device and the secondary device may perform operation821in the same manner. For example, as shown inFIG.9, if a buffer size is decreased to the second buffer size (e.g., 100 ms) as the second application (e.g., game903) is run while the first application (e.g., music901) is being run in a first electronic device, the buffer size is decreased while the audio data remains in the buffer, and some audio data is lost, so a user may experience sound interruption. For preventing sound interruption or a change in a tone due to the decrease in the buffer size, the external electronic device102may process PCM samples of the audio data which is outputted from the buffer and decoded while the size of the buffer is decreased with the changed second number of PCM samples (a number decreased from the first number of PCM samples) and output PCM samples which are processed with the second number of PCM samples. The external electronic device102may correct the PCM samples which are processed with the second number of PCM samples so that a pitch is maintained.

In operation823, the external electronic device102may identify whether the size of the buffer being adjusted reaches the second buffer size (e.g., 100 ms) which is the designated buffer size. If the size of the buffer reaches the second buffer size (e.g., 100 ms), operation825may be performed. If the size of the buffer does not reach the second buffer size (e.g., 100 ms), PCM samples of the decoded audio data may be processed with the second number of PCM samples while the size of the buffer is adjusted by performing operations819and821. For example, all of the primary device and the secondary device may perform operation823in the same manner. For another example, when operation823is performed in the primary device of the external electronic device102, the primary device may transmit, to the secondary device, control information according to a result of identifying whether the size of the buffer reaches the second buffer size (e.g., 100 ms).

In operation825, as shown inFIG.9, the external electronic device102may process PCM samples (e.g., first PCM samples) which are obtained by decoding audio data received via the buffer whose buffer size is changed to the second buffer size (e.g., 100 ms) with the first number of PCM samples, and output PCM samples (e.g., first PCM samples) which are processed with the first number of PCM samples via the audio output circuit (e.g., the audio output circuits209aand209binFIG.2). For example, the primary device and the secondary device may perform operation825in the same manner.

According to an embodiment, based on a fact that the second application is run, the electronic device101may transmit a signal indicating that the second application is run or information about the type of the second application to the external electronic device102in operation813. The external electronic device102may adjust the size of the buffer to the designated buffer size based on information about the second application (e.g., the type of the second application).

In the operation procedure as shown inFIG.8, operations of the primary device (e.g., the primary device102ainFIG.2) and the secondary device (e.g., the secondary device102binFIG.2) of the external electronic device102have been described without being separated. However, for example, the operations of the external electronic device102may be performed in the primary device in the same manner, and the primary device may interwork with the secondary device. For example, the operations of the external electronic device102may be performed in the secondary device in the same manner, and the secondary device may interwork with the primary device. For example, if all of the primary device102aand the secondary device receive audio data from the electronic device101, the operations of the external electronic device102may be performed in all of the primary device102aand the secondary device102bin the same manner.

FIG.10is a diagram illustrating an example of a screen of an electronic device for controlling a buffer according to another embodiment.

Referring toFIG.10, an electronic device101may display a setting screen1001for setting information for controlling a buffer of an external electronic device (e.g., an external electronic device102inFIG.2) on a display (e.g., a display device160inFIG.1). The electronic device101may display objects which may set an audio sound quality priority of the external electronic device102for each contents (or an application) on the setting screen1001. Here, the application displayed on the setting screen1001of the electronic device101may be an application related to a wearable device. Audio sound quality priority setting may be used as information related to adjustment of a size of a buffer of the external electronic device102. The setting screen1001may be configured to allow a user to directly input and set information. For example, if “stability” is selected as the audio sound quality priority setting for first contents (or a first application) on the setting screen1001by the user's input, the electronic device101may set information related to the adjustment of the size of the buffer as control information for increasing the size of the buffer (e.g., for changing the size of the buffer to a first buffer size). For another example, if “immediacy” is selected as the audio sound quality priority setting for the first contents (or the first application) on the setting screen1001by the user's input, the electronic device101may set the information related to the adjustment of the size of the buffer as control information for decreasing the size of the buffer (e.g., for changing the size of the buffer to a second buffer size). For still another example, if “balance setting” is selected as the audio sound quality priority setting for the first contents (or the first application) on the setting screen1001by the user's input, the electronic device101may set the information related to the adjustment of the size of the buffer as control information for maintaining a default buffer size which is set in the external electronic device102or changing the size of the buffer to the default buffer size (e.g., for changing the size of the buffer to a third buffer size which is less than the first buffer size and greater than the second buffer size).

According to another embodiment, for example, if a problem occurs when the external electronic device102performs an operation for adjusting the size of the buffer according to the audio sound quality priority setting (e.g., the balance setting) which is selected on the setting screen1001, the electronic device101may induce the user to select another audio sound quality priority setting (e.g., the stability) by displaying information related to occurrence of the problem via a current setting screen displayed on the display or another screen. As another example, if the problem occurs, the electronic device101may automatically change the audio sound quality priority setting to another audio sound quality priority setting (e.g., the stability). As another example, if the problem continuously occurs when an operation for adjusting the size of the buffer is performed in the external electronic device102according to the audio sound quality priority setting which is selected on the setting screen1001, the electronic device101may automatically change the audio sound quality priority setting to another audio sound quality priority setting, and then change to audio sound quality priority setting which has been previously selected after determined time.

FIG.11is a diagram illustrating an example of an operation procedure for controlling a buffer in an electronic device according to another embodiment, andFIG.12is a diagram illustrating an example of an operation procedure for controlling a buffer in an electronic device according to another embodiment.

Referring toFIGS.11and12, in operation1101, according to another embodiment, an electronic device101(e.g., an electronic device101inFIGS.1and2) may be connected to an external electronic device102(e.g., an external electronic device102inFIGS.1to3) via a first communication scheme (e.g., a Bluetooth communication).

In operation1103, the electronic device101(e.g., a first electronic device101inFIGS.1and2) may run a first application (or first contents), obtain an audio source of the run first application, and process obtained audio source as a first number of PCM samples (e.g., first PCM samples). For example, as shown inFIG.12, the first application may be an application which provides music.

In operation1105, the electronic device101may encode the first number of PCM samples (e.g., the first PCM samples), and transmit encoded audio data to the external electronic device102(e.g., the external electronic device102inFIGS.1and2) via the first communication scheme (e.g., the Bluetooth communication).

In operation1107, as a second application (e.g., a navigation application) is run while the first application is being run, the electronic device101may identify whether a size of a buffer of the external electronic device102is changed based on information related to a buffer size. If it is identified that the size of the buffer is changed, operation1109may be performed, and if it is identified that the size of the buffer is not changed, operation1103may be performed again. For example, the electronic device101may compare buffer size information (e.g., 500 ms) set for the first application which is the information related to the buffer size with buffer size information (e.g., 100 ms) set for the second application which is the information related to the buffer size, and identify that the size of the buffer is changed if the buffer size information set for the first application is different from the buffer size information set for the second application. For another example, the first electronic device101may identify whether the size of the buffer is changed based on information inputted by a user as the information related to the buffer size. For example, if the second application which is the navigation application1203as shown inFIG.12requires a real time characteristic, there is a need to decrease latency, so the electronic device101may perform an operation for changing the size of the buffer of the external electronic device102so that the size of the buffer is decreased.

In operation1109, as it is identified that the size of the buffer is changed, the electronic device101may set a processing number of the PCM samples of an audio source to a second number of PCM samples (e.g., a number decreased from the first number of PCM samples) based on the identified information related to the buffer size, and process PCM samples with the set second number of PCM samples.

In operation1111, the electronic device101may encode PCM samples (e.g., second PCM samples) which are processed with the second number of PCM samples. In operation1111, the electronic device101may transmit audio data (e.g., a navigation start sound (“Have a nice day”)) for encoded PCM samples (e.g., second PCM samples) to the external electronic device102. The external electronic device102may decode received audio data and output decoded PCM samples as they are without additionally changing the processing number for PCM samples. For example, the electronic device101processes PCM samples (first PCM samples or second PCM samples) with the second number of PCM samples. As amount of audio data (e.g., audio data in which music play audio and navigation audio are mixed) which is received from the electronic device101in the external electronic device102as shown inFIG.12is decreased, the size of the buffer of the external electronic device102may be automatically changed (increased or decreased). Here, the first PCM samples may be, for example, PCM samples of audio data according to music play, and the second PCM samples may be, for example, PCM samples of audio data for navigation (e.g., the navigation start sound).

In operation1113, the electronic device101may identify whether the size of the buffer reaches the second buffer size (e.g., 100 ms) which is the buffer size information set for the second application. If it is identified that the size of the buffer reaches the second buffer size (e.g., 100 ms), the electronic device101may perform operation1115. If it is identified that the size of the buffer does not reach the second buffer size (e.g., 100 ms), the electronic device101may continuously process PCM samples of the audio source with the second number of PCM samples by performing operations1109to1111.

In operation1115, if the size of the buffer reaches the second buffer size (e.g., 100 ms), the electronic device101may process PCM samples (e.g., first PCM samples and second PCM samples) of the audio source as shown inFIG.12with the first number of PCM samples.

In operation1117, the electronic device101may encode PCM samples (e.g., first PCM samples and second PCM samples) which are processed with the first number of PCM samples, and transmit encoded audio data (e.g., audio data in which music play audio and navigation audio are mixed) to the external electronic device102.

FIG.13is a diagram illustrating an example of an operation procedure for controlling a buffer in an electronic device and a plurality of external electronic devices according to another embodiment.

Referring toFIG.13, according to another embodiment, when a plurality of external electronic devices1301and1303(e.g., an external electronic device102inFIG.1) are connected to an electronic device101, signal strength or communication quality may be different according to a distance between the electronic device101and each of the external electronic devices1301and1303, and an object which is located between the electronic device101and each of the external electronic devices1301and1303, so the electronic device101may obtain and manage information related to signal strength or communication quality of a communication between the electronic device101and each of the external electronic devices1301and1303. For example, if the signal strength or communication quality is less than or equal to a reference value based on information related to the signal strength or communication quality, there is a high probability that audio interruption or noise occurs, so the electronic device101may set first control information for increasing a size of a buffer (e.g., the buffer301inFIG.3) as information related to a buffer size to in order to increase stability. For another example, if the signal strength or communication quality is greater than or equal to the reference value, there is a low probability that the audio interruption or noise occurs, so the electronic device101may set second control information for decreasing the size of the buffer as the information related to the buffer size to in order to increase immediacy.

The electronic device101may transmit the set information related to the buffer size to each of the external electronic devices1301and1303, and each of the external electronic devices1301and1303may set a designated buffer size which corresponding to the signal strength or communication quality based on the received information related to the buffer size. For example, if the external electronic device1301receives, from the electronic device101, the first control information for increasing the size of the buffer as the information related to the buffer size as signal strength (or communication quality) of a communication link between the external electronic device1301and the electronic devices101is strong, the external electronic device1301may set a first buffer size (e.g., 500 ms) as the designated buffer size, and adjust the size of the buffer so that a current buffer size (e.g., 100 ms) is gradually increased to the set first buffer size (e.g., 500 ms). For example, if the external electronic device1303receives, from the electronic device101, the second control information for decreasing the size of the buffer as the information related to the buffer size as signal strength (or communication quality) of a communication link between the external electronic device1303and the electronic devices101is weak, the external electronic device1303may set a second buffer size (e.g., 100 ms) as the designated buffer size, and adjust the size of the buffer so that a current buffer size (e.g., 500 ms) is gradually decreased to the set second buffer size (e.g., 100 ms).

According to another embodiment, the signal strength or communication quality of the communication between the electronic device101and each of the external electronic devices1301and1303as described inFIG.13may be directly identified in each of the external electronic devices1301and1303, and in this case, without receiving the information related to the buffer size from the electronic device101, each of the external electronic devices1301and1303may adjust the size of the buffer based on the information related to the buffer size which is based on the directly identified signal strength or communication quality so that the size of the buffer is increased or decreased to the designated buffer size.

According to another embodiment, each of the external electronic devices1301and1303as shown inFIG.13may identify or set the designated buffer size based on the received information related to the buffer size, and change a processing number of the PCM samples which is for processing PCM samples so that the size of the buffer is adjusted based on the designated buffer size. Each of the external electronic devices1301and1303may process PCM samples with a changed processing number, correct processed PCM samples so that a pitch is maintained, and output corrected PCM samples via an audio output circuit (e.g., an audio output circuit209aand an audio output circuit209bin FIG.2) so that a user may hear the corrected PCM samples. For example, if the external electronic device1301gradually increases the size of the buffer from the first buffer size (e.g., 100 ms) to the second buffer size (e.g., 500 ms), the external electronic device1301may process PCM samples which have been processed with the first number of PCM samples with a number increased from the first number of PCM samples so that the size of the buffer is increased. For another example, if the external electronic device1303gradually decreases the size of the buffer from the first buffer size (e.g., 500 ms) to the second buffer size (e.g., 100 ms), the external electronic device1303may process PCM samples which have been processed with the first number of PCM samples with a number decreased from the first number of PCM samples so that the size of the buffer is decreased.

According to another embodiment, each of the external electronic devices1301and1303as shown inFIG.13may perform an operation of gradually adjusting the size of the buffer (e.g., the buffer301inFIG.3) so that the size of the buffer is changed to the designated buffer size without changing the processing number for PCM samples, decode audio data outputted from the buffer whose size is being adjusted via a decoder (e.g., a decoder303inFIG.3), and output decoded PCM samples via the audio output circuit (e.g., the audio output circuit102aand the audio output circuit120binFIG.2). According to another embodiment, as described inFIG.11, the electronic device101may process PCM samples with a changed processing number so that the size of the buffer of each of the external electronic devices1301and1303is changed, and output PCM samples which are processed with the changed processing number to the external electronic device1301or1303. The external electronic device1301or1303may receive the PCM samples which are processed with the changed processing number, and the size of the buffer may be changed in response to a fact that amount of the received PCM samples is changed. For example, if it is identified that communication quality (or signal strength) of a communication link between the first electronic device101and the external electronic devices1301is good, the first electronic device101may process PCM samples for audio data to be transmitted to the external electronic devices1301with an increased processing number and output PCM samples which are processed with the increased processing number. The external electronic device1301receives PCM samples whose amount is increased as the processing number of the PCM samples is increased, so the size of the buffer of the external electronic device1301may gradually be increased to the first buffer size (e.g., 500 ms). For example, if it is identified that communication quality (or signal strength) of a communication link between the first electronic device101and the external electronic devices1303is poor, the first electronic device101may process PCM samples for audio data to be transmitted to the external electronic devices1303with a decreased processing number and output PCM samples which are processed with the decreased processing number. The external electronic device1303receives PCM samples whose amount is decreased as the processing number of the PCM samples is decreased, so the size of the buffer of the external electronic device1303may gradually be decreased to the second buffer size (e.g., 100 ms).

A method for controlling a buffer (e.g., a buffer301inFIG.3) in an electronic device (e.g., an external electronic device102inFIGS.1to3) according to an embodiment may include connecting to an external electronic device (e.g., an electronic device101inFIGS.1to3) with a first communication scheme, storing audio data which is received from the external electronic device (e.g., the electronic device101inFIGS.1to3) in a buffer, processing pulse code modulation (PCM) samples which are obtained by decoding audio data outputted from the buffer with a first number of PCM samples, and outputting the PCM samples which are processed with the first number of PCM samples, in response to receiving a request for adjusting a size of the buffer from the external electronic device, changing a processing number of the PCM samples from the first number of PCM samples to a second number of PCM samples, in response to the change in the processing number of the PCM samples to the second number of PCM samples, processing PCM samples which are obtained by decoding audio data outputted from the buffer with the second number of PCM samples while the size of the buffer is adjusted, and outputting the PCM samples which are processed with the second number of PCM samples, and when the size of the buffer being adjusted reaches a designated buffer size, processing PCM samples which are obtained by decoding audio data outputted from the buffer with the first number of PCM samples, and outputting the PCM samples which are processed with the first number of PCM samples.

According to an embodiment, the method may further include correcting the PCM samples which are processed with the second number of PCM samples so that a pitch is maintained.

According to an embodiment, the method may further include receiving information related to the size of the buffer from the external electronic device when receiving the request for adjusting the size of the buffer from the external electronic device, and identifying the designated buffer size based on the information related to the size of the buffer. The information related to the size of the buffer may include at least one of information about the designated buffer size, information about a type of an application run on the external electronic device, or information about communication quality.

According to an embodiment, the method may further include transmitting information related to a state of the buffer to the external electronic device.

According to an embodiment, the first communication scheme may be a Bluetooth communication.

As is apparent from the foregoing description, according to an electronic device and an operation method in the electronic device according to an embodiment, latency may be optimized by controlling an optimal buffer size per scenario when audio data is processed, thereby preventing sound interruption or noise and improving sound quality.

According to an electronic device and an operation method in the electronic device according to an embodiment, sound interruption or a change in sound quality may be prevented via correction so that there is no change in a mute period or a pitch while a buffer size is adjusted.

A storage medium which is readable by a machine (e.g., an electronic device101) may include a hardware device, such as hard discs, floppy discs, and magnetic tapes (e.g., a magnetic tape), optical media such as compact disc ROMs (CD-ROMs) and digital versatile discs (DVDs), magneto-optical media such as floptical disks, ROMs, RAMs, or flash memories. Examples of the program instructions may include not only machine language codes but also high-level language codes which are executable by various computing means by using an interpreter. The aforementioned hardware devices may be configured to operate as one or more software modules to carry out exemplary embodiments of the disclosure, and vice versa.

According to an embodiment, a non-transitory storage medium (e.g., a memory201aor201binFIG.2) may include an executable instruction which, when executed by a processor (e.g., a processor205aor205binFIG.2), cause the processor to perform connecting to an external electronic device (e.g., an electronic device101inFIG.1orFIG.2) using a first communication scheme, storing audio data received from the external electronic device in a buffer (e.g., a buffer301inFIG.3), processing pulse code modulation (PCM) samples with a first number of the PCM samples, and outputting the PCM samples which are processed with the first number, the PCM samples are obtained by decoding audio data output from the buffer, in response to receiving a request for adjusting a size of the buffer from the external electronic device, changing a processing number of PCM samples from the first number of PCM samples to a second number of PCM samples, in response to the change in the processing number of PCM samples to the second number of PCM samples, processing PCM samples which are obtained by decoding audio data outputted from the buffer with the second number of PCM samples while the size of the buffer is adjusted, and outputting the PCM samples which are processed with the second number of PCM samples, and when the size of the buffer being adjusted reaches a designated buffer size, processing PCM samples which are obtained by decoding the audio data outputted from the buffer with the first number of PCM samples, and outputting the PCM samples which are processed with the first number of PCM samples.

The embodiments disclosed herein are proposed for description and understanding of the disclosed technology and does not limit the scope of the disclosure. Accordingly, the scope of the disclosure should be interpreted as including all changes or various embodiments based on the technical spirit of the disclosure.