output/alsa: use std::byte instead of uint8_t
This commit is contained in:
parent
0158a2b6b9
commit
4f8d2a8b1c
@ -42,7 +42,7 @@ namespace Alsa {
|
|||||||
class PeriodBuffer {
|
class PeriodBuffer {
|
||||||
size_t capacity, head, tail;
|
size_t capacity, head, tail;
|
||||||
|
|
||||||
uint8_t *buffer;
|
std::byte *buffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PeriodBuffer() = default;
|
PeriodBuffer() = default;
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
to be able to fill the buffer with silence,
|
to be able to fill the buffer with silence,
|
||||||
after moving an unfinished frame to the
|
after moving an unfinished frame to the
|
||||||
end */
|
end */
|
||||||
buffer = new uint8_t[capacity + frame_size - 1];
|
buffer = new std::byte[capacity + frame_size - 1];
|
||||||
head = tail = 0;
|
head = tail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
* copied to the returned pointer, and call AppendBytes() to
|
* copied to the returned pointer, and call AppendBytes() to
|
||||||
* commit the operation.
|
* commit the operation.
|
||||||
*/
|
*/
|
||||||
uint8_t *GetTail() noexcept {
|
std::byte *GetTail() noexcept {
|
||||||
assert(!IsFull());
|
assert(!IsFull());
|
||||||
|
|
||||||
return buffer + tail;
|
return buffer + tail;
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @param _silence one period worth of silence
|
* @param _silence one period worth of silence
|
||||||
*/
|
*/
|
||||||
void FillWithSilence(const uint8_t *_silence,
|
void FillWithSilence(const std::byte *_silence,
|
||||||
const size_t frame_size) noexcept {
|
const size_t frame_size) noexcept {
|
||||||
assert(!IsFull());
|
assert(!IsFull());
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public:
|
|||||||
* from the returned pointer, and call ConsumeBytes() to
|
* from the returned pointer, and call ConsumeBytes() to
|
||||||
* commit the operation.
|
* commit the operation.
|
||||||
*/
|
*/
|
||||||
const uint8_t *GetHead() const noexcept {
|
const std::byte *GetHead() const noexcept {
|
||||||
return buffer + head;
|
return buffer + head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,14 +223,14 @@ class AlsaOutput final
|
|||||||
* It contains silence samples, enough to fill one period (see
|
* It contains silence samples, enough to fill one period (see
|
||||||
* #period_frames).
|
* #period_frames).
|
||||||
*/
|
*/
|
||||||
uint8_t *silence;
|
std::byte *silence;
|
||||||
|
|
||||||
AlsaNonBlockPcm non_block;
|
AlsaNonBlockPcm non_block;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For copying data from OutputThread to IOThread.
|
* For copying data from OutputThread to IOThread.
|
||||||
*/
|
*/
|
||||||
boost::lockfree::spsc_queue<uint8_t> *ring_buffer;
|
boost::lockfree::spsc_queue<std::byte> *ring_buffer;
|
||||||
|
|
||||||
Alsa::PeriodBuffer period_buffer;
|
Alsa::PeriodBuffer period_buffer;
|
||||||
|
|
||||||
@ -585,7 +585,7 @@ AlsaOutput::Setup(AudioFormat &audio_format,
|
|||||||
in the ALSA-PCM buffer */
|
in the ALSA-PCM buffer */
|
||||||
max_avail_frames = hw_result.buffer_size - hw_result.period_size;
|
max_avail_frames = hw_result.buffer_size - hw_result.period_size;
|
||||||
|
|
||||||
silence = new uint8_t[snd_pcm_frames_to_bytes(pcm, alsa_period_size)];
|
silence = new std::byte[snd_pcm_frames_to_bytes(pcm, alsa_period_size)];
|
||||||
snd_pcm_format_set_silence(hw_result.format, silence,
|
snd_pcm_format_set_silence(hw_result.format, silence,
|
||||||
alsa_period_size * audio_format.channels);
|
alsa_period_size * audio_format.channels);
|
||||||
|
|
||||||
@ -874,7 +874,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
|
|||||||
interrupted = false;
|
interrupted = false;
|
||||||
|
|
||||||
size_t period_size = period_frames * out_frame_size;
|
size_t period_size = period_frames * out_frame_size;
|
||||||
ring_buffer = new boost::lockfree::spsc_queue<uint8_t>(period_size * 4);
|
ring_buffer = new boost::lockfree::spsc_queue<std::byte>(period_size * 4);
|
||||||
|
|
||||||
period_buffer.Allocate(period_frames, out_frame_size);
|
period_buffer.Allocate(period_frames, out_frame_size);
|
||||||
|
|
||||||
@ -1234,8 +1234,7 @@ AlsaOutput::Play(const void *chunk, size_t size)
|
|||||||
if (e.empty())
|
if (e.empty())
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
size_t bytes_written = ring_buffer->push((const uint8_t *)e.data(),
|
size_t bytes_written = ring_buffer->push(e.data(), e.size());
|
||||||
e.size());
|
|
||||||
assert(bytes_written == e.size());
|
assert(bytes_written == e.size());
|
||||||
(void)bytes_written;
|
(void)bytes_written;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user