Skip to content

Commit 23ee998

Browse files
committed
Added draft of OutAudioFileStream for MacOS
1 parent 6a5b8e2 commit 23ee998

File tree

9 files changed

+480
-132
lines changed

9 files changed

+480
-132
lines changed

include/lsp-plug.in/mm/IInAudioStream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-runtime-lib
66
* Created on: 16 апр. 2020 г.
@@ -185,7 +185,7 @@ namespace lsp
185185
/**
186186
* Strict type reads
187187
* @param dst destination buffer to perform read
188-
* @param nframe number of frames to read
188+
* @param nframes number of frames to read
189189
*/
190190
inline ssize_t read_u8(void *dst, size_t nframes) { return read(static_cast<uint8_t *>(dst), nframes); }
191191
inline ssize_t read_s8(void *dst, size_t nframes) { return read(static_cast<int8_t *>(dst), nframes); }

include/lsp-plug.in/mm/IOutAudioStream.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-runtime-lib
66
* Created on: 16 апр. 2020 г.
@@ -68,7 +68,7 @@ namespace lsp
6868

6969
/**
7070
* Perform write with conversion
71-
* @param dst source buffer with frame data
71+
* @param src source buffer with frame data
7272
* @param nframes number of frames to write
7373
* @param fmt sample format
7474
* @return status if operation
@@ -180,7 +180,7 @@ namespace lsp
180180
/**
181181
* Strict type reads
182182
* @param dst destination buffer to perform read
183-
* @param nframe number of frames to read
183+
* @param nframes number of frames to read
184184
*/
185185
inline ssize_t write_u8(const void *dst, size_t nframes) { return write(static_cast<const uint8_t *>(dst), nframes); }
186186
inline ssize_t write_s8(const void *dst, size_t nframes) { return write(static_cast<const int8_t *>(dst), nframes); }

include/lsp-plug.in/mm/OutAudioFileStream.h

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-runtime-lib
66
* Created on: 20 апр. 2020 г.
@@ -37,18 +37,21 @@ namespace lsp
3737
{
3838
namespace mm
3939
{
40-
#ifndef USE_LIBSNDFILE
40+
#if defined(PLATFORM_WINDOWS)
4141
struct WAVEFILE;
42-
#endif /* USE_LIBSNDFILE */
42+
#endif /* PLATFORM_WINDOWS */
4343

4444
class OutAudioFileStream: public IOutAudioStream
4545
{
4646
protected:
4747

48-
#ifdef USE_LIBSNDFILE
49-
typedef SNDFILE handle_t;
50-
#else
48+
#if defined(PLATFORM_WINDOWS)
5149
typedef struct WAVEFILE handle_t;
50+
#elif defined(PLATFORM_MACOSX)
51+
typedef void handle_t;
52+
#else
53+
typedef SNDFILE handle_t;
54+
5255
#endif
5356

5457
protected:
@@ -57,28 +60,31 @@ namespace lsp
5760
bool bSeekable;
5861

5962
protected:
60-
#ifdef USE_LIBSNDFILE
61-
static status_t decode_sf_error(SNDFILE *fd);
62-
static bool select_sndfile_format(SF_INFO *info, audio_stream_t *fmt, size_t codec);
63-
#else
63+
#if defined(PLATFORM_WINDOWS)
6464
virtual ssize_t conv_write(const void *src, size_t nframes, size_t fmt);
6565
ssize_t write_acm_convert(const void *src, size_t nframes);
6666
status_t flush_handle(handle_t *hHandle, bool eof);
67+
#elif defined(PLATFORM_MACOSX)
68+
static status_t decode_os_status(uint32_t code);
69+
static uint32_t select_file_format(size_t codec);
70+
#else
71+
static status_t decode_sf_error(SNDFILE *fd);
72+
static bool select_sndfile_format(SF_INFO *info, audio_stream_t *fmt, size_t codec);
6773
#endif
6874

69-
virtual ssize_t direct_write(const void *src, size_t nframes, size_t fmt);
70-
71-
virtual size_t select_format(size_t rfmt);
72-
7375
status_t flush_internal(bool eof);
7476
status_t do_close();
7577
static status_t close_handle(handle_t *h);
7678

79+
protected:
80+
virtual ssize_t direct_write(const void *src, size_t nframes, size_t fmt) override;
81+
virtual size_t select_format(size_t rfmt) override;
82+
7783
public:
7884
explicit OutAudioFileStream();
7985
OutAudioFileStream(const OutAudioFileStream &) = delete;
8086
OutAudioFileStream(OutAudioFileStream &&) = delete;
81-
virtual ~OutAudioFileStream();
87+
virtual ~OutAudioFileStream() override;
8288

8389
OutAudioFileStream & operator = (const OutAudioFileStream &) = delete;
8490
OutAudioFileStream & operator = (OutAudioFileStream &&) = delete;
@@ -111,11 +117,10 @@ namespace lsp
111117
*/
112118
virtual status_t open(const io::Path *path, const audio_stream_t *fmt, size_t codec);
113119

114-
virtual status_t close();
115-
116-
virtual status_t flush();
117-
118-
virtual wssize_t seek(wsize_t nframes);
120+
public: // IOutAudioStream
121+
virtual status_t close() override;
122+
virtual status_t flush() override;
123+
virtual wssize_t seek(wsize_t nframes) override;
119124
};
120125

121126
} /* namespace mm */

src/main/mm/IInAudioStream.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ namespace lsp
132132
{
133133
if (nread > 0)
134134
break;
135-
set_error(-nread);
135+
set_error(-status_t(nread));
136136
return nread;
137137
}
138138

@@ -226,7 +226,7 @@ namespace lsp
226226
{
227227
if (nread > 0)
228228
break;
229-
set_error(-read);
229+
set_error(-status_t(read));
230230
return read;
231231
}
232232

@@ -253,7 +253,7 @@ namespace lsp
253253
{
254254
if (nread > 0)
255255
break;
256-
set_error(-read);
256+
set_error(-status_t(read));
257257
return read;
258258
}
259259

src/main/mm/IOutAudioStream.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2020 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-runtime-lib
66
* Created on: 16 апр. 2020 г.
@@ -136,7 +136,7 @@ namespace lsp
136136
{
137137
if (nwritten > 0)
138138
break;
139-
set_error(-written);
139+
set_error(-status_t(written));
140140
return written;
141141
}
142142

src/main/mm/InAudioFileStream.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <lsp-plug.in/common/alloc.h>
2323
#include <lsp-plug.in/common/debug.h>
2424
#include <lsp-plug.in/common/endian.h>
25-
#include <lsp-plug.in/lltl/parray.h>
2625
#include <lsp-plug.in/mm/InAudioFileStream.h>
2726
#include <lsp-plug.in/stdlib/stdio.h>
2827
#include <lsp-plug.in/stdlib/string.h>

0 commit comments

Comments
 (0)