mirror of
https://github.com/pion/mediadevices.git
synced 2025-09-27 04:46:10 +08:00
Add documentation around Reader interfaces
This commit is contained in:
@@ -5,6 +5,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Reader interface {
|
type Reader interface {
|
||||||
|
// Read reads data from the source. The caller is responsible to release the memory that's associated
|
||||||
|
// with data by calling the given release function. When err is not nil, the caller MUST NOT call release
|
||||||
|
// as data is going to be nil (no memory was given). Otherwise, the caller SHOULD call release after
|
||||||
|
// using the data. The caller is NOT REQUIRED to call release, as this is only a part of memory management
|
||||||
|
// optimization. If release is not called, the source is forced to allocate a new memory, which also means
|
||||||
|
// there will be new allocations during streaming, and old unused memory will become garbage. As a consequence,
|
||||||
|
// these garbage will put a lot of pressure to the garbage collector and makes it to run more often and finish
|
||||||
|
// slower as the heap memory usage increases and more garbage to collect.
|
||||||
Read() (chunk wave.Audio, release func(), err error)
|
Read() (chunk wave.Audio, release func(), err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,6 +3,14 @@ package io
|
|||||||
// Reader is a generic data reader. In the future, interface{} should be replaced by a generic type
|
// Reader is a generic data reader. In the future, interface{} should be replaced by a generic type
|
||||||
// to provide strong type.
|
// to provide strong type.
|
||||||
type Reader interface {
|
type Reader interface {
|
||||||
|
// Read reads data from the source. The caller is responsible to release the memory that's associated
|
||||||
|
// with data by calling the given release function. When err is not nil, the caller MUST NOT call release
|
||||||
|
// as data is going to be nil (no memory was given). Otherwise, the caller SHOULD call release after
|
||||||
|
// using the data. The caller is NOT REQUIRED to call release, as this is only a part of memory management
|
||||||
|
// optimization. If release is not called, the source is forced to allocate a new memory, which also means
|
||||||
|
// there will be new allocations during streaming, and old unused memory will become garbage. As a consequence,
|
||||||
|
// these garbage will put a lot of pressure to the garbage collector and makes it to run more often and finish
|
||||||
|
// slower as the heap memory usage increases and more garbage to collect.
|
||||||
Read() (data interface{}, release func(), err error)
|
Read() (data interface{}, release func(), err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Reader interface {
|
type Reader interface {
|
||||||
|
// Read reads data from the source. The caller is responsible to release the memory that's associated
|
||||||
|
// with data by calling the given release function. When err is not nil, the caller MUST NOT call release
|
||||||
|
// as data is going to be nil (no memory was given). Otherwise, the caller SHOULD call release after
|
||||||
|
// using the data. The caller is NOT REQUIRED to call release, as this is only a part of memory management
|
||||||
|
// optimization. If release is not called, the source is forced to allocate a new memory, which also means
|
||||||
|
// there will be new allocations during streaming, and old unused memory will become garbage. As a consequence,
|
||||||
|
// these garbage will put a lot of pressure to the garbage collector and makes it to run more often and finish
|
||||||
|
// slower as the heap memory usage increases and more garbage to collect.
|
||||||
Read() (img image.Image, release func(), err error)
|
Read() (img image.Image, release func(), err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user