CN104795081A - Method and device for reading and writing PCM data in PCM cache - Google Patents
Method and device for reading and writing PCM data in PCM cache Download PDFInfo
- Publication number
- CN104795081A CN104795081A CN201510198149.XA CN201510198149A CN104795081A CN 104795081 A CN104795081 A CN 104795081A CN 201510198149 A CN201510198149 A CN 201510198149A CN 104795081 A CN104795081 A CN 104795081A
- Authority
- CN
- China
- Prior art keywords
- pcm
- buffer memory
- module
- pcm data
- write
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11B—INFORMATION STORAGE BASED ON RELATIVE MOVEMENT BETWEEN RECORD CARRIER AND TRANSDUCER
- G11B20/00—Signal processing not specific to the method of recording or reproducing; Circuits therefor
- G11B20/10—Digital recording or reproducing
- G11B20/10527—Audio or video recording; Data buffering arrangements
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
The invention discloses a method and a device for reading and writing PCM data in a PCM cache and aims to solve the problem of read-write conflicts. The method includes a method for writing the PCM data into the PCM cache and a method for reading the PCM data in the PCM cache. The method for writing the PCM data into the PCM cache includes: judging whether the current PCM cache has a read operation or not, and if not, writing the PCM data into the PCM cache; if so, waiting a certain time, and judging whether the current PCM cache has a read operation or not again. The method for reading the PCM data in the PCM cache includes: judging whether the current PCM cache has a write operation or not, and if not reading the PCM data stored in the PCM cache; if so, waiting a certain time, and judging whether the current PCM cache has a write operation or not again. By the method, the problem of read-write conflicts of the data in the PCM cache is solved effectively.
Description
Technical field
The present invention relates to Audiotechnica field, particularly a kind of method and device reading and writing PCM data in PCM buffer memory.
Background technology
Through the development of Internet technology in recent years.Internet has been deep in daily life.Because remote teaching has the features such as convenient and swift, low cost, be more and more subject to liking of numerous teachers and students, by internet, student can obtain resources material easily and learn.Interactive in order to improve remote teaching, between current teachers and students, the normal video that adopts exchanges on the internet with voice mode, i.e. real-time recording audio frequency and video, then issue the other side by internet thus complete online exchange.But, at present at recording pulse code modulation (Pulse Code Modulation, PCM) when voice data issues the other side, the speed reading data due to network transmission speed and the other side there are differences, and easily occurs that loss of data or audio frequency are play discontinuous.Now conventional solution increases a PCM data buffer at receiving end, for depositing PCM data, when network transmission speed being greater than reading rate, PCM data can being put into PCM data buffer and depositing, thus avoiding event of data loss to occur.
But, when reading PCM data delay the PCM data in district, the operation this buffer zone being write to PCM data may be there is, and read-write operation is mutual exclusion, read and write improper easily causing and expect that reading PCM data is rewritten, therefore be badly in need of a kind of method reading and writing PCM data in PCM buffer memory, for solving the problem of read/write conflict.
Summary of the invention
The invention provides a kind of method and the device of reading and writing PCM data in PCM buffer memory, for solving the problem of PCM data collision in read-write PCM buffer memory.
The invention provides a kind of method to PCM buffer memory write PCM data, comprise the steps:
S11: judge whether current PC M buffer memory has read operation, is, performs S12, otherwise perform S13;
S12: after waiting for the first Preset Time, performs S11;
S13: write PCM data in PCM buffer memory.
Some beneficial effects of the embodiment of the present invention can comprise:
After judging whether current PC M buffer memory has read operation, do not having in read operation situation, to PCM buffer memory write PCM data.Thus solve in the process of PCM buffer memory write PCM data, and read the collision problem in PCM buffer memory between PCM data manipulation.
In one embodiment, describedly in PCM buffer memory, write PCM data, comprising:
Current PCM data to be written are write from the ending of PCM buffer memory;
Upgrade the length of PCM data in PCM buffer memory.
In this embodiment, write new data from the ending of PCM buffer memory, ensure that the data stored in former PCM buffer memory can not be capped.
The invention provides a kind of method reading PCM data in PCM buffer memory, it is characterized in that, comprise the steps:
S21: judge whether current PC M buffer memory has write operation, is, performs S22, otherwise perform S23;
S22: after waiting for the second Preset Time, performs S21;
S23: read the PCM data stored in PCM buffer memory.
Some beneficial effects of the embodiment of the present invention can comprise:
After judging whether current PC M buffer memory has write operation, do not having in write operation situation, reading PCM data in PCM buffer memory, thus solving in the process reading PCM data in PCM buffer memory, and writing the collision problem between PCM data manipulation to PCM buffer memory.
In one embodiment, the PCM data stored in described reading PCM buffer memory, comprising:
The number N of the frame that will read is determined according to the length of PCM data in PCM buffer memory and the frame length of setting;
From PCM buffer memory starting position, the PCM data stored in PCM buffer memory are read N frame according to the frame length order of setting;
By the position that PCM data mobile remaining in PCM buffer memory starts to PCM buffer memory;
Upgrade the length of PCM data in PCM buffer memory.
In this embodiment, read the data of PCM buffer memory according to the frame length preset, data can directly be used as voice data.
The invention provides a kind of device to PCM buffer memory write PCM data, comprising: the first judge module, first waits for module, writing module;
Described first judge module is used for according to the write instruction of user or judges whether current PC M buffer memory has read operation, is according to the first trigger pip, waits for that module sends the first waiting signal to described first; Otherwise send write signal to said write module;
Described first waits for that module is used for, after receiving the first waiting signal that described judge module sends, waiting for the first Preset Time, sending the first trigger pip to described first judge module;
Said write module is used for the write signal sent according to described first judge module, in PCM buffer memory, write PCM data.
In one embodiment, said write module writes PCM data in PCM buffer memory, comprising:
The write signal that said write module is sent according to described first judge module, writes current PCM data to be written, and upgrades the length of PCM data in PCM buffer memory from the ending of PCM buffer memory.
The invention provides a kind of device reading PCM data in PCM buffer memory, comprising: the second judge module, second waits for module, read module;
Described second judge module is used for according to the reading command of user or judges whether current PC M buffer memory has write operation, is according to the second trigger pip, waits for that module sends the second waiting signal to described second; Otherwise send to described read module and read signal;
Described second waits for that module is used for, after receiving the second waiting signal that described second judge module sends, waiting for the second Preset Time, sending the second trigger pip to described second judge module;
Described read module is used for the reading signal sent according to described second judge module, reads the PCM data stored in PCM buffer memory.
In one embodiment, described read module reads the PCM data stored in PCM buffer memory, comprising:
First described read module determines the number N of the frame that will read according to the length of PCM data in PCM buffer memory and the frame length of setting, subsequently from PCM buffer memory starting position, the PCM data stored in PCM buffer memory are read N frame according to the frame length order of setting, again by the position that PCM data mobile remaining in PCM buffer memory starts to PCM buffer memory, and upgrade the length of PCM data in PCM buffer memory.
Other features and advantages of the present invention will be set forth in the following description, and, partly become apparent from instructions, or understand by implementing the present invention.Object of the present invention and other advantages realize by structure specifically noted in write instructions, claims and accompanying drawing and obtain.
Below by drawings and Examples, technical scheme of the present invention is described in further detail.
Accompanying drawing explanation
Accompanying drawing is used to provide a further understanding of the present invention, and forms a part for instructions, together with embodiments of the present invention for explaining the present invention, is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is the process flow diagram of a kind of method to PCM buffer memory write PCM data in the embodiment of the present invention;
Fig. 2 is a kind of process flow diagram reading the method for PCM data in PCM buffer memory in the embodiment of the present invention;
Fig. 3 is the structural representation of a kind of device to PCM buffer memory write PCM data in the embodiment of the present invention;
Fig. 4 is a kind of structural representation reading the device of PCM data in PCM buffer memory in the embodiment of the present invention.
Embodiment
Below in conjunction with accompanying drawing, the preferred embodiments of the present invention are described, should be appreciated that preferred embodiment described herein is only for instruction and explanation of the present invention, is not intended to limit the present invention.
Fig. 1 is the process flow diagram of a kind of method to PCM buffer memory write PCM data in the embodiment of the present invention.As shown in Figure 1, S101-S103 is comprised the following steps:
Step S101: judge whether current PC M buffer memory has read operation, is, performs S102, otherwise perform S103;
Step S102: after waiting for the first Preset Time, performs S101;
Step S103: write PCM data in PCM buffer memory.
The technical scheme that the embodiment of the present invention provides, after judging whether current PC M buffer memory has read operation, is not having in read operation situation, to PCM buffer memory write PCM data.Thus solve in the process of PCM buffer memory write PCM data, and read the collision problem in PCM buffer memory between PCM data manipulation.
In one embodiment, describedly in PCM buffer memory, write PCM data, comprising:
Current PCM data to be written are write from the ending of PCM buffer memory;
Upgrade the length of PCM data in PCM buffer memory.
Such as, the concrete enforcement false code of such scheme can be as follows:
Time in // wait PCM buffer memory without operation, enter subsequent process steps, and lock
WaitForSingleObject(mutex,INFINITE);
// be the data enter_data to be entered of enter_data_len by length,
// be written to the ending of pcm buffer memory
memcpy(pcm_buffer+pcm_buffer_len,enter_data,enter_data_len)
The length pcm_buffer_len of PCM data in // renewal PCM buffer memory
pcm_buffer_len=pcm_buffer_len+enter_data_len
// unlock
ReleaseMutex(mutex);
Fig. 2 is a kind of process flow diagram reading the method for PCM data in PCM buffer memory provided by the invention, comprises the steps:
S201: judge whether current PC M buffer memory has write operation, is, performs S202, otherwise perform S203;
S202: after waiting for the second Preset Time, performs S201;
S203: read the PCM data stored in PCM buffer memory.
Some beneficial effects of the embodiment of the present invention can comprise:
After judging whether current PC M buffer memory has write operation, do not having in write operation situation, reading PCM data in PCM buffer memory.Thus solve in the process reading PCM data in PCM buffer memory, and write the collision problem between PCM data manipulation to PCM buffer memory.
In one embodiment, read the PCM data stored in PCM buffer memory, comprising:
The number N of the frame that will read is determined according to the length of PCM data in PCM buffer memory and the frame length of setting;
From PCM buffer memory starting position, the PCM data stored in PCM buffer memory are read N frame according to the frame length order of setting;
By the position that PCM data mobile remaining in PCM buffer memory starts to PCM buffer memory;
Upgrade the length of PCM data in PCM buffer memory.
Such as, the concrete enforcement false code of such scheme can be as follows:
A kind of method to PCM buffer memory write PCM data provided corresponding to above-described embodiment and a kind of method reading PCM data in PCM buffer memory, the embodiment of the present invention also provides a kind of device to PCM buffer memory write PCM data, as shown in Figure 3, comprising: the first judge module 31, first waits for module 32, writing module 33;
First judge module 31 is for the write instruction according to user or judge whether current PC M buffer memory has read operation, is according to the first trigger pip, waits for that module 32 sends the first waiting signal to first; Otherwise send write signal to writing module 33;
First waits for that module 32 is for after receiving the first waiting signal that judge module 31 sends, and waits for the first Preset Time, sends the first trigger pip to the first judge module 31;
The write signal of writing module 33 for sending according to the first judge module 31, writes PCM data in PCM buffer memory.
In one embodiment, the write signal that writing module 33 is sent according to the first judge module 31, writes current PCM data to be written, and upgrades the length of PCM data in PCM buffer memory from the ending of PCM buffer memory.
The present invention also provides a kind of device reading PCM data in PCM buffer memory, as shown in Figure 4, comprising: the second judge module 41, second waits for module 42, read module 43;
Second judge module 41 is for the reading command according to user or judge whether current PC M buffer memory has write operation, is according to the second trigger pip, waits for that module 42 sends the second waiting signal to second; Otherwise send to read module 43 and read signal;
Second waits for that module 42 is for after receiving the second waiting signal that the second judge module 41 sends, and waits for the second Preset Time, sends the second trigger pip to the second judge module 41;
The reading signal of read module 43 for sending according to the second judge module 41, reads the PCM data stored in PCM buffer memory.
In one embodiment, first read module 43 determines the number N of the frame that will read according to the length of PCM data in PCM buffer memory and the frame length of setting, subsequently from PCM buffer memory starting position, the PCM data stored in PCM buffer memory are read N frame according to the frame length order of setting, again by the position that PCM data mobile remaining in PCM buffer memory starts to PCM buffer memory, and upgrade the length of PCM data in PCM buffer memory.
Those skilled in the art should understand, embodiments of the invention can be provided as method, system or computer program.Therefore, the present invention can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the present invention can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disk memory and optical memory etc.) of computer usable program code.
The present invention describes with reference to according to the process flow diagram of the method for the embodiment of the present invention, equipment (system) and computer program and/or block scheme.Should understand can by the combination of the flow process in each flow process in computer program instructions realization flow figure and/or block scheme and/or square frame and process flow diagram and/or block scheme and/or square frame.These computer program instructions can being provided to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, making the instruction performed by the processor of computing machine or other programmable data processing device produce device for realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be stored in can in the computer-readable memory that works in a specific way of vectoring computer or other programmable data processing device, the instruction making to be stored in this computer-readable memory produces the manufacture comprising command device, and this command device realizes the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make on computing machine or other programmable devices, to perform sequence of operations step to produce computer implemented process, thus the instruction performed on computing machine or other programmable devices is provided for the step realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
Obviously, those skilled in the art can carry out various change and modification to the present invention and not depart from the spirit and scope of the present invention.Like this, if these amendments of the present invention and modification belong within the scope of the claims in the present invention and equivalent technologies thereof, then the present invention is also intended to comprise these change and modification.
Claims (8)
1., to a method for PCM buffer memory write PCM data, it is characterized in that, comprise the steps:
S11: judge whether current PC M buffer memory has read operation, is, performs S12, otherwise perform S13;
S12: after waiting for the first Preset Time, performs S11;
S13: write PCM data in PCM buffer memory.
2. a kind of method to PCM buffer memory write PCM data as claimed in claim 1, is characterized in that, describedly in PCM buffer memory, writes PCM data, comprising:
Current PCM data to be written are write from the ending of PCM buffer memory;
Upgrade the length of PCM data in PCM buffer memory.
3. read a method for PCM data in PCM buffer memory, it is characterized in that, comprise the steps:
S21: judge whether current PC M buffer memory has write operation, is, performs S22, otherwise perform S23;
S22: after waiting for the second Preset Time, performs S21;
S23: read the PCM data stored in PCM buffer memory.
4. a kind of method reading PCM data in PCM buffer memory as claimed in claim 3, is characterized in that, the PCM data stored in described reading PCM buffer memory, comprising:
The number N of the frame that will read is determined according to the length of PCM data in PCM buffer memory and the frame length of setting;
From PCM buffer memory starting position, the PCM data stored in PCM buffer memory are read N frame according to the frame length order of setting;
By the position that PCM data mobile remaining in PCM buffer memory starts to PCM buffer memory;
Upgrade the length of PCM data in PCM buffer memory.
5. to a device for PCM buffer memory write PCM data, it is characterized in that, comprising: the first judge module, first waits for module, writing module;
Described first judge module is used for according to the write instruction of user or judges whether current PC M buffer memory has read operation, is according to the first trigger pip, waits for that module sends the first waiting signal to described first; Otherwise send write signal to said write module;
Described first waits for that module is used for, after receiving the first waiting signal that described judge module sends, waiting for the first Preset Time, sending the first trigger pip to described first judge module;
Said write module is used for the write signal sent according to described first judge module, in PCM buffer memory, write PCM data.
6. a kind of device to PCM buffer memory write PCM data as claimed in claim 5, it is characterized in that, said write module writes PCM data in PCM buffer memory, comprising:
The write signal that said write module is sent according to described first judge module, writes current PCM data to be written, and upgrades the length of PCM data in PCM buffer memory from the ending of PCM buffer memory.
7. read a device for PCM data in PCM buffer memory, it is characterized in that, comprising: the second judge module, second waits for module, read module;
Described second judge module is used for according to the reading command of user or judges whether current PC M buffer memory has write operation, is according to the second trigger pip, waits for that module sends the second waiting signal to described second; Otherwise send to described read module and read signal;
Described second waits for that module is used for, after receiving the second waiting signal that described second judge module sends, waiting for the second Preset Time, sending the second trigger pip to described second judge module;
Described read module is used for the reading signal sent according to described second judge module, reads the PCM data stored in PCM buffer memory.
8. a kind of device reading PCM data in PCM buffer memory as claimed in claim 7, is characterized in that, described read module reads the PCM data stored in PCM buffer memory, comprising:
First described read module determines the number N of the frame that will read according to the length of PCM data in PCM buffer memory and the frame length of setting, subsequently from PCM buffer memory starting position, the PCM data stored in PCM buffer memory are read N frame according to the frame length order of setting, again by the position that PCM data mobile remaining in PCM buffer memory starts to PCM buffer memory, and upgrade the length of PCM data in PCM buffer memory.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510198149.XA CN104795081A (en) | 2015-04-23 | 2015-04-23 | Method and device for reading and writing PCM data in PCM cache |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510198149.XA CN104795081A (en) | 2015-04-23 | 2015-04-23 | Method and device for reading and writing PCM data in PCM cache |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104795081A true CN104795081A (en) | 2015-07-22 |
Family
ID=53559837
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510198149.XA Pending CN104795081A (en) | 2015-04-23 | 2015-04-23 | Method and device for reading and writing PCM data in PCM cache |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104795081A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112631526A (en) * | 2020-12-31 | 2021-04-09 | 国网浙江省电力有限公司营销服务中心 | Method for reading and writing same memory by main cycle and interrupt cycle of embedded system |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050120144A1 (en) * | 2003-07-07 | 2005-06-02 | Fujitsu Limited | Disk control unit, disk drive, disk control method, and disk control program |
CN1627280A (en) * | 2003-12-12 | 2005-06-15 | 冲电气工业株式会社 | Data transfer circuit |
CN102630007A (en) * | 2012-03-31 | 2012-08-08 | 中船重工(武汉)凌久高科有限公司 | Method for processing TCP (transmission control protocol) video data stream |
CN103581611A (en) * | 2013-11-19 | 2014-02-12 | 北京兆维电子(集团)有限责任公司 | Implementation method for audio and video recording based on routing server and routing server |
-
2015
- 2015-04-23 CN CN201510198149.XA patent/CN104795081A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050120144A1 (en) * | 2003-07-07 | 2005-06-02 | Fujitsu Limited | Disk control unit, disk drive, disk control method, and disk control program |
CN1627280A (en) * | 2003-12-12 | 2005-06-15 | 冲电气工业株式会社 | Data transfer circuit |
CN102630007A (en) * | 2012-03-31 | 2012-08-08 | 中船重工(武汉)凌久高科有限公司 | Method for processing TCP (transmission control protocol) video data stream |
CN103581611A (en) * | 2013-11-19 | 2014-02-12 | 北京兆维电子(集团)有限责任公司 | Implementation method for audio and video recording based on routing server and routing server |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112631526A (en) * | 2020-12-31 | 2021-04-09 | 国网浙江省电力有限公司营销服务中心 | Method for reading and writing same memory by main cycle and interrupt cycle of embedded system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101512656A (en) | GPU timeline with render-ahead queue | |
CN103336663A (en) | Data synchronization method, device and terminal | |
CN103180852A (en) | Distributed data processing method and apparatus | |
CN101819543A (en) | Snapshot data processing method, system and storage device | |
CN110493342B (en) | File transmission method and device, electronic equipment and readable storage medium | |
CN102981990A (en) | Data transmission method and device of terminal equipment with Androild platform | |
ATE265085T1 (en) | MEDIA STORAGE DEVICE WITH EMBEDDED DATA FILTER FOR DYNAMIC DATA PROCESSING DURING READ AND WRITE OPERATIONS | |
CN103984597A (en) | Method, device and system for task run switching | |
WO2015090043A1 (en) | Method and device for swapping data into memory | |
CN105808374A (en) | Snapshot processing method and associated equipment | |
CN102074221B (en) | Method and device for displaying characters | |
KR102166185B1 (en) | Data processing apparatus for pipeline execution acceleration and method thereof | |
CN114579055B (en) | Disk storage method, device, equipment and medium | |
CN103888867A (en) | Loudspeaker box and system and method for controlling loudspeaker box | |
CN104639973A (en) | Information pushing method and device | |
WO2016095681A1 (en) | Method and device for application running in background | |
CN103780942A (en) | Information configuration method and device thereof | |
CN104795081A (en) | Method and device for reading and writing PCM data in PCM cache | |
CN113515344A (en) | Method and device for automatically migrating virtual machine across technical platforms | |
WO2020173381A1 (en) | Data interworking method and device, terminal and storage medium | |
CN104866282A (en) | Method for controlling electronic equipment and electronic equipment | |
CN103164223A (en) | Method of intelligent terminal capable of achieving alarm clock and intelligent terminal under shutdown state | |
CN102567263A (en) | Device and method for automatic synchronization and automatic exchanging of user data of serial interface portable device | |
CN105808556A (en) | Operating method for database and database engine | |
CN110851097B (en) | Control method, device, medium and electronic equipment for consistency of handwriting data |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
EXSB | Decision made by sipo to initiate substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20150722 |
|
RJ01 | Rejection of invention patent application after publication |